From 8d0f85ceae4214267dafc379e17c85243dcdcce1 Mon Sep 17 00:00:00 2001 From: krawieck Date: Tue, 26 Jan 2021 23:16:47 +0100 Subject: [PATCH] add reusable widget BottomSafe --- lib/pages/home_tab.dart | 8 +++++--- lib/pages/manage_account.dart | 3 ++- lib/widgets/bottom_safe.dart | 10 ++++++++++ lib/widgets/comment_section.dart | 3 ++- lib/widgets/infinite_scroll.dart | 4 +++- 5 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 lib/widgets/bottom_safe.dart diff --git a/lib/pages/home_tab.dart b/lib/pages/home_tab.dart index 7276fc2..599bb6c 100644 --- a/lib/pages/home_tab.dart +++ b/lib/pages/home_tab.dart @@ -210,9 +210,11 @@ class HomeTab extends HookWidget { ), ), ), - body: InfiniteHomeList( - controller: isc, - selectedList: selectedList.value, + body: SafeArea( + child: InfiniteHomeList( + controller: isc, + selectedList: selectedList.value, + ), ), ); } diff --git a/lib/pages/manage_account.dart b/lib/pages/manage_account.dart index 282efb5..3f2890d 100644 --- a/lib/pages/manage_account.dart +++ b/lib/pages/manage_account.dart @@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:lemmur/widgets/bottom_safe.dart'; import 'package:lemmy_api_client/pictrs.dart'; import 'package:lemmy_api_client/v2.dart'; @@ -430,7 +431,7 @@ class _ManageAccount extends HookWidget { ), child: const Text('DELETE ACCOUNT'), ), - const SafeArea(top: false, child: SizedBox.shrink()), + const BottomSafe(), ], ); } diff --git a/lib/widgets/bottom_safe.dart b/lib/widgets/bottom_safe.dart new file mode 100644 index 0000000..f4eead8 --- /dev/null +++ b/lib/widgets/bottom_safe.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class BottomSafe extends StatelessWidget { + final double additionalPadding; + const BottomSafe([this.additionalPadding = 0]); + + @override + Widget build(BuildContext context) => SizedBox( + height: MediaQuery.of(context).padding.bottom + additionalPadding); +} diff --git a/lib/widgets/comment_section.dart b/lib/widgets/comment_section.dart index 8ec9c29..a224623 100644 --- a/lib/widgets/comment_section.dart +++ b/lib/widgets/comment_section.dart @@ -5,6 +5,7 @@ import 'package:lemmy_api_client/v2.dart'; import '../comment_tree.dart'; import 'bottom_modal.dart'; +import 'bottom_safe.dart'; import 'comment.dart'; /// Manages comments section, sorts them @@ -106,7 +107,7 @@ class CommentSection extends HookWidget { else for (final com in comments) CommentWidget(com, postCreatorId: postCreatorId), - const SizedBox(height: 50), + const BottomSafe(50), ]); } } diff --git a/lib/widgets/infinite_scroll.dart b/lib/widgets/infinite_scroll.dart index 0a285b3..7e4b7c4 100644 --- a/lib/widgets/infinite_scroll.dart +++ b/lib/widgets/infinite_scroll.dart @@ -3,6 +3,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import '../hooks/ref.dart'; +import 'bottom_safe.dart'; class InfiniteScrollController { VoidCallback clear; @@ -82,7 +83,7 @@ class InfiniteScroll extends HookWidget { if (i == data.value.length) { // if there are no more, skip if (!hasMore.current) { - return const SafeArea(child: SizedBox.shrink()); + return const BottomSafe(); } // if it's already fetching more, skip @@ -99,6 +100,7 @@ class InfiniteScroll extends HookWidget { } return SafeArea( + top: false, child: loadingWidget, ); }