Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Revert buggy change and changes associated with it (#1731)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnukvmd authored Feb 19, 2024
2 parents 5fc16e5 + dcb7811 commit d17880e
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 43 deletions.
3 changes: 0 additions & 3 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ gradle-wrapper.jar
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Signing config files
*.jks
13 changes: 12 additions & 1 deletion lib/ui/viewer/file/detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class DetailPage extends StatefulWidget {
class _DetailPageState extends State<DetailPage> {
static const kLoadLimit = 100;
final _logger = Logger("DetailPageState");
bool _shouldDisableScroll = false;
List<EnteFile>? _files;
late PageController _pageController;
final _selectedIndexNotifier = ValueNotifier(0);
Expand Down Expand Up @@ -171,6 +172,14 @@ class _DetailPageState extends State<DetailPage> {
file,
autoPlay: shouldAutoPlay(),
tagPrefix: widget.config.tagPrefix,
shouldDisableScroll: (value) {
if (_shouldDisableScroll != value) {
setState(() {
_logger.fine('setState $_shouldDisableScroll to $value');
_shouldDisableScroll = value;
});
}
},
playbackCallback: (isPlaying) {
Future.delayed(Duration.zero, () {
_toggleFullScreen(shouldEnable: isPlaying);
Expand Down Expand Up @@ -199,7 +208,9 @@ class _DetailPageState extends State<DetailPage> {
}
_preloadEntries();
},
physics: const FastScrollPhysics(speedFactor: 4.0),
physics: _shouldDisableScroll
? const NeverScrollableScrollPhysics()
: const FastScrollPhysics(speedFactor: 4.0),
controller: _pageController,
itemCount: _files!.length,
);
Expand Down
3 changes: 3 additions & 0 deletions lib/ui/viewer/file/file_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import "package:photos/ui/viewer/file/zoomable_live_image_new.dart";
class FileWidget extends StatelessWidget {
final EnteFile file;
final String? tagPrefix;
final Function(bool)? shouldDisableScroll;
final Function(bool)? playbackCallback;
final BoxDecoration? backgroundDecoration;
final bool? autoPlay;

const FileWidget(
this.file, {
this.autoPlay,
this.shouldDisableScroll,
this.playbackCallback,
this.tagPrefix,
this.backgroundDecoration,
Expand All @@ -30,6 +32,7 @@ class FileWidget extends StatelessWidget {
file.fileType == FileType.image) {
return ZoomableLiveImageNew(
file,
shouldDisableScroll: shouldDisableScroll,
tagPrefix: tagPrefix,
backgroundDecoration: backgroundDecoration,
key: key ?? ValueKey(fileKey),
Expand Down
73 changes: 40 additions & 33 deletions lib/ui/viewer/file/zoomable_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:logging/logging.dart';
import 'package:photo_view/photo_view.dart';
import "package:photo_view/photo_view_gallery.dart";
import 'package:photos/core/cache/thumbnail_in_memory_cache.dart';
import 'package:photos/core/constants.dart';
import 'package:photos/core/event_bus.dart';
Expand All @@ -25,13 +24,15 @@ import 'package:photos/utils/thumbnail_util.dart';

class ZoomableImage extends StatefulWidget {
final EnteFile photo;
final Function(bool)? shouldDisableScroll;
final String? tagPrefix;
final Decoration? backgroundDecoration;
final bool shouldCover;

const ZoomableImage(
this.photo, {
Key? key,
this.shouldDisableScroll,
required this.tagPrefix,
this.backgroundDecoration,
this.shouldCover = false,
Expand All @@ -51,18 +52,22 @@ class _ZoomableImageState extends State<ZoomableImage>
bool _loadedLargeThumbnail = false;
bool _loadingFinalImage = false;
bool _loadedFinalImage = false;
PhotoViewController _photoViewController = PhotoViewController();
bool _isZooming = false;
ValueChanged<PhotoViewScaleState>? _scaleStateChangedCallback;
bool _isZooming = false;
PhotoViewController _photoViewController = PhotoViewController();

@override
void initState() {
_photo = widget.photo;
_logger = Logger("ZoomableImage");
_logger.info('initState for ${_photo.generatedID} with tag ${_photo.tag}');
_scaleStateChangedCallback = (value) {
if (widget.shouldDisableScroll != null) {
widget.shouldDisableScroll!(value != PhotoViewScaleState.initial);
}
_isZooming = value != PhotoViewScaleState.initial;
debugPrint("isZooming = $_isZooming, currentState $value");
// _logger.info('is reakky zooming $_isZooming with state $value');
};
super.initState();
}
Expand All @@ -83,41 +88,41 @@ class _ZoomableImageState extends State<ZoomableImage>
Widget content;

if (_imageProvider != null) {
content = PhotoViewGallery.builder(
gaplessPlayback: true,
scaleStateChangedCallback: _scaleStateChangedCallback,
backgroundDecoration: widget.backgroundDecoration as BoxDecoration?,
builder: (context, index) {
return PhotoViewGalleryPageOptions(
imageProvider: _imageProvider!,
minScale: widget.shouldCover
? PhotoViewComputedScale.covered
: PhotoViewComputedScale.contained,
heroAttributes: PhotoViewHeroAttributes(
tag: widget.tagPrefix! + _photo.tag,
),
controller: _photoViewController,
);
},
itemCount: 1,
content = PhotoViewGestureDetectorScope(
axis: Axis.vertical,
child: PhotoView(
imageProvider: _imageProvider,
controller: _photoViewController,
scaleStateChangedCallback: _scaleStateChangedCallback,
minScale: widget.shouldCover
? PhotoViewComputedScale.covered
: PhotoViewComputedScale.contained,
gaplessPlayback: true,
heroAttributes: PhotoViewHeroAttributes(
tag: widget.tagPrefix! + _photo.tag,
),
backgroundDecoration: widget.backgroundDecoration as BoxDecoration?,
),
);
} else {
content = const EnteLoadingWidget();
}
verticalDragCallback(d) => {
if (!_isZooming)
{
if (d.delta.dy > dragSensitivity)
{
{Navigator.of(context).pop()},
}
else if (d.delta.dy < (dragSensitivity * -1))

final GestureDragUpdateCallback? verticalDragCallback = _isZooming
? null
: (d) => {
if (!_isZooming)
{
showDetailsSheet(context, widget.photo),
if (d.delta.dy > dragSensitivity)
{
{Navigator.of(context).pop()},
}
else if (d.delta.dy < (dragSensitivity * -1))
{
showDetailsSheet(context, widget.photo),
},
},
},
};

};
return GestureDetector(
onVerticalDragUpdate: verticalDragCallback,
child: content,
Expand Down Expand Up @@ -258,7 +263,9 @@ class _ZoomableImageState extends State<ZoomableImage>
required ImageProvider? previewImageProvider,
required ImageProvider finalImageProvider,
}) async {
final bool shouldFixPosition = previewImageProvider != null && _isZooming;
final bool shouldFixPosition = previewImageProvider != null &&
_isZooming &&
_photoViewController.scale != null;
ImageInfo? finalImageInfo;
if (shouldFixPosition) {
final prevImageInfo = await getImageInfo(previewImageProvider);
Expand Down
12 changes: 7 additions & 5 deletions lib/ui/viewer/file/zoomable_live_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import 'package:video_player/video_player.dart';

class ZoomableLiveImage extends StatefulWidget {
final EnteFile enteFile;
final Function(bool)? shouldDisableScroll;
final String? tagPrefix;
final Decoration? backgroundDecoration;

const ZoomableLiveImage(
this.enteFile, {
Key? key,
this.shouldDisableScroll,
required this.tagPrefix,
this.backgroundDecoration,
}) : super(key: key);
Expand All @@ -43,9 +45,8 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
@override
void initState() {
_enteFile = widget.enteFile;
_logger.info(
'initState for ${_enteFile.generatedID} with tag ${_enteFile.tag} and name ${_enteFile.displayName}',
);
_logger.info('initState for ${_enteFile.generatedID} with tag ${_enteFile
.tag} and name ${_enteFile.displayName}');
super.initState();
}

Expand Down Expand Up @@ -75,6 +76,7 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
content = ZoomableImage(
_enteFile,
tagPrefix: widget.tagPrefix,
shouldDisableScroll: widget.shouldDisableScroll,
backgroundDecoration: widget.backgroundDecoration,
);
}
Expand Down Expand Up @@ -136,8 +138,7 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
}

Future<File?> _getLivePhotoVideo() async {
if (_enteFile.isRemoteFile &&
!(await isFileCached(_enteFile, liveVideo: true))) {
if (_enteFile.isRemoteFile && !(await isFileCached(_enteFile, liveVideo: true))) {
showShortToast(context, S.of(context).downloading);
}

Expand Down Expand Up @@ -205,4 +206,5 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
}
});
}

}
3 changes: 3 additions & 0 deletions lib/ui/viewer/file/zoomable_live_image_new.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import 'package:photos/utils/toast_util.dart';

class ZoomableLiveImageNew extends StatefulWidget {
final EnteFile enteFile;
final Function(bool)? shouldDisableScroll;
final String? tagPrefix;
final Decoration? backgroundDecoration;

const ZoomableLiveImageNew(
this.enteFile, {
Key? key,
this.shouldDisableScroll,
required this.tagPrefix,
this.backgroundDecoration,
}) : super(key: key);
Expand Down Expand Up @@ -79,6 +81,7 @@ class _ZoomableLiveImageNewState extends State<ZoomableLiveImageNew>
content = ZoomableImage(
_enteFile,
tagPrefix: widget.tagPrefix,
shouldDisableScroll: widget.shouldDisableScroll,
backgroundDecoration: widget.backgroundDecoration,
);
}
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ description: ente photos application
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

version: 0.8.59+579

environment:
sdk: ">=3.0.0 <4.0.0"

Expand Down

0 comments on commit d17880e

Please sign in to comment.