π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Unify album and search list rows
ashilkn3767ec6da4fb
diff --git a/mobile/apps/photos/lib/ui/collections/album/column_item.dart b/mobile/apps/photos/lib/ui/collections/album/column_item.dartindex 452ad6c2c6..c7a82b9a09 100644--- a/mobile/apps/photos/lib/ui/collections/album/column_item.dart+++ b/mobile/apps/photos/lib/ui/collections/album/column_item.dart@@ -1,18 +1,7 @@import 'package:flutter/material.dart';-import "package:intl/intl.dart";-import 'package:logging/logging.dart';-import "package:photos/core/configuration.dart";-import "package:photos/generated/l10n.dart";import 'package:photos/models/collection/collection.dart';-import 'package:photos/models/file/file.dart';-import "package:photos/services/collections_service.dart";-import 'package:photos/theme/ente_theme.dart';-import "package:photos/ui/components/buttons/icon_button_widget.dart";-import "package:photos/ui/sharing/user_avator_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/collections/album/list_item.dart";-///https://www.figma.com/design/SYtMyLBs5SAOkTbfMMzhqt/Ente-Visual-Design?node-id=39181-172145&t=3qmSZWpXF3ZC4JGN-1class AlbumColumnItemWidget extends StatelessWidget {final Collection collection;final List<Collection> selectedCollections;@@ -25,139 +14,9 @@ class AlbumColumnItemWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);- final colorScheme = getEnteColorScheme(context);- const sideOfThumbnail = 60.0;- final isSelected = selectedCollections.contains(collection);- final isOwner = collection.isOwner(Configuration.instance.getUserID()!);- return 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(6),- ),- ),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Flexible(- flex: 6,- child: Row(- children: [- SizedBox(- height: sideOfThumbnail,- width: sideOfThumbnail,- child: Stack(- children: [- ClipRRect(- borderRadius: BorderRadius.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 ThumbnailWidget(- thumbnail,- showFavForAlbumOnly: true,- shouldShowOwnerAvatar: false,- );- } else {- return const NoThumbnailWidget(- addBorder: false,- );- }- },- ),- ),- ),- if (!isOwner)- Positioned(- left: 4,- top: 4,- child: UserAvatarWidget(- collection.owner,- type: AvatarType.sm,- thumbnailView: true,- ),- ),- ],- ),- ),- const SizedBox(width: 12),- Flexible(- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 4),- 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(- AppLocalizations.of(context).memoryCount(- count: snapshot.data!,- formattedCount:- NumberFormat().format(snapshot.data!),- ),- style: textTheme.miniMuted,- );- } 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,- )- : null,- ),- ),- ],- ),+ return AlbumListItemWidget(+ collection,+ isSelected: selectedCollections.contains(collection),);}}diff --git a/mobile/apps/photos/lib/ui/collections/album/list_item.dart b/mobile/apps/photos/lib/ui/collections/album/list_item.dartindex 88e958e4b5..ac67a92672 100644--- a/mobile/apps/photos/lib/ui/collections/album/list_item.dart+++ b/mobile/apps/photos/lib/ui/collections/album/list_item.dart@@ -1,21 +1,29 @@+import "package:ente_icons/ente_icons.dart";import "package:flutter/material.dart";-import "package:intl/intl.dart";+import "package:hugeicons/hugeicons.dart";import "package:logging/logging.dart";+import "package:photos/core/configuration.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/collection/collection.dart";import "package:photos/models/file/file.dart";import "package:photos/models/selected_albums.dart";import "package:photos/services/collections_service.dart";import "package:photos/theme/ente_theme.dart";-import "package:photos/ui/components/buttons/icon_button_widget.dart";+import "package:photos/ui/components/thumbnail_list_item.dart";+import "package:photos/ui/sharing/album_share_info_widget.dart";+import "package:photos/ui/sharing/user_avator_widget.dart";import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";import "package:photos/ui/viewer/file/thumbnail_widget.dart";class AlbumListItemWidget extends StatelessWidget {+ static final double _trailingWidth =+ getAvatarSize(AvatarType.md) + getOverlapPadding(AvatarType.md);+final Collection collection;final void Function(Collection)? onTapCallback;final void Function(Collection)? onLongPressCallback;final SelectedAlbums? selectedAlbums;+ final bool isSelected;const AlbumListItemWidget(this.collection, {@@ -23,138 +31,284 @@ class AlbumListItemWidget extends StatelessWidget {this.onTapCallback,this.onLongPressCallback,this.selectedAlbums,+ this.isSelected = false,});@overrideWidget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);+ if (selectedAlbums == null) {+ return _buildItem(context, isSelected: isSelected);+ }+ return ListenableBuilder(+ listenable: selectedAlbums!,+ builder: (context, _) {+ return _buildItem(+ context,+ isSelected: selectedAlbums!.isAlbumSelected(collection),+ );+ },+ );+ }++ Widget _buildItem(+ BuildContext context, {+ required bool isSelected,+ }) {final colorScheme = getEnteColorScheme(context);- const sideOfThumbnail = 60.0;-- final albumWidget = Flexible(- flex: 6,- child: Row(- children: [- ClipRRect(- borderRadius: BorderRadius.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 ThumbnailWidget(- thumbnail,- showFavForAlbumOnly: true,- shouldShowOwnerAvatar: false,- );- } else {- return const NoThumbnailWidget(- addBorder: false,- );- }- },- ),- ),- ),- const SizedBox(width: 12),- Flexible(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisAlignment: MainAxisAlignment.center,- children: [- Text(- collection.displayName,+ final textTheme = getEnteTextTheme(context);+ final bool isOwner = collection.isOwner(+ Configuration.instance.getUserID() ?? -1,+ );+ final bool isOutgoing = isOwner && collection.hasSharees;+ final bool isIncoming = !isOwner;+ final bool showSharingIndicator = isOutgoing || isIncoming;+ final bool isFavoriteAlbum = collection.type == CollectionType.favorites;+ final bool showPin = isOwner+ ? collection.isPinned+ : collection.hasShareePinned();+ final bool showArchive = isOwner+ ? collection.isArchived()+ : collection.hasShareeArchived();+ final bool hasAnyStatus = isFavoriteAlbum || showPin || showArchive;++ return ThumbnailListItem(+ isSelected: isSelected,+ onTap: onTapCallback == null ? null : () => onTapCallback!(collection),+ onLongPress: onLongPressCallback == null+ ? null+ : () => onLongPressCallback!(collection),+ leading: _AlbumListItemCover(+ collection: collection,+ showSharingIndicator: showSharingIndicator,+ isOutgoing: isOutgoing,+ ),+ title: Text(+ collection.displayName,+ style: textTheme.body,+ overflow: TextOverflow.ellipsis,+ ),+ subtitle: FutureBuilder<int>(+ future: CollectionsService.instance.getFileCount(collection),+ builder: (context, snapshot) {+ String countText = "";+ if (snapshot.hasData) {+ countText = AppLocalizations.of(context).itemCount(+ count: snapshot.data!,+ );+ } else if (snapshot.hasError) {+ Logger("AlbumListItemWidget").severe(+ "Failed to fetch file count of collection",+ snapshot.error,+ );+ }+ return Row(+ crossAxisAlignment: CrossAxisAlignment.center,+ children: [+ Flexible(+ child: Text(+ countText,+ style: textTheme.smallMuted,overflow: TextOverflow.ellipsis,),- FutureBuilder<int>(- future: CollectionsService.instance.getFileCount(collection),- builder: (context, snapshot) {- if (snapshot.hasData) {- return Text(- AppLocalizations.of(context).memoryCount(- count: snapshot.data!,- formattedCount: 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,- ),- );- }- },- ),+ ),+ if (hasAnyStatus) ...[+ Text(" \u2022 ", style: textTheme.smallMuted),+ if (showPin)+ HugeIcon(+ icon: HugeIcons.strokeRoundedPin,+ size: 12,+ color: colorScheme.textMuted,+ strokeWidth: 2.0,+ ),+ if (showArchive)+ Icon(+ Icons.archive_outlined,+ size: 12,+ color: colorScheme.textMuted,+ ),+ if (isFavoriteAlbum)+ Icon(+ EnteIcons.favoriteFilled,+ size: 12,+ color: colorScheme.greenBase,+ ),],+ ],+ );+ },+ ),+ trailing: Padding(+ padding: const EdgeInsets.only(right: 8),+ child: SizedBox(+ width: _trailingWidth,+ height: getAvatarSize(AvatarType.md),+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 300),+ switchInCurve: Curves.easeOut,+ switchOutCurve: Curves.easeIn,+ layoutBuilder: (currentChild, previousChildren) {+ return Stack(+ alignment: Alignment.centerRight,+ children: [+ ...previousChildren,+ if (currentChild != null) currentChild,+ ],+ );+ },+ child: _buildTrailingIndicator(+ context,+ isSelected: isSelected,+ isOwner: isOwner,),),- ],+ ),),);+ }- return GestureDetector(- onTap: () => onTapCallback?.call(collection),- onLongPress: () => onLongPressCallback?.call(collection),- behavior: HitTestBehavior.opaque,- child: ListenableBuilder(- listenable: selectedAlbums!,- builder: (context, _) {- final isSelected =- selectedAlbums?.isAlbumSelected(collection) ?? false;-- return 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(6)),- ),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- albumWidget,- 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,- )- : IconButtonWidget(- key: const ValueKey("unselected"),- icon: Icons.chevron_right_outlined,- iconButtonType: IconButtonType.secondary,- iconColor: colorScheme.blurStrokePressed,- ),- ),- ),- ],+ Widget _buildTrailingIndicator(+ BuildContext context, {+ required bool isSelected,+ required bool isOwner,+ }) {+ final double avatarSize = getAvatarSize(AvatarType.md);+ final double slotOverlap = getOverlapPadding(AvatarType.md);++ if (isSelected) {+ return const _CollectionSelectedBadge(+ key: ValueKey("selected"),+ );+ }+ if (!isOwner) {+ return UserAvatarWidget(+ key: const ValueKey("owner"),+ collection.owner,+ type: AvatarType.md,+ thumbnailView: true,+ );+ }+ if (collection.hasSharees) {+ final sharees = collection.getSharees();+ final int total = sharees.length;+ final int limit = total > 2 ? 1 : 2;+ final int displayCount = total.clamp(1, limit).toInt();+ final bool hasMore = total > limit;+ final double contentWidth =+ avatarSize + (displayCount - 1 + (hasMore ? 1 : 0)) * slotOverlap;+ return SizedBox(+ key: const ValueKey("sharees"),+ width: contentWidth,+ height: avatarSize,+ child: AlbumSharesIcons(+ sharees: sharees,+ type: AvatarType.md,+ limitCountTo: limit,+ padding: EdgeInsets.zero,+ ),+ );+ }+ return const SizedBox.shrink(key: ValueKey("unselected"));+ }+}++class _AlbumListItemCover extends StatelessWidget {+ final Collection collection;+ final bool showSharingIndicator;+ final bool isOutgoing;++ const _AlbumListItemCover({+ required this.collection,+ required this.showSharingIndicator,+ required this.isOutgoing,+ });++ @override+ Widget build(BuildContext context) {+ return Stack(+ clipBehavior: Clip.none,+ children: [+ ClipRRect(+ borderRadius: BorderRadius.circular(+ ThumbnailListItem.defaultLeadingRadius,+ ),+ child: SizedBox.expand(+ child: FutureBuilder<EnteFile?>(+ future: CollectionsService.instance.getCover(collection),+ builder: (context, snapshot) {+ if (snapshot.hasData) {+ return ThumbnailWidget(+ snapshot.data!,+ shouldShowFavoriteIcon: false,+ shouldShowOwnerAvatar: false,+ );+ }+ return const NoThumbnailWidget(+ borderRadius: ThumbnailListItem.defaultLeadingRadius,+ addBorder: false,+ );+ },),- );- },+ ),+ ),+ if (showSharingIndicator)+ Positioned(+ right: -4,+ bottom: -4,+ child: _CollectionShareBadge(isOutgoing: isOutgoing),+ ),+ ],+ );+ }+}++class _CollectionShareBadge extends StatelessWidget {+ final bool isOutgoing;++ const _CollectionShareBadge({+ required this.isOutgoing,+ });++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ return Container(+ width: 20,+ height: 20,+ decoration: BoxDecoration(+ color: colorScheme.backgroundElevated,+ shape: BoxShape.circle,+ border: Border.all(color: colorScheme.strokeFainter),+ ),+ child: Center(+ child: Icon(+ isOutgoing+ ? Icons.person_add_alt_1_outlined+ : Icons.person_outline_rounded,+ size: 12,+ color: colorScheme.textMuted,+ ),+ ),+ );+ }+}++class _CollectionSelectedBadge extends StatelessWidget {+ const _CollectionSelectedBadge({super.key});++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ return Container(+ width: getAvatarSize(AvatarType.md),+ height: getAvatarSize(AvatarType.md),+ decoration: BoxDecoration(+ color: colorScheme.greenBase,+ shape: BoxShape.circle,+ ),+ child: const Icon(+ Icons.check_rounded,+ size: 16,+ color: Colors.white,),);}diff --git a/mobile/apps/photos/lib/ui/collections/album/new_list_item.dart b/mobile/apps/photos/lib/ui/collections/album/new_list_item.dartindex c3c8abef45..8d381e96fa 100644--- a/mobile/apps/photos/lib/ui/collections/album/new_list_item.dart+++ b/mobile/apps/photos/lib/ui/collections/album/new_list_item.dart@@ -1,7 +1,7 @@-import 'package:dotted_border/dotted_border.dart';import 'package:flutter/material.dart';import "package:photos/generated/l10n.dart";import 'package:photos/theme/ente_theme.dart';+import "package:photos/ui/components/thumbnail_list_item.dart";//https://www.figma.com/design/SYtMyLBs5SAOkTbfMMzhqt/Ente-Visual-Design?node-id=39181-172209&t=3qmSZWpXF3ZC4JGN-1@@ -14,63 +14,26 @@ class NewAlbumListItemWidget extends StatelessWidget {Widget build(BuildContext context) {final textTheme = getEnteTextTheme(context);final colorScheme = getEnteColorScheme(context);- const sideOfThumbnail = 60.0;- return LayoutBuilder(- builder: (context, constraints) {- return Stack(- alignment: Alignment.center,- children: [- Row(- children: [- ClipRRect(- borderRadius: BorderRadius.circular(4),- child: Container(- height: sideOfThumbnail,- width: sideOfThumbnail,- color: Theme.of(context).brightness == Brightness.light- ? colorScheme.backdropBase- : colorScheme.backdropFaint,- child: Icon(- Icons.add_outlined,- color: colorScheme.strokeMuted,- ),- ),- ),- Padding(- padding: const EdgeInsets.only(left: 12),- child: Text(- AppLocalizations.of(context).newAlbum,- style:- textTheme.body.copyWith(color: colorScheme.textMuted),- ),- ),- ],- ),- IgnorePointer(- child: DottedBorder(- dashPattern: const [4],- color: colorScheme.strokeFaint,- strokeWidth: 1,- padding: const EdgeInsets.all(0),- borderType: BorderType.RRect,- radius: const Radius.circular(4),- child: SizedBox(- //Have to decrease the height and width by 1 pt as the stroke- //dotted border gives is of strokeAlign.center, so 0.5 inside and- // outside. Here for the row, stroke should be inside so we- //decrease the size of this sizedBox by 1 (so it shrinks 0.5 from- //every side) so that the strokeAlign.center of this sizedBox- //looks like a strokeAlign.inside in the row.- height: sideOfThumbnail - 1,- //This width will work for this only if the row widget takes up the- //full size it's parent (stack).- width: constraints.maxWidth - 1,- ),- ),- ),- ],- );- },+ return ThumbnailListItem(+ borderStyle: ThumbnailListItemBorderStyle.dotted,+ leading: ClipRRect(+ borderRadius: BorderRadius.circular(+ ThumbnailListItem.defaultLeadingRadius,+ ),+ child: Container(+ color: Theme.of(context).brightness == Brightness.light+ ? colorScheme.backdropBase+ : colorScheme.backdropFaint,+ child: Icon(+ Icons.add_outlined,+ color: colorScheme.strokeMuted,+ ),+ ),+ ),+ title: Text(+ AppLocalizations.of(context).newAlbum,+ style: textTheme.body.copyWith(color: colorScheme.textMuted),+ ),);}}diff --git a/mobile/apps/photos/lib/ui/components/thumbnail_list_item.dart b/mobile/apps/photos/lib/ui/components/thumbnail_list_item.dartnew file mode 100644index 0000000000..df8ef5c460--- /dev/null+++ b/mobile/apps/photos/lib/ui/components/thumbnail_list_item.dart@@ -0,0 +1,163 @@+import "package:dotted_border/dotted_border.dart";+import "package:flutter/material.dart";+import "package:photos/theme/colors.dart";+import "package:photos/theme/ente_theme.dart";++enum ThumbnailListItemBorderStyle {+ solid,+ dotted,+}++class ThumbnailListItem extends StatefulWidget {+ static const defaultPadding = EdgeInsets.all(8);+ static const defaultLeadingSize = 52.0;+ static const defaultLeadingRadius = 12.0;+ static const defaultBorderRadius = 20.0;+ static const defaultContentSpacing = 12.0;+ static const _stateTransitionDuration = Duration(milliseconds: 120);++ final Widget leading;+ final Widget title;+ final Widget? subtitle;+ final Widget? trailing;+ final VoidCallback? onTap;+ final VoidCallback? onLongPress;+ final bool isSelected;+ final ThumbnailListItemBorderStyle borderStyle;+ final EdgeInsetsGeometry padding;+ final double leadingSize;+ final double borderRadius;+ final double contentSpacing;+ final Color? backgroundColor;+ final Color? borderColor;+ final Color? selectedBorderColor;+ final Color? dottedBorderColor;++ const ThumbnailListItem({+ super.key,+ required this.leading,+ required this.title,+ this.subtitle,+ this.trailing,+ this.onTap,+ this.onLongPress,+ this.isSelected = false,+ this.borderStyle = ThumbnailListItemBorderStyle.solid,+ this.padding = defaultPadding,+ this.leadingSize = defaultLeadingSize,+ this.borderRadius = defaultBorderRadius,+ this.contentSpacing = defaultContentSpacing,+ this.backgroundColor,+ this.borderColor,+ this.selectedBorderColor,+ this.dottedBorderColor,+ });++ @override+ State<ThumbnailListItem> createState() => _ThumbnailListItemState();+}++class _ThumbnailListItemState extends State<ThumbnailListItem> {+ bool _isPressed = false;++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final child = _decorate(+ context,+ AnimatedContainer(+ duration: ThumbnailListItem._stateTransitionDuration,+ width: double.infinity,+ padding: widget.padding,+ decoration: BoxDecoration(+ color: _backgroundColor(colorScheme),+ borderRadius: BorderRadius.all(Radius.circular(widget.borderRadius)),+ border: Border.all(+ color: widget.borderStyle == ThumbnailListItemBorderStyle.solid+ ? widget.isSelected+ ? widget.selectedBorderColor ?? colorScheme.greenBase+ : widget.borderColor ?? _backgroundColor(colorScheme)+ : Colors.transparent,+ ),+ ),+ child: Row(+ children: [+ SizedBox.square(+ dimension: widget.leadingSize,+ child: widget.leading,+ ),+ SizedBox(width: widget.contentSpacing),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisAlignment: MainAxisAlignment.center,+ mainAxisSize: MainAxisSize.min,+ children: [+ widget.title,+ if (widget.subtitle != null) ...[+ const SizedBox(height: 4),+ widget.subtitle!,+ ],+ ],+ ),+ ),+ if (widget.trailing != null) ...[+ SizedBox(width: widget.contentSpacing),+ widget.trailing!,+ ],+ ],+ ),+ ),+ );++ if (widget.onTap == null && widget.onLongPress == null) {+ return child;+ }+ return Material(+ color: Colors.transparent,+ child: InkWell(+ onTap: widget.onTap,+ onLongPress: widget.onLongPress,+ onHighlightChanged: _setPressed,+ borderRadius: BorderRadius.circular(widget.borderRadius),+ highlightColor: Colors.transparent,+ hoverColor: Colors.transparent,+ splashColor: Colors.transparent,+ splashFactory: NoSplash.splashFactory,+ child: child,+ ),+ );+ }++ Widget _decorate(BuildContext context, Widget child) {+ if (widget.borderStyle != ThumbnailListItemBorderStyle.dotted) {+ return child;+ }+ final colorScheme = getEnteColorScheme(context);+ return DottedBorder(+ dashPattern: const [4, 4],+ color: widget.dottedBorderColor ?? colorScheme.strokeFaint,+ strokeWidth: 1,+ padding: EdgeInsets.zero,+ borderType: BorderType.RRect,+ radius: Radius.circular(widget.borderRadius),+ child: child,+ );+ }++ Color _backgroundColor(EnteColorScheme colorScheme) {+ if (_isPressed) {+ return colorScheme.fillDarker;+ }+ return widget.backgroundColor ?? colorScheme.fill;+ }++ void _setPressed(bool value) {+ if (_isPressed == value) {+ return;+ }+ setState(() {+ _isPressed = value;+ });+ }+}diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/search_result_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/result/search_result_widget.dartindex fa41cc551c..6d8033c980 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/search_result_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/search_result_widget.dart@@ -7,6 +7,7 @@ import "package:photos/models/search/recent_searches.dart";import 'package:photos/models/search/search_result.dart';import "package:photos/models/search/search_types.dart";import "package:photos/theme/ente_theme.dart";+import "package:photos/ui/components/thumbnail_list_item.dart";import "package:photos/ui/viewer/search/result/contact_result_page.dart";import 'package:photos/ui/viewer/search/result/search_result_page.dart';import 'package:photos/ui/viewer/search/result/search_thumbnail_widget.dart';@@ -15,7 +16,6 @@ class SearchResultWidget extends StatelessWidget {final SearchResult searchResult;final Future<int>? resultCount;final Function? onResultTap;- final BorderRadius borderRadius;final EdgeInsetsGeometry padding;final bool showTypeLabel;@@ -24,8 +24,7 @@ class SearchResultWidget extends StatelessWidget {super.key,this.resultCount,this.onResultTap,- this.borderRadius = BorderRadius.zero,- this.padding = const EdgeInsets.symmetric(horizontal: 10, vertical: 10),+ this.padding = ThumbnailListItem.defaultPadding,this.showTypeLabel = true,});@@ -37,99 +36,83 @@ class SearchResultWidget extends StatelessWidget {return SizedBox(key: ValueKey(searchResult.hashCode),- child: Material(- color: Colors.transparent,- child: InkWell(- borderRadius: borderRadius,- onTap: () {- RecentSearches().add(searchResult.name());+ child: ThumbnailListItem(+ padding: padding,+ onTap: () {+ RecentSearches().add(searchResult.name());- if (onResultTap != null) {- onResultTap!();+ if (onResultTap != null) {+ onResultTap!();+ } else {+ if (searchResult.type() == ResultType.shared) {+ routeToPage(+ context,+ ContactResultPage(+ searchResult,+ ),+ );} else {- if (searchResult.type() == ResultType.shared) {- routeToPage(- context,- ContactResultPage(- searchResult,- ),- );- } else {- routeToPage(- context,- SearchResultPage(- searchResult,- ),- );- }+ routeToPage(+ context,+ SearchResultPage(+ searchResult,+ ),+ );+ }+ }+ },+ leading: searchResult.type() == ResultType.shared+ ? ContactSearchThumbnailWidget(+ heroTagPrefix,+ searchResult: searchResult as GenericSearchResult,+ size: ThumbnailListItem.defaultLeadingSize,+ borderRadius: ThumbnailListItem.defaultLeadingRadius,+ )+ : SearchThumbnailWidget(+ searchResult.previewThumbnail(),+ heroTagPrefix,+ searchResult: searchResult,+ size: ThumbnailListItem.defaultLeadingSize,+ borderRadius: ThumbnailListItem.defaultLeadingRadius,+ ),+ title: Text(+ searchResult.name(),+ style: textTheme.bodyBold,+ overflow: TextOverflow.ellipsis,+ ),+ subtitle: FutureBuilder<int>(+ future:+ resultCount ?? Future.value(searchResult.resultFiles().length),+ builder: (context, snapshot) {+ final label = showTypeLabel+ ? _resultTypeLabel(context, searchResult.type())+ : null;+ if (snapshot.hasData && (snapshot.data ?? 0) > 0) {+ final count = snapshot.data!;+ final countText = count > 9999+ ? NumberFormat().format(count)+ : count.toString();+ return Text(+ label != null ? "$label \u2022 $countText" : countText,+ style: textTheme.smallMuted,+ overflow: TextOverflow.ellipsis,+ );}+ if (label != null) {+ return Text(+ label,+ style: textTheme.smallMuted,+ overflow: TextOverflow.ellipsis,+ );+ }+ return const SizedBox.shrink();},- child: Padding(- padding: padding,- child: Row(- crossAxisAlignment: CrossAxisAlignment.center,- children: [- searchResult.type() == ResultType.shared- ? ContactSearchThumbnailWidget(- heroTagPrefix,- searchResult: searchResult as GenericSearchResult,- )- : SearchThumbnailWidget(- searchResult.previewThumbnail(),- heroTagPrefix,- searchResult: searchResult,- ),- const SizedBox(width: 12),- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- searchResult.name(),- style: textTheme.bodyBold,- overflow: TextOverflow.ellipsis,- ),- const SizedBox(height: 4),- FutureBuilder<int>(- future: resultCount ??- Future.value(searchResult.resultFiles().length),- builder: (context, snapshot) {- final label = showTypeLabel- ? _resultTypeLabel(context, searchResult.type())- : null;- if (snapshot.hasData && (snapshot.data ?? 0) > 0) {- final count = snapshot.data!;- final countText = count > 9999- ? NumberFormat().format(count)- : count.toString();- return Text(- label != null- ? "$label \u2022 $countText"- : countText,- style: textTheme.smallMuted,- overflow: TextOverflow.ellipsis,- );- }- if (label != null) {- return Text(- label,- style: textTheme.smallMuted,- overflow: TextOverflow.ellipsis,- );- }- return const SizedBox.shrink();- },- ),- ],- ),- ),- const SizedBox(width: 12),- Icon(- Icons.chevron_right,- color: colorScheme.strokeMuted,- ),- ],- ),+ ),+ trailing: Padding(+ padding: const EdgeInsets.only(right: 8),+ child: Icon(+ Icons.chevron_right,+ color: colorScheme.strokeMuted,),),),diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/search_thumbnail_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/result/search_thumbnail_widget.dartindex 2a0cc624eb..c94b0570a9 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/search_thumbnail_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/search_thumbnail_widget.dart@@ -16,11 +16,15 @@ class SearchThumbnailWidget extends StatelessWidget {final EnteFile? file;final SearchResult? searchResult;final String tagPrefix;+ final double size;+ final double borderRadius;const SearchThumbnailWidget(this.file,this.tagPrefix, {this.searchResult,+ this.size = 56,+ this.borderRadius = 12,super.key,});@@ -29,22 +33,22 @@ class SearchThumbnailWidget extends StatelessWidget {return Hero(tag: tagPrefix + (file?.tag ?? ""),child: SizedBox(- height: 56,- width: 56,+ height: size,+ width: size,child: ClipRRect(- borderRadius: BorderRadius.circular(12),+ borderRadius: BorderRadius.circular(borderRadius),child: file != null? (searchResult != null &&- searchResult!.type() == ResultType.faces)- ? PersonFaceWidget(- personId: (searchResult as GenericSearchResult)- .params[kPersonParamID],- clusterID: (searchResult as GenericSearchResult)- .params[kClusterParamId],- )- : ThumbnailWidget(- file!,- )+ searchResult!.type() == ResultType.faces)+ ? PersonFaceWidget(+ personId: (searchResult as GenericSearchResult)+ .params[kPersonParamID],+ clusterID: (searchResult as GenericSearchResult)+ .params[kClusterParamId],+ )+ : ThumbnailWidget(+ file!,+ ): const NoThumbnailWidget(addBorder: false,),@@ -57,9 +61,14 @@ class SearchThumbnailWidget extends StatelessWidget {class ContactSearchThumbnailWidget extends StatefulWidget {final GenericSearchResult searchResult;final String tagPrefix;+ final double size;+ final double borderRadius;+const ContactSearchThumbnailWidget(this.tagPrefix, {required this.searchResult,+ this.size = 56,+ this.borderRadius = 12,super.key,});@@ -100,10 +109,10 @@ class _ContactSearchThumbnailWidgetState@overrideWidget build(BuildContext context) {return SizedBox(- height: 56,- width: 56,+ height: widget.size,+ width: widget.size,child: ClipRRect(- borderRadius: BorderRadius.circular(12),+ borderRadius: BorderRadius.circular(widget.borderRadius),child: _canUsePersonFaceWidget? PersonFaceWidget(personId: _personID,diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/searchable_item.dart b/mobile/apps/photos/lib/ui/viewer/search/result/searchable_item.dartindex 32d384a829..8cceb27643 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/searchable_item.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/searchable_item.dart@@ -1,13 +1,14 @@-import "package:dotted_border/dotted_border.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";+import "package:intl/intl.dart";+import "package:photos/generated/l10n.dart";import "package:photos/models/search/generic_search_result.dart";import "package:photos/models/search/recent_searches.dart";import "package:photos/models/search/search_constants.dart";import "package:photos/models/search/search_result.dart";import "package:photos/models/search/search_types.dart";import "package:photos/theme/ente_theme.dart";-import "package:photos/ui/components/buttons/icon_button_widget.dart";+import "package:photos/ui/components/thumbnail_list_item.dart";import "package:photos/ui/viewer/search/result/contact_result_page.dart";import "package:photos/ui/viewer/search/result/search_result_page.dart";import "package:photos/ui/viewer/search/result/search_thumbnail_widget.dart";@@ -34,11 +35,12 @@ class SearchableItemWidget extends StatelessWidget {final textTheme = getEnteTextTheme(context);final colorScheme = getEnteColorScheme(context);final result = searchResult;- final bool isCluster = result.type() == ResultType.faces &&+ final bool isCluster =+ result.type() == ResultType.faces &&result is GenericSearchResult &&result.params.containsKey(kClusterParamId);- return GestureDetector(+ return ThumbnailListItem(onTap: () {RecentSearches().add(searchResult.name());if (onResultTap != null) {@@ -63,88 +65,52 @@ class SearchableItemWidget extends StatelessWidget {}}},- child: Container(- decoration: BoxDecoration(- border: Border.all(color: colorScheme.strokeFainter),- borderRadius: const BorderRadius.all(- Radius.circular(6),- ),- ),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Flexible(- flex: 6,- child: Row(- children: [- SizedBox(- width: 60,- height: 60,- child: searchResult.type() == ResultType.shared- ? ContactSearchThumbnailWidget(- heroTagPrefix,- searchResult: searchResult as GenericSearchResult,- )- : SearchThumbnailWidget(- searchResult.previewThumbnail(),- heroTagPrefix,- searchResult: searchResult,- ),- ),- const SizedBox(width: 12),- Flexible(- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 4),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- isCluster- ? const SizedBox.shrink()- : Text(- searchResult.name(),- style: searchResult.type() ==- ResultType.locationSuggestion- ? textTheme.bodyFaint- : textTheme.body,- overflow: TextOverflow.ellipsis,- ),- const SizedBox(- height: 2,- ),- FutureBuilder<int>(- future: resultCount ??- Future.value(searchResult.resultFiles().length),- builder: (context, snapshot) {- if (snapshot.hasData && snapshot.data! > 0) {- final noOfMemories = snapshot.data;- final String suffix =- noOfMemories! > 1 ? " memories" : " memory";-- return Text(- noOfMemories.toString() + suffix,- style: textTheme.smallMuted,- );- } else {- return const SizedBox.shrink();- }- },- ),- ],- ),- ),- ),- ],- ),+ leading: searchResult.type() == ResultType.shared+ ? ContactSearchThumbnailWidget(+ heroTagPrefix,+ searchResult: searchResult as GenericSearchResult,+ size: ThumbnailListItem.defaultLeadingSize,+ borderRadius: ThumbnailListItem.defaultLeadingRadius,+ )+ : SearchThumbnailWidget(+ searchResult.previewThumbnail(),+ heroTagPrefix,+ searchResult: searchResult,+ size: ThumbnailListItem.defaultLeadingSize,+ borderRadius: ThumbnailListItem.defaultLeadingRadius,),- Flexible(- flex: 1,- child: IconButtonWidget(- icon: Icons.chevron_right_outlined,- iconButtonType: IconButtonType.secondary,- iconColor: colorScheme.blurStrokePressed,- ),+ title: isCluster+ ? const SizedBox.shrink()+ : Text(+ searchResult.name(),+ style: searchResult.type() == ResultType.locationSuggestion+ ? textTheme.bodyFaint+ : textTheme.body,+ overflow: TextOverflow.ellipsis,),- ],+ subtitle: FutureBuilder<int>(+ future: resultCount ?? Future.value(searchResult.resultFiles().length),+ builder: (context, snapshot) {+ if (snapshot.hasData && snapshot.data! > 0) {+ final noOfMemories = snapshot.data!;+ return Text(+ AppLocalizations.of(context).memoryCount(+ count: noOfMemories,+ formattedCount: NumberFormat().format(noOfMemories),+ ),+ style: textTheme.smallMuted,+ overflow: TextOverflow.ellipsis,+ );+ } else {+ return const SizedBox.shrink();+ }+ },+ ),+ trailing: Padding(+ padding: const EdgeInsets.only(right: 8),+ child: Icon(+ Icons.chevron_right_outlined,+ color: colorScheme.blurStrokePressed,),),);@@ -163,41 +129,26 @@ class SearchableItemPlaceholder extends StatelessWidget {final colorScheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);- return Padding(- padding: const EdgeInsets.only(right: 1),- child: GestureDetector(- onTap: sectionType.ctaOnTap(context),- child: DottedBorder(- strokeWidth: 2,- borderType: BorderType.RRect,- radius: const Radius.circular(4),- padding: EdgeInsets.zero,- dashPattern: const [4, 4],- color: colorScheme.strokeFainter,- child: Row(- children: [- Container(- width: 60,- height: 60,- decoration: BoxDecoration(- borderRadius:- const BorderRadius.horizontal(left: Radius.circular(4)),- color: colorScheme.fillFaint,- ),- child: Icon(- sectionType.getCTAIcon(),- color: colorScheme.strokeMuted,- ),- ),- const SizedBox(width: 12),- Text(- sectionType.getCTAText(context),- style: textTheme.body,- ),- ],+ return ThumbnailListItem(+ borderStyle: ThumbnailListItemBorderStyle.dotted,+ dottedBorderColor: colorScheme.strokeFainter,+ onTap: sectionType.ctaOnTap(context),+ leading: ClipRRect(+ borderRadius: BorderRadius.circular(+ ThumbnailListItem.defaultLeadingRadius,+ ),+ child: Container(+ color: colorScheme.fillFaint,+ child: Icon(+ sectionType.getCTAIcon(),+ color: colorScheme.strokeMuted,),),),+ title: Text(+ sectionType.getCTAText(context),+ style: textTheme.body,+ ),);}}diff --git a/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart b/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dartindex 2a15bab51b..2a9e41b560 100644--- a/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/search_suggestions.dart@@ -70,12 +70,13 @@ class _SearchSuggestionsWidgetState extends State<SearchSuggestionsWidget> {},onDone: () {Future.delayed(- const Duration(milliseconds: _surfaceNewResultsInterval + 20),- () {- if (_resultsCount == 0) {- IndexOfStackNotifier().searchState = SearchState.empty;- }- });+ const Duration(milliseconds: _surfaceNewResultsInterval + 20),+ () {+ if (_resultsCount == 0) {+ IndexOfStackNotifier().searchState = SearchState.empty;+ }+ },+ );SearchWidgetState.isLoading.value = false;},);@@ -99,15 +100,17 @@ class _SearchSuggestionsWidgetState extends State<SearchSuggestionsWidget> {///updates the UI.void generateResultWidgetsInIntervalsFromQueue() {timer = Timer.periodic(- const Duration(milliseconds: _surfaceNewResultsInterval), (timer) {- if (queueOfSearchResults.isNotEmpty) {- for (List<SearchResult> event in queueOfSearchResults) {- _addResultsToSections(event);+ const Duration(milliseconds: _surfaceNewResultsInterval),+ (timer) {+ if (queueOfSearchResults.isNotEmpty) {+ for (List<SearchResult> event in queueOfSearchResults) {+ _addResultsToSections(event);+ }+ queueOfSearchResults.clear();+ setState(() {});}- queueOfSearchResults.clear();- setState(() {});- }- });+ },+ );}@override@@ -203,11 +206,9 @@ class _SearchSuggestionsWidgetState extends State<SearchSuggestionsWidget> {class SearchResultsWidgetGenerator extends StatelessWidget {final SearchResult result;- final BorderRadius borderRadius;final bool showTypeLabel;const SearchResultsWidgetGenerator(this.result, {- this.borderRadius = BorderRadius.zero,this.showTypeLabel = true,super.key,});@@ -221,7 +222,6 @@ class SearchResultsWidgetGenerator extends StatelessWidget {resultCount: CollectionsService.instance.getFileCount(albumSearchResult.collectionWithThumbnail.collection,),- borderRadius: borderRadius,showTypeLabel: showTypeLabel,onResultTap: () => routeToPage(context,@@ -236,7 +236,6 @@ class SearchResultsWidgetGenerator extends StatelessWidget {return SearchResultWidget(result,resultCount: Future.value(deviceResult.deviceCollection.count),- borderRadius: borderRadius,showTypeLabel: showTypeLabel,onResultTap: () => routeToPage(context,@@ -246,7 +245,6 @@ class SearchResultsWidgetGenerator extends StatelessWidget {} else if (result is GenericSearchResult) {return SearchResultWidget(result,- borderRadius: borderRadius,showTypeLabel: showTypeLabel,onResultTap: (result as GenericSearchResult).onResultTap != null? () => (result as GenericSearchResult).onResultTap!(context)@@ -370,11 +368,11 @@ class _SearchResultsSectionWidget extends StatelessWidget {color: colorScheme.backgroundElevated,borderRadius: radius,clipBehavior: Clip.antiAlias,- child: SearchResultsWidgetGenerator(- results[i],- borderRadius: radius,- showTypeLabel: showTypeLabel,- ).animate().fadeIn(+ child:+ SearchResultsWidgetGenerator(+ results[i],+ showTypeLabel: showTypeLabel,+ ).animate().fadeIn(duration: const Duration(milliseconds: 80),curve: Curves.easeIn,),