Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: black theme #76

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"theme-system": "System",
"theme-light": "Light",
"theme-dark": "Dark",
"theme-black": "Black",
"nsfw": "NSFW",
"nsfw-subtitle": "Show NSFW content",
"external-player": "Preferred video player",
Expand Down
1 change: 1 addition & 0 deletions assets/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"theme-system": "跟随系统",
"theme-light": "浅色",
"theme-dark": "深色",
"theme-black": "黑色",
"nsfw": "NSFW",
"nsfw-subtitle": "显示 NSFW 内容",
"external-player": "优先使用的视频播放器",
Expand Down
38 changes: 38 additions & 0 deletions lib/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,50 @@ class ApplicationController extends GetxController {
super.onInit();
}

ThemeData get currentThemeData {
switch (themeText.value) {
case "light":
return ThemeData.light(useMaterial3: true);
case "dark":
return ThemeData.dark(useMaterial3: true);
case "black":
return ThemeData.dark(
useMaterial3: true,
).copyWith(
scaffoldBackgroundColor: Colors.black,
canvasColor: Colors.black,
cardColor: Colors.black,
dialogBackgroundColor: Colors.black,
primaryColor: Colors.black,
hintColor: Colors.black,
primaryColorDark: Colors.black,
primaryColorLight: Colors.black,
colorScheme: const ColorScheme.dark(
primary: Colors.white,
onBackground: Colors.white,
onSecondary: Colors.white,
onSurface: Colors.white,
secondary: Colors.black,
surface: Colors.black,
background: Colors.black,
onPrimary: Colors.black,
primaryContainer: Color.fromARGB(255, 31, 31, 31),
surfaceTint: Colors.black,
),
);
default:
return ThemeData.light(useMaterial3: true);
}
}

ThemeMode get theme {
switch (themeText.value) {
case "light":
return ThemeMode.light;
case "dark":
return ThemeMode.dark;
case "black":
return ThemeMode.light;
default:
return ThemeMode.system;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class _MainAppState extends fluent.State<MainApp> {
title: "Miru",
debugShowCheckedModeBanner: false,
themeMode: c.theme,
theme: ThemeData(useMaterial3: true),
theme: c.currentThemeData,
darkTheme: ThemeData.dark(useMaterial3: true),
home: const AndroidMainPage(),
localizationsDelegates: [
Expand Down
16 changes: 11 additions & 5 deletions lib/pages/settings/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,17 @@ class _SettingsPageState extends State<SettingsPage> {
desktopWidget: Icon(fluent.FluentIcons.color, size: 24),
),
title: 'settings.theme'.i18n,
itemNameValue: {
'settings.theme-system'.i18n: 'system',
'settings.theme-light'.i18n: 'light',
'settings.theme-dark'.i18n: 'dark',
},
itemNameValue: () {
final map = {
'settings.theme-system'.i18n: 'system',
'settings.theme-light'.i18n: 'light',
'settings.theme-dark'.i18n: 'dark',
};
if (Platform.isAndroid) {
map['settings.theme-black'.i18n] = 'black';
}
return map;
}(),
buildSubtitle: () => 'settings.theme-subtitle'.i18n,
applyValue: (value) {
Get.find<ApplicationController>().changeTheme(value);
Expand Down
9 changes: 9 additions & 0 deletions lib/widgets/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ class PlatformToggleButton extends fluent.StatelessWidget {
Widget _buildAndroid(BuildContext context) {
return TextButton(
onPressed: () => onChanged?.call(!checked),
style: ButtonStyle(
side: MaterialStateProperty.all(
BorderSide(
color: checked
? Theme.of(context).colorScheme.primary
: Colors.transparent,
),
),
),
child: Text(
text,
style: TextStyle(
Expand Down