support minimize sheet
This commit is contained in:
@@ -368,10 +368,12 @@ class _ViewUrlSheet extends HookConsumerWidget {
|
|||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final draggableScrollableController = useDraggableScrollableController();
|
final draggableScrollableController = useDraggableScrollableController();
|
||||||
|
|
||||||
|
final initialHeight = 172.0 / MediaQuery.of(context).size.height;
|
||||||
|
|
||||||
return DraggableScrollableSheet(
|
return DraggableScrollableSheet(
|
||||||
controller: draggableScrollableController,
|
controller: draggableScrollableController,
|
||||||
expand: false,
|
expand: false,
|
||||||
initialChildSize: 172.0 / MediaQuery.of(context).size.height,
|
initialChildSize: initialHeight,
|
||||||
minChildSize: 0.1,
|
minChildSize: 0.1,
|
||||||
maxChildSize: maxChildSize,
|
maxChildSize: maxChildSize,
|
||||||
builder: (context, scrollController) {
|
builder: (context, scrollController) {
|
||||||
@@ -387,6 +389,7 @@ class _ViewUrlSheet extends HookConsumerWidget {
|
|||||||
onClose: () {
|
onClose: () {
|
||||||
ref.read(bottomSheetControllerProvider.notifier).dismiss();
|
ref.read(bottomSheetControllerProvider.notifier).dismiss();
|
||||||
},
|
},
|
||||||
|
initialHeight: initialHeight,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
+23
-6
@@ -61,12 +61,14 @@ class ViewTabSheetWidget extends HookConsumerWidget {
|
|||||||
final ScrollController sheetScrollController;
|
final ScrollController sheetScrollController;
|
||||||
final DraggableScrollableController draggableScrollableController;
|
final DraggableScrollableController draggableScrollableController;
|
||||||
final VoidCallback onClose;
|
final VoidCallback onClose;
|
||||||
|
final double initialHeight;
|
||||||
|
|
||||||
const ViewTabSheetWidget({
|
const ViewTabSheetWidget({
|
||||||
required this.initialTabState,
|
required this.initialTabState,
|
||||||
required this.sheetScrollController,
|
required this.sheetScrollController,
|
||||||
required this.draggableScrollableController,
|
required this.draggableScrollableController,
|
||||||
required this.onClose,
|
required this.onClose,
|
||||||
|
required this.initialHeight,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -99,7 +101,7 @@ class ViewTabSheetWidget extends HookConsumerWidget {
|
|||||||
await draggableScrollableController.animateTo(
|
await draggableScrollableController.animateTo(
|
||||||
relative,
|
relative,
|
||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
curve: Curves.bounceIn,
|
curve: Curves.easeInOut,
|
||||||
);
|
);
|
||||||
scrolledTo.value = relative;
|
scrolledTo.value = relative;
|
||||||
}
|
}
|
||||||
@@ -110,25 +112,26 @@ class ViewTabSheetWidget extends HookConsumerWidget {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
final changes = useRef(0.0);
|
final bottomInsets = useRef(0.0);
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
final diff =
|
final diff =
|
||||||
((MediaQuery.of(context).viewInsets.bottom / 2) /
|
((MediaQuery.of(context).viewInsets.bottom / 2) /
|
||||||
MediaQuery.of(context).size.height) -
|
MediaQuery.of(context).size.height) -
|
||||||
changes.value;
|
bottomInsets.value;
|
||||||
|
|
||||||
draggableScrollableController.jumpTo(
|
draggableScrollableController.jumpTo(
|
||||||
draggableScrollableController.size + diff,
|
draggableScrollableController.size + diff,
|
||||||
);
|
);
|
||||||
|
|
||||||
changes.value += diff;
|
bottomInsets.value += diff;
|
||||||
});
|
});
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}, [MediaQuery.of(context).viewInsets.bottom]);
|
}, [MediaQuery.of(context).viewInsets.bottom]);
|
||||||
|
|
||||||
return NestedScrollView(
|
return NestedScrollView(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: DraggableScrollableHeader(
|
child: DraggableScrollableHeader(
|
||||||
@@ -140,8 +143,22 @@ class ViewTabSheetWidget extends HookConsumerWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 0.0),
|
padding: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 0.0),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
draggableScrollableController.jumpTo(1.0);
|
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),
|
child: WebsiteTitleTile(initialTabState),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user