opt: dark theme, add follow system mode

This commit is contained in:
csf
2022-09-21 23:32:59 +08:00
parent 5a4806e9b2
commit 86d83e12b0
10 changed files with 89 additions and 52 deletions

View File

@@ -205,22 +205,28 @@ class _GeneralState extends State<_General> {
}
Widget theme() {
change() {
MyTheme.changeTo(!isDarkTheme());
final current = MyTheme.getThemeModePreference().toShortString();
onChanged(String value) {
MyTheme.changeDarkMode(MyTheme.themeModeFromString(value));
setState(() {});
}
return _Card(title: 'Theme', children: [
GestureDetector(
onTap: change,
child: Row(
children: [
Checkbox(value: isDarkTheme(), onChanged: (_) => change())
.marginOnly(right: 5),
Expanded(child: Text(translate('Dark Theme'))),
],
).marginOnly(left: _kCheckBoxLeftMargin),
)
_Radio<String>(context,
value: "light",
groupValue: current,
label: "Light",
onChanged: onChanged),
_Radio<String>(context,
value: "dark",
groupValue: current,
label: "Dark",
onChanged: onChanged),
_Radio<String>(context,
value: "system",
groupValue: current,
label: "Follow System",
onChanged: onChanged),
]);
}

View File

@@ -247,7 +247,7 @@ class _PortForwardPageState extends State<PortForwardPage>
height: _kRowHeight,
decoration: BoxDecoration(
color: index % 2 == 0
? isDarkTheme()
? MyTheme.currentThemeMode() == ThemeMode.dark
? const Color(0xFF202020)
: const Color(0xFFF4F5F6)
: MyTheme.color(context).bg),