Swipe up to open detail pane in viewer

This commit is contained in:
Ming Ming 2021-11-26 18:10:18 +08:00
parent e322197117
commit 42d6851bf5
3 changed files with 45 additions and 15 deletions

View file

@ -50,7 +50,7 @@ class _ImageViewerState extends State<ImageViewer>
minScale: 1.0, minScale: 1.0,
maxScale: 3.0, maxScale: 3.0,
transformationController: _transformationController, transformationController: _transformationController,
panEnabled: widget.canZoom, panEnabled: widget.canZoom && _isZoomed,
scaleEnabled: widget.canZoom, scaleEnabled: widget.canZoom,
// allow the image to be zoomed to fill the whole screen // allow the image to be zoomed to fill the whole screen
child: Container( child: Container(

View file

@ -233,13 +233,12 @@ class _ViewerState extends State<Viewer>
onNotification: (notif) => _onPageContentScrolled(notif, index), onNotification: (notif) => _onPageContentScrolled(notif, index),
child: SingleChildScrollView( child: SingleChildScrollView(
controller: _pageStates[index]!.scrollController, controller: _pageStates[index]!.scrollController,
physics: physics: !_isZoomed ? null : const NeverScrollableScrollPhysics(),
_isDetailPaneActive ? null : const NeverScrollableScrollPhysics(),
child: Stack( child: Stack(
children: [ children: [
_buildItemView(context, index), _buildItemView(context, index),
Visibility( Visibility(
visible: _isDetailPaneActive, visible: !_isZoomed,
child: AnimatedOpacity( child: AnimatedOpacity(
opacity: _isShowDetailPane ? 1 : 0, opacity: _isShowDetailPane ? 1 : 0,
duration: k.animationDurationNormal, duration: k.animationDurationNormal,
@ -260,11 +259,17 @@ class _ViewerState extends State<Viewer>
const BorderRadius.vertical(top: Radius.circular(4)), const BorderRadius.vertical(top: Radius.circular(4)),
), ),
margin: EdgeInsets.only(top: _calcDetailPaneOffset(index)), margin: EdgeInsets.only(top: _calcDetailPaneOffset(index)),
child: ViewerDetailPane( // this visibility widget avoids loading the detail pane
account: widget.account, // until it's actually opened, otherwise swiping between
file: widget.streamFiles[index], // photos will slow down severely
album: widget.album, child: Visibility(
onSlideshowPressed: _onSlideshowPressed, visible: _isShowDetailPane,
child: ViewerDetailPane(
account: widget.account,
file: widget.streamFiles[index],
album: widget.album,
onSlideshowPressed: _onSlideshowPressed,
),
), ),
), ),
), ),
@ -350,6 +355,14 @@ class _ViewerState extends State<Viewer>
}); });
} }
} }
} else if (notification is ScrollUpdateNotification) {
if (!_isShowDetailPane) {
Future.delayed(Duration.zero, () {
setState(() {
_isShowDetailPane = true;
});
});
}
} }
return false; return false;
} }

View file

@ -30,6 +30,7 @@ import 'package:nc_photos/theme.dart';
import 'package:nc_photos/use_case/remove_from_album.dart'; import 'package:nc_photos/use_case/remove_from_album.dart';
import 'package:nc_photos/use_case/update_album.dart'; import 'package:nc_photos/use_case/update_album.dart';
import 'package:nc_photos/use_case/update_property.dart'; import 'package:nc_photos/use_case/update_property.dart';
import 'package:nc_photos/widget/animated_visibility.dart';
import 'package:nc_photos/widget/gps_map.dart'; import 'package:nc_photos/widget/gps_map.dart';
import 'package:nc_photos/widget/handler/add_selection_to_album_handler.dart'; import 'package:nc_photos/widget/handler/add_selection_to_album_handler.dart';
import 'package:nc_photos/widget/photo_date_time_edit_dialog.dart'; import 'package:nc_photos/widget/photo_date_time_edit_dialog.dart';
@ -71,6 +72,15 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
_initMetadata(); _initMetadata();
} }
} }
// postpone loading map to improve responsiveness
Future.delayed(const Duration(milliseconds: 750)).then((_) {
if (mounted) {
setState(() {
_shouldBlockGpsMap = false;
});
}
});
} }
@override @override
@ -239,12 +249,17 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
subtitle: cameraSubStr.isNotEmpty ? Text(cameraSubStr) : null, subtitle: cameraSubStr.isNotEmpty ? Text(cameraSubStr) : null,
), ),
if (features.isSupportMapView && _gps != null) if (features.isSupportMapView && _gps != null)
SizedBox( AnimatedVisibility(
height: 256, opacity: _shouldBlockGpsMap ? 0 : 1,
child: GpsMap( curve: Curves.easeInOut,
center: _gps!, duration: k.animationDurationNormal,
zoom: 16, child: SizedBox(
onTap: _onMapTap, height: 256,
child: GpsMap(
center: _gps!,
zoom: 16,
onTap: _onMapTap,
),
), ),
), ),
], ],
@ -489,6 +504,8 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
late final bool _canRemoveFromAlbum = _checkCanRemoveFromAlbum(); late final bool _canRemoveFromAlbum = _checkCanRemoveFromAlbum();
var _shouldBlockGpsMap = true;
static final _log = static final _log =
Logger("widget.viewer_detail_pane._ViewerDetailPaneState"); Logger("widget.viewer_detail_pane._ViewerDetailPaneState");
} }