mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Automatically apply new dark theme settings
This commit is contained in:
parent
6b8cc2569d
commit
fe3f0c0e85
@ -28,7 +28,7 @@ void subMain() async {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
class ComunicApplication extends StatelessWidget {
|
class ComunicApplication extends StatefulWidget {
|
||||||
final PreferencesHelper preferences;
|
final PreferencesHelper preferences;
|
||||||
|
|
||||||
const ComunicApplication({
|
const ComunicApplication({
|
||||||
@ -37,12 +37,22 @@ class ComunicApplication extends StatelessWidget {
|
|||||||
}) : assert(preferences != null),
|
}) : assert(preferences != null),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComunicApplicationState createState() => ComunicApplicationState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ComunicApplicationState extends State<ComunicApplication> {
|
||||||
|
/// Use this method to force the application to rebuild
|
||||||
|
void refresh() => setState(() {});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
home: AccountHelper.isUserIDLoaded ? InitializeWidget() : LoginRoute(),
|
home: AccountHelper.isUserIDLoaded ? InitializeWidget() : LoginRoute(),
|
||||||
theme: preferences.preferences.enableDarkMode ? ThemeData.dark() : null,
|
theme: widget.preferences.preferences.enableDarkMode
|
||||||
|
? ThemeData.dark()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ class __ApplicationSettingsScreenState
|
|||||||
/// Apply new settings
|
/// Apply new settings
|
||||||
_updatedSettings() {
|
_updatedSettings() {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
applyNewThemeSettings(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:comunic/helpers/preferences_helper.dart';
|
import 'package:comunic/helpers/preferences_helper.dart';
|
||||||
|
import 'package:comunic/main.dart';
|
||||||
import 'package:comunic/ui/routes/full_screen_image.dart';
|
import 'package:comunic/ui/routes/full_screen_image.dart';
|
||||||
import 'package:comunic/ui/widgets/dialogs/auto_sized_dialog_content_widget.dart';
|
import 'package:comunic/ui/widgets/dialogs/auto_sized_dialog_content_widget.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
@ -222,3 +223,7 @@ void showAboutAppDialog(BuildContext context) {
|
|||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Apply new theme settings
|
||||||
|
void applyNewThemeSettings(BuildContext context) =>
|
||||||
|
context.findAncestorStateOfType<ComunicApplicationState>().refresh();
|
||||||
|
Loading…
Reference in New Issue
Block a user