Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] Select only the new copy when duplicating editor layers

r4khul205db9deab1f
diff --git a/mobile/apps/photos/changes/image-editor-duplicate-selection.md b/mobile/apps/photos/changes/image-editor-duplicate-selection.md
new file mode 100644
index 0000000000..082b863019
--- /dev/null
+++ b/mobile/apps/photos/changes/image-editor-duplicate-selection.md
@@ -0,0 +1 @@
+- Fixed duplicated text and drawings moving together in the photo editor.
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart
index f2fa5673e3..73891c4591 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart
@@ -64,7 +64,13 @@ LayerInteractionConfigs imageEditorLayerInteractionConfigs(
label: strings.imageEditorDuplicate,
icon: HugeIcons.strokeRoundedCopy01,
color: colors.iconColor,
- onTap: interactions.duplicated,
+ onTap: () {
+ interactions.duplicated();
+ final state = editor();
+ if (state != null) {
+ _selectLayerWhenReady(state, state.activeLayers.last.id);
+ }
+ },
),
_LayerAction(
label: strings.delete,
@@ -195,11 +201,11 @@ Future<TextLayer?> imageEditorCreateTextLayer(
);
if (layer == null) return null;
layer.id = id;
- _selectLayerAfterClose(state, id);
+ _selectLayerWhenReady(state, id);
return layer;
}
-void _selectLayerAfterClose(ProImageEditorState state, String id) {
+void _selectLayerWhenReady(ProImageEditorState state, String id) {
void selectWhenReady(Duration _) {
if (!state.mounted) return;
if (state.isSubEditorOpen) {
@@ -282,7 +288,7 @@ Future<void> _editTextLayer(ProImageEditorState editor, TextLayer layer) async {
index: editor.activeLayers.indexWhere((other) => other.id == layer.id),
layer: updated,
);
- _selectLayerAfterClose(editor, layer.id);
+ _selectLayerWhenReady(editor, layer.id);
WidgetsBinding.instance.addPostFrameCallback((_) {
updated
..color = color
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 ad813d0f2d..e8da7c4aa6 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
@@ -88,6 +88,30 @@ void main() {
expect(editor.activeLayers, hasLength(1));
});
+ testWidgets('each duplicate is selected on its own and drags alone', (
+ tester,
+ ) async {
+ final editor = await _openEditor(tester);
+ await _tap(tester, find.text('Done'));
+ for (var i = 0; i < 3; i++) {
+ await _tap(tester, find.byTooltip('Duplicate'));
+ expect(editor.layerInteractionManager.selectedLayerIds, {
+ editor.activeLayers.last.id,
+ });
+ }
+ final offsets = [for (final layer in editor.activeLayers) layer.offset];
+
+ await tester.drag(
+ find.byKey(editor.activeLayers.last.keyInternalSize),
+ const Offset(60, 40),
+ );
+ await tester.pumpAndSettle();
+
+ final moved = [for (final layer in editor.activeLayers) layer.offset];
+ expect(moved.take(3), offsets.take(3));
+ expect(moved.last, isNot(offsets.last));
+ });
+
testWidgets('double tapping applied text reopens it for typing', (
tester,
) async {