Skip to content

Commit ea539a0

Browse files
authored
feat: black theme (#76)
* feat: black theme * fix: `ToggleButton` not clear in black theme
1 parent 66d6962 commit ea539a0

File tree

6 files changed

+61
-6
lines changed

6 files changed

+61
-6
lines changed

assets/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"theme-system": "System",
9090
"theme-light": "Light",
9191
"theme-dark": "Dark",
92+
"theme-black": "Black",
9293
"nsfw": "NSFW",
9394
"nsfw-subtitle": "Show NSFW content",
9495
"external-player": "Preferred video player",

assets/i18n/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"theme-system": "跟随系统",
7979
"theme-light": "浅色",
8080
"theme-dark": "深色",
81+
"theme-black": "黑色",
8182
"nsfw": "NSFW",
8283
"nsfw-subtitle": "显示 NSFW 内容",
8384
"external-player": "优先使用的视频播放器",

lib/controller.dart

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,50 @@ class ApplicationController extends GetxController {
1313
super.onInit();
1414
}
1515

16+
ThemeData get currentThemeData {
17+
switch (themeText.value) {
18+
case "light":
19+
return ThemeData.light(useMaterial3: true);
20+
case "dark":
21+
return ThemeData.dark(useMaterial3: true);
22+
case "black":
23+
return ThemeData.dark(
24+
useMaterial3: true,
25+
).copyWith(
26+
scaffoldBackgroundColor: Colors.black,
27+
canvasColor: Colors.black,
28+
cardColor: Colors.black,
29+
dialogBackgroundColor: Colors.black,
30+
primaryColor: Colors.black,
31+
hintColor: Colors.black,
32+
primaryColorDark: Colors.black,
33+
primaryColorLight: Colors.black,
34+
colorScheme: const ColorScheme.dark(
35+
primary: Colors.white,
36+
onBackground: Colors.white,
37+
onSecondary: Colors.white,
38+
onSurface: Colors.white,
39+
secondary: Colors.black,
40+
surface: Colors.black,
41+
background: Colors.black,
42+
onPrimary: Colors.black,
43+
primaryContainer: Color.fromARGB(255, 31, 31, 31),
44+
surfaceTint: Colors.black,
45+
),
46+
);
47+
default:
48+
return ThemeData.light(useMaterial3: true);
49+
}
50+
}
51+
1652
ThemeMode get theme {
1753
switch (themeText.value) {
1854
case "light":
1955
return ThemeMode.light;
2056
case "dark":
2157
return ThemeMode.dark;
58+
case "black":
59+
return ThemeMode.light;
2260
default:
2361
return ThemeMode.system;
2462
}

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class _MainAppState extends fluent.State<MainApp> {
9595
title: "Miru",
9696
debugShowCheckedModeBanner: false,
9797
themeMode: c.theme,
98-
theme: ThemeData(useMaterial3: true),
98+
theme: c.currentThemeData,
9999
darkTheme: ThemeData.dark(useMaterial3: true),
100100
home: const AndroidMainPage(),
101101
localizationsDelegates: [

lib/pages/settings/view.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,17 @@ class _SettingsPageState extends State<SettingsPage> {
223223
desktopWidget: Icon(fluent.FluentIcons.color, size: 24),
224224
),
225225
title: 'settings.theme'.i18n,
226-
itemNameValue: {
227-
'settings.theme-system'.i18n: 'system',
228-
'settings.theme-light'.i18n: 'light',
229-
'settings.theme-dark'.i18n: 'dark',
230-
},
226+
itemNameValue: () {
227+
final map = {
228+
'settings.theme-system'.i18n: 'system',
229+
'settings.theme-light'.i18n: 'light',
230+
'settings.theme-dark'.i18n: 'dark',
231+
};
232+
if (Platform.isAndroid) {
233+
map['settings.theme-black'.i18n] = 'black';
234+
}
235+
return map;
236+
}(),
231237
buildSubtitle: () => 'settings.theme-subtitle'.i18n,
232238
applyValue: (value) {
233239
Get.find<ApplicationController>().changeTheme(value);

lib/widgets/button.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ class PlatformToggleButton extends fluent.StatelessWidget {
121121
Widget _buildAndroid(BuildContext context) {
122122
return TextButton(
123123
onPressed: () => onChanged?.call(!checked),
124+
style: ButtonStyle(
125+
side: MaterialStateProperty.all(
126+
BorderSide(
127+
color: checked
128+
? Theme.of(context).colorScheme.primary
129+
: Colors.transparent,
130+
),
131+
),
132+
),
124133
child: Text(
125134
text,
126135
style: TextStyle(

0 commit comments

Comments
 (0)