Skip to content

Commit 53390fd

Browse files
committed
compose_box [nfc]: Factor out _ComposeBoxContainer
1 parent 052f203 commit 53390fd

File tree

1 file changed

+45
-30
lines changed

1 file changed

+45
-30
lines changed

lib/widgets/compose_box.dart

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,25 @@ class _SendButtonState extends State<_SendButton> {
844844
}
845845
}
846846

847+
class _ComposeBoxContainer extends StatelessWidget {
848+
const _ComposeBoxContainer({required this.child});
849+
850+
final Widget child;
851+
852+
@override
853+
Widget build(BuildContext context) {
854+
ColorScheme colorScheme = Theme.of(context).colorScheme;
855+
856+
return Material(
857+
color: colorScheme.surfaceContainerHighest,
858+
child: SafeArea(
859+
minimum: const EdgeInsets.fromLTRB(8, 0, 8, 8),
860+
child: Padding(
861+
padding: const EdgeInsets.only(top: 8.0),
862+
child: child)));
863+
}
864+
}
865+
847866
class _ComposeBoxLayout extends StatelessWidget {
848867
const _ComposeBoxLayout({
849868
required this.topicInput,
@@ -880,36 +899,32 @@ class _ComposeBoxLayout extends StatelessWidget {
880899
),
881900
);
882901

883-
return Material(
884-
color: colorScheme.surfaceContainerHighest,
885-
child: SafeArea(
886-
minimum: const EdgeInsets.fromLTRB(8, 0, 8, 8),
887-
child: Padding(
888-
padding: const EdgeInsets.only(top: 8.0),
889-
child: blockingErrorBanner != null
890-
? SizedBox(width: double.infinity, child: blockingErrorBanner)
891-
: Column(children: [
892-
Row(crossAxisAlignment: CrossAxisAlignment.end, children: [
893-
Expanded(
894-
child: Theme(
895-
data: inputThemeData,
896-
child: Column(children: [
897-
if (topicInput != null) topicInput!,
898-
if (topicInput != null) const SizedBox(height: 8),
899-
contentInput,
900-
]))),
901-
const SizedBox(width: 8),
902-
sendButton,
903-
]),
904-
Theme(
905-
data: themeData.copyWith(
906-
iconTheme: themeData.iconTheme.copyWith(color: colorScheme.onSurfaceVariant)),
907-
child: Row(children: [
908-
_AttachFileButton(contentController: contentController, contentFocusNode: contentFocusNode),
909-
_AttachMediaButton(contentController: contentController, contentFocusNode: contentFocusNode),
910-
_AttachFromCameraButton(contentController: contentController, contentFocusNode: contentFocusNode),
911-
])),
912-
])))); }
902+
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+
]));
927+
}
913928
}
914929

915930
abstract class ComposeBoxController<T extends StatefulWidget> extends State<T> {

0 commit comments

Comments
 (0)