π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] Fix swipe-to-select with already selected files
ashilkn3fbfbf315147
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.dartindex c5fe147e62..9ba161735a 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@@ -43,6 +43,7 @@ class _GalleryFileWidgetState extends State<GalleryFileWidget> {static const borderRadius = BorderRadius.all(Radius.circular(1));late bool _isFileSelected;int? _currentPointerId;+ bool _isPointerInside = false;@overridevoid initState() {@@ -89,55 +90,115 @@ class _GalleryFileWidgetState extends State<GalleryFileWidget> {final swipeActiveNotifier =GallerySwipeHelper.swipeActiveNotifierOf(context);- return TouchCrossDetector(- onPointerDown: (event) {- _currentPointerId = event.pointer;- // Don't start selection immediately - wait for horizontal swipe detection- },- onHover: (event) {- // Only handle the initial file selection when swipe becomes active- if (swipeActiveNotifier?.value == true &&+ return ValueListenableBuilder<bool>(+ valueListenable: swipeActiveNotifier ?? ValueNotifier(false),+ builder: (context, isSwipeActive, child) {+ // Check if we need to start selection when swipe becomes active+ if (isSwipeActive &&+ _isPointerInside &&swipeHelper != null &&!swipeHelper.isActive &&widget.selectedFiles != null &&widget.selectedFiles!.files.isNotEmpty) {- // Start selection for the first file when horizontal swipe is detected- swipeHelper.startSelection(widget.file);- }- },- onEnter: (event) {- // Check if horizontal swipe is active before starting or updating selection- if (swipeActiveNotifier?.value == true && swipeHelper != null) {- if (!swipeHelper.isActive) {- // Start selection when first entering a file during active swipe- swipeHelper.startSelection(widget.file);- } else {- // Update selection for subsequent files- swipeHelper.updateSelection(widget.file);- }+ // Schedule the selection to happen after the current build+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (mounted &&+ isSwipeActive &&+ _isPointerInside &&+ !swipeHelper.isActive) {+ swipeHelper.startSelection(widget.file);+ }+ });}- },- onExit: (event) {- if (_currentPointerId == event.pointer) {- _currentPointerId = null;- }- },- child: GestureDetector(- onTap: () {- widget.limitSelectionToOne- ? _onTapWithSelectionLimit(widget.file)- : _onTapNoSelectionLimit(context, widget.file);- },- onLongPress: () {- widget.limitSelectionToOne- ? _onLongPressWithSelectionLimit(context, widget.file)- : _onLongPressNoSelectionLimit(context, widget.file);- },- child: _isFileSelected- ? Stack(- clipBehavior: Clip.none,- children: [- ClipRRect(++ return TouchCrossDetector(+ onPointerDown: (event) {+ _currentPointerId = event.pointer;+ _isPointerInside = true;+ // If files are already selected and swipe is not active, prepare for potential swipe+ // The actual selection will start when horizontal movement is detected+ },+ onHover: (event) {+ _isPointerInside = true;+ // Handle the initial file selection when swipe becomes active+ if (swipeActiveNotifier?.value == true &&+ swipeHelper != null &&+ !swipeHelper.isActive &&+ widget.selectedFiles != null &&+ widget.selectedFiles!.files.isNotEmpty) {+ // Start selection for the first file when horizontal swipe is detected+ swipeHelper.startSelection(widget.file);+ }+ },+ onEnter: (event) {+ _isPointerInside = true;+ // Check if horizontal swipe is active before starting or updating selection+ if (swipeActiveNotifier?.value == true && swipeHelper != null) {+ if (!swipeHelper.isActive) {+ // Start selection when first entering a file during active swipe+ swipeHelper.startSelection(widget.file);+ } else {+ // Update selection for subsequent files+ swipeHelper.updateSelection(widget.file);+ }+ }+ },+ onExit: (event) {+ _isPointerInside = false;+ if (_currentPointerId == event.pointer) {+ _currentPointerId = null;+ }+ },+ child: GestureDetector(+ onTap: () {+ widget.limitSelectionToOne+ ? _onTapWithSelectionLimit(widget.file)+ : _onTapNoSelectionLimit(context, widget.file);+ },+ onLongPress: () {+ widget.limitSelectionToOne+ ? _onLongPressWithSelectionLimit(context, widget.file)+ : _onLongPressNoSelectionLimit(context, widget.file);+ },+ child: _isFileSelected+ ? Stack(+ clipBehavior: Clip.none,+ children: [+ ClipRRect(+ key: ValueKey(heroTag),+ borderRadius: borderRadius,+ child: Hero(+ tag: heroTag,+ flightShuttleBuilder: (+ flightContext,+ animation,+ flightDirection,+ fromHeroContext,+ toHeroContext,+ ) =>+ thumbnailWidget,+ transitionOnUserGestures: true,+ child: thumbnailWidget,+ ),+ ),+ Container(+ decoration: const BoxDecoration(+ color: Color.fromARGB(102, 0, 0, 0),+ borderRadius: borderRadius,+ ),+ ),+ Positioned(+ right: 4,+ top: 4,+ child: Icon(+ Icons.check_circle_rounded,+ size: 20,+ color: selectionColor, //same for both themes+ ),+ ),+ ],+ )+ : ClipRRect(key: ValueKey(heroTag),borderRadius: borderRadius,child: Hero(@@ -154,41 +215,9 @@ class _GalleryFileWidgetState extends State<GalleryFileWidget> {child: thumbnailWidget,),),- Container(- decoration: const BoxDecoration(- color: Color.fromARGB(102, 0, 0, 0),- borderRadius: borderRadius,- ),- ),- Positioned(- right: 4,- top: 4,- child: Icon(- Icons.check_circle_rounded,- size: 20,- color: selectionColor, //same for both themes- ),- ),- ],- )- : ClipRRect(- key: ValueKey(heroTag),- borderRadius: borderRadius,- child: Hero(- tag: heroTag,- flightShuttleBuilder: (- flightContext,- animation,- flightDirection,- fromHeroContext,- toHeroContext,- ) =>- thumbnailWidget,- transitionOnUserGestures: true,- child: thumbnailWidget,- ),- ),- ),+ ),+ );+ },);}