Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Make SortFilterSheet scrollable #351

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions lib/app/sort_filter/sort_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,51 +148,64 @@ class SortFilterSelection<T> {
assert(callback != null);

var currentSelection = this;
context.showFancyModalBottomSheet(
// Gives us more vertical space.
// Ideally, this should be changed in the black_hole_flutter package
// so we can use a FancyModalBottomSheet
context.showModalBottomSheet(
// Allows the sheet to expand vertically
isScrollControlled: true,
useRootNavigator: true,
builder: (_) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: StatefulBuilder(
builder: (_, setState) {
return SortFilterSelectionWidget(
selection: currentSelection,
onSelectionChange: (selection) {
setState(() => currentSelection = selection);
callback(selection);
},
);
},
return DraggableScrollableSheet(
expand: false,
builder: (context, controller) => Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: StatefulBuilder(
builder: (_, setState) {
return _SortFilterSelectionWidget(
selection: currentSelection,
onSelectionChange: (selection) {
setState(() => currentSelection = selection);
callback(selection);
},
scrollController: controller,
);
},
),
),
);
},
);
}
}

class SortFilterSelectionWidget<T> extends StatelessWidget {
const SortFilterSelectionWidget({
class _SortFilterSelectionWidget<T> extends StatelessWidget {
const _SortFilterSelectionWidget({
Key key,
@required this.selection,
@required this.onSelectionChange,
this.scrollController,
}) : assert(selection != null),
assert(onSelectionChange != null),
super(key: key);

final SortFilterSelection<T> selection;
SortFilter<T> get config => selection.config;
final ScrollController scrollController;

final SortFilterChangeCallback<T> onSelectionChange;

@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
return ListView(
controller: scrollController,
children: [
SizedBox(height: 8),
Center(child: DragIndicator()),
SizedBox(height: 8),
_buildSortSection(context),
for (final filterKey in config.filters.keys)
_buildFilterSection(context, filterKey),
SizedBox(height: 8),
],
);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ packages:
name: black_hole_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.14"
version: "0.2.15"
boolean_selector:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:
sdk: flutter

banners: ^0.2.0
black_hole_flutter: ^0.2.13
black_hole_flutter: ^0.2.15
collection: ^1.14.13
datetime_picker_formfield: ^1.0.0
device_info: ^0.4.2+4
Expand Down