@@ -1384,6 +1384,18 @@ abstract class _Banner extends StatelessWidget {
1384
1384
Color getLabelColor (DesignVariables designVariables);
1385
1385
Color getBackgroundColor (DesignVariables designVariables);
1386
1386
1387
+ /// A trailing element, with no outer padding for spacing/positioning.
1388
+ ///
1389
+ /// To control the element's distance from the end edge, override [padEnd] .
1390
+ Widget ? buildTrailing (BuildContext context);
1391
+
1392
+ /// Whether to add 8px trailing padding.
1393
+ ///
1394
+ /// Subclasses can use `false` when the [buildTrailing] element
1395
+ /// is meant to abut the edge of the screen
1396
+ /// in the common case that there are no horizontal device insets.
1397
+ bool get padEnd => true ;
1398
+
1387
1399
@override
1388
1400
Widget build (BuildContext context) {
1389
1401
final designVariables = DesignVariables .of (context);
@@ -1393,6 +1405,7 @@ abstract class _Banner extends StatelessWidget {
1393
1405
color: getLabelColor (designVariables),
1394
1406
).merge (weightVariableTextStyle (context, wght: 600 ));
1395
1407
1408
+ final trailing = buildTrailing (context);
1396
1409
return DecoratedBox (
1397
1410
decoration: BoxDecoration (
1398
1411
color: getBackgroundColor (designVariables)),
@@ -1409,9 +1422,11 @@ abstract class _Banner extends StatelessWidget {
1409
1422
padding: const EdgeInsets .symmetric (vertical: 4 ),
1410
1423
child: Text (style: labelTextStyle,
1411
1424
label))),
1412
- const SizedBox (width: 8 ),
1413
- // TODO(#720) "x" button for the error banner goes here.
1414
- // 24px square with 8px touchable padding in all directions?
1425
+ if (trailing != null ) ...[
1426
+ const SizedBox (width: 8 ),
1427
+ trailing,
1428
+ ],
1429
+ if (padEnd) const SizedBox (width: 8 ),
1415
1430
]))));
1416
1431
}
1417
1432
}
@@ -1426,6 +1441,15 @@ class _ErrorBanner extends _Banner {
1426
1441
@override
1427
1442
Color getBackgroundColor (DesignVariables designVariables) =>
1428
1443
designVariables.bannerBgIntDanger;
1444
+
1445
+ @override
1446
+ Widget ? buildTrailing (context) {
1447
+ // TODO(#720) "x" button goes here.
1448
+ // 24px square with 8px touchable padding in all directions?
1449
+ // and `bool get padEnd => false`; see Figma:
1450
+ // https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4031-17029&m=dev
1451
+ return null ;
1452
+ }
1429
1453
}
1430
1454
1431
1455
/// The compose box.
0 commit comments