Skip to content

Commit 16fa5f2

Browse files
committed
fix: constrains custom bottom sheet size
Because the place where we could insert view padding is not hold the exact view padding of the page, set sheet maximum height to 80% to avoid contents covered by status bar. Also add bottom padding to avoid navigation bar.
1 parent a16d41a commit 16fa5f2

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

lib/features/forum/widgets/thread_filter_chip.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ class ThreadChip extends StatelessWidget {
3232
/// Build to provide a list of widgets as bottom sheet content.
3333
final List<Widget> Function(BuildContext context, ForumState state) sheetItemBuilder;
3434

35-
Widget _buildContent(BuildContext context, ForumState state) {
36-
return SingleChildScrollView(child: Column(children: sheetItemBuilder(context, state)));
37-
}
38-
3935
@override
4036
Widget build(BuildContext context) {
4137
return BlocBuilder<ForumBloc, ForumState>(
@@ -52,7 +48,9 @@ class ThreadChip extends StatelessWidget {
5248
context: context,
5349
builder: (_) => BlocProvider.value(
5450
value: context.read<ForumBloc>(),
55-
child: BlocBuilder<ForumBloc, ForumState>(builder: _buildContent),
51+
child: BlocBuilder<ForumBloc, ForumState>(
52+
builder: (_, state) => ListView(children: sheetItemBuilder(context, state)),
53+
),
5654
),
5755
);
5856
},
@@ -82,7 +80,7 @@ class ThreadTypeChip extends StatelessWidget {
8280
chipLabel: currFilter ?? state.filterTypeList.firstWhereOrNull((e) => e.typeID == null)?.name ?? '',
8381
chipSelected: state.filterState.filterType?.typeID != null,
8482
sheetTitle: context.t.forumPage.threadTab.threadType,
85-
sheetItemBuilder: (context, state) => state.filterTypeList
83+
sheetItemBuilder: (context, state) => [...state.filterTypeList, ...state.filterTypeList]
8684
.map(
8785
(e) => SelectableListTile(
8886
title: Text(e.name),

lib/utils/show_bottom_sheet.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ Future<T?> showCustomBottomSheet<T>({
2727
content = SingleChildScrollView(child: Column(children: childrenBuilder!(context)));
2828
}
2929

30+
final size = MediaQuery.sizeOf(context);
31+
3032
// Copied from [showHeroDialog]
3133
final ret = Navigator.push<T>(
3234
context,
3335
ModalSheetRoute(
3436
maintainState: false,
3537
swipeDismissible: true,
36-
viewportPadding: EdgeInsets.only(
37-
// Add the top padding to avoid the status bar.
38-
top: MediaQuery.viewPaddingOf(context).top,
39-
),
38+
// Here we do not have a context carrying expected padding values.
39+
// Set the maximum height to 80% to avoid covered by status bar.
40+
viewportPadding: EdgeInsets.only(top: size.height * 0.2),
4041
builder: (context) {
4142
return ClipRRect(
4243
borderRadius: const BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)),
@@ -62,7 +63,7 @@ Future<T?> showCustomBottomSheet<T>({
6263
],
6364
),
6465
),
65-
body: content,
66+
body: Padding(padding: context.safePadding(), child: content),
6667
bottomBar: bottomBar,
6768
),
6869
),

0 commit comments

Comments
 (0)