Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Refactor: rename onFileLoad to onFinalFileLoad for consistency across file handling

AmanRajSinghMourya4412b016cee8
diff --git a/mobile/lib/ui/home/memories/full_screen_memory.dart b/mobile/lib/ui/home/memories/full_screen_memory.dart
index 685c999d6e..21435b562a 100644
--- a/mobile/lib/ui/home/memories/full_screen_memory.dart
+++ b/mobile/lib/ui/home/memories/full_screen_memory.dart
@@ -137,7 +137,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
PageController? _pageController;
final _showTitle = ValueNotifier<bool>(true);
AnimationController? _progressAnimationController;
- AnimationController? _kenBurnsAnimationController;
+ AnimationController? _zoomAnimationController;
final ValueNotifier<Duration> durationNotifier =
ValueNotifier(const Duration(seconds: 5));
@@ -169,42 +169,38 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
_progressAnimationController!.forward();
}
}
- if (_kenBurnsAnimationController != null) {
+ if (_zoomAnimationController != null) {
if (pause) {
- _kenBurnsAnimationController!.stop();
+ _zoomAnimationController!.stop();
} else {
- _kenBurnsAnimationController!.forward();
+ _zoomAnimationController!.forward();
}
}
}
void _resetAnimation() {
- if (_progressAnimationController != null) {
- _progressAnimationController!.reset();
- }
- if (_kenBurnsAnimationController != null) {
- _kenBurnsAnimationController!.reset();
- }
+ _progressAnimationController
+ ?..stop()
+ ..reset();
+ _zoomAnimationController
+ ?..stop()
+ ..reset();
}
- void onFileLoad(
- bool isLoaded,
- int duration, {
- bool isVideo = false,
- }) {
- if (isLoaded) {
- durationNotifier.value = Duration(seconds: duration);
-
- _progressAnimationController?.reset();
- _progressAnimationController?.duration = durationNotifier.value;
- _progressAnimationController?.forward();
-
- _kenBurnsAnimationController?.reset();
- _kenBurnsAnimationController?.forward();
- } else {
- _progressAnimationController?.stop();
- _kenBurnsAnimationController?.stop();
+ void onFinalFileLoad(bool isLoaded, int duration) {
+ if (_progressAnimationController!.isAnimating == true) {
+ _progressAnimationController!.stop();
}
+ durationNotifier.value = Duration(seconds: duration);
+ _progressAnimationController
+ ?..stop()
+ ..reset()
+ ..duration = durationNotifier.value
+ ..forward();
+ _zoomAnimationController
+ ?..stop()
+ ..reset()
+ ..forward();
}
@override
@@ -254,6 +250,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
inheritedData.indexNotifier.value;
if (currentIndex <
inheritedData.memories.length - 1) {
+ _resetAnimation();
_pageController!.nextPage(
duration: const Duration(milliseconds: 250),
curve: Curves.ease,
@@ -325,32 +322,32 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
final edgeWidth = screenWidth * 0.20;
if (details.localPosition.dx < edgeWidth) {
if (index > 0) {
+ _resetAnimation();
_pageController!.previousPage(
duration: const Duration(milliseconds: 250),
curve: Curves.ease,
);
- _resetAnimation();
}
} else if (details.localPosition.dx >
screenWidth - edgeWidth) {
if (index < (inheritedData.memories.length - 1)) {
+ _resetAnimation();
_pageController!.nextPage(
duration: const Duration(milliseconds: 250),
curve: Curves.ease,
);
}
- _resetAnimation();
}
},
onLongPress: () {
- isVideo ? null : _toggleAnimation(true);
+ _toggleAnimation(true);
},
onLongPressUp: () {
- isVideo ? null : _toggleAnimation(false);
+ _toggleAnimation(false);
},
child: MemoriesZoomWidget(
scaleController: (controller) {
- _kenBurnsAnimationController = controller;
+ _zoomAnimationController = controller;
},
zoomIn: index % 2 == 0,
isVideo: isVideo,
@@ -367,12 +364,8 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
? _toggleAnimation(false)
: _toggleAnimation(true);
},
- onFileLoad: (isLoaded, duration) {
- onFileLoad(
- isLoaded,
- duration,
- isVideo: isVideo,
- );
+ onFinalFileLoad: (isLoaded, duration) {
+ onFinalFileLoad(isLoaded, duration);
},
),
),
diff --git a/mobile/lib/ui/viewer/file/file_widget.dart b/mobile/lib/ui/viewer/file/file_widget.dart
index 83bfcbbd23..cfbfdaa8c1 100644
--- a/mobile/lib/ui/viewer/file/file_widget.dart
+++ b/mobile/lib/ui/viewer/file/file_widget.dart
@@ -13,7 +13,7 @@ class FileWidget extends StatelessWidget {
final BoxDecoration? backgroundDecoration;
final bool? autoPlay;
final bool? isFromMemories;
- final Function(bool, int)? onFileLoad;
+ final Function(bool, int)? onFinalFileLoad;
const FileWidget(
this.file, {
@@ -23,7 +23,7 @@ class FileWidget extends StatelessWidget {
required this.tagPrefix,
this.backgroundDecoration,
this.isFromMemories = false,
- this.onFileLoad,
+ this.onFinalFileLoad,
super.key,
});
@@ -43,7 +43,7 @@ class FileWidget extends StatelessWidget {
backgroundDecoration: backgroundDecoration,
isFromMemories: isFromMemories ?? false,
key: key ?? ValueKey(fileKey),
- onFileLoad: onFileLoad,
+ onFinalFileLoad: onFinalFileLoad,
);
} else if (file.fileType == FileType.video) {
// use old video widget on iOS simulator as the new one crashes while
@@ -60,7 +60,8 @@ class FileWidget extends StatelessWidget {
file,
tagPrefix: tagPrefix,
playbackCallback: playbackCallback,
- onFileLoad: onFileLoad,
+ onFinalFileLoad: onFinalFileLoad,
+ isFromMemories: isFromMemories ?? false,
key: key ?? ValueKey(fileKey),
);
} else {
diff --git a/mobile/lib/ui/viewer/file/zoomable_image.dart b/mobile/lib/ui/viewer/file/zoomable_image.dart
index 3a29136361..82d643bc93 100644
--- a/mobile/lib/ui/viewer/file/zoomable_image.dart
+++ b/mobile/lib/ui/viewer/file/zoomable_image.dart
@@ -31,7 +31,7 @@ class ZoomableImage extends StatefulWidget {
final Decoration? backgroundDecoration;
final bool shouldCover;
final bool isGuestView;
- final Function(bool, int)? onFileLoad;
+ final Function(bool, int)? onFinalFileLoad;
const ZoomableImage(
this.photo, {
@@ -41,7 +41,7 @@ class ZoomableImage extends StatefulWidget {
this.backgroundDecoration,
this.shouldCover = false,
this.isGuestView = false,
- this.onFileLoad,
+ this.onFinalFileLoad,
});
@override
@@ -429,9 +429,9 @@ class _ZoomableImageState extends State<ZoomableImage> {
_logger.info("Final image loaded");
});
if (_imageProvider == null) {
- widget.onFileLoad?.call(false, 5);
+ widget.onFinalFileLoad?.call(false, 5);
} else {
- widget.onFileLoad?.call(true, 5);
+ widget.onFinalFileLoad?.call(true, 5);
}
}
diff --git a/mobile/lib/ui/viewer/file/zoomable_live_image_new.dart b/mobile/lib/ui/viewer/file/zoomable_live_image_new.dart
index 739238097e..7b95e1378c 100644
--- a/mobile/lib/ui/viewer/file/zoomable_live_image_new.dart
+++ b/mobile/lib/ui/viewer/file/zoomable_live_image_new.dart
@@ -24,7 +24,7 @@ class ZoomableLiveImageNew extends StatefulWidget {
final String? tagPrefix;
final Decoration? backgroundDecoration;
final bool isFromMemories;
- final Function(bool, int)? onFileLoad;
+ final Function(bool, int)? onFinalFileLoad;
const ZoomableLiveImageNew(
this.enteFile, {
@@ -33,7 +33,7 @@ class ZoomableLiveImageNew extends StatefulWidget {
required this.tagPrefix,
this.backgroundDecoration,
this.isFromMemories = false,
- this.onFileLoad,
+ this.onFinalFileLoad,
});
@override
@@ -98,7 +98,7 @@ class _ZoomableLiveImageNewState extends State<ZoomableLiveImageNew>
shouldDisableScroll: widget.shouldDisableScroll,
backgroundDecoration: widget.backgroundDecoration,
isGuestView: isGuestView,
- onFileLoad: widget.onFileLoad,
+ onFinalFileLoad: widget.onFinalFileLoad,
);
}
if (!widget.isFromMemories) {