π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add a delay before gallery loads in 'add photos sheet' to make opening of the bottom sheet jank free
ashilknaf7b533016eb
diff --git a/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart b/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dartindex 78dd4a4245..0ccdc93e11 100644--- a/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart+++ b/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart@@ -2,6 +2,7 @@ import "dart:math";import "package:flutter/foundation.dart";import "package:flutter/material.dart";+import "package:flutter_animate/flutter_animate.dart";import "package:modal_bottom_sheet/modal_bottom_sheet.dart";import "package:photos/core/configuration.dart";import "package:photos/db/files_db.dart";@@ -15,6 +16,7 @@ import "package:photos/theme/colors.dart";import "package:photos/theme/ente_theme.dart";import "package:photos/ui/actions/collection/collection_file_actions.dart";import "package:photos/ui/actions/collection/collection_sharing_actions.dart";+import "package:photos/ui/common/loading_widget.dart";import "package:photos/ui/components/bottom_of_title_bar_widget.dart";import "package:photos/ui/components/buttons/button_widget.dart";import "package:photos/ui/components/models/button_type.dart";@@ -91,33 +93,9 @@ class AddPhotosPhotoWidget extends StatelessWidget {showCloseButton: true,),Expanded(- child: Gallery(- inSelectionMode: true,- asyncLoader: (- creationStartTime,- creationEndTime, {- limit,- asc,- }) {- return FilesDB.instance- .getAllPendingOrUploadedFiles(- creationStartTime,- creationEndTime,- Configuration.instance.getUserID()!,- limit: limit,- asc: asc,- filterOptions: DBFilterOptions(- hideIgnoredForUpload: true,- dedupeUploadID: true,- ignoredCollectionIDs: hiddenCollectionIDs,- ),- applyOwnerCheck: true,- );- },- tagPrefix: "pick_add_photos_gallery",+ child: DelayedGallery(+ hiddenCollectionIDs: hiddenCollectionIDs,selectedFiles: selectedFiles,- showSelectAllByDefault: true,- sortAsyncFn: () => false,),),],@@ -227,3 +205,71 @@ class AddPhotosPhotoWidget extends StatelessWidget {}}}++class DelayedGallery extends StatefulWidget {+ const DelayedGallery({+ super.key,+ required this.hiddenCollectionIDs,+ required this.selectedFiles,+ });++ final Set<int> hiddenCollectionIDs;+ final SelectedFiles selectedFiles;++ @override+ State<DelayedGallery> createState() => _DelayedGalleryState();+}++class _DelayedGalleryState extends State<DelayedGallery> {+ bool _showGallery = false;++ @override+ void initState() {+ super.initState();+ Future.delayed(const Duration(milliseconds: 500), () {+ if (mounted) {+ setState(() {+ _showGallery = true;+ });+ }+ });+ }++ @override+ Widget build(BuildContext context) {+ if (_showGallery) {+ return Gallery(+ inSelectionMode: true,+ asyncLoader: (+ creationStartTime,+ creationEndTime, {+ limit,+ asc,+ }) {+ return FilesDB.instance.getAllPendingOrUploadedFiles(+ creationStartTime,+ creationEndTime,+ Configuration.instance.getUserID()!,+ limit: limit,+ asc: asc,+ filterOptions: DBFilterOptions(+ hideIgnoredForUpload: true,+ dedupeUploadID: true,+ ignoredCollectionIDs: widget.hiddenCollectionIDs,+ ),+ applyOwnerCheck: true,+ );+ },+ tagPrefix: "pick_add_photos_gallery",+ selectedFiles: widget.selectedFiles,+ showSelectAllByDefault: true,+ sortAsyncFn: () => false,+ ).animate().fadeIn(+ duration: const Duration(milliseconds: 175),+ curve: Curves.easeOutCirc,+ );+ } else {+ return const EnteLoadingWidget();+ }+ }+}