add reusable widget BottomSafe

This commit is contained in:
krawieck 2021-01-26 23:16:47 +01:00
parent 5a449eb0be
commit 8d0f85ceae
5 changed files with 22 additions and 6 deletions

View File

@ -210,9 +210,11 @@ class HomeTab extends HookWidget {
), ),
), ),
), ),
body: InfiniteHomeList( body: SafeArea(
controller: isc, child: InfiniteHomeList(
selectedList: selectedList.value, controller: isc,
selectedList: selectedList.value,
),
), ),
); );
} }

View File

@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:image_picker/image_picker.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/pictrs.dart';
import 'package:lemmy_api_client/v2.dart'; import 'package:lemmy_api_client/v2.dart';
@ -430,7 +431,7 @@ class _ManageAccount extends HookWidget {
), ),
child: const Text('DELETE ACCOUNT'), child: const Text('DELETE ACCOUNT'),
), ),
const SafeArea(top: false, child: SizedBox.shrink()), const BottomSafe(),
], ],
); );
} }

View File

@ -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);
}

View File

@ -5,6 +5,7 @@ import 'package:lemmy_api_client/v2.dart';
import '../comment_tree.dart'; import '../comment_tree.dart';
import 'bottom_modal.dart'; import 'bottom_modal.dart';
import 'bottom_safe.dart';
import 'comment.dart'; import 'comment.dart';
/// Manages comments section, sorts them /// Manages comments section, sorts them
@ -106,7 +107,7 @@ class CommentSection extends HookWidget {
else else
for (final com in comments) for (final com in comments)
CommentWidget(com, postCreatorId: postCreatorId), CommentWidget(com, postCreatorId: postCreatorId),
const SizedBox(height: 50), const BottomSafe(50),
]); ]);
} }
} }

View File

@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import '../hooks/ref.dart'; import '../hooks/ref.dart';
import 'bottom_safe.dart';
class InfiniteScrollController { class InfiniteScrollController {
VoidCallback clear; VoidCallback clear;
@ -82,7 +83,7 @@ class InfiniteScroll<T> extends HookWidget {
if (i == data.value.length) { if (i == data.value.length) {
// if there are no more, skip // if there are no more, skip
if (!hasMore.current) { if (!hasMore.current) {
return const SafeArea(child: SizedBox.shrink()); return const BottomSafe();
} }
// if it's already fetching more, skip // if it's already fetching more, skip
@ -99,6 +100,7 @@ class InfiniteScroll<T> extends HookWidget {
} }
return SafeArea( return SafeArea(
top: false,
child: loadingWidget, child: loadingWidget,
); );
} }