Skip to content

Commit d78b698

Browse files
committed
compose: Support error banner redesign for replacing the compose box
While this design is for errors displayed on top of the compose box (not yet implemented), this can also be conveniently applied to the error banner that we replace the compose box with, reusing the existing _ErrorBanner implementation. The referenced Figma design: - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4031-15770&node-type=frame&t=vOSEWlXAhBa5EsAv-0 - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4031-16992&node-type=frame&t=vOSEWlXAhBa5EsAv-0 Signed-off-by: Zixuan James Li <[email protected]>
1 parent 1f3d907 commit d78b698

File tree

2 files changed

+41
-33
lines changed

2 files changed

+41
-33
lines changed

lib/widgets/compose_box.dart

+20-12
Original file line numberDiff line numberDiff line change
@@ -1282,16 +1282,27 @@ class _ErrorBanner extends StatelessWidget {
12821282
@override
12831283
Widget build(BuildContext context) {
12841284
final designVariables = DesignVariables.of(context);
1285+
final labelTextStyle = TextStyle(
1286+
fontSize: 17,
1287+
height: 22 / 17,
1288+
color: designVariables.btnLabelAttMediumDanger,
1289+
).merge(weightVariableTextStyle(context,
1290+
// The Figma uses a weight of SemiBold,
1291+
// which is a variable equivalent to this value.
1292+
wght: 600));
1293+
12851294
return Container(
1286-
padding: const EdgeInsets.all(8),
1295+
constraints: const BoxConstraints(minHeight: 40),
12871296
decoration: BoxDecoration(
1288-
color: designVariables.errorBannerBackground,
1289-
border: Border.all(color: designVariables.errorBannerBorder),
1290-
borderRadius: BorderRadius.circular(5)),
1291-
child: Text(label,
1292-
style: TextStyle(fontSize: 18, color: designVariables.errorBannerLabel),
1293-
),
1294-
);
1297+
color: designVariables.bannerBgIntDanger),
1298+
child: Row(
1299+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1300+
children: [
1301+
Expanded(
1302+
child: Padding(
1303+
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 9),
1304+
child: Text(label, style: labelTextStyle))),
1305+
]));
12951306
}
12961307
}
12971308

@@ -1403,10 +1414,7 @@ class ComposeBox extends StatelessWidget {
14031414
Widget build(BuildContext context) {
14041415
final errorBanner = _errorBanner(context);
14051416
if (errorBanner != null) {
1406-
return _ComposeBoxContainer(children: [
1407-
SafeArea(minimum: const EdgeInsets.symmetric(horizontal: 8),
1408-
child: errorBanner)
1409-
]);
1417+
return _ComposeBoxContainer(children: [errorBanner]);
14101418
}
14111419

14121420
final narrow = this.narrow;

lib/widgets/theme.dart

+21-21
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
114114
DesignVariables.light() :
115115
this._(
116116
background: const Color(0xffffffff),
117+
bannerBgIntDanger: const Color(0xfff2e4e4),
117118
bgContextMenu: const Color(0xfff2f2f2),
118119
bgCounterUnread: const Color(0xff666699).withValues(alpha: 0.15),
119120
bgTopBar: const Color(0xfff5f5f5),
120121
borderBar: Colors.black.withValues(alpha: 0.2),
122+
btnLabelAttLowIntDanger: const Color(0xffc0070a),
123+
btnLabelAttMediumDanger: const Color(0xffac0508),
121124
composeBoxBg: const Color(0xffffffff),
122125
contextMenuCancelText: const Color(0xff222222),
123126
contextMenuItemBg: const Color(0xff6159e1),
@@ -135,9 +138,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
135138
atMentionMarker: const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor(),
136139
contextMenuCancelBg: const Color(0xff797986),
137140
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor(),
138-
errorBannerBackground: const HSLColor.fromAHSL(1, 4, 0.33, 0.90).toColor(),
139-
errorBannerBorder: const HSLColor.fromAHSL(0.4, 3, 0.57, 0.33).toColor(),
140-
errorBannerLabel: const HSLColor.fromAHSL(1, 4, 0.58, 0.33).toColor(),
141141
groupDmConversationIcon: Colors.black.withValues(alpha: 0.5),
142142
groupDmConversationIconBg: const Color(0x33808080),
143143
loginOrDivider: const Color(0xffdedede),
@@ -154,10 +154,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
154154
DesignVariables.dark() :
155155
this._(
156156
background: const Color(0xff000000),
157+
bannerBgIntDanger: const Color(0xff461616),
157158
bgContextMenu: const Color(0xff262626),
158159
bgCounterUnread: const Color(0xff666699).withValues(alpha: 0.37),
159160
bgTopBar: const Color(0xff242424),
160161
borderBar: Colors.black.withValues(alpha: 0.5),
162+
btnLabelAttLowIntDanger: const Color(0xffff8b7c),
163+
btnLabelAttMediumDanger: const Color(0xffff8b7c),
161164
composeBoxBg: const Color(0xff0f0f0f),
162165
contextMenuCancelText: const Color(0xffffffff).withValues(alpha: 0.75),
163166
contextMenuItemBg: const Color(0xff7977fe),
@@ -176,9 +179,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
176179
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
177180
atMentionMarker: const HSLColor.fromAHSL(0.4, 0, 0, 1).toColor(),
178181
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.15, 0.2).toColor(),
179-
errorBannerBackground: const HSLColor.fromAHSL(1, 0, 0.61, 0.19).toColor(),
180-
errorBannerBorder: const HSLColor.fromAHSL(0.4, 3, 0.73, 0.74).toColor(),
181-
errorBannerLabel: const HSLColor.fromAHSL(1, 2, 0.73, 0.80).toColor(),
182182
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
183183
groupDmConversationIcon: Colors.white.withValues(alpha: 0.5),
184184
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
@@ -201,10 +201,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
201201

202202
DesignVariables._({
203203
required this.background,
204+
required this.bannerBgIntDanger,
204205
required this.bgContextMenu,
205206
required this.bgCounterUnread,
206207
required this.bgTopBar,
207208
required this.borderBar,
209+
required this.btnLabelAttLowIntDanger,
210+
required this.btnLabelAttMediumDanger,
208211
required this.composeBoxBg,
209212
required this.contextMenuCancelText,
210213
required this.contextMenuItemBg,
@@ -222,9 +225,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
222225
required this.atMentionMarker,
223226
required this.contextMenuCancelBg,
224227
required this.dmHeaderBg,
225-
required this.errorBannerBackground,
226-
required this.errorBannerBorder,
227-
required this.errorBannerLabel,
228228
required this.groupDmConversationIcon,
229229
required this.groupDmConversationIconBg,
230230
required this.loginOrDivider,
@@ -249,10 +249,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
249249
}
250250

251251
final Color background;
252+
final Color bannerBgIntDanger;
252253
final Color bgContextMenu;
253254
final Color bgCounterUnread;
254255
final Color bgTopBar;
255256
final Color borderBar;
257+
final Color btnLabelAttLowIntDanger;
258+
final Color btnLabelAttMediumDanger;
256259
final Color composeBoxBg;
257260
final Color contextMenuCancelText;
258261
final Color contextMenuItemBg;
@@ -274,9 +277,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
274277
final Color atMentionMarker;
275278
final Color contextMenuCancelBg; // In Figma, but unnamed.
276279
final Color dmHeaderBg;
277-
final Color errorBannerBackground;
278-
final Color errorBannerBorder;
279-
final Color errorBannerLabel;
280280
final Color groupDmConversationIcon;
281281
final Color groupDmConversationIconBg;
282282
final Color loginOrDivider; // TODO(design-dark) need proper dark-theme color (this is ad hoc)
@@ -292,10 +292,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
292292
@override
293293
DesignVariables copyWith({
294294
Color? background,
295+
Color? bannerBgIntDanger,
295296
Color? bgContextMenu,
296297
Color? bgCounterUnread,
297298
Color? bgTopBar,
298299
Color? borderBar,
300+
Color? btnLabelAttLowIntDanger,
301+
Color? btnLabelAttMediumDanger,
299302
Color? composeBoxBg,
300303
Color? contextMenuCancelText,
301304
Color? contextMenuItemBg,
@@ -313,9 +316,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
313316
Color? atMentionMarker,
314317
Color? contextMenuCancelBg,
315318
Color? dmHeaderBg,
316-
Color? errorBannerBackground,
317-
Color? errorBannerBorder,
318-
Color? errorBannerLabel,
319319
Color? groupDmConversationIcon,
320320
Color? groupDmConversationIconBg,
321321
Color? loginOrDivider,
@@ -330,10 +330,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
330330
}) {
331331
return DesignVariables._(
332332
background: background ?? this.background,
333+
bannerBgIntDanger: bannerBgIntDanger ?? this.bannerBgIntDanger,
333334
bgContextMenu: bgContextMenu ?? this.bgContextMenu,
334335
bgCounterUnread: bgCounterUnread ?? this.bgCounterUnread,
335336
bgTopBar: bgTopBar ?? this.bgTopBar,
336337
borderBar: borderBar ?? this.borderBar,
338+
btnLabelAttLowIntDanger: btnLabelAttLowIntDanger ?? this.btnLabelAttLowIntDanger,
339+
btnLabelAttMediumDanger: btnLabelAttMediumDanger ?? this.btnLabelAttMediumDanger,
337340
composeBoxBg: composeBoxBg ?? this.composeBoxBg,
338341
contextMenuCancelText: contextMenuCancelText ?? this.contextMenuCancelText,
339342
contextMenuItemBg: contextMenuItemBg ?? this.contextMenuItemBg,
@@ -351,9 +354,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
351354
atMentionMarker: atMentionMarker ?? this.atMentionMarker,
352355
contextMenuCancelBg: contextMenuCancelBg ?? this.contextMenuCancelBg,
353356
dmHeaderBg: dmHeaderBg ?? this.dmHeaderBg,
354-
errorBannerBackground: errorBannerBackground ?? this.errorBannerBackground,
355-
errorBannerBorder: errorBannerBorder ?? this.errorBannerBorder,
356-
errorBannerLabel: errorBannerLabel ?? this.errorBannerLabel,
357357
groupDmConversationIcon: groupDmConversationIcon ?? this.groupDmConversationIcon,
358358
groupDmConversationIconBg: groupDmConversationIconBg ?? this.groupDmConversationIconBg,
359359
loginOrDivider: loginOrDivider ?? this.loginOrDivider,
@@ -375,10 +375,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
375375
}
376376
return DesignVariables._(
377377
background: Color.lerp(background, other.background, t)!,
378+
bannerBgIntDanger: Color.lerp(bannerBgIntDanger, other.bannerBgIntDanger, t)!,
378379
bgContextMenu: Color.lerp(bgContextMenu, other.bgContextMenu, t)!,
379380
bgCounterUnread: Color.lerp(bgCounterUnread, other.bgCounterUnread, t)!,
380381
bgTopBar: Color.lerp(bgTopBar, other.bgTopBar, t)!,
381382
borderBar: Color.lerp(borderBar, other.borderBar, t)!,
383+
btnLabelAttLowIntDanger: Color.lerp(btnLabelAttLowIntDanger, other.btnLabelAttLowIntDanger, t)!,
384+
btnLabelAttMediumDanger: Color.lerp(btnLabelAttMediumDanger, other.btnLabelAttMediumDanger, t)!,
382385
composeBoxBg: Color.lerp(composeBoxBg, other.composeBoxBg, t)!,
383386
contextMenuCancelText: Color.lerp(contextMenuCancelText, other.contextMenuCancelText, t)!,
384387
contextMenuItemBg: Color.lerp(contextMenuItemBg, other.contextMenuItemBg, t)!,
@@ -396,9 +399,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
396399
atMentionMarker: Color.lerp(atMentionMarker, other.atMentionMarker, t)!,
397400
contextMenuCancelBg: Color.lerp(contextMenuCancelBg, other.contextMenuCancelBg, t)!,
398401
dmHeaderBg: Color.lerp(dmHeaderBg, other.dmHeaderBg, t)!,
399-
errorBannerBackground: Color.lerp(errorBannerBackground, other.errorBannerBackground, t)!,
400-
errorBannerBorder: Color.lerp(errorBannerBorder, other.errorBannerBorder, t)!,
401-
errorBannerLabel: Color.lerp(errorBannerLabel, other.errorBannerLabel, t)!,
402402
groupDmConversationIcon: Color.lerp(groupDmConversationIcon, other.groupDmConversationIcon, t)!,
403403
groupDmConversationIconBg: Color.lerp(groupDmConversationIconBg, other.groupDmConversationIconBg, t)!,
404404
loginOrDivider: Color.lerp(loginOrDivider, other.loginOrDivider, t)!,

0 commit comments

Comments
 (0)