@@ -5,11 +5,50 @@ import 'content.dart';
5
5
import 'stream_colors.dart' ;
6
6
import 'text.dart' ;
7
7
8
+ /// In debug mode, controls whether the UI responds to
9
+ /// [MediaQueryData.platformBrightness] .
10
+ ///
11
+ /// Outside of debug mode, this is always false and the setter has no effect.
12
+ // TODO(#95) when dark theme is fully implemented, simplify away;
13
+ // the UI should always respond.
14
+ bool get debugFollowPlatformBrightness {
15
+ bool result = false ;
16
+ assert (() {
17
+ result = _debugFollowPlatformBrightness;
18
+ return true ;
19
+ }());
20
+ return result;
21
+ }
22
+ bool _debugFollowPlatformBrightness = false ;
23
+ set debugFollowPlatformBrightness (bool value) {
24
+ assert (() {
25
+ _debugFollowPlatformBrightness = value;
26
+ return true ;
27
+ }());
28
+ }
29
+
30
+
8
31
ThemeData zulipThemeData (BuildContext context) {
9
- final designVariables = DesignVariables ();
32
+ final DesignVariables designVariables;
33
+ final List <ThemeExtension > themeExtensions;
34
+ Brightness brightness = debugFollowPlatformBrightness
35
+ ? MediaQuery .of (context).platformBrightness
36
+ : Brightness .light;
37
+ switch (brightness) {
38
+ case Brightness .light: {
39
+ designVariables = DesignVariables ();
40
+ themeExtensions = [ContentTheme .light (context), designVariables];
41
+ }
42
+ case Brightness .dark: {
43
+ designVariables = DesignVariables (); // TODO(#95)
44
+ themeExtensions = [ContentTheme .dark (context), designVariables];
45
+ }
46
+ }
47
+
10
48
return ThemeData (
49
+ brightness: brightness,
11
50
typography: zulipTypography (context),
12
- extensions: [ ContentTheme . light (context), designVariables] ,
51
+ extensions: themeExtensions ,
13
52
appBarTheme: AppBarTheme (
14
53
// Set these two fields to prevent a color change in [AppBar]s when
15
54
// there is something scrolled under it. If an app bar hasn't been
@@ -57,6 +96,7 @@ ThemeData zulipThemeData(BuildContext context) {
57
96
// Or try this tool to see the whole palette:
58
97
// https://m3.material.io/theme-builder#/custom
59
98
colorScheme: ColorScheme .fromSeed (
99
+ brightness: brightness,
60
100
seedColor: kZulipBrandColor,
61
101
),
62
102
scaffoldBackgroundColor: designVariables.mainBackground,
0 commit comments