π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] feat: reflect SelectAll action change on UI
Aman Raj Singh Mouryad7cb5c29cf64
diff --git a/mobile/lib/ui/collections/album/list_item.dart b/mobile/lib/ui/collections/album/list_item.dartindex 79f6e92f81..2a9d7a4ac8 100644--- a/mobile/lib/ui/collections/album/list_item.dart+++ b/mobile/lib/ui/collections/album/list_item.dart@@ -29,138 +29,143 @@ class AlbumListItemWidget extends StatelessWidget {Widget build(BuildContext context) {final textTheme = getEnteTextTheme(context);final colorScheme = getEnteColorScheme(context);- final bool isSelected =- selectedAlbums?.isAlbumSelected(collection) ?? false;const sideOfThumbnail = 60.0;- return GestureDetector(- onTap: () {- if (onTapCallback != null) {- onTapCallback!(collection);- }- },- onLongPress: () {- if (onLongPressCallback != null) {- onLongPressCallback!(collection);- }- },- behavior: HitTestBehavior.opaque,- child: AnimatedContainer(- curve: Curves.easeOut,- duration: const Duration(milliseconds: 200),- decoration: BoxDecoration(- border: Border.all(- color: isSelected- ? colorScheme.strokeMuted- : colorScheme.strokeFainter,- ),- borderRadius: const BorderRadius.all(- Radius.circular(4),- ),- ),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Flexible(- flex: 6,- child: Row(- children: [- ClipRRect(- borderRadius: const BorderRadius.horizontal(- left: Radius.circular(4),- ),- child: SizedBox(- height: sideOfThumbnail,- width: sideOfThumbnail,- child: FutureBuilder<EnteFile?>(- future:- CollectionsService.instance.getCover(collection),- builder: (context, snapshot) {- if (snapshot.hasData) {- final thumbnail = snapshot.data!;+ return ListenableBuilder(+ listenable: selectedAlbums!,+ builder: (context, _) {+ final isSelected = selectedAlbums?.isAlbumSelected(collection) ?? false;- return ThumbnailWidget(- thumbnail,- showFavForAlbumOnly: true,- shouldShowOwnerAvatar: false,- );- } else {- return const NoThumbnailWidget(- addBorder: false,- );- }- },- ),- ),- ),- const SizedBox(width: 12),- Flexible(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- collection.displayName,- overflow: TextOverflow.ellipsis,+ return GestureDetector(+ onTap: () {+ if (onTapCallback != null) {+ onTapCallback!(collection);+ }+ },+ onLongPress: () {+ if (onLongPressCallback != null) {+ onLongPressCallback!(collection);+ }+ },+ behavior: HitTestBehavior.opaque,+ child: AnimatedContainer(+ curve: Curves.easeOut,+ duration: const Duration(milliseconds: 200),+ decoration: BoxDecoration(+ border: Border.all(+ color: isSelected+ ? colorScheme.strokeMuted+ : colorScheme.strokeFainter,+ ),+ borderRadius: const BorderRadius.all(+ Radius.circular(4),+ ),+ ),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ Flexible(+ flex: 6,+ child: Row(+ children: [+ ClipRRect(+ borderRadius: const BorderRadius.horizontal(+ left: Radius.circular(4),),- FutureBuilder<int>(- future: CollectionsService.instance- .getFileCount(collection),- builder: (context, snapshot) {- if (snapshot.hasData) {- return Text(- S.of(context).memoryCount(- snapshot.data!,- NumberFormat().format(snapshot.data!),- ),- style: textTheme.small.copyWith(- color: colorScheme.textMuted,- ),- );- } else {- if (snapshot.hasError) {- Logger("AlbumListItemWidget").severe(- "Failed to fetch file count of collection",- snapshot.error,+ child: SizedBox(+ height: sideOfThumbnail,+ width: sideOfThumbnail,+ child: FutureBuilder<EnteFile?>(+ future: CollectionsService.instance+ .getCover(collection),+ builder: (context, snapshot) {+ if (snapshot.hasData) {+ final thumbnail = snapshot.data!;++ return ThumbnailWidget(+ thumbnail,+ showFavForAlbumOnly: true,+ shouldShowOwnerAvatar: false,+ );+ } else {+ return const NoThumbnailWidget(+ addBorder: false,);}- return Text(- "",- style: textTheme.small.copyWith(- color: colorScheme.textMuted,- ),- );- }- },+ },+ ),),- ],- ),- ),- ],- ),- ),- Flexible(- flex: 1,- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 200),- switchInCurve: Curves.easeOut,- switchOutCurve: Curves.easeIn,- child: isSelected- ? IconButtonWidget(- key: const ValueKey("selected"),- icon: Icons.check_circle_rounded,- iconButtonType: IconButtonType.secondary,- iconColor: colorScheme.blurStrokeBase,- )- : const IconButtonWidget(- key: ValueKey("unselected"),- icon: Icons.chevron_right_outlined,- iconButtonType: IconButtonType.secondary,),- ),+ const SizedBox(width: 12),+ Flexible(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ collection.displayName,+ overflow: TextOverflow.ellipsis,+ ),+ FutureBuilder<int>(+ future: CollectionsService.instance+ .getFileCount(collection),+ builder: (context, snapshot) {+ if (snapshot.hasData) {+ return Text(+ S.of(context).memoryCount(+ snapshot.data!,+ NumberFormat().format(snapshot.data!),+ ),+ style: textTheme.small.copyWith(+ color: colorScheme.textMuted,+ ),+ );+ } else {+ if (snapshot.hasError) {+ Logger("AlbumListItemWidget").severe(+ "Failed to fetch file count of collection",+ snapshot.error,+ );+ }+ return Text(+ "",+ style: textTheme.small.copyWith(+ color: colorScheme.textMuted,+ ),+ );+ }+ },+ ),+ ],+ ),+ ),+ ],+ ),+ ),+ Flexible(+ flex: 1,+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 200),+ switchInCurve: Curves.easeOut,+ switchOutCurve: Curves.easeIn,+ child: isSelected+ ? IconButtonWidget(+ key: const ValueKey("selected"),+ icon: Icons.check_circle_rounded,+ iconButtonType: IconButtonType.secondary,+ iconColor: colorScheme.blurStrokeBase,+ )+ : const IconButtonWidget(+ key: ValueKey("unselected"),+ icon: Icons.chevron_right_outlined,+ iconButtonType: IconButtonType.secondary,+ ),+ ),+ ),+ ],),- ],- ),- ),+ ),+ );+ },);}}diff --git a/mobile/lib/ui/collections/album/row_item.dart b/mobile/lib/ui/collections/album/row_item.dartindex 67c8c7cc56..7c8e273a3a 100644--- a/mobile/lib/ui/collections/album/row_item.dart+++ b/mobile/lib/ui/collections/album/row_item.dart@@ -24,7 +24,7 @@ class AlbumRowItemWidget extends StatelessWidget {final bool? hasVerifiedLock;final void Function(Collection)? onTapCallback;final void Function(Collection)? onLongPressCallback;- final SelectedAlbums? selectedAlbum;+ final SelectedAlbums? selectedAlbums;const AlbumRowItemWidget(this.c,@@ -35,13 +35,12 @@ class AlbumRowItemWidget extends StatelessWidget {this.hasVerifiedLock,this.onTapCallback,this.onLongPressCallback,- this.selectedAlbum,+ this.selectedAlbums,});@overrideWidget build(BuildContext context) {final colorScheme = getEnteColorScheme(context);- final bool isSelected = selectedAlbum?.isAlbumSelected(c) ?? false;final bool isOwner = c.isOwner(Configuration.instance.getUserID()!);final String tagPrefix = (isOwner ? "collection" : "shared_collection") +tag +@@ -54,190 +53,199 @@ class AlbumRowItemWidget extends StatelessWidget {color: c.publicURLs.first.isExpired ? warning500 : strokeBaseDark,): null;- return GestureDetector(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: <Widget>[- Stack(- children: [- ClipRRect(- borderRadius: BorderRadius.circular(1),- child: SizedBox(- height: sideOfThumbnail,- width: sideOfThumbnail,- child: Stack(- children: [- FutureBuilder<EnteFile?>(- future: CollectionsService.instance.getCover(c),- builder: (context, snapshot) {- EnteFile? thumbnail;- if (snapshot.hasData) {- thumbnail = snapshot.data!;- } else {- //Need to use cached thumbnail so that the hero- //animation works as expected.- thumbnail =- CollectionsService.instance.getCoverCache(c);- }- if (thumbnail != null) {- final String heroTag = tagPrefix + thumbnail.tag;- return Hero(- tag: heroTag,+ return ListenableBuilder(+ listenable: selectedAlbums ?? ValueNotifier(false),+ builder: (context, _) {+ final bool isSelected = selectedAlbums?.isAlbumSelected(c) ?? false;+ return GestureDetector(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: <Widget>[+ Stack(+ children: [+ ClipRRect(+ borderRadius: BorderRadius.circular(1),+ child: SizedBox(+ height: sideOfThumbnail,+ width: sideOfThumbnail,+ child: Stack(+ children: [+ FutureBuilder<EnteFile?>(+ future: CollectionsService.instance.getCover(c),+ builder: (context, snapshot) {+ EnteFile? thumbnail;+ if (snapshot.hasData) {+ thumbnail = snapshot.data!;+ } else {+ //Need to use cached thumbnail so that the hero+ //animation works as expected.+ thumbnail = CollectionsService.instance+ .getCoverCache(c);+ }+ if (thumbnail != null) {+ final String heroTag =+ tagPrefix + thumbnail.tag;+ return Hero(+ tag: heroTag,+ transitionOnUserGestures: true,+ child: ThumbnailWidget(+ thumbnail,+ shouldShowArchiveStatus: isOwner+ ? c.isArchived()+ : c.hasShareeArchived(),+ showFavForAlbumOnly: true,+ shouldShowSyncStatus: false,+ shouldShowPinIcon: isOwner && c.isPinned,+ key: Key(heroTag),+ ),+ );+ } else {+ return const NoThumbnailWidget();+ }+ },+ ),+ if (isOwner && (c.hasSharees || c.hasLink))+ Hero(+ tag: tagPrefix + "_sharees",transitionOnUserGestures: true,- child: ThumbnailWidget(- thumbnail,- shouldShowArchiveStatus: isOwner- ? c.isArchived()- : c.hasShareeArchived(),- showFavForAlbumOnly: true,- shouldShowSyncStatus: false,- shouldShowPinIcon: isOwner && c.isPinned,- key: Key(heroTag),+ child: Align(+ alignment: Alignment.topLeft,+ child: AlbumSharesIcons(+ sharees: c.getSharees(),+ type: AvatarType.mini,+ trailingWidget: linkIcon,+ ),+ ),+ ),+ Align(+ alignment: Alignment.topRight,+ child: Hero(+ tag: tagPrefix + "_album_selection",+ transitionOnUserGestures: true,+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 200),+ switchInCurve: Curves.easeOut,+ switchOutCurve: Curves.easeIn,+ child: isSelected+ ? IconButtonWidget(+ key: const ValueKey("selected"),+ icon: Icons.check_circle_rounded,+ iconButtonType:+ IconButtonType.secondary,+ iconColor: colorScheme.blurStrokeBase,+ )+ : null,),- );- } else {- return const NoThumbnailWidget();- }- },- ),- if (isOwner && (c.hasSharees || c.hasLink))- Hero(- tag: tagPrefix + "_sharees",- transitionOnUserGestures: true,- child: Align(- alignment: Alignment.topLeft,- child: AlbumSharesIcons(- sharees: c.getSharees(),- type: AvatarType.mini,- trailingWidget: linkIcon,),),- ),- Align(- alignment: Alignment.topRight,- child: Hero(- tag: tagPrefix + "_album_selection",- transitionOnUserGestures: true,- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 200),- switchInCurve: Curves.easeOut,- switchOutCurve: Curves.easeIn,- child: isSelected- ? IconButtonWidget(- key: const ValueKey("selected"),- icon: Icons.check_circle_rounded,- iconButtonType: IconButtonType.secondary,- iconColor: colorScheme.blurStrokeBase,- )- : null,- ),- ),+ if (!isOwner)+ Align(+ alignment: Alignment.bottomRight,+ child: Hero(+ tag: tagPrefix + "_owner_other",+ transitionOnUserGestures: true,+ child: Padding(+ padding: const EdgeInsets.only(+ right: 8.0,+ bottom: 8.0,+ ),+ child: UserAvatarWidget(+ c.owner,+ thumbnailView: true,+ ),+ ),+ ),+ ),+ ],),- if (!isOwner)- Align(- alignment: Alignment.bottomRight,- child: Hero(- tag: tagPrefix + "_owner_other",- transitionOnUserGestures: true,- child: Padding(- padding: const EdgeInsets.only(- right: 8.0,- bottom: 8.0,+ ),+ ),+ ],+ ),+ const SizedBox(height: 4),+ Hero(+ tag: tagPrefix + "_title",+ transitionOnUserGestures: true,+ child: SizedBox(+ width: sideOfThumbnail,+ child: FutureBuilder<int>(+ future: showFileCount+ ? CollectionsService.instance.getFileCount(c)+ : Future.value(0),+ builder: (context, snapshot) {+ int? cachedCount;+ if (showFileCount) {+ if (snapshot.hasData) {+ cachedCount = snapshot.data;+ } else {+ //Need to use cached count so that the hero+ //animation works as expected without flickering.+ cachedCount =+ CollectionsService.instance.getCachedFileCount(c);+ }+ }+ if (cachedCount != null && cachedCount > 0) {+ final String textCount =+ NumberFormat().format(cachedCount);+ return Row(+ children: [+ Container(+ constraints: BoxConstraints(+ maxWidth: sideOfThumbnail -+ ((textCount.length + 3) * 10),),- child: UserAvatarWidget(- c.owner,- thumbnailView: true,+ child: Text(+ c.displayName,+ style: enteTextTheme.small,+ overflow: TextOverflow.ellipsis,),),- ),- ),- ],+ RichText(+ text: TextSpan(+ style: enteTextTheme.smallMuted,+ children: [+ TextSpan(text: ' \u2022 $textCount'),+ ],+ ),+ ),+ ],+ );+ } else {+ return Text(+ c.displayName,+ style: enteTextTheme.small,+ overflow: TextOverflow.ellipsis,+ );+ }+ },),),),],),- const SizedBox(height: 4),- Hero(- tag: tagPrefix + "_title",- transitionOnUserGestures: true,- child: SizedBox(- width: sideOfThumbnail,- child: FutureBuilder<int>(- future: showFileCount- ? CollectionsService.instance.getFileCount(c)- : Future.value(0),- builder: (context, snapshot) {- int? cachedCount;- if (showFileCount) {- if (snapshot.hasData) {- cachedCount = snapshot.data;- } else {- //Need to use cached count so that the hero- //animation works as expected without flickering.- cachedCount =- CollectionsService.instance.getCachedFileCount(c);- }- }- if (cachedCount != null && cachedCount > 0) {- final String textCount = NumberFormat().format(cachedCount);- return Row(- children: [- Container(- constraints: BoxConstraints(- maxWidth:- sideOfThumbnail - ((textCount.length + 3) * 10),- ),- child: Text(- c.displayName,- style: enteTextTheme.small,- overflow: TextOverflow.ellipsis,- ),- ),- RichText(- text: TextSpan(- style: enteTextTheme.smallMuted,- children: [- TextSpan(text: ' \u2022 $textCount'),- ],- ),- ),- ],- );- } else {- return Text(- c.displayName,- style: enteTextTheme.small,- overflow: TextOverflow.ellipsis,- );- }- },+ onTap: () async {+ if (onTapCallback != null) {+ onTapCallback!(c);+ return;+ }+ final thumbnail = await CollectionsService.instance.getCover(c);+ // ignore: unawaited_futures+ routeToPage(+ context,+ CollectionPage(+ CollectionWithThumbnail(c, thumbnail),+ tagPrefix: tagPrefix,+ hasVerifiedLock: hasVerifiedLock,),- ),- ),- ],- ),- onTap: () async {- if (onTapCallback != null) {- onTapCallback!(c);- return;- }- final thumbnail = await CollectionsService.instance.getCover(c);- // ignore: unawaited_futures- routeToPage(- context,- CollectionPage(- CollectionWithThumbnail(c, thumbnail),- tagPrefix: tagPrefix,- hasVerifiedLock: hasVerifiedLock,- ),+ );+ },+ onLongPress: () {+ if (onLongPressCallback != null) {+ onLongPressCallback!(c);+ }+ },);},- onLongPress: () {- if (onLongPressCallback != null) {- onLongPressCallback!(c);- }- },);}}