support minimize sheet

This commit is contained in:
Fabian Freund
2025-08-02 13:03:23 +02:00
parent 06f7d70326
commit 6ab4681e33
2 changed files with 27 additions and 7 deletions
@@ -368,10 +368,12 @@ class _ViewUrlSheet extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final draggableScrollableController = useDraggableScrollableController();
final initialHeight = 172.0 / MediaQuery.of(context).size.height;
return DraggableScrollableSheet(
controller: draggableScrollableController,
expand: false,
initialChildSize: 172.0 / MediaQuery.of(context).size.height,
initialChildSize: initialHeight,
minChildSize: 0.1,
maxChildSize: maxChildSize,
builder: (context, scrollController) {
@@ -387,6 +389,7 @@ class _ViewUrlSheet extends HookConsumerWidget {
onClose: () {
ref.read(bottomSheetControllerProvider.notifier).dismiss();
},
initialHeight: initialHeight,
),
);
},
@@ -61,12 +61,14 @@ class ViewTabSheetWidget extends HookConsumerWidget {
final ScrollController sheetScrollController;
final DraggableScrollableController draggableScrollableController;
final VoidCallback onClose;
final double initialHeight;
const ViewTabSheetWidget({
required this.initialTabState,
required this.sheetScrollController,
required this.draggableScrollableController,
required this.onClose,
required this.initialHeight,
});
@override
@@ -99,7 +101,7 @@ class ViewTabSheetWidget extends HookConsumerWidget {
await draggableScrollableController.animateTo(
relative,
duration: const Duration(milliseconds: 150),
curve: Curves.bounceIn,
curve: Curves.easeInOut,
);
scrolledTo.value = relative;
}
@@ -110,25 +112,26 @@ class ViewTabSheetWidget extends HookConsumerWidget {
return null;
});
final changes = useRef(0.0);
final bottomInsets = useRef(0.0);
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((_) {
final diff =
((MediaQuery.of(context).viewInsets.bottom / 2) /
MediaQuery.of(context).size.height) -
changes.value;
bottomInsets.value;
draggableScrollableController.jumpTo(
draggableScrollableController.size + diff,
);
changes.value += diff;
bottomInsets.value += diff;
});
return null;
}, [MediaQuery.of(context).viewInsets.bottom]);
return NestedScrollView(
physics: const NeverScrollableScrollPhysics(),
headerSliverBuilder: (context, innerBoxIsScrolled) => [
SliverToBoxAdapter(
child: DraggableScrollableHeader(
@@ -140,8 +143,22 @@ class ViewTabSheetWidget extends HookConsumerWidget {
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 0.0),
child: GestureDetector(
onTap: () {
draggableScrollableController.jumpTo(1.0);
onTap: () async {
if (draggableScrollableController.size > 0.95) {
await draggableScrollableController.animateTo(
(scrolledTo.value > 0.0)
? scrolledTo.value
: initialHeight,
duration: const Duration(milliseconds: 150),
curve: Curves.easeInOut,
);
} else {
await draggableScrollableController.animateTo(
1.0,
duration: const Duration(milliseconds: 150),
curve: Curves.easeInOut,
);
}
},
child: WebsiteTitleTile(initialTabState),
),