@@ -4,26 +4,27 @@ 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
- color: const Color ( 0xff1a1a1a ), // ` title` in Figma
27
+ color: designVariables. title,
27
28
fontSize: 20 ,
28
29
letterSpacing: 0.0 ,
29
30
height: (30 / 20 ),
@@ -40,8 +41,8 @@ ThemeData zulipThemeData(BuildContext context) {
40
41
// that it looks reasonable with different system text-size settings.
41
42
// Also the back button will look too big and need adjusting.
42
43
43
- shape: const Border (bottom: BorderSide (
44
- color: Color ( 0x33000000 ), // `border-bar` in Figma
44
+ shape: Border (bottom: BorderSide (
45
+ color: designVariables.borderBar,
45
46
strokeAlign: BorderSide .strokeAlignInside, // (default restated for explicitness)
46
47
)),
47
48
),
@@ -56,7 +57,7 @@ ThemeData zulipThemeData(BuildContext context) {
56
57
colorScheme: ColorScheme .fromSeed (
57
58
seedColor: kZulipBrandColor,
58
59
),
59
- scaffoldBackgroundColor: const Color ( 0xfff0f0f0 ), // `bg-main` in Figma
60
+ scaffoldBackgroundColor: designVariables.bgMain,
60
61
tooltipTheme: const TooltipThemeData (preferBelow: false ),
61
62
);
62
63
}
@@ -66,3 +67,71 @@ ThemeData zulipThemeData(BuildContext context) {
66
67
/// This is chosen as the sRGB midpoint of the Zulip logo's gradient.
67
68
// As computed by Anders: https://github.com/zulip/zulip-mobile/pull/4467
68
69
const kZulipBrandColor = Color .fromRGBO (0x64 , 0x92 , 0xfe , 1 );
70
+
71
+ /// Variables from the Figma design.
72
+ ///
73
+ /// For how to export these from the Figma, see:
74
+ /// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=2945-49492&t=MEb4vtp7S26nntxm-0
75
+ class DesignVariables extends ThemeExtension <DesignVariables > {
76
+ DesignVariables () :
77
+ bgMain = const Color (0xfff0f0f0 ),
78
+ bgTopBar = const Color (0xfff5f5f5 ),
79
+ borderBar = const Color (0x33000000 ),
80
+ icon = const Color (0xff666699 ),
81
+ title = const Color (0xff1a1a1a );
82
+
83
+ DesignVariables ._({
84
+ required this .bgMain,
85
+ required this .bgTopBar,
86
+ required this .borderBar,
87
+ required this .icon,
88
+ required this .title,
89
+ });
90
+
91
+ /// The [DesignVariables] from the context's active theme.
92
+ ///
93
+ /// The [ThemeData] must include [DesignVariables] in [ThemeData.extensions] .
94
+ static DesignVariables of (BuildContext context) {
95
+ final theme = Theme .of (context);
96
+ final extension = theme.extension < DesignVariables > ();
97
+ assert (extension != null );
98
+ return extension ! ;
99
+ }
100
+
101
+ final Color bgMain;
102
+ final Color bgTopBar;
103
+ final Color borderBar;
104
+ final Color icon;
105
+ final Color title;
106
+
107
+ @override
108
+ DesignVariables copyWith ({
109
+ Color ? bgMain,
110
+ Color ? bgTopBar,
111
+ Color ? borderBar,
112
+ Color ? icon,
113
+ Color ? title,
114
+ }) {
115
+ return DesignVariables ._(
116
+ bgMain: bgMain ?? this .bgMain,
117
+ bgTopBar: bgTopBar ?? this .bgTopBar,
118
+ borderBar: borderBar ?? this .borderBar,
119
+ icon: icon ?? this .icon,
120
+ title: title ?? this .title,
121
+ );
122
+ }
123
+
124
+ @override
125
+ DesignVariables lerp (DesignVariables ? other, double t) {
126
+ if (identical (this , other)) {
127
+ return this ;
128
+ }
129
+ return DesignVariables ._(
130
+ bgMain: Color .lerp (bgMain, other? .bgMain, t)! ,
131
+ bgTopBar: Color .lerp (bgTopBar, other? .bgTopBar, t)! ,
132
+ borderBar: Color .lerp (borderBar, other? .borderBar, t)! ,
133
+ icon: Color .lerp (icon, other? .icon, t)! ,
134
+ title: Color .lerp (title, other? .title, t)! ,
135
+ );
136
+ }
137
+ }
0 commit comments