This commit is contained in:
Neeraj Gupta 2023-12-02 00:15:28 +05:30 committed by GitHub
commit 478c6f0238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 25 deletions

View file

@ -53,13 +53,18 @@ class _ZoomableImageState extends State<ZoomableImage>
bool _loadingFinalImage = false;
bool _loadedFinalImage = false;
PhotoViewController _photoViewController = PhotoViewController();
double? _initialScale;
bool _isZooming = false;
ValueChanged<PhotoViewScaleState>? _scaleStateChangedCallback;
@override
void initState() {
_photo = widget.photo;
_logger = Logger("ZoomableImage");
_logger.info('initState for ${_photo.generatedID} with tag ${_photo.tag}');
_scaleStateChangedCallback = (value) {
_isZooming = value != PhotoViewScaleState.initial;
debugPrint("isZooming = $_isZooming, currentState $value");
};
super.initState();
}
@ -81,6 +86,7 @@ class _ZoomableImageState extends State<ZoomableImage>
if (_imageProvider != null) {
content = PhotoViewGallery.builder(
gaplessPlayback: true,
scaleStateChangedCallback: _scaleStateChangedCallback,
backgroundDecoration: widget.backgroundDecoration as BoxDecoration?,
builder: (context, index) {
return PhotoViewGalleryPageOptions(
@ -99,24 +105,21 @@ class _ZoomableImageState extends State<ZoomableImage>
} else {
content = const EnteLoadingWidget();
}
dragFunction(d) => {
if (d.delta.dy > dragSensitivity)
{
{Navigator.of(context).pop()},
}
else if (d.delta.dy < (dragSensitivity * -1))
{
showDetailsSheet(context, widget.photo),
},
};
verticalDragCallback(d) {
if (_initialScale == null ||
_photoViewController.scale! <= _initialScale!) {
dragFunction(d);
}
}
final GestureDragUpdateCallback? verticalDragCallback = _isZooming
? null
: (d) => {
if (!_isZooming)
{
if (d.delta.dy > dragSensitivity)
{
{Navigator.of(context).pop()},
}
else if (d.delta.dy < (dragSensitivity * -1))
{
showDetailsSheet(context, widget.photo),
},
},
};
return GestureDetector(
onVerticalDragUpdate: verticalDragCallback,
@ -258,8 +261,7 @@ class _ZoomableImageState extends State<ZoomableImage>
required ImageProvider? previewImageProvider,
required ImageProvider finalImageProvider,
}) async {
final bool shouldFixPosition =
previewImageProvider != null && _photoViewController.scale != null;
final bool shouldFixPosition = previewImageProvider != null && _isZooming;
ImageInfo? finalImageInfo;
if (shouldFixPosition) {
if (kDebugMode) {
@ -282,9 +284,6 @@ class _ZoomableImageState extends State<ZoomableImage>
initialPosition: newPosition,
initialScale: scale,
);
setState(() {
_initialScale = scale;
});
}
final bool canUpdateMetadata = _photo.canEditMetaInfo;
// forcefully get finalImageInfo is dimensions are not available in metadata

View file

@ -12,7 +12,7 @@ description: ente photos application
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.8.7+527
version: 0.8.9+529
environment:
sdk: ">=3.0.0 <4.0.0"