@@ -4,27 +4,28 @@ import 'content.dart';
4
4
import 'text.dart' ;
5
5
6
6
ThemeData zulipThemeData (BuildContext context) {
7
+ final designVariables = DesignVariables ();
7
8
return ThemeData (
8
9
typography: zulipTypography (context),
9
- extensions: [ContentTheme (context)],
10
+ extensions: [ContentTheme (context), designVariables ],
10
11
appBarTheme: AppBarTheme (
11
12
// Set these two fields to prevent a color change in [AppBar]s when
12
13
// there is something scrolled under it. If an app bar hasn't been
13
14
// given a backgroundColor directly or by theme, it uses
14
15
// ColorScheme.surfaceContainer for the scrolled-under state and
15
16
// ColorScheme.surface otherwise, and those are different colors.
16
17
scrolledUnderElevation: 0 ,
17
- backgroundColor: const Color ( 0xfff5f5f5 ), // `bg-top-bar` in Figma
18
+ backgroundColor: designVariables.bgTopBar,
18
19
19
20
// TODO match layout to Figma
20
- actionsIconTheme: const IconThemeData (
21
- color: Color ( 0xff666699 ), // ` icon` in Figma
21
+ actionsIconTheme: IconThemeData (
22
+ color: designVariables. icon,
22
23
),
23
24
24
25
titleTextStyle: TextStyle (
25
26
inherit: false ,
26
27
27
- color: const Color ( 0xff1a1a1a ), // ` title` in Figma
28
+ color: designVariables. title,
28
29
fontSize: 20 ,
29
30
letterSpacing: 0.0 ,
30
31
height: (30 / 20 ),
@@ -41,8 +42,8 @@ ThemeData zulipThemeData(BuildContext context) {
41
42
// that it looks reasonable with different system text-size settings.
42
43
// Also the back button will look too big and need adjusting.
43
44
44
- shape: const Border (bottom: BorderSide (
45
- color: Color ( 0x33000000 ), // `border-bar` in Figma
45
+ shape: Border (bottom: BorderSide (
46
+ color: designVariables.borderBar,
46
47
strokeAlign: BorderSide .strokeAlignInside, // (default restated for explicitness)
47
48
)),
48
49
),
@@ -57,7 +58,7 @@ ThemeData zulipThemeData(BuildContext context) {
57
58
colorScheme: ColorScheme .fromSeed (
58
59
seedColor: kZulipBrandColor,
59
60
),
60
- scaffoldBackgroundColor: const Color ( 0xfff0f0f0 ), // `bg-main` in Figma
61
+ scaffoldBackgroundColor: designVariables.bgMain,
61
62
tooltipTheme: const TooltipThemeData (preferBelow: false ),
62
63
);
63
64
}
@@ -67,3 +68,71 @@ ThemeData zulipThemeData(BuildContext context) {
67
68
/// This is chosen as the sRGB midpoint of the Zulip logo's gradient.
68
69
// As computed by Anders: https://github.com/zulip/zulip-mobile/pull/4467
69
70
const kZulipBrandColor = Color .fromRGBO (0x64 , 0x92 , 0xfe , 1 );
71
+
72
+ /// Variables from the Figma design.
73
+ ///
74
+ /// For how to export these from the Figma, see:
75
+ /// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=2945-49492&t=MEb4vtp7S26nntxm-0
76
+ class DesignVariables extends ThemeExtension <DesignVariables > {
77
+ DesignVariables () :
78
+ bgMain = const Color (0xfff0f0f0 ),
79
+ bgTopBar = const Color (0xfff5f5f5 ),
80
+ borderBar = const Color (0x33000000 ),
81
+ icon = const Color (0xff666699 ),
82
+ title = const Color (0xff1a1a1a );
83
+
84
+ DesignVariables ._({
85
+ required this .bgMain,
86
+ required this .bgTopBar,
87
+ required this .borderBar,
88
+ required this .icon,
89
+ required this .title,
90
+ });
91
+
92
+ /// The [DesignVariables] from the context's active theme.
93
+ ///
94
+ /// The [ThemeData] must include [DesignVariables] in [ThemeData.extensions] .
95
+ static DesignVariables of (BuildContext context) {
96
+ final theme = Theme .of (context);
97
+ final extension = theme.extension < DesignVariables > ();
98
+ assert (extension != null );
99
+ return extension ! ;
100
+ }
101
+
102
+ final Color bgMain;
103
+ final Color bgTopBar;
104
+ final Color borderBar;
105
+ final Color icon;
106
+ final Color title;
107
+
108
+ @override
109
+ DesignVariables copyWith ({
110
+ Color ? bgMain,
111
+ Color ? bgTopBar,
112
+ Color ? borderBar,
113
+ Color ? icon,
114
+ Color ? title,
115
+ }) {
116
+ return DesignVariables ._(
117
+ bgMain: bgMain ?? this .bgMain,
118
+ bgTopBar: bgTopBar ?? this .bgTopBar,
119
+ borderBar: borderBar ?? this .borderBar,
120
+ icon: icon ?? this .icon,
121
+ title: title ?? this .title,
122
+ );
123
+ }
124
+
125
+ @override
126
+ DesignVariables lerp (DesignVariables ? other, double t) {
127
+ if (identical (this , other)) {
128
+ return this ;
129
+ }
130
+ return DesignVariables ._(
131
+ bgMain: Color .lerp (bgMain, other? .bgMain, t)! ,
132
+ bgTopBar: Color .lerp (bgTopBar, other? .bgTopBar, t)! ,
133
+ borderBar: Color .lerp (borderBar, other? .borderBar, t)! ,
134
+ icon: Color .lerp (icon, other? .icon, t)! ,
135
+ title: Color .lerp (title, other? .title, t)! ,
136
+ );
137
+ }
138
+ }
0 commit comments