π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Batch operation to delete quick links
Aman Raj Singh Mourya6361859a1b1c
diff --git a/mobile/lib/ui/tabs/shared/all_quick_links_page.dart b/mobile/lib/ui/tabs/shared/all_quick_links_page.dartindex 3a42ad0b61..65670ad500 100644--- a/mobile/lib/ui/tabs/shared/all_quick_links_page.dart+++ b/mobile/lib/ui/tabs/shared/all_quick_links_page.dart@@ -1,10 +1,17 @@import "package:flutter/material.dart";+import "package:logging/logging.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/collection/collection.dart";+import "package:photos/models/collection/collection_items.dart";+import "package:photos/services/collections_service.dart";+import "package:photos/ui/actions/collection/collection_sharing_actions.dart";import "package:photos/ui/components/title_bar_title_widget.dart";import "package:photos/ui/tabs/shared/quick_link_album_item.dart";+import "package:photos/ui/viewer/gallery/collection_page.dart";+import "package:photos/utils/dialog_util.dart";+import "package:photos/utils/navigation_util.dart";-class AllQuickLinksPage extends StatelessWidget {+class AllQuickLinksPage extends StatefulWidget {final List<Collection> quickLinks;final String titleHeroTag;const AllQuickLinksPage({@@ -13,6 +20,71 @@ class AllQuickLinksPage extends StatelessWidget {super.key,});+ @override+ State<AllQuickLinksPage> createState() => _AllQuickLinksPageState();+}++class _AllQuickLinksPageState extends State<AllQuickLinksPage> {+ List<Collection> selectedQuickLinks = [];+ bool isAnyQuickLinkSelected = false;+ final _logger = Logger("QuickLinks");+ static const heroTagPrefix = "outgoing_collection";++ Future<void> _navigateToCollectionPage(Collection c) async {+ final thumbnail = await CollectionsService.instance.getCover(c);+ final page = CollectionPage(+ CollectionWithThumbnail(+ c,+ thumbnail,+ ),+ tagPrefix: heroTagPrefix,+ );+ // ignore: unawaited_futures+ routeToPage(context, page);+ }++ void _toggleQuickLinkSelection(Collection c) {+ if (selectedQuickLinks.contains(c)) {+ selectedQuickLinks.remove(c);+ } else {+ selectedQuickLinks.add(c);+ }+ setState(() {+ isAnyQuickLinkSelected = selectedQuickLinks.isNotEmpty;+ });+ }++ Future<void> _removeQuickLink() async {+ try {+ final dialog = createProgressDialog(+ context,+ S.of(context).removeLink,+ isDismissible: true,+ );+ await dialog.show();++ for (var selectedQuickLink in selectedQuickLinks) {+ if (selectedQuickLink.isQuickLinkCollection() &&+ !selectedQuickLink.hasSharees) {+ await CollectionActions(CollectionsService.instance)+ .trashCollectionKeepingPhotos(selectedQuickLink, context);+ widget.quickLinks.remove(selectedQuickLink);+ } else {+ widget.quickLinks.remove(selectedQuickLink);+ await CollectionsService.instance.disableShareUrl(selectedQuickLink);+ }+ }+ setState(() {+ selectedQuickLinks.clear();+ isAnyQuickLinkSelected = false;+ });+ await dialog.hide();+ } catch (e, s) {+ _logger.severe("failed to trash collection", e, s);+ await showGenericErrorDialog(context: context, error: e);+ }+ }+@overrideWidget build(BuildContext context) {return Scaffold(@@ -27,6 +99,14 @@ class AllQuickLinksPage extends StatelessWidget {Icons.arrow_back_outlined,),),+ actions: [+ IconButton(+ onPressed: () async {+ await _removeQuickLink();+ },+ icon: const Icon(Icons.remove_circle_outline_outlined),+ ),+ ],),body: Column(crossAxisAlignment: CrossAxisAlignment.start,@@ -38,9 +118,9 @@ class AllQuickLinksPage extends StatelessWidget {children: [TitleBarTitleWidget(title: S.of(context).quickLinks,- heroTag: titleHeroTag,+ heroTag: widget.titleHeroTag,),- Text(quickLinks.length.toString()),+ Text(widget.quickLinks.length.toString()),],),),@@ -52,12 +132,28 @@ class AllQuickLinksPage extends StatelessWidget {),child: ListView.separated(itemBuilder: (context, index) {- return QuickLinkAlbumItem(c: quickLinks[index]);+ return GestureDetector(+ onTap: () {+ isAnyQuickLinkSelected+ ? _toggleQuickLinkSelection(widget.quickLinks[index])+ : _navigateToCollectionPage(widget.quickLinks[index]);+ },+ onLongPress: () {+ isAnyQuickLinkSelected+ ? _navigateToCollectionPage(widget.quickLinks[index])+ : _toggleQuickLinkSelection(widget.quickLinks[index]);+ },+ behavior: HitTestBehavior.opaque,+ child: QuickLinkAlbumItem(+ c: widget.quickLinks[index],+ selectedQuickLinks: selectedQuickLinks,+ ),+ );},separatorBuilder: (context, index) {return const SizedBox(height: 10);},- itemCount: quickLinks.length,+ itemCount: widget.quickLinks.length,physics: const BouncingScrollPhysics(),),),diff --git a/mobile/lib/ui/tabs/shared/quick_link_album_item.dart b/mobile/lib/ui/tabs/shared/quick_link_album_item.dartindex 9debde5e84..fb5ee2fe65 100644--- a/mobile/lib/ui/tabs/shared/quick_link_album_item.dart+++ b/mobile/lib/ui/tabs/shared/quick_link_album_item.dart@@ -1,7 +1,6 @@import "package:flutter/material.dart";import "package:photos/generated/l10n.dart";import 'package:photos/models/collection/collection.dart';-import 'package:photos/models/collection/collection_items.dart';import 'package:photos/models/file/file.dart';import "package:photos/services/collections_service.dart";import "package:photos/theme/ente_theme.dart";@@ -9,149 +8,141 @@ import "package:photos/ui/common/loading_widget.dart";import "package:photos/ui/components/buttons/icon_button_widget.dart";import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";import "package:photos/ui/viewer/file/thumbnail_widget.dart";-import "package:photos/ui/viewer/gallery/collection_page.dart";-import "package:photos/utils/navigation_util.dart";class QuickLinkAlbumItem extends StatelessWidget {final Collection c;static const heroTagPrefix = "outgoing_collection";+ final List<Collection> selectedQuickLinks;- const QuickLinkAlbumItem({super.key, required this.c});+ const QuickLinkAlbumItem({+ super.key,+ required this.c,+ this.selectedQuickLinks = const [],+ });@overrideWidget build(BuildContext context) {final colorScheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);- return GestureDetector(- behavior: HitTestBehavior.opaque,- child: Container(- decoration: BoxDecoration(- border: Border.all(color: colorScheme.strokeFainter),- borderRadius: const BorderRadius.all(- Radius.circular(2),- ),+ return Container(+ decoration: BoxDecoration(+ border: Border.all(+ color: selectedQuickLinks.contains(c)+ ? colorScheme.primary300+ : colorScheme.strokeFainter,+ ),+ borderRadius: const BorderRadius.all(+ Radius.circular(2),),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Flexible(- flex: 6,- child: Row(- children: [- SizedBox(- width: 60,- height: 60,- child: FutureBuilder<EnteFile?>(- future: CollectionsService.instance.getCover(c),- builder: (context, snapshot) {- if (snapshot.hasData) {- final String heroTag =- heroTagPrefix + snapshot.data!.tag;- return Hero(- tag: heroTag,- child: ClipRRect(- borderRadius: const BorderRadius.horizontal(- left: Radius.circular(2),- ),- child: ThumbnailWidget(- snapshot.data!,- key: ValueKey(heroTag),- ),+ ),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ Flexible(+ flex: 6,+ child: Row(+ children: [+ SizedBox(+ width: 60,+ height: 60,+ child: FutureBuilder<EnteFile?>(+ future: CollectionsService.instance.getCover(c),+ builder: (context, snapshot) {+ if (snapshot.hasData) {+ final String heroTag =+ heroTagPrefix + snapshot.data!.tag;+ return Hero(+ tag: heroTag,+ child: ClipRRect(+ borderRadius: const BorderRadius.horizontal(+ left: Radius.circular(2),+ ),+ child: ThumbnailWidget(+ snapshot.data!,+ key: ValueKey(heroTag),),- );- } else {- return const NoThumbnailWidget();- }- },- ),- ),- const SizedBox(width: 12),- Flexible(- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 4),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- c.displayName,- overflow: TextOverflow.ellipsis,- ),- const SizedBox(- height: 2,),- FutureBuilder<int>(- future: CollectionsService.instance.getFileCount(c),- builder: (context, snapshot) {- if (!snapshot.hasError) {- if (!snapshot.hasData) {- return Row(- children: [- EnteLoadingWidget(- size: 10,- color: colorScheme.strokeMuted,- ),- ],- );- }- final noOfMemories = snapshot.data;-+ );+ } else {+ return const NoThumbnailWidget();+ }+ },+ ),+ ),+ const SizedBox(width: 12),+ Flexible(+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 4),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ c.displayName,+ overflow: TextOverflow.ellipsis,+ ),+ const SizedBox(+ height: 2,+ ),+ FutureBuilder<int>(+ future: CollectionsService.instance.getFileCount(c),+ builder: (context, snapshot) {+ if (!snapshot.hasError) {+ if (!snapshot.hasData) {return Row(children: [- Text(- noOfMemories.toString() + " \u2022 ",- style: textTheme.smallMuted,+ EnteLoadingWidget(+ size: 10,+ color: colorScheme.strokeMuted,),- c.hasLink- ? (c.publicURLs!.first!.isExpired- ? Icon(- Icons.link_outlined,- color: colorScheme.warning500,- size: 22,- )- : Icon(- Icons.link_outlined,- color: colorScheme.strokeMuted,- size: 22,- ))- : const SizedBox.shrink(),],);- } else if (snapshot.hasError) {- return Text(S.of(context).somethingWentWrong);- } else {- return const EnteLoadingWidget(size: 10);}- },- ),- ],- ),+ final noOfMemories = snapshot.data;++ return Row(+ children: [+ Text(+ noOfMemories.toString() + " \u2022 ",+ style: textTheme.smallMuted,+ ),+ c.hasLink+ ? (c.publicURLs!.first!.isExpired+ ? Icon(+ Icons.link_outlined,+ color: colorScheme.warning500,+ size: 22,+ )+ : Icon(+ Icons.link_outlined,+ color: colorScheme.strokeMuted,+ size: 22,+ ))+ : const SizedBox.shrink(),+ ],+ );+ } else if (snapshot.hasError) {+ return Text(S.of(context).somethingWentWrong);+ } else {+ return const EnteLoadingWidget(size: 10);+ }+ },+ ),+ ],),),- ],- ),+ ),+ ],),- const Flexible(- flex: 1,- child: IconButtonWidget(- icon: Icons.chevron_right_outlined,- iconButtonType: IconButtonType.secondary,- ),+ ),+ const Flexible(+ flex: 1,+ child: IconButtonWidget(+ icon: Icons.chevron_right_outlined,+ iconButtonType: IconButtonType.secondary,),- ],- ),- ),- onTap: () async {- final thumbnail = await CollectionsService.instance.getCover(c);- final page = CollectionPage(- CollectionWithThumbnail(- c,- thumbnail,),- tagPrefix: heroTagPrefix,- );- // ignore: unawaited_futures- routeToPage(context, page);- },+ ],+ ),);}}diff --git a/mobile/lib/ui/tabs/shared_collections_tab.dart b/mobile/lib/ui/tabs/shared_collections_tab.dartindex c8a94c55fd..2994a293c2 100644--- a/mobile/lib/ui/tabs/shared_collections_tab.dart+++ b/mobile/lib/ui/tabs/shared_collections_tab.dart@@ -21,12 +21,13 @@ import 'package:photos/ui/tabs/section_title.dart';import "package:photos/ui/tabs/shared/all_quick_links_page.dart";import "package:photos/ui/tabs/shared/empty_state.dart";import "package:photos/ui/tabs/shared/quick_link_album_item.dart";+import "package:photos/ui/viewer/gallery/collection_page.dart";import "package:photos/utils/debouncer.dart";import "package:photos/utils/navigation_util.dart";import "package:photos/utils/share_util.dart";class SharedCollectionsTab extends StatefulWidget {- const SharedCollectionsTab({Key? key}) : super(key: key);+ const SharedCollectionsTab({super.key});@overrideState<SharedCollectionsTab> createState() => _SharedCollectionsTabState();@@ -43,6 +44,7 @@ class _SharedCollectionsTabState extends State<SharedCollectionsTab>const Duration(seconds: 2),executionInterval: const Duration(seconds: 5),);+ static const heroTagPrefix = "outgoing_collection";@overridevoid initState() {@@ -262,8 +264,24 @@ class _SharedCollectionsTabState extends State<SharedCollectionsTab>),physics: const NeverScrollableScrollPhysics(),itemBuilder: (context, index) {- return QuickLinkAlbumItem(- c: collections.quickLinks[index],+ return GestureDetector(+ onTap: () async {+ final thumbnail = await CollectionsService+ .instance+ .getCover(collections.quickLinks[index]);+ final page = CollectionPage(+ CollectionWithThumbnail(+ collections.quickLinks[index],+ thumbnail,+ ),+ tagPrefix: heroTagPrefix,+ );+ // ignore: unawaited_futures+ routeToPage(context, page);+ },+ child: QuickLinkAlbumItem(+ c: collections.quickLinks[index],+ ),);},separatorBuilder: (context, index) {