mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: change theme
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,13 +1,26 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||||
|
|
||||||
enum ThemeType {
|
enum ThemeType {
|
||||||
light,
|
light,
|
||||||
dark,
|
dark,
|
||||||
system,
|
system,
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ThemeTypeDesc on ThemeType {
|
extension ThemeTypeExt on ThemeType {
|
||||||
String get description => ['浅色', '深色', '跟随系统'][index];
|
String get description => ['浅色', '深色', '跟随系统'][index];
|
||||||
}
|
|
||||||
|
|
||||||
extension ThemeTypeCode on ThemeType {
|
int get code => index;
|
||||||
int get code => [0, 1, 2][index];
|
|
||||||
|
ThemeMode get toThemeMode => switch (this) {
|
||||||
|
ThemeType.light => ThemeMode.light,
|
||||||
|
ThemeType.dark => ThemeMode.dark,
|
||||||
|
ThemeType.system => ThemeMode.system,
|
||||||
|
};
|
||||||
|
|
||||||
|
IconData get iconData => switch (this) {
|
||||||
|
ThemeType.light => MdiIcons.weatherSunny,
|
||||||
|
ThemeType.dark => MdiIcons.weatherNight,
|
||||||
|
ThemeType.system => MdiIcons.themeLightDark,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ class MineController extends GetxController {
|
|||||||
onChangeTheme() {
|
onChangeTheme() {
|
||||||
themeType.value = nextThemeType;
|
themeType.value = nextThemeType;
|
||||||
setting.put(SettingBoxKey.themeMode, themeType.value.code);
|
setting.put(SettingBoxKey.themeMode, themeType.value.code);
|
||||||
Get.forceAppUpdate();
|
Get.changeThemeMode(themeType.value.toThemeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushFollow() {
|
pushFollow() {
|
||||||
|
|||||||
@@ -55,33 +55,27 @@ class _MinePageState extends State<MinePage> {
|
|||||||
size: 24,
|
size: 24,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
Obx(
|
||||||
iconSize: 40.0,
|
() {
|
||||||
padding: const EdgeInsets.all(8),
|
return IconButton(
|
||||||
constraints: const BoxConstraints(),
|
iconSize: 40.0,
|
||||||
style: const ButtonStyle(
|
padding: const EdgeInsets.all(8),
|
||||||
tapTargetSize:
|
style: const ButtonStyle(
|
||||||
MaterialTapTargetSize.shrinkWrap, // the '2023' part
|
tapTargetSize:
|
||||||
),
|
MaterialTapTargetSize.shrinkWrap, // the '2023' part
|
||||||
tooltip: '切换至${switch (_mineController.nextThemeType) {
|
),
|
||||||
ThemeType.light => '浅色',
|
tooltip: '切换至${_mineController.nextThemeType.description}主题',
|
||||||
ThemeType.dark => '深色',
|
onPressed: _mineController.onChangeTheme,
|
||||||
ThemeType.system => '跟随系统',
|
icon: Icon(
|
||||||
}}主题',
|
_mineController.themeType.value.iconData,
|
||||||
onPressed: _mineController.onChangeTheme,
|
size: 24,
|
||||||
icon: Icon(
|
),
|
||||||
switch (_mineController.themeType.value) {
|
);
|
||||||
ThemeType.light => MdiIcons.weatherSunny,
|
},
|
||||||
ThemeType.dark => MdiIcons.weatherNight,
|
|
||||||
ThemeType.system => MdiIcons.themeLightDark,
|
|
||||||
},
|
|
||||||
size: 24,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
iconSize: 40.0,
|
iconSize: 40.0,
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
style: const ButtonStyle(
|
style: const ButtonStyle(
|
||||||
tapTargetSize:
|
tapTargetSize:
|
||||||
MaterialTapTargetSize.shrinkWrap, // the '2023' part
|
MaterialTapTargetSize.shrinkWrap, // the '2023' part
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
ctr.themeType.value = result;
|
ctr.themeType.value = result;
|
||||||
GStorage.setting.put(SettingBoxKey.themeMode, result.index);
|
GStorage.setting.put(SettingBoxKey.themeMode, result.index);
|
||||||
Get.forceAppUpdate();
|
Get.changeThemeMode(result.toThemeMode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
leading: Container(
|
leading: Container(
|
||||||
|
|||||||
@@ -538,7 +538,7 @@ List<SettingsModel> get styleSettings => [
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
GStorage.setting.put(SettingBoxKey.themeMode, result.index);
|
GStorage.setting.put(SettingBoxKey.themeMode, result.index);
|
||||||
Get.put(ColorSelectController()).themeType.value = result;
|
Get.put(ColorSelectController()).themeType.value = result;
|
||||||
Get.forceAppUpdate();
|
Get.changeThemeMode(result.toThemeMode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
leading: const Icon(Icons.flashlight_on_outlined),
|
leading: const Icon(Icons.flashlight_on_outlined),
|
||||||
|
|||||||
Reference in New Issue
Block a user