From 58c7679857686ece147301adb02110a9d1bcd27e Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Mon, 19 Feb 2024 20:54:37 +0800 Subject: [PATCH] restructure light slider widget --- lib/widgets/light_slider.dart | 207 ++++++++++++++++++---------------- 1 file changed, 110 insertions(+), 97 deletions(-) diff --git a/lib/widgets/light_slider.dart b/lib/widgets/light_slider.dart index b9e9f9a2..564c7565 100644 --- a/lib/widgets/light_slider.dart +++ b/lib/widgets/light_slider.dart @@ -68,8 +68,7 @@ class _IblRotationSliderWidgetState extends State { lightDir.x, lightDir.y, lightDir.z, - castShadows, - async: false); + castShadows); setState(() {}); } @@ -83,100 +82,114 @@ class _IblRotationSliderWidgetState extends State { data: ThemeData(platform: TargetPlatform.android), child: Container( decoration: BoxDecoration(color: Colors.white.withOpacity(0.5)), - child: Column(children: [ - Slider( - label: "POSX", - value: lightPos.x, - min: -10.0, - max: 10.0, - onChanged: (value) { - lightPos.x = value; - _set(); - }), - Slider( - label: "POSY", - value: lightPos.y, - min: -10.0, - max: 10.0, - onChanged: (value) { - lightPos.y = value; - _set(); - }), - Slider( - label: "POSZ", - value: lightPos.z, - min: -10.0, - max: 10.0, - onChanged: (value) { - lightPos.z = value; - _set(); - }), - Slider( - label: "DIRX", - value: lightDir.x, - min: -10.0, - max: 10.0, - onChanged: (value) { - lightDir.x = value; - _set(); - }), - Slider( - label: "DIRY", - value: lightDir.y, - min: -10.0, - max: 10.0, - onChanged: (value) { - lightDir.y = value; - _set(); - }), - Slider( - label: "DIRZ", - value: lightDir.z, - min: -10.0, - max: 10.0, - onChanged: (value) { - lightDir.z = value; - _set(); - }), - Slider( - label: "Color", - value: color, - min: 0, - max: 16000, - onChanged: (value) { - color = value; - _set(); - }), - Slider( - label: "Intensity", - value: intensity, - min: 0, - max: 1000000, - onChanged: (value) { - intensity = value; - _set(); - }), - DropdownButton( - onChanged: (v) { - this.type = v; - _set(); - }, - value: type, - items: List.generate( - 5, - (idx) => DropdownMenuItem( - value: idx, - child: Text("$idx"), - ))), - Row(children: [ - Text("Shadows: $castShadows"), - Checkbox( - value: castShadows, - onChanged: (v) { - this.castShadows = v!; - _set(); - }) - ]) - ]))); + child: SliderTheme( + data: SliderThemeData( + showValueIndicator: ShowValueIndicator.always, + valueIndicatorTextStyle: TextStyle(color: Colors.black)), + child: Column(mainAxisSize: MainAxisSize.min, children: [ + Row(children: [ + Expanded( + child: Slider( + label: "POSX", + value: lightPos.x, + min: -10.0, + max: 10.0, + onChanged: (value) { + lightPos.x = value; + _set(); + })), + Expanded( + child: Slider( + label: "POSY", + value: lightPos.y, + min: -10.0, + max: 10.0, + onChanged: (value) { + lightPos.y = value; + _set(); + })), + Expanded( + child: Slider( + label: "POSZ", + value: lightPos.z, + min: -10.0, + max: 10.0, + onChanged: (value) { + lightPos.z = value; + _set(); + })) + ]), + Row(children: [ + Expanded( + child: Slider( + label: "DIRX", + value: lightDir.x, + min: -10.0, + max: 10.0, + onChanged: (value) { + lightDir.x = value; + _set(); + })), + Expanded( + child: Slider( + label: "DIRY", + value: lightDir.y, + min: -10.0, + max: 10.0, + onChanged: (value) { + lightDir.y = value; + _set(); + })), + Expanded( + child: Slider( + label: "DIRZ", + value: lightDir.z, + min: -10.0, + max: 10.0, + onChanged: (value) { + lightDir.z = value; + _set(); + })) + ]), + Slider( + label: "Color", + value: color, + min: 0, + max: 16000, + onChanged: (value) { + color = value; + _set(); + }), + Slider( + label: "Intensity", + value: intensity, + min: 0, + max: 1000000, + onChanged: (value) { + intensity = value; + _set(); + }), + DropdownButton( + onChanged: (v) { + this.type = v; + _set(); + }, + value: type, + items: List.generate( + 5, + (idx) => DropdownMenuItem( + value: idx, + child: Text("$idx"), + ))), + Row(children: [ + Text("Shadows: $castShadows"), + Checkbox( + value: castShadows, + onChanged: (v) { + this.castShadows = v!; + _set(); + }) + ]) + ])))); } }