Skip to content

Commit 0ebe1b9

Browse files
chrisbobbegnprice
authored andcommitted
compose [nfc]: Extract base class from _ErrorBanner, for reuse
We'll add a new subclass for the "Cancel" / "Save" banner in the upcoming edit-message compose box.
1 parent 8cf9c37 commit 0ebe1b9

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

lib/widgets/compose_box.dart

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,23 +1376,26 @@ class StreamComposeBoxController extends ComposeBoxController {
13761376

13771377
class FixedDestinationComposeBoxController extends ComposeBoxController {}
13781378

1379-
class _ErrorBanner extends StatelessWidget {
1380-
const _ErrorBanner({required this.label});
1379+
abstract class _Banner extends StatelessWidget {
1380+
const _Banner({required this.label});
13811381

13821382
final String label;
13831383

1384+
Color getLabelColor(DesignVariables designVariables);
1385+
Color getBackgroundColor(DesignVariables designVariables);
1386+
13841387
@override
13851388
Widget build(BuildContext context) {
13861389
final designVariables = DesignVariables.of(context);
13871390
final labelTextStyle = TextStyle(
13881391
fontSize: 17,
13891392
height: 22 / 17,
1390-
color: designVariables.btnLabelAttMediumIntDanger,
1393+
color: getLabelColor(designVariables),
13911394
).merge(weightVariableTextStyle(context, wght: 600));
13921395

13931396
return DecoratedBox(
13941397
decoration: BoxDecoration(
1395-
color: designVariables.bannerBgIntDanger),
1398+
color: getBackgroundColor(designVariables)),
13961399
child: SafeArea(
13971400
minimum: const EdgeInsetsDirectional.only(start: 8)
13981401
// (SafeArea.minimum doesn't take an EdgeInsetsDirectional)
@@ -1405,12 +1408,24 @@ class _ErrorBanner extends StatelessWidget {
14051408
child: Text(style: labelTextStyle,
14061409
label))),
14071410
const SizedBox(width: 8),
1408-
// TODO(#720) "x" button goes here.
1411+
// TODO(#720) "x" button for the error banner goes here.
14091412
// 24px square with 8px touchable padding in all directions?
14101413
])));
14111414
}
14121415
}
14131416

1417+
class _ErrorBanner extends _Banner {
1418+
const _ErrorBanner({required super.label});
1419+
1420+
@override
1421+
Color getLabelColor(DesignVariables designVariables) =>
1422+
designVariables.btnLabelAttMediumIntDanger;
1423+
1424+
@override
1425+
Color getBackgroundColor(DesignVariables designVariables) =>
1426+
designVariables.bannerBgIntDanger;
1427+
}
1428+
14141429
/// The compose box.
14151430
///
14161431
/// Takes the full screen width, covering the horizontal insets with its surface.

0 commit comments

Comments
 (0)