forked from firka/firka
dark mode toggle
This commit is contained in:
@@ -26,13 +26,12 @@ const language = 1008;
|
||||
const appIcon = 1009;
|
||||
const childProtection = 1010;
|
||||
const betaWarning = 1011;
|
||||
|
||||
const ttToastLessonNo = 1012;
|
||||
const ttToastTestsAndHw = 1013;
|
||||
const ttToastBreaks = 1014;
|
||||
|
||||
const statsForNerds = 1015;
|
||||
const developerOptsEnabled = 1016;
|
||||
const themeBrightness = 1017;
|
||||
|
||||
bool always() {
|
||||
return true;
|
||||
@@ -245,6 +244,36 @@ class SettingsStore {
|
||||
always),
|
||||
}),
|
||||
isAndroid),
|
||||
"theme_header":
|
||||
SettingsHeaderSmall(0, l10n.s_c_theme_header, always),
|
||||
"theme": SettingsItemsRadio(
|
||||
themeBrightness,
|
||||
null,
|
||||
null,
|
||||
[
|
||||
l10n.s_c_theme_auto,
|
||||
l10n.s_c_theme_light,
|
||||
l10n.s_c_theme_dark
|
||||
],
|
||||
0,
|
||||
always, () async {
|
||||
Navigator.of(navigatorKey.currentContext!)
|
||||
.popUntil((route) => false);
|
||||
|
||||
initTheme(initData);
|
||||
|
||||
Navigator.push(
|
||||
navigatorKey.currentContext!,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DefaultAssetBundle(
|
||||
bundle: FirkaBundle(),
|
||||
child: HomeScreen(
|
||||
initData,
|
||||
false,
|
||||
key: ValueKey('homeScreen'),
|
||||
))),
|
||||
);
|
||||
})
|
||||
}),
|
||||
always),
|
||||
"notifications": SettingsSubGroup(
|
||||
|
||||
Submodule firka/lib/l10n updated: 5056adcce0...1b0ccb183b
@@ -20,6 +20,7 @@ import 'package:firka/ui/phone/screens/home/home_screen.dart';
|
||||
import 'package:firka/ui/phone/screens/login/login_screen.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
@@ -126,6 +127,28 @@ void initLang(AppInitialization data) {
|
||||
}
|
||||
}
|
||||
|
||||
void initTheme(AppInitialization data) {
|
||||
final brightness =
|
||||
SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
||||
|
||||
switch ((data.settings.group("settings").subGroup("customization")["theme"]
|
||||
as SettingsItemsRadio)
|
||||
.activeIndex) {
|
||||
case 1:
|
||||
appStyle = lightStyle;
|
||||
break;
|
||||
case 2:
|
||||
appStyle = darkStyle;
|
||||
break;
|
||||
default:
|
||||
if (brightness == Brightness.dark) {
|
||||
appStyle = darkStyle;
|
||||
} else {
|
||||
appStyle = lightStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<AppInitialization> initializeApp() async {
|
||||
final isar = await initDB();
|
||||
final tokenCount = await isar.tokenModels.count();
|
||||
@@ -172,6 +195,7 @@ Future<AppInitialization> initializeApp() async {
|
||||
|
||||
await init.settings.load(init.isar.appSettingsModels);
|
||||
initLang(init);
|
||||
initTheme(init);
|
||||
init.settings = SettingsStore(init.l10n);
|
||||
await init.settings.load(init.isar.appSettingsModels);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user