Skip to content

Commit

Permalink
new: auto amoled
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Nov 7, 2023
1 parent 2133302 commit 8693ce0
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .dart_tool/flutter_gen/gen_l10n/l10n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ abstract class S {
/// No description provided for @deleteScripts.
///
/// In en, this message translates to:
/// **'Delete scripts'**
/// **'Delete server scripts at the same time'**
String get deleteScripts;

/// No description provided for @deleteServers.
Expand Down
2 changes: 1 addition & 1 deletion .dart_tool/flutter_gen/gen_l10n/l10n_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class SDe extends S {
String get delete => 'Löschen';

@override
String get deleteScripts => 'Skripte löschen';
String get deleteScripts => 'Gleichzeitiges Löschen von Server-Skripten';

@override
String get deleteServers => 'Batch-Löschung von Servern';
Expand Down
2 changes: 1 addition & 1 deletion .dart_tool/flutter_gen/gen_l10n/l10n_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class SEn extends S {
String get delete => 'Delete';

@override
String get deleteScripts => 'Delete scripts';
String get deleteScripts => 'Delete server scripts at the same time';

@override
String get deleteServers => 'Batch delete servers';
Expand Down
2 changes: 1 addition & 1 deletion .dart_tool/flutter_gen/gen_l10n/l10n_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class SId extends S {
String get delete => 'Menghapus';

@override
String get deleteScripts => 'Menghapus skrip';
String get deleteScripts => 'Menghapus skrip server secara bersamaan';

@override
String get deleteServers => 'Penghapusan server secara batch';
Expand Down
14 changes: 10 additions & 4 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ class MyApp extends StatelessWidget {
listenable: RebuildNodes.app,
build: () {
final tMode = Stores.setting.themeMode.fetch();
final isAMOLED = tMode >= 0 && tMode <= ThemeMode.values.length - 1;
// Issue #57
// if not [ok] -> [AMOLED] mode, use [ThemeMode.dark]
final themeMode = isAMOLED ? ThemeMode.values[tMode] : ThemeMode.dark;
var themeMode = ThemeMode.system;
switch (tMode) {
case 1 || 2:
themeMode = ThemeMode.values[tMode];
break;
case 3:
themeMode = ThemeMode.dark;
break;
}
final locale = Stores.setting.locale.fetch().toLocale;
final darkTheme = ThemeData(
useMaterial3: true,
Expand All @@ -62,7 +68,7 @@ class MyApp extends StatelessWidget {
useMaterial3: true,
colorSchemeSeed: primaryColor,
),
darkTheme: isAMOLED ? darkTheme : _getAmoledTheme(darkTheme),
darkTheme: tMode < 3 ? darkTheme : _getAmoledTheme(darkTheme),
home: Stores.setting.fullScreen.fetch()
? const FullScreenPage()
: const HomePage(),
Expand Down
2 changes: 1 addition & 1 deletion lib/data/store/setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class SettingStore extends PersistentStore {
// Max retry count when connect to server
late final maxRetryCount = StoreProperty(box, 'maxRetryCount', 2);

// Night mode: 0 -> auto, 1 -> light, 2 -> dark
// Night mode: 0 -> auto, 1 -> light, 2 -> dark, 3 -> AMOLED, 4 -> AUTO-AMOLED
late final themeMode = StoreProperty(box, 'themeMode', 0);

// Font file path
Expand Down
9 changes: 9 additions & 0 deletions lib/view/page/setting/entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,15 @@ class _SettingPageState extends State<SettingPage> {
.toList();
// Issue #57
final len = ThemeMode.values.length;

/// Add AMOLED theme
items.add(PopupMenuItem(value: len, child: Text(_buildThemeModeStr(len))));

/// Add AUTO-AMOLED theme
items.add(
PopupMenuItem(value: len + 1, child: Text(_buildThemeModeStr(len + 1))),
);

return ListTile(
title: Text(
l10n.themeMode,
Expand Down Expand Up @@ -518,6 +525,8 @@ class _SettingPageState extends State<SettingPage> {
return l10n.dark;
case 3:
return 'AMOLED';
case 4:
return '${l10n.auto} AMOLED';
default:
return l10n.auto;
}
Expand Down

0 comments on commit 8693ce0

Please sign in to comment.