initial
This commit is contained in:
38
lib/features/settings/widgets/theme_mode_switch_button.dart
Normal file
38
lib/features/settings/widgets/theme_mode_switch_button.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ThemeModeSwitch extends StatelessWidget {
|
||||
const ThemeModeSwitch({
|
||||
super.key,
|
||||
required this.themeMode,
|
||||
required this.onChanged,
|
||||
});
|
||||
final ThemeMode themeMode;
|
||||
final ValueChanged<ThemeMode> onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<bool> isSelected = <bool>[
|
||||
themeMode == ThemeMode.light,
|
||||
themeMode == ThemeMode.system,
|
||||
themeMode == ThemeMode.dark,
|
||||
];
|
||||
|
||||
return ToggleButtons(
|
||||
isSelected: isSelected,
|
||||
onPressed: (int newIndex) {
|
||||
if (newIndex == 0) {
|
||||
onChanged(ThemeMode.light);
|
||||
} else if (newIndex == 1) {
|
||||
onChanged(ThemeMode.system);
|
||||
} else {
|
||||
onChanged(ThemeMode.dark);
|
||||
}
|
||||
},
|
||||
children: const <Widget>[
|
||||
Icon(Icons.wb_sunny),
|
||||
Icon(Icons.phone_iphone),
|
||||
Icon(Icons.bedtime),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user