mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 18:38:48 +01:00
Swipe down to dismiss viewer
This commit is contained in:
parent
d4334f3a2b
commit
77a99f30af
1 changed files with 21 additions and 0 deletions
|
@ -326,7 +326,12 @@ class _ViewerState extends State<Viewer>
|
|||
if (!_canOpenDetailPane()) {
|
||||
return false;
|
||||
}
|
||||
if (notification is ScrollStartNotification) {
|
||||
_scrollStartPosition =
|
||||
_pageStates[index]?.scrollController.position.pixels;
|
||||
}
|
||||
if (notification is ScrollEndNotification) {
|
||||
_scrollStartPosition = null;
|
||||
final scrollPos = _pageStates[index]!.scrollController.position;
|
||||
if (scrollPos.pixels == 0) {
|
||||
setState(() {
|
||||
|
@ -360,6 +365,19 @@ class _ViewerState extends State<Viewer>
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (notification is OverscrollNotification) {
|
||||
if (_scrollStartPosition == 0) {
|
||||
// start at top
|
||||
_overscrollSum += notification.overscroll;
|
||||
if (_overscrollSum < -176) {
|
||||
// and scroll downwards
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_overscrollSum = 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -578,6 +596,9 @@ class _ViewerState extends State<Viewer>
|
|||
bool _isViewerLoaded = false;
|
||||
final _pageStates = <int, _PageState>{};
|
||||
|
||||
double? _scrollStartPosition;
|
||||
var _overscrollSum = 0.0;
|
||||
|
||||
static final _log = Logger("widget.viewer._ViewerState");
|
||||
|
||||
static const _viewportFraction = 1.05;
|
||||
|
|
Loading…
Reference in a new issue