mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 19:22:22 +01:00
Added headless switch
Fixed UI
This commit is contained in:
@@ -3,17 +3,17 @@ import 'package:get/get.dart';
|
||||
import 'package:system_theme/system_theme.dart';
|
||||
|
||||
class SmartSwitch extends StatefulWidget {
|
||||
final String label;
|
||||
final String? label;
|
||||
final bool enabled;
|
||||
final Function()? onDisabledPress;
|
||||
final Rx<bool> value;
|
||||
|
||||
const SmartSwitch(
|
||||
{Key? key,
|
||||
required this.label,
|
||||
required this.value,
|
||||
this.enabled = true,
|
||||
this.onDisabledPress})
|
||||
required this.value,
|
||||
this.label,
|
||||
this.enabled = true,
|
||||
this.onDisabledPress})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -23,22 +23,32 @@ class SmartSwitch extends StatefulWidget {
|
||||
class _SmartSwitchState extends State<SmartSwitch> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return widget.label == null ? _createSwitch() : _createLabel();
|
||||
}
|
||||
|
||||
InfoLabel _createLabel() {
|
||||
return InfoLabel(
|
||||
label: widget.label,
|
||||
child: Obx(() => ToggleSwitch(
|
||||
enabled: widget.enabled,
|
||||
onDisabledPress: widget.onDisabledPress,
|
||||
checked: widget.value.value,
|
||||
onChanged: _onChanged,
|
||||
style: ToggleSwitchThemeData.standard(ThemeData(
|
||||
checkedColor: _toolTipColor.withOpacity(_checkedOpacity),
|
||||
uncheckedColor: _toolTipColor.withOpacity(_uncheckedOpacity),
|
||||
borderInputColor: _toolTipColor.withOpacity(_uncheckedOpacity),
|
||||
accentColor: _bodyColor
|
||||
.withOpacity(widget.value.value
|
||||
? _checkedOpacity
|
||||
: _uncheckedOpacity)
|
||||
.toAccentColor())))));
|
||||
label: widget.label!,
|
||||
child: _createSwitch()
|
||||
);
|
||||
}
|
||||
|
||||
Widget _createSwitch() {
|
||||
return Obx(() => ToggleSwitch(
|
||||
enabled: widget.enabled,
|
||||
onDisabledPress: widget.onDisabledPress,
|
||||
checked: widget.value.value,
|
||||
onChanged: _onChanged,
|
||||
style: ToggleSwitchThemeData.standard(ThemeData(
|
||||
checkedColor: _toolTipColor.withOpacity(_checkedOpacity),
|
||||
uncheckedColor: _toolTipColor.withOpacity(_uncheckedOpacity),
|
||||
borderInputColor: _toolTipColor.withOpacity(_uncheckedOpacity),
|
||||
accentColor: _bodyColor
|
||||
.withOpacity(widget.value.value
|
||||
? _checkedOpacity
|
||||
: _uncheckedOpacity)
|
||||
.toAccentColor())))
|
||||
);
|
||||
}
|
||||
|
||||
Color get _toolTipColor =>
|
||||
|
||||
Reference in New Issue
Block a user