Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Implement Photos search tab redesign

ashilkn827aa18cd7da
diff --git a/mobile/apps/photos/assets/2.0x/map_world.png b/mobile/apps/photos/assets/2.0x/map_world.png
deleted file mode 100644
index c8ebc02c64..0000000000
Binary files a/mobile/apps/photos/assets/2.0x/map_world.png and /dev/null differ
diff --git a/mobile/apps/photos/assets/2.0x/search_map_tile_dark.png b/mobile/apps/photos/assets/2.0x/search_map_tile_dark.png
new file mode 100644
index 0000000000..2d329d5951
Binary files /dev/null and b/mobile/apps/photos/assets/2.0x/search_map_tile_dark.png differ
diff --git a/mobile/apps/photos/assets/2.0x/search_map_tile_light.png b/mobile/apps/photos/assets/2.0x/search_map_tile_light.png
new file mode 100644
index 0000000000..a4be474c34
Binary files /dev/null and b/mobile/apps/photos/assets/2.0x/search_map_tile_light.png differ
diff --git a/mobile/apps/photos/assets/3.0x/map_world.png b/mobile/apps/photos/assets/3.0x/map_world.png
deleted file mode 100644
index 077211f6ab..0000000000
Binary files a/mobile/apps/photos/assets/3.0x/map_world.png and /dev/null differ
diff --git a/mobile/apps/photos/assets/3.0x/search_map_tile_dark.png b/mobile/apps/photos/assets/3.0x/search_map_tile_dark.png
new file mode 100644
index 0000000000..b87ff3e8d0
Binary files /dev/null and b/mobile/apps/photos/assets/3.0x/search_map_tile_dark.png differ
diff --git a/mobile/apps/photos/assets/3.0x/search_map_tile_light.png b/mobile/apps/photos/assets/3.0x/search_map_tile_light.png
new file mode 100644
index 0000000000..937c2753fe
Binary files /dev/null and b/mobile/apps/photos/assets/3.0x/search_map_tile_light.png differ
diff --git a/mobile/apps/photos/assets/map_world.png b/mobile/apps/photos/assets/map_world.png
deleted file mode 100644
index 1e8df27771..0000000000
Binary files a/mobile/apps/photos/assets/map_world.png and /dev/null differ
diff --git a/mobile/apps/photos/assets/search_map_tile_dark.png b/mobile/apps/photos/assets/search_map_tile_dark.png
new file mode 100644
index 0000000000..77f247c641
Binary files /dev/null and b/mobile/apps/photos/assets/search_map_tile_dark.png differ
diff --git a/mobile/apps/photos/assets/search_map_tile_light.png b/mobile/apps/photos/assets/search_map_tile_light.png
new file mode 100644
index 0000000000..e5256fbcab
Binary files /dev/null and b/mobile/apps/photos/assets/search_map_tile_light.png differ
diff --git a/mobile/apps/photos/changes/search-tab-design-refresh.md b/mobile/apps/photos/changes/search-tab-design-refresh.md
new file mode 100644
index 0000000000..ee254648c3
--- /dev/null
+++ b/mobile/apps/photos/changes/search-tab-design-refresh.md
@@ -0,0 +1 @@
+- Refreshed the search tab layout to match the updated visual design.
diff --git a/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart b/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart
index 61c78e6432..bfe337fcf7 100644
--- a/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart
+++ b/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart
@@ -22,8 +22,8 @@ class RitualsBanner extends StatelessWidget {
const RitualsBanner({super.key});
static const _cardRadius = 25.0;
- static const _cardHeight = 100.0;
- static const _cardWidth = 180.0;
+ static const _cardHeight = 94.0;
+ static const _cardWidth = 167.5;
@override
Widget build(BuildContext context) {
@@ -48,7 +48,7 @@ class RitualsBanner extends StatelessWidget {
const SizedBox(height: 2),
if (rituals.isEmpty)
Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
+ padding: EdgeInsets.zero,
child: StartNewRitualCard(
variant: StartNewRitualCardVariant.wide,
onTap: () async {
@@ -60,7 +60,7 @@ class RitualsBanner extends StatelessWidget {
SizedBox(
height: _cardHeight,
child: SingleChildScrollView(
- padding: const EdgeInsets.symmetric(horizontal: 12),
+ padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
child: Row(
@@ -139,33 +139,31 @@ class _RitualsHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Padding(
- padding: const EdgeInsets.all(12),
- child: Text(
+ child: SizedBox(
+ height: 38,
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
context.l10n.ritualsTitle,
- style: TextStyles.h2.copyWith(color: textTheme.largeBold.color),
+ style: TextStyles.display3.copyWith(color: colorScheme.textBase),
),
- ),
- if (showChevron)
- Container(
- color: Colors.transparent,
- child: Padding(
- padding: const EdgeInsets.fromLTRB(24, 12, 12, 12),
+ if (showChevron)
+ Container(
+ color: Colors.transparent,
+ width: 38,
+ height: 38,
child: Icon(
Icons.chevron_right_outlined,
color: colorScheme.blurStrokePressed,
),
),
- ),
- ],
+ ],
+ ),
),
);
}
diff --git a/mobile/apps/photos/lib/ui/rituals/start_new_ritual_card.dart b/mobile/apps/photos/lib/ui/rituals/start_new_ritual_card.dart
index 51df940dd0..ac0c2e5468 100644
--- a/mobile/apps/photos/lib/ui/rituals/start_new_ritual_card.dart
+++ b/mobile/apps/photos/lib/ui/rituals/start_new_ritual_card.dart
@@ -6,6 +6,7 @@ import "package:ente_icons/ente_icons.dart";
import "package:flutter/material.dart";
import "package:flutter_svg/flutter_svg.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/utils/pending_translation.dart";
enum StartNewRitualCardVariant { compact, wide }
@@ -21,7 +22,8 @@ class StartNewRitualCard extends StatelessWidget {
static const _cardRadius = 25.0;
static const _cardHeight = 100.0;
- static const _compactWidth = 220.0;
+ static const _compactHeight = 94.0;
+ static const _compactWidth = 167.5;
static const _wideDuckyHeightReduction = 12.0;
static const _wideDuckyAspectRatio = 149 / 81;
static const _wideDuckyRightOverflow = 4.0;
@@ -29,20 +31,19 @@ class StartNewRitualCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
+
+ if (variant == StartNewRitualCardVariant.compact) {
+ return _CompactStartNewRitualCard(onTap: onTap);
+ }
+
final componentColors = context.componentColors;
const fillColor = Colors.transparent;
final dottedBorderColor = componentColors.textLightest;
- final contentRightPadding = variant == StartNewRitualCardVariant.compact
- ? 14.0
- : 0.0;
const duckyHeight = _cardHeight - _wideDuckyHeightReduction;
const duckyNaturalWidth = duckyHeight * _wideDuckyAspectRatio;
const duckyChildWidth = duckyNaturalWidth + _wideDuckyRightOverflow;
return SizedBox(
- width: variant == StartNewRitualCardVariant.compact
- ? _compactWidth
- : null,
height: _cardHeight,
child: DottedBorder(
borderType: BorderType.RRect,
@@ -60,97 +61,80 @@ class StartNewRitualCard extends StatelessWidget {
child: LayoutBuilder(
builder: (context, constraints) {
var duckyWidth = 0.0;
- if (variant == StartNewRitualCardVariant.wide) {
- final textScaler = MediaQuery.textScalerOf(context);
- final textDirection = Directionality.of(context);
- const leftPadding = 14.0;
- const iconWidth = 24.0;
- const iconSpacing = 10.0;
-
- bool fits(double candidateDuckyWidth) {
- final leftWidth = math.max(
- 0.0,
- constraints.maxWidth - candidateDuckyWidth,
- );
- final titleMaxWidth =
- leftWidth -
- leftPadding -
- contentRightPadding -
- iconWidth -
- iconSpacing;
- const titleWidthEpsilon = 8.0;
- final adjustedTitleMaxWidth =
- titleMaxWidth - titleWidthEpsilon;
- final subtitleMaxWidth =
- leftWidth - leftPadding - contentRightPadding;
- if (adjustedTitleMaxWidth <= 0 || subtitleMaxWidth <= 0) {
- return false;
- }
+ final textScaler = MediaQuery.textScalerOf(context);
+ final textDirection = Directionality.of(context);
+ const leftPadding = 14.0;
+ const iconWidth = 24.0;
+ const iconSpacing = 10.0;
- final titlePainter = TextPainter(
- text: TextSpan(
- text: "Start new ritual",
- style: textTheme.body,
- ),
- maxLines: 1,
- ellipsis: "…",
- textDirection: textDirection,
- textScaler: textScaler,
- textHeightBehavior: _tightTextHeightBehavior,
- )..layout(maxWidth: adjustedTitleMaxWidth);
- if (titlePainter.didExceedMaxLines) return false;
-
- final subtitlePainter = TextPainter(
- text: TextSpan(
- text:
- "Create a ritual, build streaks, and share your progress.",
- style: textTheme.miniMuted,
- ),
- maxLines: 3,
- ellipsis: "…",
- textDirection: textDirection,
- textScaler: textScaler,
- )..layout(maxWidth: subtitleMaxWidth);
- return !subtitlePainter.didExceedMaxLines;
+ bool fits(double candidateDuckyWidth) {
+ final leftWidth = math.max(
+ 0.0,
+ constraints.maxWidth - candidateDuckyWidth,
+ );
+ final titleMaxWidth =
+ leftWidth - leftPadding - iconWidth - iconSpacing;
+ const titleWidthEpsilon = 8.0;
+ final adjustedTitleMaxWidth =
+ titleMaxWidth - titleWidthEpsilon;
+ final subtitleMaxWidth = leftWidth - leftPadding;
+ if (adjustedTitleMaxWidth <= 0 || subtitleMaxWidth <= 0) {
+ return false;
}
- final upperBound = math.min(
- duckyChildWidth,
- constraints.maxWidth,
- );
- if (fits(upperBound)) {
- duckyWidth = upperBound;
- } else if (fits(0.0)) {
- var low = 0.0;
- var high = upperBound;
- for (var i = 0; i < 10; i++) {
- final mid = (low + high) / 2;
- if (fits(mid)) {
- low = mid;
- } else {
- high = mid;
- }
+ final titlePainter = TextPainter(
+ text: TextSpan(
+ text: pendingTranslation("Start new ritual"),
+ style: textTheme.body,
+ ),
+ maxLines: 1,
+ ellipsis: "…",
+ textDirection: textDirection,
+ textScaler: textScaler,
+ textHeightBehavior: _tightTextHeightBehavior,
+ )..layout(maxWidth: adjustedTitleMaxWidth);
+ if (titlePainter.didExceedMaxLines) return false;
+
+ final subtitlePainter = TextPainter(
+ text: TextSpan(
+ text: pendingTranslation(
+ "Create a ritual, build streaks, and share your progress.",
+ ),
+ style: textTheme.miniMuted,
+ ),
+ maxLines: 3,
+ ellipsis: "…",
+ textDirection: textDirection,
+ textScaler: textScaler,
+ )..layout(maxWidth: subtitleMaxWidth);
+ return !subtitlePainter.didExceedMaxLines;
+ }
+
+ final upperBound = math.min(
+ duckyChildWidth,
+ constraints.maxWidth,
+ );
+ if (fits(upperBound)) {
+ duckyWidth = upperBound;
+ } else if (fits(0.0)) {
+ var low = 0.0;
+ var high = upperBound;
+ for (var i = 0; i < 10; i++) {
+ final mid = (low + high) / 2;
+ if (fits(mid)) {
+ low = mid;
+ } else {
+ high = mid;
}
- duckyWidth = low;
- } else {
- duckyWidth = 0.0;
}
+ duckyWidth = low;
}
- final showDucky =
- variant == StartNewRitualCardVariant.wide &&
- duckyWidth > 0;
-
return Row(
children: [
Expanded(
child: Padding(
- padding: EdgeInsets.fromLTRB(
- 14,
- 11,
- contentRightPadding,
- 11,
- ),
+ padding: const EdgeInsets.fromLTRB(14, 11, 0, 11),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -176,7 +160,7 @@ class StartNewRitualCard extends StatelessWidget {
const SizedBox(width: 10),
Expanded(
child: Text(
- "Start new ritual",
+ pendingTranslation("Start new ritual"),
style: textTheme.body,
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -188,7 +172,9 @@ class StartNewRitualCard extends StatelessWidget {
),
const SizedBox(height: 3),
Text(
- "Create a ritual, build streaks, and share your progress.",
+ pendingTranslation(
+ "Create a ritual, build streaks, and share your progress.",
+ ),
style: textTheme.miniMuted,
maxLines: 3,
overflow: TextOverflow.ellipsis,
@@ -197,7 +183,7 @@ class StartNewRitualCard extends StatelessWidget {
),
),
),
- if (showDucky)
+ if (duckyWidth > 0)
SizedBox(
width: duckyWidth,
height: double.infinity,
@@ -246,6 +232,86 @@ class StartNewRitualCard extends StatelessWidget {
}
}
+class _CompactStartNewRitualCard extends StatelessWidget {
+ const _CompactStartNewRitualCard({required this.onTap});
+
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final borderRadius = BorderRadius.circular(StartNewRitualCard._cardRadius);
+ return SizedBox(
+ width: StartNewRitualCard._compactWidth,
+ height: StartNewRitualCard._compactHeight,
+ child: Material(
+ color: colorScheme.fill,
+ borderRadius: borderRadius,
+ child: InkWell(
+ borderRadius: borderRadius,
+ onTap: onTap,
+ child: Stack(
+ children: [
+ const Positioned(
+ left: 22,
+ top: 19,
+ child: Icon(
+ Icons.auto_awesome,
+ size: 13,
+ color: Color(0xFFFFBC03),
+ ),
+ ),
+ const Positioned(
+ right: 28,
+ top: 19,
+ child: Icon(
+ Icons.auto_awesome,
+ size: 10,
+ color: Color(0xFFFFD25A),
+ ),
+ ),
+ Center(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Container(
+ width: 24,
+ height: 24,
+ decoration: BoxDecoration(
+ color: colorScheme.greenBase,
+ shape: BoxShape.circle,
+ ),
+ child: const Icon(
+ Icons.add,
+ size: 17,
+ color: Colors.white,
+ ),
+ ),
+ const SizedBox(height: 4),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ child: Text(
+ pendingTranslation("Start new ritual"),
+ style: textTheme.bodyBold.copyWith(
+ color: colorScheme.textBase,
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.center,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
const _tightTextHeightBehavior = TextHeightBehavior(
applyHeightToFirstAscent: false,
applyHeightToLastDescent: false,
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/go_to_map_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/result/go_to_map_widget.dart
index d4d5be3419..93f37fd0b3 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/go_to_map_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/go_to_map_widget.dart
@@ -12,6 +12,9 @@ class GoToMap extends StatelessWidget {
@override
Widget build(BuildContext context) {
+ final mapTileAsset = EnteTheme.isDark(context)
+ ? "assets/search_map_tile_dark.png"
+ : "assets/search_map_tile_light.png";
return GestureDetector(
onTap: () async {
if (!mapEnabled) {
@@ -40,11 +43,15 @@ class GoToMap extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
- Transform.scale(
- scale: 1.2,
- child: Image.asset("assets/map_world.png", width: 64, height: 64),
+ ClipOval(
+ child: Image.asset(
+ mapTileAsset,
+ width: 66.5,
+ height: 66.5,
+ fit: BoxFit.cover,
+ ),
),
- const SizedBox(height: 11.5),
+ const SizedBox(height: 10),
Text(
AppLocalizations.of(context).yourMap,
maxLines: 2,
diff --git a/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart
index 802192acf1..c9cf208de5 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart
@@ -8,12 +8,12 @@ import "package:logging/logging.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/clear_and_unfocus_search_bar_event.dart";
import "package:photos/events/tab_changed_event.dart";
-import "package:photos/generated/l10n.dart";
import "package:photos/models/search/generic_search_result.dart";
import "package:photos/models/search/index_of_indexed_stack.dart";
import "package:photos/models/search/search_result.dart";
import "package:photos/services/search_service.dart";
import "package:photos/ui/viewer/search/search_suffix_icon_widget.dart";
+import "package:photos/utils/pending_translation.dart";
class SearchWidget extends StatefulWidget {
const SearchWidget({super.key, this.shouldConsumeBackNotifier});
@@ -147,27 +147,24 @@ class SearchWidgetState extends State<SearchWidget> {
MediaQuery.viewInsetsOf(context).bottom > 0 ||
textController.text.trim().isNotEmpty;
return RepaintBoundary(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
- child: TextInputComponent(
- controller: textController,
- focusNode: focusNode,
- hintText: AppLocalizations.of(context).search,
- shouldUnfocusOnClearOrSubmit: true,
- prefix: HugeIcon(
- icon: HugeIcons.strokeRoundedSearch01,
- size: 18,
- color: componentColors.textLight,
- ),
- suffix: ValueListenableBuilder(
- valueListenable: isLoading,
- builder: (BuildContext context, bool isSearching, Widget? child) {
- return SearchSuffixIcon(
- isSearching,
- showClearButton: shouldShowClearButton,
- );
- },
- ),
+ child: TextInputComponent(
+ controller: textController,
+ focusNode: focusNode,
+ hintText: pendingTranslation("Search photos, people, places..."),
+ shouldUnfocusOnClearOrSubmit: true,
+ prefix: HugeIcon(
+ icon: HugeIcons.strokeRoundedSearch01,
+ size: 18,
+ color: componentColors.textLight,
+ ),
+ suffix: ValueListenableBuilder(
+ valueListenable: isLoading,
+ builder: (BuildContext context, bool isSearching, Widget? child) {
+ return SearchSuffixIcon(
+ isSearching,
+ showClearButton: shouldShowClearButton,
+ );
+ },
),
),
);
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart
index 71c6323b32..145d7623ab 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart
@@ -1,9 +1,9 @@
import "dart:async";
-import "package:dotted_border/dotted_border.dart";
import "package:ente_components/ente_components.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:photos/core/constants.dart";
import "package:photos/events/event.dart";
import "package:photos/generated/l10n.dart";
@@ -56,12 +56,12 @@ class ContactsLoadingSection extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const Padding(
- padding: EdgeInsets.only(top: 8, bottom: 24),
+ padding: EdgeInsets.only(bottom: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SectionHeader(SectionType.contacts, hasMore: false),
- SizedBox(height: 80, child: EnteLoadingWidget()),
+ SizedBox(height: 92, child: EnteLoadingWidget()),
],
),
);
@@ -152,17 +152,8 @@ class _ContactsSectionState extends State<ContactsSection> {
),
);
} else {
- final recommendations = <Widget>[
- ..._contactSearchResults.map(
- (contactSearchResult) => ContactRecommendation(
- contactSearchResult,
- key: ValueKey(contactSearchResult.name()),
- ),
- ),
- const ContactCTA(),
- ];
return Padding(
- padding: const EdgeInsets.only(top: 8, bottom: 24),
+ padding: const EdgeInsets.only(bottom: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -171,16 +162,25 @@ class _ContactsSectionState extends State<ContactsSection> {
hasMore:
(_contactSearchResults.length >= kSearchSectionLimit - 1),
),
- const SizedBox(height: 2),
+ const SizedBox(height: 4),
SizedBox(
- child: SingleChildScrollView(
- padding: const EdgeInsets.symmetric(horizontal: 4.5),
+ height: 92,
+ child: ListView.separated(
+ padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: recommendations,
- ),
+ itemCount: _contactSearchResults.length + 1,
+ itemBuilder: (context, index) {
+ if (index == _contactSearchResults.length) {
+ return const ContactCTA();
+ }
+ final contactSearchResult = _contactSearchResults[index];
+ return ContactRecommendation(
+ contactSearchResult,
+ key: ValueKey(contactSearchResult.name()),
+ );
+ },
+ separatorBuilder: (context, index) => const SizedBox(width: 12),
),
),
],
@@ -208,64 +208,41 @@ class _ContactRecommendationState extends State<ContactRecommendation> {
widget.contactSearchResult.params[kContactUserId] as int?;
final contactEmail =
widget.contactSearchResult.params[kContactEmail] as String;
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 2.5),
- child: GestureDetector(
- onTap: () {
- RecentSearches().add(widget.contactSearchResult.name());
- if (widget.contactSearchResult.onResultTap != null) {
- widget.contactSearchResult.onResultTap!(context);
- } else {
- routeToPage(context, ContactResultPage(widget.contactSearchResult));
- }
- },
- child: ConstrainedBox(
- constraints: const BoxConstraints(
- maxHeight: double.infinity,
- minHeight: 115.5,
- maxWidth: 100,
- minWidth: 100,
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 4.25,
- vertical: 10.5,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- ClipOval(
- child: SizedBox(
- width: 67.75,
- height: 67.75,
- child: ContactAvatarWidget(
- contactUserId: contactUserId,
- email: contactEmail,
- personId: personId,
- size: 67.75,
- ),
- ),
- ),
- const SizedBox(height: 10.5),
- SizedBox(
- width: 91.5,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- widget.contactSearchResult.name(),
- style: TextStyles.body.copyWith(color: colors.textBase),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.center,
- ),
- ],
- ),
+ return GestureDetector(
+ onTap: () {
+ RecentSearches().add(widget.contactSearchResult.name());
+ if (widget.contactSearchResult.onResultTap != null) {
+ widget.contactSearchResult.onResultTap!(context);
+ } else {
+ routeToPage(context, ContactResultPage(widget.contactSearchResult));
+ }
+ },
+ child: SizedBox(
+ width: 92,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ ClipOval(
+ child: SizedBox(
+ width: 62,
+ height: 62,
+ child: ContactAvatarWidget(
+ contactUserId: contactUserId,
+ email: contactEmail,
+ personId: personId,
+ size: 62,
),
- ],
+ ),
+ ),
+ const SizedBox(height: 10),
+ Text(
+ widget.contactSearchResult.name(),
+ style: TextStyles.mini.copyWith(color: colors.textBase),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.center,
),
- ),
+ ],
),
),
);
@@ -277,52 +254,38 @@ class ContactCTA extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final colors = context.componentColors;
- final enteColorScheme = getEnteColorScheme(context);
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 2.5),
- child: GestureDetector(
- onTap: SectionType.contacts.ctaOnTap(context),
- child: ConstrainedBox(
- constraints: const BoxConstraints(
- maxHeight: double.infinity,
- minHeight: 115.5,
- maxWidth: 100,
- minWidth: 100,
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 4.25,
- vertical: 10.5,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- DottedBorder(
- borderType: BorderType.Circle,
- strokeWidth: 1.5,
- borderPadding: const EdgeInsets.all(0.75),
- dashPattern: const [4, 4],
- radius: const Radius.circular(2.35),
- padding: EdgeInsets.zero,
- color: enteColorScheme.strokeFaint,
- child: SizedBox(
- height: 67.75,
- width: 67.75,
- child: Icon(
- Icons.adaptive.share,
- color: enteColorScheme.strokeFaint,
- ),
- ),
- ),
- const SizedBox(height: 10.5),
- Text(
- AppLocalizations.of(context).invite,
- style: TextStyles.body.copyWith(color: colors.textLighter),
+ final colorScheme = getEnteColorScheme(context);
+ return GestureDetector(
+ onTap: SectionType.contacts.ctaOnTap(context),
+ child: SizedBox(
+ width: 62,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Container(
+ width: 62,
+ height: 62,
+ decoration: BoxDecoration(
+ color: colorScheme.fill,
+ shape: BoxShape.circle,
+ ),
+ child: Center(
+ child: HugeIcon(
+ icon: HugeIcons.strokeRoundedUserAdd01,
+ size: 24,
+ color: colorScheme.textMuted,
),
- ],
+ ),
+ ),
+ const SizedBox(height: 10),
+ Text(
+ AppLocalizations.of(context).invite,
+ style: TextStyles.mini.copyWith(color: colorScheme.textMuted),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.center,
),
- ),
+ ],
),
),
);
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/file_type_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/file_type_section.dart
index dbafb8fe60..b9a485a881 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/file_type_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/file_type_section.dart
@@ -3,6 +3,7 @@ import "dart:async";
import "package:ente_components/theme/text_styles.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:logging/logging.dart";
import "package:photos/models/file/file_type.dart";
import "package:photos/models/search/generic_search_result.dart";
@@ -59,23 +60,23 @@ class FileTypeSection extends StatelessWidget {
final tiles = _previewTiles(context);
return Padding(
- padding: const EdgeInsets.only(top: 8, bottom: 24),
+ padding: const EdgeInsets.only(bottom: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SectionHeader(SectionType.fileTypesAndExtension, hasMore: true),
- const SizedBox(height: 2),
+ const SizedBox(height: 8),
SizedBox(
- child: SingleChildScrollView(
- padding: const EdgeInsets.symmetric(horizontal: 4.5),
+ height: 56,
+ child: ListView.separated(
+ padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: tiles
- .map((tile) => _FileTypeRecommendation(tile))
- .toList(),
- ),
+ itemCount: tiles.length,
+ itemBuilder: (context, index) {
+ return _FileTypeRecommendation(tiles[index]);
+ },
+ separatorBuilder: (context, index) => const SizedBox(width: 10),
),
),
],
@@ -84,65 +85,77 @@ class FileTypeSection extends StatelessWidget {
}
List<_FileTypeTile> _previewTiles(BuildContext context) {
+ final photos = getHumanReadableString(context, FileType.image);
+ final videos = getHumanReadableString(context, FileType.video);
+ final livePhotos = getHumanReadableString(context, FileType.livePhoto);
return [
_FileTypeTile.fileType(
- assetKey: "PHOTO",
- name: getHumanReadableString(context, FileType.image),
+ label: photos,
+ name: photos,
type: FileType.image,
+ icon: HugeIcons.strokeRoundedImage01,
),
_FileTypeTile.fileType(
- assetKey: "VIDEO",
- name: getHumanReadableString(context, FileType.video),
+ label: videos,
+ name: videos,
type: FileType.video,
+ icon: HugeIcons.strokeRoundedVideo02,
),
_FileTypeTile.fileType(
- assetKey: "LIVE",
- name: getHumanReadableString(context, FileType.livePhoto),
+ label: livePhotos,
+ name: livePhotos,
type: FileType.livePhoto,
+ icon: HugeIcons.strokeRoundedLiveStreaming01,
),
const _FileTypeTile.extension(
- assetKey: "PNG",
+ label: "PNG",
name: "PNGs",
extension: "PNG",
+ icon: HugeIcons.strokeRoundedFile01,
),
const _FileTypeTile.extension(
- assetKey: "JPG",
+ label: "JPG",
name: "JPGs",
extension: "JPG",
+ icon: HugeIcons.strokeRoundedFile01,
),
const _FileTypeTile.extension(
- assetKey: "HEIC",
+ label: "HEIC",
name: "HEICs",
extension: "HEIC",
+ icon: HugeIcons.strokeRoundedFile01,
),
const _FileTypeTile.extension(
- assetKey: "MP4",
+ label: "MP4",
name: "MP4s",
extension: "MP4",
+ icon: HugeIcons.strokeRoundedFile01,
),
];
}
}
class _FileTypeTile {
- final String assetKey;
+ final String label;
final String name;
final FileType? fileType;
final String? extension;
+ final List<List<dynamic>> icon;
const _FileTypeTile.fileType({
- required this.assetKey,
+ required this.label,
required this.name,
required FileType type,
+ required this.icon,
}) : fileType = type,
extension = null;
const _FileTypeTile.extension({
- required this.assetKey,
+ required this.label,
required this.name,
required this.extension,
- }) : fileType = null,
- assert(extension != null);
+ required this.icon,
+ }) : fileType = null;
Future<GenericSearchResult> resolve() {
final type = fileType;
@@ -170,32 +183,37 @@ class _FileTypeRecommendation extends StatefulWidget {
}
class _FileTypeRecommendationState extends State<_FileTypeRecommendation> {
- static const knownTypesToAssetPath = {
- "PHOTO": "assets/type_photos.png",
- "VIDEO": "assets/type_videos.png",
- "LIVE": "assets/type_live.png",
- "AVI": "assets/type_AVI.png",
- "GIF": "assets/type_GIF.png",
- "HEIC": "assets/type_HEIC.png",
- "JPEG": "assets/type_JPEG.png",
- "JPG": "assets/type_JPG.png",
- "MKV": "assets/type_MKV.png",
- "MP4": "assets/type_MP4.png",
- "PNG": "assets/type_PNG.png",
- "WEBP": "assets/type_WEBP.png",
- };
-
final _logger = Logger("FileTypeRecommendation");
@override
Widget build(BuildContext context) {
- final fileTypeKey = widget.tile.assetKey;
- final assetPath = knownTypesToAssetPath[fileTypeKey]!;
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: ConstrainedBox(
- constraints: const BoxConstraints(maxHeight: 68),
- child: GestureDetector(onTap: _onTap, child: Image.asset(assetPath)),
+ final colorScheme = getEnteColorScheme(context);
+ return GestureDetector(
+ onTap: _onTap,
+ child: Container(
+ width: 78.75,
+ height: 56,
+ decoration: BoxDecoration(
+ color: colorScheme.fill,
+ borderRadius: BorderRadius.circular(25),
+ ),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ HugeIcon(
+ icon: widget.tile.icon,
+ size: 22,
+ color: colorScheme.textBase,
+ ),
+ const SizedBox(height: 2),
+ Text(
+ widget.tile.label,
+ style: TextStyles.tiny.copyWith(color: colorScheme.textBase),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ],
+ ),
),
);
}
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/locations_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/locations_section.dart
index aecb2cff17..723cb593ac 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/locations_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/locations_section.dart
@@ -1,8 +1,5 @@
import "dart:async";
-import "dart:math";
-import "dart:ui";
-import "package:dotted_border/dotted_border.dart";
import "package:ente_components/ente_components.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:figma_squircle/figma_squircle.dart";
@@ -107,16 +104,8 @@ class _LocationsSectionState extends State<LocationsSection> {
),
);
} else {
- final recommendations = <Widget>[
- const RepaintBoundary(child: GoToMapWithBG()),
- ..._locationsSearchResults.map(
- (locationSearchResult) =>
- LocationRecommendation(locationSearchResult),
- ),
- const RepaintBoundary(child: LocationCTA()),
- ];
return Padding(
- padding: const EdgeInsets.only(top: 8, bottom: 24),
+ padding: const EdgeInsets.only(bottom: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -125,17 +114,23 @@ class _LocationsSectionState extends State<LocationsSection> {
hasMore:
(_locationsSearchResults.length >= kSearchSectionLimit - 1),
),
- const SizedBox(height: 2),
+ const SizedBox(height: 4),
SizedBox(
- child: SingleChildScrollView(
- clipBehavior: Clip.none,
- padding: const EdgeInsets.symmetric(horizontal: 4.5),
+ height: LocationRecommendation.height,
+ child: ListView.separated(
+ padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: recommendations,
- ),
+ itemCount: _locationsSearchResults.length + 1,
+ itemBuilder: (context, index) {
+ if (index == 0) {
+ return const GoToMapTile();
+ }
+ return LocationRecommendation(
+ _locationsSearchResults[index - 1],
+ );
+ },
+ separatorBuilder: (context, index) => const SizedBox(width: 10),
),
),
],
@@ -146,16 +141,11 @@ class _LocationsSectionState extends State<LocationsSection> {
}
class LocationRecommendation extends StatelessWidget {
- static const width = 100.0;
- static const height = 124.0;
- static const thumbnailBorderWidth = 1.0;
- static const outerCornerRadius = 12.0;
+ static const width = 108.0;
+ static const height = 158.0;
+ static const outerCornerRadius = 20.0;
static const cornerSmoothing = 1.0;
- static const sideOfThumbnail = 90.0;
- static const outerStrokeWidth = 1.0;
- //This is the space between this widget's boundary and the border stroke of
- //thumbnail.
- static const outerPadding = 4.0;
+ static const sideOfThumbnail = 108.0;
final GenericSearchResult locationSearchResult;
const LocationRecommendation(this.locationSearchResult, {super.key});
@@ -164,203 +154,96 @@ class LocationRecommendation extends StatelessWidget {
final heroTag =
locationSearchResult.heroTag() +
(locationSearchResult.previewThumbnail()?.tag ?? "");
- final colors = context.componentColors;
- return Padding(
- padding: EdgeInsets.symmetric(horizontal: max(0, 2.5 - outerStrokeWidth)),
- child: GestureDetector(
- onTap: () {
- RecentSearches().add(locationSearchResult.name());
- if (locationSearchResult.onResultTap != null) {
- locationSearchResult.onResultTap!(context);
- } else {
- routeToPage(context, SearchResultPage(locationSearchResult));
- }
- },
- child: RepaintBoundary(
- child: Stack(
- alignment: Alignment.center,
- clipBehavior: Clip.none,
+ final textTheme = getEnteTextTheme(context);
+ return GestureDetector(
+ onTap: () {
+ RecentSearches().add(locationSearchResult.name());
+ if (locationSearchResult.onResultTap != null) {
+ locationSearchResult.onResultTap!(context);
+ } else {
+ routeToPage(context, SearchResultPage(locationSearchResult));
+ }
+ },
+ child: RepaintBoundary(
+ child: SizedBox(
+ width: width,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
children: [
- ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius: outerCornerRadius + outerStrokeWidth,
- cornerSmoothing: cornerSmoothing,
- ),
- child: Container(
- color: Colors.white.withValues(alpha: 0.1),
- width: width + outerStrokeWidth * 2,
- height: height + outerStrokeWidth * 2,
- ),
- ),
- SizedBox(
- width: width,
- height: height,
- child: Container(
- decoration: const BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(12)),
- boxShadow: [
- BoxShadow(
- blurRadius: 1,
- offset: Offset(0, 0),
- color: Color.fromRGBO(0, 0, 0, 0.09),
- ),
- BoxShadow(
- blurRadius: 1,
- offset: Offset(1, 2),
- color: Color.fromRGBO(0, 0, 0, 0.05),
- ),
- ],
- ),
- child: ClipSmoothRect(
+ Stack(
+ children: [
+ ClipSmoothRect(
radius: SmoothBorderRadius(
cornerRadius: outerCornerRadius,
cornerSmoothing: cornerSmoothing,
),
+ child: SizedBox(
+ width: sideOfThumbnail,
+ height: sideOfThumbnail,
+ child: locationSearchResult.previewThumbnail() != null
+ ? Hero(
+ tag: heroTag,
+ child: ThumbnailWidget(
+ locationSearchResult.previewThumbnail()!,
+ shouldShowSyncStatus: false,
+ shouldShowFavoriteIcon: false,
+ ),
+ )
+ : const NoThumbnailWidget(),
+ ),
+ ),
+ Positioned(
+ left: 8,
+ bottom: 8,
child: Stack(
clipBehavior: Clip.none,
+ alignment: Alignment.center,
children: [
- Stack(
- children: [
- ImageFiltered(
- imageFilter: ImageFilter.blur(
- sigmaX: 24,
- sigmaY: 24,
- ),
- child:
- locationSearchResult.previewThumbnail() !=
- null
- ? ThumbnailWidget(
- locationSearchResult.previewThumbnail()!,
- shouldShowSyncStatus: false,
- shouldShowFavoriteIcon: false,
- )
- : const NoThumbnailWidget(),
- ),
- ],
- ),
- Padding(
- padding: const EdgeInsets.fromLTRB(
- outerPadding,
- outerPadding,
- outerPadding,
- outerPadding,
+ ClipOval(
+ child: Container(
+ color: const Color.fromRGBO(0, 0, 0, 0.6),
+ width: 15,
+ height: 15,
),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Stack(
- alignment: Alignment.center,
- children: [
- ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius:
- outerCornerRadius - outerPadding,
- cornerSmoothing: cornerSmoothing,
- ),
- child: Container(
- color: Colors.black.withValues(
- alpha: 0.1,
- ),
- width:
- sideOfThumbnail +
- thumbnailBorderWidth * 2,
- height:
- sideOfThumbnail +
- thumbnailBorderWidth * 2,
- ),
- ),
- SizedBox(
- width: sideOfThumbnail,
- height: sideOfThumbnail,
- child:
- locationSearchResult
- .previewThumbnail() !=
- null
- ? Hero(
- tag: heroTag,
- child: ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius:
- outerCornerRadius -
- outerPadding -
- thumbnailBorderWidth,
- cornerSmoothing:
- cornerSmoothing,
- ),
- clipBehavior:
- Clip.antiAliasWithSaveLayer,
- child: ThumbnailWidget(
- locationSearchResult
- .previewThumbnail()!,
- shouldShowSyncStatus: false,
- shouldShowFavoriteIcon: false,
- ),
- ),
- )
- : const NoThumbnailWidget(),
- ),
- ],
- ),
- const SizedBox(height: 4),
- Expanded(
- child: SizedBox(
- width: 90,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- locationSearchResult.name(),
- style: TextStyles.body.copyWith(
- color: colors.textBase,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.center,
- ),
- ],
- ),
- ),
- ),
- ],
+ ),
+ Container(
+ width: 16,
+ height: 16,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ border: Border.all(
+ width: 0.5,
+ color: strokeSolidMutedLight,
+ ),
),
),
+ const Icon(
+ Icons.location_on_sharp,
+ color: Colors.white,
+ size: 11,
+ ),
],
),
),
- ),
+ ],
),
- Positioned(
- left: 8,
- top: 8,
- child: Stack(
- clipBehavior: Clip.none,
- alignment: Alignment.center,
- children: [
- ClipOval(
- child: Container(
- color: const Color.fromRGBO(0, 0, 0, 0.6),
- width: 15,
- height: 15,
- ),
- ),
- Container(
- width: 16,
- height: 16,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- border: Border.all(
- width: 0.5,
- color: strokeSolidMutedLight,
- ),
- ),
- ),
- const Icon(
- Icons.location_on_sharp,
- color: Colors.white,
- size: 11,
- ),
- ],
+ const SizedBox(height: 8),
+ Text(
+ locationSearchResult.name(),
+ style: TextStyles.body.copyWith(color: textTheme.body.color),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ const SizedBox(height: 2),
+ Text(
+ AppLocalizations.of(
+ context,
+ ).itemCount(count: locationSearchResult.fileCount()),
+ style: TextStyles.mini.copyWith(
+ color: textTheme.miniMuted.color,
),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
),
],
),
@@ -370,252 +253,60 @@ class LocationRecommendation extends StatelessWidget {
}
}
-//Used for non-empty state of location section.
-class GoToMapWithBG extends StatelessWidget {
- const GoToMapWithBG({super.key});
+class GoToMapTile extends StatelessWidget {
+ const GoToMapTile({super.key});
@override
Widget build(BuildContext context) {
- final colors = context.componentColors;
- return Padding(
- padding: EdgeInsets.symmetric(
- horizontal: max(0, 2.5 - LocationRecommendation.outerStrokeWidth),
- ),
- child: GestureDetector(
- onTap: () async {
- if (!mapEnabled) {
- try {
- await setMapEnabled(true);
- } catch (e) {
- showShortToast(
- context,
- AppLocalizations.of(context).somethingWentWrong,
- );
- return;
- }
+ final textTheme = getEnteTextTheme(context);
+ final mapTileAsset = EnteTheme.isDark(context)
+ ? "assets/search_map_tile_dark.png"
+ : "assets/search_map_tile_light.png";
+ return GestureDetector(
+ onTap: () async {
+ if (!mapEnabled) {
+ try {
+ await setMapEnabled(true);
+ } catch (e) {
+ showShortToast(
+ context,
+ AppLocalizations.of(context).somethingWentWrong,
+ );
+ return;
}
- // ignore: unawaited_futures
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (context) => MapScreen(
- filesFutureFn: SearchService.instance.getAllFilesForSearch,
- ),
- ),
- );
- },
- child: Stack(
- alignment: Alignment.center,
- children: [
- ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius:
- LocationRecommendation.outerCornerRadius +
- LocationRecommendation.outerStrokeWidth,
- cornerSmoothing: LocationRecommendation.cornerSmoothing,
- ),
- child: Container(
- color: Colors.white.withValues(alpha: 0.1),
- width:
- LocationRecommendation.width +
- LocationRecommendation.outerStrokeWidth * 2,
- height:
- LocationRecommendation.height +
- LocationRecommendation.outerStrokeWidth * 2,
- ),
- ),
- SizedBox(
- width: LocationRecommendation.width,
- height: LocationRecommendation.height,
- child: Container(
- decoration: const BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(12)),
- boxShadow: [
- BoxShadow(
- blurRadius: 1,
- offset: Offset(0, 0),
- color: Color.fromRGBO(0, 0, 0, 0.09),
- blurStyle: BlurStyle.outer,
- ),
- BoxShadow(
- blurRadius: 1,
- offset: Offset(1, 2),
- color: Color.fromRGBO(0, 0, 0, 0.05),
- blurStyle: BlurStyle.outer,
- ),
- ],
- ),
- child: ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius: LocationRecommendation.outerCornerRadius,
- cornerSmoothing: LocationRecommendation.cornerSmoothing,
- ),
- child: Stack(
- clipBehavior: Clip.none,
- children: [
- Image.asset("assets/earth_blurred.png"),
- Padding(
- padding: const EdgeInsets.fromLTRB(
- LocationRecommendation.outerPadding,
- LocationRecommendation.outerPadding,
- LocationRecommendation.outerPadding,
- LocationRecommendation.outerPadding,
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- SizedBox(
- width: LocationRecommendation.sideOfThumbnail,
- height: LocationRecommendation.sideOfThumbnail,
- child: Image.asset("assets/map_world.png"),
- ),
- const SizedBox(height: 4),
- Expanded(
- child: SizedBox(
- width: 90,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- AppLocalizations.of(context).yourMap,
- style: TextStyles.mini.copyWith(
- color: colors.specialWhite,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.center,
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ),
+ }
+ // ignore: unawaited_futures
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (context) => MapScreen(
+ filesFutureFn: SearchService.instance.getAllFilesForSearch,
),
- ],
- ),
- ),
- );
- }
-}
-
-class LocationCTA extends StatelessWidget {
- const LocationCTA({super.key});
-
- @override
- Widget build(BuildContext context) {
- final colors = context.componentColors;
- final enteColorScheme = getEnteColorScheme(context);
- return Padding(
- padding: EdgeInsets.symmetric(
- horizontal: max(0, 2.5 - LocationRecommendation.outerStrokeWidth),
- ),
- child: GestureDetector(
- onTap: SectionType.location.ctaOnTap(context),
- child: Stack(
- alignment: Alignment.center,
+ ),
+ );
+ },
+ child: SizedBox(
+ width: LocationRecommendation.width,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipSmoothRect(
radius: SmoothBorderRadius(
- cornerRadius:
- LocationRecommendation.outerCornerRadius +
- LocationRecommendation.outerStrokeWidth,
+ cornerRadius: LocationRecommendation.outerCornerRadius,
cornerSmoothing: LocationRecommendation.cornerSmoothing,
),
- child: Container(
- color: Colors.white.withValues(alpha: 0.1),
- width:
- LocationRecommendation.width +
- LocationRecommendation.outerStrokeWidth * 2,
- height:
- LocationRecommendation.height +
- LocationRecommendation.outerStrokeWidth * 2,
+ child: Image.asset(
+ mapTileAsset,
+ width: LocationRecommendation.sideOfThumbnail,
+ height: LocationRecommendation.sideOfThumbnail,
+ fit: BoxFit.cover,
),
),
- SizedBox(
- width: LocationRecommendation.width,
- height: LocationRecommendation.height,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Radius.circular(12)),
- boxShadow: const [
- BoxShadow(
- blurRadius: 1,
- offset: Offset(0, 0),
- color: Color.fromRGBO(0, 0, 0, 0.09),
- blurStyle: BlurStyle.outer,
- ),
- BoxShadow(
- blurRadius: 1,
- offset: Offset(1, 2),
- color: Color.fromRGBO(0, 0, 0, 0.05),
- blurStyle: BlurStyle.outer,
- ),
- ],
- color: enteColorScheme.backgroundElevated,
- ),
- child: ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius: LocationRecommendation.outerCornerRadius,
- cornerSmoothing: LocationRecommendation.cornerSmoothing,
- ),
- child: Padding(
- padding: const EdgeInsets.fromLTRB(
- LocationRecommendation.outerPadding + 2,
- LocationRecommendation.outerPadding + 3,
- LocationRecommendation.outerPadding + 2,
- LocationRecommendation.outerPadding,
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- DottedBorder(
- dashPattern: const [2, 2],
- color: enteColorScheme.strokeFaint,
- strokeWidth: 1,
- padding: const EdgeInsets.all(0),
- borderType: BorderType.RRect,
- radius: const Radius.circular(4.5),
- child: SizedBox(
- width: 90,
- height: 84,
- child: Icon(
- Icons.add_location_alt_outlined,
- color: enteColorScheme.strokeFaint,
- size: 28,
- ),
- ),
- ),
- const SizedBox(height: 8),
- Expanded(
- child: SizedBox(
- width: 90,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- AppLocalizations.of(context).addNew,
- style: TextStyles.mini.copyWith(
- color: colors.textLighter,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.center,
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ),
+ const SizedBox(height: 8),
+ Text(
+ AppLocalizations.of(context).yourMap,
+ style: TextStyles.body.copyWith(color: textTheme.body.color),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
),
],
),
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart
index 629a5c4c69..f089a221f3 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/magic_section.dart
@@ -1,11 +1,11 @@
import "dart:async";
-import "dart:math";
import "package:ente_components/ente_components.dart";
import "package:figma_squircle/figma_squircle.dart";
import "package:flutter/material.dart";
import "package:photos/core/constants.dart";
import "package:photos/events/event.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_types.dart";
@@ -98,7 +98,7 @@ class _MagicSectionState extends State<MagicSection> {
return const SizedBox.shrink();
} else {
return Padding(
- padding: const EdgeInsets.symmetric(vertical: 8),
+ padding: const EdgeInsets.only(bottom: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -106,22 +106,18 @@ class _MagicSectionState extends State<MagicSection> {
SectionType.magic,
hasMore: (_magicSearchResults.length >= kSearchSectionLimit - 1),
),
- const SizedBox(height: 2),
+ const SizedBox(height: 4),
SizedBox(
- child: SingleChildScrollView(
- clipBehavior: Clip.none,
- padding: const EdgeInsets.symmetric(horizontal: 4.5),
+ height: 158,
+ child: ListView.separated(
+ padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: _magicSearchResults
- .map(
- (magicSearchResult) =>
- MagicRecommendation(magicSearchResult),
- )
- .toList(),
- ),
+ itemCount: _magicSearchResults.length,
+ itemBuilder: (context, index) {
+ return MagicRecommendation(_magicSearchResults[index]);
+ },
+ separatorBuilder: (context, index) => const SizedBox(width: 10),
),
),
],
@@ -132,10 +128,9 @@ class _MagicSectionState extends State<MagicSection> {
}
class MagicRecommendation extends StatelessWidget {
- static const _width = 100.0;
- static const _height = 110.0;
- static const _borderWidth = 1.0;
- static const _cornerRadius = 12.0;
+ static const _width = 108.0;
+ static const _thumbnailSize = 108.0;
+ static const _cornerRadius = 20.0;
static const _cornerSmoothing = 1.0;
final GenericSearchResult magicSearchResult;
const MagicRecommendation(this.magicSearchResult, {super.key});
@@ -145,101 +140,54 @@ class MagicRecommendation extends StatelessWidget {
final heroTag =
magicSearchResult.heroTag() +
(magicSearchResult.previewThumbnail()?.tag ?? "");
- final colors = context.componentColors;
- return Padding(
- padding: EdgeInsets.symmetric(horizontal: max(2.5 - _borderWidth, 0)),
- child: GestureDetector(
- onTap: () {
- RecentSearches().add(magicSearchResult.name());
+ final textTheme = getEnteTextTheme(context);
+ return GestureDetector(
+ onTap: () {
+ RecentSearches().add(magicSearchResult.name());
- magicSearchResult.onResultTap!(context);
- },
- child: SizedBox(
- width: _width + _borderWidth * 2,
- height: _height + _borderWidth * 2,
- child: Stack(
- clipBehavior: Clip.none,
- alignment: Alignment.center,
- children: [
- ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius: _cornerRadius + _borderWidth,
- cornerSmoothing: _cornerSmoothing,
- ),
- child: Container(
- color: getEnteColorScheme(context).strokeFaint,
- width: _width + _borderWidth * 2,
- height: _height + _borderWidth * 2,
- ),
+ magicSearchResult.onResultTap!(context);
+ },
+ child: SizedBox(
+ width: _width,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ ClipSmoothRect(
+ radius: SmoothBorderRadius(
+ cornerRadius: _cornerRadius,
+ cornerSmoothing: _cornerSmoothing,
),
- Container(
- decoration: BoxDecoration(
- boxShadow: [
- BoxShadow(
- color: Colors.black.withValues(alpha: 0.1),
- blurRadius: 6.25,
- offset: const Offset(-1.25, 2.5),
- ),
- ],
- ),
- child: ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius: _cornerRadius,
- cornerSmoothing: _cornerSmoothing,
- ),
- child: Stack(
- alignment: Alignment.bottomCenter,
- clipBehavior: Clip.none,
- children: [
- SizedBox(
- width: _width,
- height: _height,
- child: magicSearchResult.previewThumbnail() != null
- ? Hero(
- tag: heroTag,
- child: ThumbnailWidget(
- magicSearchResult.previewThumbnail()!,
- shouldShowSyncStatus: false,
- ),
- )
- : const NoThumbnailWidget(),
- ),
- Container(
- height: _height,
- width: _width,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: [
- Colors.black.withValues(alpha: 0),
- Colors.black.withValues(alpha: 0),
- Colors.black.withValues(alpha: 0.5),
- ],
- stops: const [0, 0.1, 1],
- ),
- ),
- ),
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 88),
- child: Padding(
- padding: const EdgeInsets.only(bottom: 8),
- child: Text(
- magicSearchResult.name(),
- style: TextStyles.body.copyWith(
- color: colors.specialWhite,
- ),
- maxLines: 3,
- overflow: TextOverflow.fade,
- ),
+ child: SizedBox(
+ width: _thumbnailSize,
+ height: _thumbnailSize,
+ child: magicSearchResult.previewThumbnail() != null
+ ? Hero(
+ tag: heroTag,
+ child: ThumbnailWidget(
+ magicSearchResult.previewThumbnail()!,
+ shouldShowSyncStatus: false,
),
- ),
- ],
- ),
- ),
+ )
+ : const NoThumbnailWidget(),
),
- ],
- ),
+ ),
+ const SizedBox(height: 8),
+ Text(
+ magicSearchResult.name(),
+ style: TextStyles.body.copyWith(color: textTheme.body.color),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ const SizedBox(height: 2),
+ Text(
+ AppLocalizations.of(
+ context,
+ ).itemCount(count: magicSearchResult.fileCount()),
+ style: TextStyles.mini.copyWith(color: textTheme.miniMuted.color),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ],
),
),
);
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart
index 677b590674..e8c8e21f3b 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart
@@ -27,6 +27,7 @@ import 'package:photos/ui/viewer/people/person_face_widget.dart';
import "package:photos/ui/viewer/search/result/people_section_all_page.dart";
import "package:photos/ui/viewer/search/result/search_result_page.dart";
import "package:photos/ui/viewer/search/search_section_cta.dart";
+import "package:photos/ui/viewer/search_tab/section_header.dart";
class PeopleSection extends StatefulWidget {
final SectionType sectionType = SectionType.face;
@@ -80,45 +81,20 @@ class _PeopleSectionState extends State<PeopleSection> {
@override
Widget build(BuildContext context) {
- debugPrint("Building section for ${widget.sectionType.name}");
- final shouldShowMore = _examples.isNotEmpty;
final textTheme = getEnteTextTheme(context);
- final colorScheme = getEnteColorScheme(context);
return _examples.isNotEmpty
? GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
- if (shouldShowMore) {
- routeToPage(context, const PeopleSectionAllPage());
- }
+ routeToPage(context, const PeopleSectionAllPage());
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Padding(
- padding: const EdgeInsets.all(12),
- child: Text(
- widget.sectionType.sectionTitle(context),
- style: TextStyles.h2.copyWith(
- color: textTheme.largeBold.color,
- ),
- ),
- ),
- if (shouldShowMore)
- Padding(
- padding: const EdgeInsets.all(12),
- child: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.blurStrokePressed,
- ),
- ),
- ],
- ),
- const SizedBox(height: 2),
+ SectionHeader(widget.sectionType, hasMore: true),
+ const SizedBox(height: 4),
SearchExampleRow(_examples, widget.sectionType),
+ const SizedBox(height: 20),
],
),
)
@@ -170,9 +146,9 @@ class SearchExampleRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SizedBox(
- height: 128,
+ height: 158,
child: ListView.separated(
- padding: const EdgeInsets.symmetric(horizontal: 6),
+ padding: EdgeInsets.zero,
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: examples.length,
@@ -182,7 +158,7 @@ class SearchExampleRow extends StatelessWidget {
selectedPeople: null,
);
},
- separatorBuilder: (context, index) => const SizedBox(width: 3),
+ separatorBuilder: (context, index) => const SizedBox(width: 10),
),
);
}
@@ -197,7 +173,7 @@ class PersonSearchExample extends StatelessWidget {
super.key,
required this.searchResult,
required this.selectedPeople,
- this.size = 102,
+ this.size = 108,
});
void toggleSelection() {
@@ -352,16 +328,11 @@ class PersonSearchExample extends StatelessWidget {
),
)
: Padding(
- padding: const EdgeInsets.only(top: 6, bottom: 0),
- child: SizedBox(
+ padding: EdgeInsets.zero,
+ child: _PersonLabel(
+ name: searchResult.name(),
+ count: searchResult.fileCount(),
width: size,
- child: Text(
- searchResult.name(),
- maxLines: 1,
- textAlign: TextAlign.center,
- overflow: TextOverflow.ellipsis,
- style: getEnteTextTheme(context).small,
- ),
),
),
],
@@ -372,6 +343,47 @@ class PersonSearchExample extends StatelessWidget {
}
}
+class _PersonLabel extends StatelessWidget {
+ const _PersonLabel({
+ required this.name,
+ required this.count,
+ required this.width,
+ });
+
+ final String name;
+ final int count;
+ final double width;
+
+ @override
+ Widget build(BuildContext context) {
+ final textTheme = getEnteTextTheme(context);
+ return Padding(
+ padding: const EdgeInsets.only(top: 8),
+ child: SizedBox(
+ width: width,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyles.body.copyWith(color: textTheme.body.color),
+ ),
+ const SizedBox(height: 2),
+ Text(
+ AppLocalizations.of(context).itemCount(count: count),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyles.mini.copyWith(color: textTheme.miniMuted.color),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
class FaceSearchResult extends StatelessWidget {
final SearchResult searchResult;
final double displaySize;
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart
index b5108ce365..3c873c8421 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/search_tab.dart
@@ -1,3 +1,4 @@
+import "package:ente_components/theme/text_styles.dart";
import "package:fade_indexed_stack/fade_indexed_stack.dart";
import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
@@ -6,6 +7,7 @@ import "package:logging/logging.dart";
import "package:photos/generated/intl/app_localizations.dart";
import "package:photos/models/search/generic_search_result.dart";
import "package:photos/models/search/index_of_indexed_stack.dart";
+import "package:photos/models/search/search_result.dart";
import "package:photos/models/search/search_types.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/wrapped/wrapped_service.dart";
@@ -72,8 +74,23 @@ class _SearchTabState extends State<SearchTab> {
color: headerColor,
child: SafeArea(
bottom: false,
- child: SearchWidget(
- shouldConsumeBackNotifier: widget.shouldConsumeBackNotifier,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(15, 12, 15, 20),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ AppLocalizations.of(context).search,
+ style: TextStyles.display1.copyWith(
+ color: colorScheme.textBase,
+ ),
+ ),
+ const SizedBox(height: 16),
+ SearchWidget(
+ shouldConsumeBackNotifier: widget.shouldConsumeBackNotifier,
+ ),
+ ],
+ ),
),
),
),
@@ -108,160 +125,119 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
@override
Widget build(BuildContext context) {
- final searchTypes = SectionType.values.toList(growable: true);
final keyboardInset = MediaQuery.viewInsetsOf(context).bottom;
final bottomPadding = keyboardInset > 130.0 ? keyboardInset + 50.0 : 180.0;
- return Padding(
- padding: const EdgeInsets.only(top: 4),
- child: Stack(
- children: [
- FutureBuilder<AllSectionsExamplesData>(
- future: InheritedAllSectionsExamples.of(
- context,
- ).allSectionsExamplesFuture,
- builder: (context, snapshot) {
- if (snapshot.hasData &&
- snapshot.data!.sectionResults.isNotEmpty) {
- final sectionResultsByType = snapshot.data!.sectionResults;
- final hasAnySearchableFiles =
- snapshot.data!.hasAnySearchableFiles;
- final shouldRenderContacts = !isLocalGalleryMode;
- if (!hasAnySearchableFiles &&
- sectionResultsByType.every((element) => element.isEmpty) &&
- !shouldRenderContacts) {
- return const Padding(
- padding: EdgeInsets.only(bottom: 72),
- child: SearchTabEmptyState(),
- );
- }
- if (sectionResultsByType.length != searchTypes.length) {
- return Padding(
- padding: const EdgeInsets.only(bottom: 72),
- child: Text(
- AppLocalizations.of(context).searchSectionsLengthMismatch(
- snapshotLength: sectionResultsByType.length,
- searchLength: searchTypes.length,
- ),
- ),
- );
- }
- final faceSectionIndex = searchTypes.indexOf(SectionType.face);
- final hasSurfacedOfflineFaces =
- isLocalGalleryMode &&
- faceSectionIndex >= 0 &&
- faceSectionIndex < sectionResultsByType.length &&
- sectionResultsByType.elementAt(faceSectionIndex).isNotEmpty;
- return ListView.builder(
- padding: EdgeInsets.only(bottom: bottomPadding),
- physics: const BouncingScrollPhysics(),
- itemCount: searchTypes.length + 1,
- itemBuilder: (context, index) {
- if (index == 0) {
- if (!isLocalGalleryMode) {
- return const SizedBox.shrink();
- }
- if (hasSurfacedOfflineFaces) {
- return const SizedBox.shrink();
- }
- return const MLProgressBanner();
- }
- final sectionIndex = index - 1;
- final sectionType = searchTypes[sectionIndex];
- switch (sectionType) {
- case SectionType.face:
- if (!hasGrantedMLConsent) {
- return const SizedBox.shrink();
- }
- return PeopleSection(
- examples:
- sectionResultsByType.elementAt(sectionIndex)
- as List<GenericSearchResult>,
- );
- case SectionType.album:
- return const SizedBox.shrink();
- case SectionType.ritual:
- if (isLocalGalleryMode) {
- return const SizedBox.shrink();
- }
- return const _RitualsDiscoverySection();
- case SectionType.wrapped:
- return ValueListenableBuilder<WrappedEntryState>(
- valueListenable: wrappedService.stateListenable,
- builder:
- (
- BuildContext context,
- WrappedEntryState state,
- Widget? child,
- ) {
- if (!wrappedService
- .shouldShowDiscoveryEntry) {
- return const SizedBox.shrink();
- }
- return WrappedDiscoverySection(
- state: state,
- );
- },
- );
- case SectionType.location:
- return LocationsSection(
- sectionResultsByType.elementAt(sectionIndex)
- as List<GenericSearchResult>,
- );
- case SectionType.contacts:
- return const ContactsSectionLoader();
- case SectionType.fileTypesAndExtension:
- return FileTypeSection(
- hasAnySearchableFiles: hasAnySearchableFiles,
- );
- case SectionType.magic:
- return MagicSection(
- sectionResultsByType.elementAt(sectionIndex)
- as List<GenericSearchResult>,
- );
- }
- },
- )
- .animate(delay: const Duration(milliseconds: 150))
- .slide(
- begin: const Offset(0, -0.015),
- end: const Offset(0, 0),
- duration: const Duration(milliseconds: 300),
- curve: Curves.easeOut,
- )
- .fadeIn(
- duration: const Duration(milliseconds: 150),
- curve: Curves.easeOut,
- );
- } else if (snapshot.hasError) {
- _logger.severe(
- 'Failed to load sections: ',
- snapshot.error,
- snapshot.stackTrace,
- );
- if (kDebugMode) {
- return Padding(
- padding: const EdgeInsets.only(bottom: 72),
- child: Text(
- AppLocalizations.of(context).error +
- ': ${snapshot.error}',
- ),
- );
+ return FutureBuilder<AllSectionsExamplesData>(
+ future: InheritedAllSectionsExamples.of(
+ context,
+ ).allSectionsExamplesFuture,
+ builder: (context, snapshot) {
+ if (snapshot.hasData && snapshot.data!.sectionResults.isNotEmpty) {
+ final sectionResults = snapshot.data!.sectionResults;
+ final hasAnySearchableFiles = snapshot.data!.hasAnySearchableFiles;
+ final shouldRenderContacts = !isLocalGalleryMode;
+ if (!hasAnySearchableFiles &&
+ sectionResults.every((element) => element.isEmpty) &&
+ !shouldRenderContacts) {
+ return const Padding(
+ padding: EdgeInsets.only(bottom: 72),
+ child: SearchTabEmptyState(),
+ );
+ }
+ if (sectionResults.length != SectionType.values.length) {
+ return Padding(
+ padding: const EdgeInsets.only(bottom: 72),
+ child: Text(
+ AppLocalizations.of(context).searchSectionsLengthMismatch(
+ snapshotLength: sectionResults.length,
+ searchLength: SectionType.values.length,
+ ),
+ ),
+ );
+ }
+ final resultsBySection =
+ Map<SectionType, List<SearchResult>>.fromIterables(
+ SectionType.values,
+ sectionResults,
+ );
+ List<GenericSearchResult> examplesFor(SectionType type) =>
+ resultsBySection[type]! as List<GenericSearchResult>;
+
+ final hasSurfacedOfflineFaces =
+ isLocalGalleryMode &&
+ resultsBySection[SectionType.face]!.isNotEmpty;
+ final sectionWidgets = [
+ if (hasGrantedMLConsent)
+ PeopleSection(examples: examplesFor(SectionType.face)),
+ MagicSection(examplesFor(SectionType.magic)),
+ LocationsSection(examplesFor(SectionType.location)),
+ if (!isLocalGalleryMode) const _RitualsDiscoverySection(),
+ ValueListenableBuilder<WrappedEntryState>(
+ valueListenable: wrappedService.stateListenable,
+ builder: (BuildContext context, WrappedEntryState state, _) {
+ if (!wrappedService.shouldShowDiscoveryEntry) {
+ return const SizedBox.shrink();
}
- return const Padding(
- padding: EdgeInsets.only(bottom: 72),
- child: EnteLoadingWidget(),
- );
- } else {
- return const Padding(
- padding: EdgeInsets.only(bottom: 72),
- child: EnteLoadingWidget(),
- );
- }
- },
- ),
- ],
- ),
+ return WrappedDiscoverySection(state: state);
+ },
+ ),
+ const ContactsSectionLoader(),
+ FileTypeSection(hasAnySearchableFiles: hasAnySearchableFiles),
+ ];
+ return ListView.builder(
+ padding: EdgeInsets.fromLTRB(15, 0, 15, bottomPadding),
+ physics: const BouncingScrollPhysics(),
+ itemCount: sectionWidgets.length + 1,
+ itemBuilder: (context, index) {
+ if (index == 0) {
+ if (!isLocalGalleryMode) {
+ return const SizedBox.shrink();
+ }
+ if (hasSurfacedOfflineFaces) {
+ return const SizedBox.shrink();
+ }
+ return const MLProgressBanner();
+ }
+ return sectionWidgets[index - 1];
+ },
+ )
+ .animate(delay: const Duration(milliseconds: 150))
+ .slide(
+ begin: const Offset(0, -0.015),
+ end: const Offset(0, 0),
+ duration: const Duration(milliseconds: 300),
+ curve: Curves.easeOut,
+ )
+ .fadeIn(
+ duration: const Duration(milliseconds: 150),
+ curve: Curves.easeOut,
+ );
+ } else if (snapshot.hasError) {
+ _logger.severe(
+ 'Failed to load sections: ',
+ snapshot.error,
+ snapshot.stackTrace,
+ );
+ if (kDebugMode) {
+ return Padding(
+ padding: const EdgeInsets.only(bottom: 72),
+ child: Text(
+ AppLocalizations.of(context).error + ': ${snapshot.error}',
+ ),
+ );
+ }
+ return const Padding(
+ padding: EdgeInsets.only(bottom: 72),
+ child: EnteLoadingWidget(),
+ );
+ } else {
+ return const Padding(
+ padding: EdgeInsets.only(bottom: 72),
+ child: EnteLoadingWidget(),
+ );
+ }
+ },
);
}
}
@@ -275,7 +251,7 @@ class _RitualsDiscoverySection extends StatelessWidget {
return const SizedBox.shrink();
}
return const Padding(
- padding: EdgeInsets.only(top: 8, bottom: 24),
+ padding: EdgeInsets.only(bottom: 20),
child: RitualsBanner(),
);
}
diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/section_header.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/section_header.dart
index b22f11f7e2..ec0460356b 100644
--- a/mobile/apps/photos/lib/ui/viewer/search_tab/section_header.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/section_header.dart
@@ -4,6 +4,7 @@ import "package:flutter/material.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/viewer/search/result/people_section_all_page.dart";
import "package:photos/ui/viewer/search/result/search_section_all_page.dart";
class SectionHeader extends StatelessWidget {
@@ -20,54 +21,61 @@ class SectionHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
return GestureDetector(
onTap: () {
if (hasMore) {
- routeToPage(context, SearchSectionAllPage(sectionType: sectionType));
+ routeToPage(context, _sectionAllPage());
}
},
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Padding(
- padding: const EdgeInsets.all(12),
- child: Text(
+ child: SizedBox(
+ height: 38,
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
sectionType.sectionTitle(context),
- style: TextStyles.h2.copyWith(color: textTheme.largeBold.color),
+ style: TextStyles.display3.copyWith(color: colorScheme.textBase),
),
- ),
- hasMore
- ? Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- if (showSearch)
- IconButtonWidget(
- icon: Icons.search,
- iconButtonType: IconButtonType.secondary,
- iconColor: colorScheme.blurStrokePressed,
- onTap: () {
- routeToPage(
- context,
- SearchSectionAllPage(
- sectionType: sectionType,
- startInSearchMode: true,
- ),
- );
- },
+ hasMore
+ ? Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (showSearch)
+ IconButtonWidget(
+ icon: Icons.search,
+ iconButtonType: IconButtonType.secondary,
+ iconColor: colorScheme.blurStrokePressed,
+ onTap: () {
+ routeToPage(
+ context,
+ _sectionAllPage(startInSearchMode: true),
+ );
+ },
+ ),
+ SizedBox(
+ width: 38,
+ height: 38,
+ child: Icon(
+ Icons.chevron_right_outlined,
+ color: colorScheme.blurStrokePressed,
+ ),
),
- Padding(
- padding: const EdgeInsets.fromLTRB(24, 12, 12, 12),
- child: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.blurStrokePressed,
- ),
- ),
- ],
- )
- : const SizedBox.shrink(),
- ],
+ ],
+ )
+ : const SizedBox.shrink(),
+ ],
+ ),
),
);
}
+
+ Widget _sectionAllPage({bool startInSearchMode = false}) {
+ if (sectionType == SectionType.face) {
+ return PeopleSectionAllPage(startInSearchMode: startInSearchMode);
+ }
+ return SearchSectionAllPage(
+ sectionType: sectionType,
+ startInSearchMode: startInSearchMode,
+ );
+ }
}