Skip to content

Commit f0fe523

Browse files
committed
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 2117fe1 commit f0fe523

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
@@ -1320,23 +1320,26 @@ class StreamComposeBoxController extends ComposeBoxController {
13201320

13211321
class FixedDestinationComposeBoxController extends ComposeBoxController {}
13221322

1323-
class _ErrorBanner extends StatelessWidget {
1324-
const _ErrorBanner({required this.label});
1323+
abstract class _Banner extends StatelessWidget {
1324+
const _Banner({required this.label});
13251325

13261326
final String label;
13271327

1328+
Color getLabelColor(DesignVariables designVariables);
1329+
Color getBackgroundColor(DesignVariables designVariables);
1330+
13281331
@override
13291332
Widget build(BuildContext context) {
13301333
final designVariables = DesignVariables.of(context);
13311334
final labelTextStyle = TextStyle(
13321335
fontSize: 17,
13331336
height: 22 / 17,
1334-
color: designVariables.btnLabelAttMediumIntDanger,
1337+
color: getLabelColor(designVariables),
13351338
).merge(weightVariableTextStyle(context, wght: 600));
13361339

13371340
return DecoratedBox(
13381341
decoration: BoxDecoration(
1339-
color: designVariables.bannerBgIntDanger),
1342+
color: getBackgroundColor(designVariables)),
13401343
child: SafeArea(
13411344
minimum: const EdgeInsetsDirectional.only(start: 8)
13421345
// (SafeArea.minimum doesn't take an EdgeInsetsDirectional)
@@ -1349,12 +1352,24 @@ class _ErrorBanner extends StatelessWidget {
13491352
child: Text(style: labelTextStyle,
13501353
label))),
13511354
const SizedBox(width: 8),
1352-
// TODO(#720) "x" button goes here.
1355+
// TODO(#720) "x" button for the error banner goes here.
13531356
// 24px square with 8px touchable padding in all directions?
13541357
])));
13551358
}
13561359
}
13571360

1361+
class _ErrorBanner extends _Banner {
1362+
const _ErrorBanner({required super.label});
1363+
1364+
@override
1365+
Color getLabelColor(DesignVariables designVariables) =>
1366+
designVariables.btnLabelAttMediumIntDanger;
1367+
1368+
@override
1369+
Color getBackgroundColor(DesignVariables designVariables) =>
1370+
designVariables.bannerBgIntDanger;
1371+
}
1372+
13581373
/// The compose box.
13591374
///
13601375
/// Takes the full screen width, covering the horizontal insets with its surface.

0 commit comments

Comments
 (0)