Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] Prevent crop editor from getting stuck

r4khulfd8900d8979b
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_main_bottom_bar.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_main_bottom_bar.dart
index f4feb2432a..ff9a8da1a5 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_main_bottom_bar.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_main_bottom_bar.dart
@@ -16,9 +16,11 @@ class ImageEditorMainBottomBar extends StatefulWidget with SimpleConfigsAccess {
required this.configs,
required this.callbacks,
required this.editor,
+ required this.imageReady,
});
final ProImageEditorState editor;
+ final Future<void> imageReady;
@override
final ProImageEditorConfigs configs;
@@ -90,7 +92,14 @@ class ImageEditorMainBottomBarState extends State<ImageEditorMainBottomBar>
CircularIconButton(
hugeIcon: HugeIcons.strokeRoundedCrop,
label: context.strings.cropAndRotate,
- onTap: () {
+ onTap: () async {
+ await widget.imageReady;
+ if (!mounted ||
+ !widget.editor.mounted ||
+ ModalRoute.of(context)?.isCurrent != true ||
+ widget.editor.isSubEditorOpen) {
+ return;
+ }
widget.editor.openCropRotateEditor();
},
),
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
index 45217c5da8..d4125a03c8 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
@@ -59,6 +59,7 @@ class ImageEditorPage extends StatefulWidget {
class _ImageEditorPageState extends State<ImageEditorPage> {
final _mainEditorBarKey = GlobalKey<ImageEditorMainBottomBarState>();
final editorKey = GlobalKey<ProImageEditorState>();
+ final _imageReady = Completer<void>();
late final _layerDoubleTap = ImageEditorLayerDoubleTap(
() => editorKey.currentState,
);
@@ -285,6 +286,9 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
_showExitConfirmationDialog(context);
},
mainEditorCallbacks: MainEditorCallbacks(
+ onImageDecoded: () {
+ if (!_imageReady.isCompleted) _imageReady.complete();
+ },
onOpenSubEditor: (editor) => _activeSubEditor = editor,
onLayerTapDown: _layerDoubleTap.onLayerDown,
onLayerTapUp: _layerDoubleTap.onLayerUp,
@@ -391,6 +395,7 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
return ImageEditorMainBottomBar(
key: _mainEditorBarKey,
editor: editor,
+ imageReady: _imageReady.future,
configs: editor.configs,
callbacks: editor.callbacks,
);
diff --git a/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart b/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart
index 3567379285..2874c9c98e 100644
--- a/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart
+++ b/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart
@@ -360,6 +360,7 @@ Future<ProImageEditorState> _openEditor(
stream: stream,
builder: (_) => ImageEditorMainBottomBar(
editor: editor,
+ imageReady: Future<void>.value(),
configs: editor.configs,
callbacks: editor.callbacks,
),