fullscreen: can yield to vertical pageview even when image is not in initial scale
This commit is contained in:
parent
fb7df6fcf2
commit
10e18ae7c9
2 changed files with 3 additions and 18 deletions
|
@ -383,7 +383,6 @@ class FullscreenVerticalPageView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView> {
|
class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView> {
|
||||||
bool _isInitialScale = true;
|
|
||||||
final ValueNotifier<Color> _backgroundColorNotifier = ValueNotifier(Colors.black);
|
final ValueNotifier<Color> _backgroundColorNotifier = ValueNotifier(Colors.black);
|
||||||
final ValueNotifier<bool> _infoPageVisibleNotifier = ValueNotifier(false);
|
final ValueNotifier<bool> _infoPageVisibleNotifier = ValueNotifier(false);
|
||||||
|
|
||||||
|
@ -404,9 +403,6 @@ class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView>
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
_unregisterWidget(oldWidget);
|
_unregisterWidget(oldWidget);
|
||||||
_registerWidget(widget);
|
_registerWidget(widget);
|
||||||
if (oldWidget.entry != widget.entry) {
|
|
||||||
_onEntryChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -436,12 +432,10 @@ class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView>
|
||||||
pageController: widget.horizontalPager,
|
pageController: widget.horizontalPager,
|
||||||
onTap: widget.onImageTap,
|
onTap: widget.onImageTap,
|
||||||
onPageChanged: widget.onHorizontalPageChanged,
|
onPageChanged: widget.onHorizontalPageChanged,
|
||||||
onScaleChanged: _onScaleChanged,
|
|
||||||
videoControllers: widget.videoControllers,
|
videoControllers: widget.videoControllers,
|
||||||
)
|
)
|
||||||
: SingleImagePage(
|
: SingleImagePage(
|
||||||
entry: entry,
|
entry: entry,
|
||||||
onScaleChanged: _onScaleChanged,
|
|
||||||
onTap: widget.onImageTap,
|
onTap: widget.onImageTap,
|
||||||
videoControllers: widget.videoControllers,
|
videoControllers: widget.videoControllers,
|
||||||
),
|
),
|
||||||
|
@ -466,7 +460,7 @@ class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView>
|
||||||
child: PageView(
|
child: PageView(
|
||||||
scrollDirection: Axis.vertical,
|
scrollDirection: Axis.vertical,
|
||||||
controller: widget.verticalPager,
|
controller: widget.verticalPager,
|
||||||
physics: _isInitialScale ? const PageScrollPhysics() : const NeverScrollableScrollPhysics(),
|
physics: const PhotoViewPageViewScrollPhysics(parent: PageScrollPhysics()),
|
||||||
onPageChanged: (page) {
|
onPageChanged: (page) {
|
||||||
widget.onVerticalPageChanged(page);
|
widget.onVerticalPageChanged(page);
|
||||||
_infoPageVisibleNotifier.value = page == pages.length - 1;
|
_infoPageVisibleNotifier.value = page == pages.length - 1;
|
||||||
|
@ -481,14 +475,6 @@ class _FullscreenVerticalPageViewState extends State<FullscreenVerticalPageView>
|
||||||
_backgroundColorNotifier.value = _backgroundColorNotifier.value.withOpacity(opacity * opacity);
|
_backgroundColorNotifier.value = _backgroundColorNotifier.value.withOpacity(opacity * opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onEntryChanged() {
|
|
||||||
_onScaleChanged(PhotoViewScaleState.initial);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onScaleChanged(PhotoViewScaleState state) {
|
|
||||||
setState(() => _isInitialScale = state == PhotoViewScaleState.initial);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onImageChanged() async {
|
void _onImageChanged() async {
|
||||||
await UriImage(uri: entry.uri, mimeType: entry.mimeType).evict();
|
await UriImage(uri: entry.uri, mimeType: entry.mimeType).evict();
|
||||||
await ThumbnailProvider(entry: entry, extent: Constants.thumbnailCacheExtent).evict();
|
await ThumbnailProvider(entry: entry, extent: Constants.thumbnailCacheExtent).evict();
|
||||||
|
|
|
@ -34,11 +34,10 @@ class MultiImagePageState extends State<MultiImagePage> with AutomaticKeepAliveC
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
|
|
||||||
const scrollDirection = Axis.horizontal;
|
|
||||||
return PhotoViewGestureDetectorScope(
|
return PhotoViewGestureDetectorScope(
|
||||||
axis: scrollDirection,
|
axis: [Axis.horizontal, Axis.vertical],
|
||||||
child: PageView.builder(
|
child: PageView.builder(
|
||||||
scrollDirection: scrollDirection,
|
scrollDirection: Axis.horizontal,
|
||||||
controller: widget.pageController,
|
controller: widget.pageController,
|
||||||
physics: const PhotoViewPageViewScrollPhysics(parent: BouncingScrollPhysics()),
|
physics: const PhotoViewPageViewScrollPhysics(parent: BouncingScrollPhysics()),
|
||||||
onPageChanged: widget.onPageChanged,
|
onPageChanged: widget.onPageChanged,
|
||||||
|
|
Loading…
Reference in a new issue