@@ -1328,6 +1328,18 @@ abstract class _Banner extends StatelessWidget {
1328
1328
Color getLabelColor (DesignVariables designVariables);
1329
1329
Color getBackgroundColor (DesignVariables designVariables);
1330
1330
1331
+ /// A trailing element, with no outer padding for spacing/positioning.
1332
+ ///
1333
+ /// To control the element's distance from the end edge, override [padEnd] .
1334
+ Widget ? buildTrailing (BuildContext context);
1335
+
1336
+ /// Whether to add 8px trailing padding.
1337
+ ///
1338
+ /// Subclasses can use `false` when the [buildTrailing] element
1339
+ /// is meant to abut the edge of the screen
1340
+ /// in the common case that there are no horizontal device insets.
1341
+ bool get padEnd => true ;
1342
+
1331
1343
@override
1332
1344
Widget build (BuildContext context) {
1333
1345
final designVariables = DesignVariables .of (context);
@@ -1337,6 +1349,7 @@ abstract class _Banner extends StatelessWidget {
1337
1349
color: getLabelColor (designVariables),
1338
1350
).merge (weightVariableTextStyle (context, wght: 600 ));
1339
1351
1352
+ final trailing = buildTrailing (context);
1340
1353
return DecoratedBox (
1341
1354
decoration: BoxDecoration (
1342
1355
color: getBackgroundColor (designVariables)),
@@ -1353,9 +1366,11 @@ abstract class _Banner extends StatelessWidget {
1353
1366
padding: const EdgeInsets .symmetric (vertical: 4 ),
1354
1367
child: Text (style: labelTextStyle,
1355
1368
label))),
1356
- const SizedBox (width: 8 ),
1357
- // TODO(#720) "x" button for the error banner goes here.
1358
- // 24px square with 8px touchable padding in all directions?
1369
+ if (trailing != null ) ...[
1370
+ const SizedBox (width: 8 ),
1371
+ trailing,
1372
+ ],
1373
+ if (padEnd) const SizedBox (width: 8 ),
1359
1374
]))));
1360
1375
}
1361
1376
}
@@ -1370,6 +1385,15 @@ class _ErrorBanner extends _Banner {
1370
1385
@override
1371
1386
Color getBackgroundColor (DesignVariables designVariables) =>
1372
1387
designVariables.bannerBgIntDanger;
1388
+
1389
+ @override
1390
+ Widget ? buildTrailing (context) {
1391
+ // TODO(#720) "x" button goes here.
1392
+ // 24px square with 8px touchable padding in all directions?
1393
+ // and `bool get padEnd => false`; see Figma:
1394
+ // https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4031-17029&m=dev
1395
+ return null ;
1396
+ }
1373
1397
}
1374
1398
1375
1399
/// The compose box.
0 commit comments