follow system theme at startup and changing

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-09-06 22:34:01 +08:00
parent a3c1e5ddb4
commit 17a7cbf7bb
5 changed files with 60 additions and 19 deletions

View File

@@ -224,21 +224,18 @@ class _UserInterfaceState extends State<_UserInterface>
}
Widget theme() {
var change = () {
bool dark = !isDarkTheme();
Get.changeTheme(dark ? MyTheme.darkTheme : MyTheme.lightTheme);
Get.find<SharedPreferences>().setString("darkTheme", dark ? "Y" : "");
Get.forceAppUpdate();
};
change() {
MyTheme.changeTo(!isDarkTheme());
}
return GestureDetector(
onTap: change,
child: Row(
children: [
Checkbox(value: isDarkTheme(), onChanged: (_) => change()),
Expanded(child: Text(translate('Dark Theme'))),
],
).marginOnly(left: _kCheckBoxLeftMargin),
onTap: change,
);
}
}

View File

@@ -33,7 +33,6 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
@override
Widget build(BuildContext context) {
final dark = isDarkTheme();
RxBool fullscreen = false.obs;
Get.put(fullscreen, tag: 'fullscreen');
return Obx(() => DragToResizeArea(