Skip to content

Commit 8c862ad

Browse files
committed
compose_box [nfc]: Move blockingErrorBanner from _ComposeBoxLayout to caller
This lets _ComposeBoxLayout stay focused on the complexity of how the text inputs, the editing buttons, and the send button relate to each other. In the case where an error banner is present, this also lets us skip in the build method some logic to compute things that won't end up getting used.
1 parent 8a574fc commit 8c862ad

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

lib/widgets/compose_box.dart

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -870,13 +870,11 @@ class _ComposeBoxLayout extends StatelessWidget {
870870
required this.sendButton,
871871
required this.contentController,
872872
required this.contentFocusNode,
873-
this.blockingErrorBanner,
874873
});
875874

876875
final Widget? topicInput;
877876
final Widget contentInput;
878877
final Widget sendButton;
879-
final Widget? blockingErrorBanner;
880878
final ComposeContentController contentController;
881879
final FocusNode contentFocusNode;
882880

@@ -900,30 +898,28 @@ class _ComposeBoxLayout extends StatelessWidget {
900898
);
901899

902900
return _ComposeBoxContainer(
903-
child: blockingErrorBanner != null
904-
? SizedBox(width: double.infinity, child: blockingErrorBanner)
905-
: Column(children: [
906-
Row(crossAxisAlignment: CrossAxisAlignment.end, children: [
907-
Expanded(
908-
child: Theme(
909-
data: inputThemeData,
910-
child: Column(children: [
911-
if (topicInput != null) topicInput!,
912-
if (topicInput != null) const SizedBox(height: 8),
913-
contentInput,
914-
]))),
915-
const SizedBox(width: 8),
916-
sendButton,
917-
]),
918-
Theme(
919-
data: themeData.copyWith(
920-
iconTheme: themeData.iconTheme.copyWith(color: colorScheme.onSurfaceVariant)),
921-
child: Row(children: [
922-
_AttachFileButton(contentController: contentController, contentFocusNode: contentFocusNode),
923-
_AttachMediaButton(contentController: contentController, contentFocusNode: contentFocusNode),
924-
_AttachFromCameraButton(contentController: contentController, contentFocusNode: contentFocusNode),
925-
])),
926-
]));
901+
child: Column(children: [
902+
Row(crossAxisAlignment: CrossAxisAlignment.end, children: [
903+
Expanded(
904+
child: Theme(
905+
data: inputThemeData,
906+
child: Column(children: [
907+
if (topicInput != null) topicInput!,
908+
if (topicInput != null) const SizedBox(height: 8),
909+
contentInput,
910+
]))),
911+
const SizedBox(width: 8),
912+
sendButton,
913+
]),
914+
Theme(
915+
data: themeData.copyWith(
916+
iconTheme: themeData.iconTheme.copyWith(color: colorScheme.onSurfaceVariant)),
917+
child: Row(children: [
918+
_AttachFileButton(contentController: contentController, contentFocusNode: contentFocusNode),
919+
_AttachMediaButton(contentController: contentController, contentFocusNode: contentFocusNode),
920+
_AttachFromCameraButton(contentController: contentController, contentFocusNode: contentFocusNode),
921+
])),
922+
]));
927923
}
928924
}
929925

@@ -1054,6 +1050,13 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox
10541050

10551051
@override
10561052
Widget build(BuildContext context) {
1053+
final errorBanner = _errorBanner(context);
1054+
if (errorBanner != null) {
1055+
return _ComposeBoxContainer(
1056+
child: SizedBox(width: double.infinity,
1057+
child: errorBanner));
1058+
}
1059+
10571060
return _ComposeBoxLayout(
10581061
contentController: _contentController,
10591062
contentFocusNode: _contentFocusNode,
@@ -1067,8 +1070,7 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox
10671070
topicController: null,
10681071
contentController: _contentController,
10691072
getDestination: () => widget.narrow.destination,
1070-
),
1071-
blockingErrorBanner: _errorBanner(context));
1073+
));
10721074
}
10731075
}
10741076

0 commit comments

Comments
 (0)