info: handle back button to image page
This commit is contained in:
parent
3ba9e5f5e6
commit
714cea3cd2
1 changed files with 63 additions and 59 deletions
|
@ -30,19 +30,13 @@ class FullscreenPage extends AnimatedWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return WillPopScope(
|
return Scaffold(
|
||||||
onWillPop: () {
|
backgroundColor: Colors.black,
|
||||||
Screen.keepOn(false);
|
body: FullscreenBody(
|
||||||
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
|
collection: collection,
|
||||||
return Future.value(true);
|
initialUri: initialUri,
|
||||||
},
|
),
|
||||||
child: Scaffold(
|
resizeToAvoidBottomInset: false,
|
||||||
backgroundColor: Colors.black,
|
|
||||||
body: FullscreenBody(
|
|
||||||
collection: collection,
|
|
||||||
initialUri: initialUri,
|
|
||||||
),
|
|
||||||
resizeToAvoidBottomInset: false,
|
|
||||||
// Hero(
|
// Hero(
|
||||||
// tag: uri,
|
// tag: uri,
|
||||||
// child: Stack(
|
// child: Stack(
|
||||||
|
@ -71,7 +65,6 @@ class FullscreenPage extends AnimatedWidget {
|
||||||
// ],
|
// ],
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,53 +138,64 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final entry = entries[_currentHorizontalPage];
|
final entry = entries[_currentHorizontalPage];
|
||||||
return Stack(
|
return WillPopScope(
|
||||||
children: [
|
onWillPop: () {
|
||||||
PageView(
|
if (_currentVerticalPage == 1) {
|
||||||
scrollDirection: Axis.vertical,
|
goToVerticalPage(0);
|
||||||
controller: _verticalPager,
|
return Future.value(false);
|
||||||
physics: _isInitialScale ? PageScrollPhysics() : NeverScrollableScrollPhysics(),
|
}
|
||||||
onPageChanged: (page) => setState(() => _currentVerticalPage = page),
|
Screen.keepOn(false);
|
||||||
children: [
|
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
|
||||||
ImagePage(
|
return Future.value(true);
|
||||||
collection: collection,
|
},
|
||||||
pageController: _horizontalPager,
|
child: Stack(
|
||||||
onTap: () => _overlayVisible.value = !_overlayVisible.value,
|
children: [
|
||||||
onPageChanged: (page) => setState(() => _currentHorizontalPage = page),
|
PageView(
|
||||||
onScaleChanged: (state) => setState(() => _isInitialScale = state == PhotoViewScaleState.initial),
|
scrollDirection: Axis.vertical,
|
||||||
),
|
controller: _verticalPager,
|
||||||
NotificationListener(
|
physics: _isInitialScale ? PageScrollPhysics() : NeverScrollableScrollPhysics(),
|
||||||
onNotification: (notification) {
|
onPageChanged: (page) => setState(() => _currentVerticalPage = page),
|
||||||
if (notification is BackUpNotification) goToVerticalPage(0);
|
children: [
|
||||||
return false;
|
ImagePage(
|
||||||
},
|
collection: collection,
|
||||||
child: InfoPage(collection: collection, entry: entry),
|
pageController: _horizontalPager,
|
||||||
),
|
onTap: () => _overlayVisible.value = !_overlayVisible.value,
|
||||||
],
|
onPageChanged: (page) => setState(() => _currentHorizontalPage = page),
|
||||||
),
|
onScaleChanged: (state) => setState(() => _isInitialScale = state == PhotoViewScaleState.initial),
|
||||||
if (_currentHorizontalPage != null && _currentVerticalPage == 0) ...[
|
|
||||||
FullscreenTopOverlay(
|
|
||||||
entries: entries,
|
|
||||||
index: _currentHorizontalPage,
|
|
||||||
scale: _topOverlayScale,
|
|
||||||
viewInsets: _frozenViewInsets,
|
|
||||||
viewPadding: _frozenViewPadding,
|
|
||||||
onActionSelected: (action) => onActionSelected(entry, action),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
child: SlideTransition(
|
|
||||||
position: _bottomOverlayOffset,
|
|
||||||
child: FullscreenBottomOverlay(
|
|
||||||
entries: entries,
|
|
||||||
index: _currentHorizontalPage,
|
|
||||||
viewInsets: _frozenViewInsets,
|
|
||||||
viewPadding: _frozenViewPadding,
|
|
||||||
),
|
),
|
||||||
|
NotificationListener(
|
||||||
|
onNotification: (notification) {
|
||||||
|
if (notification is BackUpNotification) goToVerticalPage(0);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: InfoPage(collection: collection, entry: entry),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (_currentHorizontalPage != null && _currentVerticalPage == 0) ...[
|
||||||
|
FullscreenTopOverlay(
|
||||||
|
entries: entries,
|
||||||
|
index: _currentHorizontalPage,
|
||||||
|
scale: _topOverlayScale,
|
||||||
|
viewInsets: _frozenViewInsets,
|
||||||
|
viewPadding: _frozenViewPadding,
|
||||||
|
onActionSelected: (action) => onActionSelected(entry, action),
|
||||||
),
|
),
|
||||||
)
|
Positioned(
|
||||||
]
|
bottom: 0,
|
||||||
],
|
child: SlideTransition(
|
||||||
|
position: _bottomOverlayOffset,
|
||||||
|
child: FullscreenBottomOverlay(
|
||||||
|
entries: entries,
|
||||||
|
index: _currentHorizontalPage,
|
||||||
|
viewInsets: _frozenViewInsets,
|
||||||
|
viewPadding: _frozenViewPadding,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue