Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] Fix swipe-to-select UX issues

ashilkn9979d5d4f5dd
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart
index 724bdbcd7d..47d052f0a8 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart
@@ -42,6 +42,7 @@ class GalleryFileWidget extends StatefulWidget {
class _GalleryFileWidgetState extends State<GalleryFileWidget> {
static const borderRadius = BorderRadius.all(Radius.circular(1));
late bool _isFileSelected;
+ int? _currentPointerId;
@override
void initState() {
@@ -87,7 +88,10 @@ class _GalleryFileWidgetState extends State<GalleryFileWidget> {
);
return TouchCrossDetector(
onPointerDown: (event) {
- if (swipeHelper != null && widget.selectedFiles != null) {
+ _currentPointerId = event.pointer;
+ if (swipeHelper != null &&
+ widget.selectedFiles != null &&
+ widget.selectedFiles!.files.isNotEmpty) {
swipeHelper.startSelection(widget.file);
}
},
@@ -97,7 +101,9 @@ class _GalleryFileWidgetState extends State<GalleryFileWidget> {
}
},
onExit: (event) {
- // Handle exit if needed
+ if (_currentPointerId == event.pointer) {
+ _currentPointerId = null;
+ }
},
child: GestureDetector(
onTap: () {
@@ -218,6 +224,15 @@ class _GalleryFileWidgetState extends State<GalleryFileWidget> {
} else {
HapticFeedback.lightImpact();
_toggleFileSelection(file);
+ // Start swipe selection if pointer is still down after long press
+ // Force selecting mode since we just selected this file
+ final swipeHelper = GallerySwipeHelper.of(context);
+ if (_currentPointerId != null &&
+ TouchCrossDetector.isPointerActive(_currentPointerId!) &&
+ swipeHelper != null &&
+ widget.selectedFiles!.files.isNotEmpty) {
+ swipeHelper.startSelection(file, forceSelecting: true);
+ }
}
}
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/swipe_to_select_helper.dart b/mobile/apps/photos/lib/ui/viewer/gallery/swipe_to_select_helper.dart
index 62d6e2e7a6..81f9a4a748 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/swipe_to_select_helper.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/swipe_to_select_helper.dart
@@ -27,14 +27,15 @@ class SwipeToSelectHelper {
bool get isActive => _fromIndex != null;
/// Start a selection gesture at the given file
- void startSelection(EnteFile file) {
+ /// [forceSelecting] - if true, forces adding mode regardless of file's current state
+ void startSelection(EnteFile file, {bool? forceSelecting}) {
final index = allFiles.indexOf(file);
if (index == -1) return;
_fromIndex = index;
_lastToIndex = index;
- // Determine mode based on initial file's selection state
- _selecting = !selectedFiles.isFileSelected(file);
+ // Use forced mode if provided, otherwise determine based on initial file's selection state
+ _selecting = forceSelecting ?? !selectedFiles.isFileSelected(file);
}
/// Update selection as the pointer moves to a new file