From b39d6b06d768a79b93c92e4ccb4fb9a0d7b19ade Mon Sep 17 00:00:00 2001 From: Filip Krawczyk Date: Thu, 25 Aug 2022 17:27:40 +0200 Subject: [PATCH] create widget for stuff that sticks to bottom --- lib/pages/create_post/create_post.dart | 16 +++++----------- lib/pages/manage_account.dart | 18 ++++++------------ lib/widgets/editor/editor_toolbar.dart | 18 +++++++++++++++++- lib/widgets/write_comment.dart | 16 +++++----------- 4 files changed, 33 insertions(+), 35 deletions(-) diff --git a/lib/pages/create_post/create_post.dart b/lib/pages/create_post/create_post.dart index af64f45..39128d2 100644 --- a/lib/pages/create_post/create_post.dart +++ b/lib/pages/create_post/create_post.dart @@ -142,17 +142,11 @@ class CreatePostPage extends HookWidget { ), ), ), - SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const Spacer(), - EditorToolbar( - editorFocusNode: editorFocusNode, - controller: bodyController, - instanceHost: context.read().instanceHost, - ), - ], + BottomSticky( + child: EditorToolbar( + editorFocusNode: editorFocusNode, + controller: bodyController, + instanceHost: context.read().instanceHost, ), ), ], diff --git a/lib/pages/manage_account.dart b/lib/pages/manage_account.dart index 84047c3..3d914c8 100644 --- a/lib/pages/manage_account.dart +++ b/lib/pages/manage_account.dart @@ -384,19 +384,13 @@ class _ManageAccount extends HookWidget { const BottomSafe(), ], ), - SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const Spacer(), - EditorToolbar( - editorFocusNode: bioFocusNode, - controller: bioController, - instanceHost: user.instanceHost, - ), - ], + BottomSticky( + child: EditorToolbar( + editorFocusNode: bioFocusNode, + controller: bioController, + instanceHost: user.instanceHost, ), - ), + ) ], ); } diff --git a/lib/widgets/editor/editor_toolbar.dart b/lib/widgets/editor/editor_toolbar.dart index 709560b..6572cf3 100644 --- a/lib/widgets/editor/editor_toolbar.dart +++ b/lib/widgets/editor/editor_toolbar.dart @@ -87,7 +87,23 @@ class EditorToolbar extends HookWidget { ); } - static Widget safeArea = const SizedBox(height: _height); + static const safeArea = SizedBox(height: _height); +} + +class BottomSticky extends StatelessWidget { + final Widget child; + const BottomSticky({required this.child}); + + @override + Widget build(BuildContext context) => SafeArea( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Spacer(), + child, + ], + ), + ); } class _ToolbarBody extends HookWidget { diff --git a/lib/widgets/write_comment.dart b/lib/widgets/write_comment.dart index 5456f2c..4f6e1c3 100644 --- a/lib/widgets/write_comment.dart +++ b/lib/widgets/write_comment.dart @@ -137,17 +137,11 @@ class WriteComment extends HookWidget { EditorToolbar.safeArea, ], ), - SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const Spacer(), - EditorToolbar( - editorFocusNode: editorFocusNode, - controller: controller, - instanceHost: post.instanceHost, - ), - ], + BottomSticky( + child: EditorToolbar( + editorFocusNode: editorFocusNode, + controller: controller, + instanceHost: post.instanceHost, ), ), ],