Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix banner states

AmanRajSinghMourya510e02dfc784
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arb
index d4de43eadb..e5493b2c40 100644
--- a/mobile/apps/photos/lib/l10n/intl_en.arb
+++ b/mobile/apps/photos/lib/l10n/intl_en.arb
@@ -2592,5 +2592,19 @@
"shareYourMemories": "Share your Memories",
"shareYourMemoriesDesc": "Share your albums, create links, collect photos and drop a comment",
"privateAndSecureBackups": "Private and Secure Backups",
- "privateAndSecureBackupsDesc": "End-to-End encrypted, triple replication, open source, and independently audited"
+ "privateAndSecureBackupsDesc": "End-to-End encrypted, triple replication, open source, and independently audited",
+ "mlProgressBannerTitle": "Hang tight!",
+ "mlProgressBannerDescription": "Your photos are getting processed on device to detect faces, objects and more.",
+ "mlProgressBannerStatus": "{indexed} out of {total} photos processed",
+ "@mlProgressBannerStatus": {
+ "placeholders": {
+ "indexed": { "type": "String" },
+ "total": { "type": "String" }
+ }
+ },
+ "offlineFacesBannerTitle": "Want to save these faces?",
+ "offlineFacesBannerSubtitle": "Sign up to tag people and easily find them later.",
+ "offlineNameFaceBannerTitle": "Give this face a name",
+ "offlineNameFaceBannerSubtitle": "Sign up to tag them and easily find their photos later.",
+ "signUp": "Sign up"
}
diff --git a/mobile/apps/photos/lib/ui/components/banners/name_face_banner.dart b/mobile/apps/photos/lib/ui/components/banners/name_face_banner.dart
index 6705ec1c99..429b70ef7a 100644
--- a/mobile/apps/photos/lib/ui/components/banners/name_face_banner.dart
+++ b/mobile/apps/photos/lib/ui/components/banners/name_face_banner.dart
@@ -34,15 +34,15 @@ class _NameFaceBannerState extends State<NameFaceBanner> {
color: colorScheme.backgroundColour,
borderRadius: BorderRadius.circular(20),
),
- child: Stack(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
children: [
- SizedBox(
- width: double.infinity,
- child: Column(
- mainAxisSize: MainAxisSize.min,
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
children: [
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 220),
+ Expanded(
child: Text(
l10n.offlineNameFaceBannerTitle,
textAlign: TextAlign.center,
@@ -56,67 +56,64 @@ class _NameFaceBannerState extends State<NameFaceBanner> {
),
),
),
- const SizedBox(height: 8),
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 250),
- child: Text(
- l10n.offlineNameFaceBannerSubtitle,
- textAlign: TextAlign.center,
- style: TextStyle(
- fontFamily: "Inter",
- fontWeight: FontWeight.w500,
- fontSize: 10,
- height: 16 / 10,
- color: colorScheme.textBase.withValues(alpha: 0.6),
- ),
- ),
- ),
- const SizedBox(height: 16),
GestureDetector(
- onTap: () {
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (_) => const LandingPageWidget(),
- ),
- );
- },
- child: Container(
- decoration: BoxDecoration(
- color: colorScheme.greenBase,
- borderRadius: BorderRadius.circular(12),
- ),
- padding: const EdgeInsets.symmetric(
- horizontal: 24,
- vertical: 18,
- ),
- child: Text(
- l10n.signUp,
- style: const TextStyle(
- fontFamily: "Montserrat",
- fontWeight: FontWeight.w600,
- fontSize: 10,
- height: 12 / 10,
- color: Colors.white,
- ),
+ onTap: _onDismiss,
+ behavior: HitTestBehavior.opaque,
+ child: Padding(
+ padding: const EdgeInsets.all(4),
+ child: HugeIcon(
+ icon: HugeIcons.strokeRoundedCancel01,
+ color: colorScheme.contentLight,
+ size: 18,
+ strokeWidth: 2,
),
),
),
],
),
),
- Positioned(
- top: 0,
- right: 16,
- child: GestureDetector(
- onTap: _onDismiss,
- behavior: HitTestBehavior.opaque,
- child: Padding(
- padding: const EdgeInsets.all(4),
- child: HugeIcon(
- icon: HugeIcons.strokeRoundedCancel01,
- color: colorScheme.textFaint,
- size: 20,
- strokeWidth: 2,
+ const SizedBox(height: 8),
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 250),
+ child: Text(
+ l10n.offlineNameFaceBannerSubtitle,
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ fontFamily: "Inter",
+ fontWeight: FontWeight.w500,
+ fontSize: 10,
+ height: 16 / 10,
+ color: colorScheme.contentLight,
+ ),
+ ),
+ ),
+ const SizedBox(height: 16),
+ GestureDetector(
+ onTap: () {
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (_) => const LandingPageWidget(),
+ ),
+ );
+ },
+ child: Container(
+ width: 140,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(
+ color: colorScheme.greenBase,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ padding: const EdgeInsets.symmetric(
+ vertical: 18,
+ ),
+ child: Text(
+ l10n.signUp,
+ style: const TextStyle(
+ fontFamily: "Montserrat",
+ fontWeight: FontWeight.w600,
+ fontSize: 10,
+ height: 12 / 10,
+ color: Colors.white,
),
),
),
diff --git a/mobile/apps/photos/lib/ui/components/banners/save_faces_banner.dart b/mobile/apps/photos/lib/ui/components/banners/save_faces_banner.dart
index 2414be73a1..ae82bf7937 100644
--- a/mobile/apps/photos/lib/ui/components/banners/save_faces_banner.dart
+++ b/mobile/apps/photos/lib/ui/components/banners/save_faces_banner.dart
@@ -34,15 +34,15 @@ class _SaveFacesBannerState extends State<SaveFacesBanner> {
color: colorScheme.backgroundColour,
borderRadius: BorderRadius.circular(20),
),
- child: Stack(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
children: [
- SizedBox(
- width: double.infinity,
- child: Column(
- mainAxisSize: MainAxisSize.min,
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
children: [
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 220),
+ Expanded(
child: Text(
l10n.offlineFacesBannerTitle,
textAlign: TextAlign.center,
@@ -56,67 +56,64 @@ class _SaveFacesBannerState extends State<SaveFacesBanner> {
),
),
),
- const SizedBox(height: 8),
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 250),
- child: Text(
- l10n.offlineFacesBannerSubtitle,
- textAlign: TextAlign.center,
- style: TextStyle(
- fontFamily: "Inter",
- fontWeight: FontWeight.w500,
- fontSize: 10,
- height: 16 / 10,
- color: colorScheme.textBase.withValues(alpha: 0.6),
- ),
- ),
- ),
- const SizedBox(height: 16),
GestureDetector(
- onTap: () {
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (_) => const LandingPageWidget(),
- ),
- );
- },
- child: Container(
- decoration: BoxDecoration(
- color: colorScheme.greenBase,
- borderRadius: BorderRadius.circular(12),
- ),
- padding: const EdgeInsets.symmetric(
- horizontal: 24,
- vertical: 18,
- ),
- child: Text(
- l10n.signUp,
- style: const TextStyle(
- fontFamily: "Montserrat",
- fontWeight: FontWeight.w600,
- fontSize: 10,
- height: 12 / 10,
- color: Colors.white,
- ),
+ onTap: _onDismiss,
+ behavior: HitTestBehavior.opaque,
+ child: Padding(
+ padding: const EdgeInsets.all(4),
+ child: HugeIcon(
+ icon: HugeIcons.strokeRoundedCancel01,
+ color: colorScheme.contentLight,
+ size: 18,
+ strokeWidth: 2,
),
),
),
],
),
),
- Positioned(
- top: 0,
- right: 16,
- child: GestureDetector(
- onTap: _onDismiss,
- behavior: HitTestBehavior.opaque,
- child: Padding(
- padding: const EdgeInsets.all(4),
- child: HugeIcon(
- icon: HugeIcons.strokeRoundedCancel01,
- color: colorScheme.textFaint,
- size: 20,
- strokeWidth: 2,
+ const SizedBox(height: 8),
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 250),
+ child: Text(
+ l10n.offlineFacesBannerSubtitle,
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ fontFamily: "Inter",
+ fontWeight: FontWeight.w500,
+ fontSize: 10,
+ height: 16 / 10,
+ color: colorScheme.contentLight,
+ ),
+ ),
+ ),
+ const SizedBox(height: 16),
+ GestureDetector(
+ onTap: () {
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (_) => const LandingPageWidget(),
+ ),
+ );
+ },
+ child: Container(
+ width: 140,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(
+ color: colorScheme.greenBase,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ padding: const EdgeInsets.symmetric(
+ vertical: 18,
+ ),
+ child: Text(
+ l10n.signUp,
+ style: const TextStyle(
+ fontFamily: "Montserrat",
+ fontWeight: FontWeight.w600,
+ fontSize: 10,
+ height: 12 / 10,
+ color: Colors.white,
),
),
),
diff --git a/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart b/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart
index 2984b4b683..1799b4d4d9 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/cluster_page.dart
@@ -17,6 +17,7 @@ import "package:photos/service_locator.dart" show isOfflineMode;
import "package:photos/services/machine_learning/face_ml/feedback/cluster_feedback.dart";
import "package:photos/services/machine_learning/face_ml/person/person_service.dart";
import "package:photos/services/machine_learning/ml_result.dart";
+import "package:photos/ui/components/banners/name_face_banner.dart";
import "package:photos/ui/notification/toast.dart";
import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
@@ -223,31 +224,32 @@ class _ClusterPageState extends State<ClusterPage> {
enableFileGrouping: widget.enableGrouping,
initialFiles: files,
header: widget.showNamingBanner &&
- !isOfflineMode &&
files.isNotEmpty &&
!_isNamingBannerDismissed
- ? SavePersonBanner(
- faceWidget: PersonFaceWidget(
- clusterID: widget.clusterID,
- ),
- text: AppLocalizations.of(context).savePerson,
- subText: AppLocalizations.of(context).findThemQuickly,
- primaryActionLabel: AppLocalizations.of(context).save,
- secondaryActionLabel: AppLocalizations.of(context).merge,
- onPrimaryTap: _handleSavePerson,
- onSecondaryTap: _handleMergePerson,
- onDismissed: () {
- if (!mounted) {
- return;
- }
- setState(() {
- _isNamingBannerDismissed = true;
- });
- },
- dismissibleKey: ValueKey(
- "save-person-banner-${widget.clusterID}",
- ),
- )
+ ? isOfflineMode
+ ? const NameFaceBanner()
+ : SavePersonBanner(
+ faceWidget: PersonFaceWidget(
+ clusterID: widget.clusterID,
+ ),
+ text: AppLocalizations.of(context).savePerson,
+ subText: AppLocalizations.of(context).findThemQuickly,
+ primaryActionLabel: AppLocalizations.of(context).save,
+ secondaryActionLabel: AppLocalizations.of(context).merge,
+ onPrimaryTap: _handleSavePerson,
+ onSecondaryTap: _handleMergePerson,
+ onDismissed: () {
+ if (!mounted) {
+ return;
+ }
+ setState(() {
+ _isNamingBannerDismissed = true;
+ });
+ },
+ dismissibleKey: ValueKey(
+ "save-person-banner-${widget.clusterID}",
+ ),
+ )
: null,
);
return GalleryBoundariesProvider(
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart
index 8aa3da6678..336437af36 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart
@@ -7,7 +7,7 @@ import "package:photos/core/event_bus.dart";
import "package:photos/events/event.dart";
import "package:photos/events/people_changed_event.dart";
import "package:photos/events/people_sort_order_change_event.dart";
-import "package:photos/generated/l10n.dart";
+import "package:photos/generated/intl/app_localizations.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";
@@ -21,6 +21,7 @@ import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/theme/text_style.dart";
import "package:photos/ui/common/loading_widget.dart";
+import "package:photos/ui/components/banners/save_faces_banner.dart";
import "package:photos/ui/components/bottom_action_bar/people_bottom_action_bar_widget.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/components/searchable_appbar.dart";
@@ -727,6 +728,10 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
showAllFaces && filteredExtraFaces.isNotEmpty;
slivers.addAll(
[
+ if (isOfflineMode)
+ const SliverToBoxAdapter(
+ child: SaveFacesBanner(),
+ ),
(!userDismissedPersonGallerySuggestion &&
!widget.namedOnly &&
!_showingIgnoredPeople)
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 74045e7a63..4e5e4511ca 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
@@ -3,7 +3,7 @@ import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
import "package:flutter_animate/flutter_animate.dart";
import "package:logging/logging.dart";
-import "package:photos/generated/l10n.dart";
+import "package:photos/generated/intl/app_localizations.dart";
import "package:photos/models/search/album_search_result.dart";
import "package:photos/models/search/generic_search_result.dart";
import "package:photos/models/search/index_of_indexed_stack.dart";
@@ -14,6 +14,7 @@ import "package:photos/services/wrapped/wrapped_service.dart";
import "package:photos/states/all_sections_examples_state.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/common/loading_widget.dart";
+import "package:photos/ui/components/banners/ml_progress_banner.dart";
import "package:photos/ui/rituals/rituals_banner.dart";
import "package:photos/ui/viewer/search/result/no_result_widget.dart";
import "package:photos/ui/viewer/search/search_suggestions.dart";
@@ -140,16 +141,20 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
return ListView.builder(
padding: const EdgeInsets.only(bottom: 180),
physics: const BouncingScrollPhysics(),
- itemCount: searchTypes.length,
+ itemCount: searchTypes.length + 1,
itemBuilder: (context, index) {
- final sectionType = searchTypes[index];
+ if (index == 0) {
+ 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: snapshot.data!.elementAt(index)
+ examples: snapshot.data!.elementAt(sectionIndex)
as List<GenericSearchResult>,
);
case SectionType.album:
@@ -157,7 +162,7 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
return const DeviceAlbumsSection();
}
return AlbumsSection(
- snapshot.data!.elementAt(index)
+ snapshot.data!.elementAt(sectionIndex)
as List<AlbumSearchResult>,
);
case SectionType.ritual:
@@ -181,19 +186,19 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
);
case SectionType.location:
return LocationsSection(
- snapshot.data!.elementAt(index)
+ snapshot.data!.elementAt(sectionIndex)
as List<GenericSearchResult>,
);
case SectionType.contacts:
return const SizedBox.shrink();
case SectionType.fileTypesAndExtension:
return FileTypeSection(
- snapshot.data!.elementAt(index)
+ snapshot.data!.elementAt(sectionIndex)
as List<GenericSearchResult>,
);
case SectionType.magic:
return MagicSection(
- snapshot.data!.elementAt(index)
+ snapshot.data!.elementAt(sectionIndex)
as List<GenericSearchResult>,
);
}
diff --git a/mobile/apps/photos/lib/utils/local_settings.dart b/mobile/apps/photos/lib/utils/local_settings.dart
index 6006cb7ea4..65f95e7b61 100644
--- a/mobile/apps/photos/lib/utils/local_settings.dart
+++ b/mobile/apps/photos/lib/utils/local_settings.dart
@@ -74,6 +74,11 @@ class LocalSettings {
static const _kAppModeEnvKey = "app_mode";
static const _kOfflineGetStartedBannerDismissed =
"ls.offline_get_started_banner_dismissed";
+ static const _kMLProgressBannerDismissed = "ls.ml_progress_banner_dismissed";
+ static const _kOfflineFacesBannerDismissed =
+ "ls.offline_faces_banner_dismissed";
+ static const _kOfflineNameFaceBannerDismissed =
+ "ls.offline_name_face_banner_dismissed";
final SharedPreferences _prefs;
@@ -448,4 +453,25 @@ class LocalSettings {
Future<void> setOfflineGetStartedBannerDismissed(bool value) async {
await _prefs.setBool(_kOfflineGetStartedBannerDismissed, value);
}
+
+ bool get isMLProgressBannerDismissed =>
+ _prefs.getBool(_kMLProgressBannerDismissed) ?? false;
+
+ Future<void> setMLProgressBannerDismissed(bool value) async {
+ await _prefs.setBool(_kMLProgressBannerDismissed, value);
+ }
+
+ bool get isOfflineFacesBannerDismissed => false;
+ // _prefs.getBool(_kOfflineFacesBannerDismissed) ?? false;
+
+ Future<void> setOfflineFacesBannerDismissed(bool value) async {
+ await _prefs.setBool(_kOfflineFacesBannerDismissed, value);
+ }
+
+ bool get isOfflineNameFaceBannerDismissed => false;
+ // _prefs.getBool(_kOfflineNameFaceBannerDismissed) ?? false;
+
+ Future<void> setOfflineNameFaceBannerDismissed(bool value) async {
+ await _prefs.setBool(_kOfflineNameFaceBannerDismissed, value);
+ }
}