fullscreen: can yield to vertical pageview even when image is not in initial scale

This commit is contained in:
Thibault Deckers 2020-05-22 10:15:40 +09:00
parent fb7df6fcf2
commit 10e18ae7c9
2 changed files with 3 additions and 18 deletions

View file

@ -383,7 +383,6 @@ class FullscreenVerticalPageView extends StatefulWidget {
}
class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView> {
bool _isInitialScale = true;
final ValueNotifier<Color> _backgroundColorNotifier = ValueNotifier(Colors.black);
final ValueNotifier<bool> _infoPageVisibleNotifier = ValueNotifier(false);
@ -404,9 +403,6 @@ class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView>
super.didUpdateWidget(oldWidget);
_unregisterWidget(oldWidget);
_registerWidget(widget);
if (oldWidget.entry != widget.entry) {
_onEntryChanged();
}
}
@override
@ -436,12 +432,10 @@ class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView>
pageController: widget.horizontalPager,
onTap: widget.onImageTap,
onPageChanged: widget.onHorizontalPageChanged,
onScaleChanged: _onScaleChanged,
videoControllers: widget.videoControllers,
)
: SingleImagePage(
entry: entry,
onScaleChanged: _onScaleChanged,
onTap: widget.onImageTap,
videoControllers: widget.videoControllers,
),
@ -466,7 +460,7 @@ class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView>
child: PageView(
scrollDirection: Axis.vertical,
controller: widget.verticalPager,
physics: _isInitialScale ? const PageScrollPhysics() : const NeverScrollableScrollPhysics(),
physics: const PhotoViewPageViewScrollPhysics(parent: PageScrollPhysics()),
onPageChanged: (page) {
widget.onVerticalPageChanged(page);
_infoPageVisibleNotifier.value = page == pages.length - 1;
@ -481,14 +475,6 @@ class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView>
_backgroundColorNotifier.value = _backgroundColorNotifier.value.withOpacity(opacity * opacity);
}
void _onEntryChanged() {
_onScaleChanged(PhotoViewScaleState.initial);
}
void _onScaleChanged(PhotoViewScaleState state) {
setState(() => _isInitialScale = state == PhotoViewScaleState.initial);
}
void _onImageChanged() async {
await UriImage(uri: entry.uri, mimeType: entry.mimeType).evict();
await ThumbnailProvider(entry: entry, extent: Constants.thumbnailCacheExtent).evict();

View file

@ -34,11 +34,10 @@ class MultiImagePageState extends State<MultiImagePage> with AutomaticKeepAliveC
Widget build(BuildContext context) {
super.build(context);
const scrollDirection = Axis.horizontal;
return PhotoViewGestureDetectorScope(
axis: scrollDirection,
axis: [Axis.horizontal, Axis.vertical],
child: PageView.builder(
scrollDirection: scrollDirection,
scrollDirection: Axis.horizontal,
controller: widget.pageController,
physics: const PhotoViewPageViewScrollPhysics(parent: BouncingScrollPhysics()),
onPageChanged: widget.onPageChanged,