π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][locker] Add Legacy setup banner
AmanRajSinghMourya9f285db6bbe4
diff --git a/mobile/apps/locker/assets/2.0x/legacy_banner.png b/mobile/apps/locker/assets/2.0x/legacy_banner.pngnew file mode 100644index 0000000000..86906b945cBinary files /dev/null and b/mobile/apps/locker/assets/2.0x/legacy_banner.png differdiff --git a/mobile/apps/locker/assets/3.0x/legacy_banner.png b/mobile/apps/locker/assets/3.0x/legacy_banner.pngnew file mode 100644index 0000000000..d9b3c57b7fBinary files /dev/null and b/mobile/apps/locker/assets/3.0x/legacy_banner.png differdiff --git a/mobile/apps/locker/assets/legacy_banner.png b/mobile/apps/locker/assets/legacy_banner.pngnew file mode 100644index 0000000000..cb850679eaBinary files /dev/null and b/mobile/apps/locker/assets/legacy_banner.png differdiff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arbindex dc9a959e53..4cfd91a6a9 100644--- a/mobile/apps/locker/lib/l10n/app_en.arb+++ b/mobile/apps/locker/lib/l10n/app_en.arb@@ -280,6 +280,18 @@"@setupYourLegacy": {"description": "Action that opens Legacy setup from the empty Locker home state"},+ "shareYourLegacyBannerTitle": "Share your Legacy",+ "@shareYourLegacyBannerTitle": {+ "description": "Title of the home banner prompting the user to set up Legacy"+ },+ "setupLegacy": "Setup Legacy",+ "@setupLegacy": {+ "description": "Short action label on the home banner that opens Legacy setup"+ },+ "shareYourLegacyBannerDescription": "Help loved ones access important information, in your absence.",+ "@shareYourLegacyBannerDescription": {+ "description": "Description of the home banner prompting the user to set up Legacy"+ },"uploadDocument": "Upload document","items": "{count} items","@items": {diff --git a/mobile/apps/locker/lib/main.dart b/mobile/apps/locker/lib/main.dartindex 0534581ebc..5a74c0f7aa 100644--- a/mobile/apps/locker/lib/main.dart+++ b/mobile/apps/locker/lib/main.dart@@ -37,6 +37,7 @@ import 'package:locker/services/files/download/service_locator.dart';import 'package:locker/services/files/links/links_client.dart';import 'package:locker/services/files/links/links_service.dart';import 'package:locker/services/files/offline/offline_files_service.dart';+import 'package:locker/services/local_settings.dart';import 'package:locker/services/trash/trash_service.dart';import 'package:locker/services/update_service.dart';import 'package:locker/ui/pages/home_page.dart';@@ -189,6 +190,8 @@ Future<void> _init(bool bool, {String? via}) async {final SharedPreferences preferences = await SharedPreferences.getInstance();final PackageInfo packageInfo = await PackageInfo.fromPlatform();+ LocalSettings.instance.init(preferences);+await CryptoUtil.init();await LockerDB.instance.init();diff --git a/mobile/apps/locker/lib/services/local_settings.dart b/mobile/apps/locker/lib/services/local_settings.dartnew file mode 100644index 0000000000..dc8ede69a5--- /dev/null+++ b/mobile/apps/locker/lib/services/local_settings.dart@@ -0,0 +1,21 @@+import "package:shared_preferences/shared_preferences.dart";++class LocalSettings {+ LocalSettings._privateConstructor();+ static final LocalSettings instance = LocalSettings._privateConstructor();++ static const _legacySetupBannerDismissedKey =+ "ls.legacy_setup_banner_dismissed";++ late final SharedPreferences _prefs;++ void init(SharedPreferences prefs) {+ _prefs = prefs;+ }++ bool get isLegacySetupBannerDismissed =>+ _prefs.getBool(_legacySetupBannerDismissedKey) ?? false;++ Future<void> setLegacySetupBannerDismissed(bool value) =>+ _prefs.setBool(_legacySetupBannerDismissedKey, value);+}diff --git a/mobile/apps/locker/lib/ui/components/legacy_setup_banner.dart b/mobile/apps/locker/lib/ui/components/legacy_setup_banner.dartnew file mode 100644index 0000000000..1da229ea57--- /dev/null+++ b/mobile/apps/locker/lib/ui/components/legacy_setup_banner.dart@@ -0,0 +1,200 @@+import "dart:async";++import "package:ente_components/ente_components.dart";+import "package:ente_legacy/services/emergency_service.dart";+import "package:ente_legacy/services/legacy_kit_service.dart";+import "package:flutter/material.dart";+import "package:hugeicons/hugeicons.dart";+import "package:locker/l10n/l10n.dart";+import "package:locker/services/local_settings.dart";+import "package:locker/ui/utils/legacy_utils.dart";+import "package:logging/logging.dart";++const _titleStyle = TextStyle(+ fontFamily: TextStyles.outfitFontFamily,+ package: TextStyles.fontPackage,+ fontWeight: FontWeight.w600,+ fontSize: 18,+ height: 32 / 18,+);++const _descriptionStyle = TextStyle(+ fontFamily: TextStyles.fontFamily,+ package: TextStyles.fontPackage,+ fontWeight: FontWeight.w600,+ fontSize: 10,+ height: 14 / 10,+ letterSpacing: -0.2,+);++const _buttonStyle = TextStyle(+ fontFamily: TextStyles.outfitFontFamily,+ package: TextStyles.fontPackage,+ fontWeight: FontWeight.w600,+ fontSize: 10,+);++class LegacySetupBanner extends StatefulWidget {+ const LegacySetupBanner({super.key});++ @override+ State<LegacySetupBanner> createState() => _LegacySetupBannerState();+}++class _LegacySetupBannerState extends State<LegacySetupBanner> {+ static const _illustrationWidth = 155.0;+ static const _contentRightReserve = 150.0;++ final _logger = Logger("LegacySetupBanner");+ bool _shouldShow = false;++ @override+ void initState() {+ super.initState();+ unawaited(_evaluateVisibility());+ }++ Future<void> _evaluateVisibility() async {+ if (LocalSettings.instance.isLegacySetupBannerDismissed) {+ _setShouldShow(false);+ return;+ }+ try {+ final info = await EmergencyContactService.instance.getInfo();+ final legacyConfigured =+ info.contacts.isNotEmpty || await _hasLegacyKit();+ if (!mounted) return;+ _setShouldShow(!legacyConfigured);+ } catch (e, s) {+ _logger.warning("Failed to fetch legacy info for banner", e, s);+ }+ }++ void _setShouldShow(bool value) {+ if (!mounted || _shouldShow == value) return;+ setState(() => _shouldShow = value);+ }++ Future<bool> _hasLegacyKit() async {+ if (!LegacyKitService.instance.isInitialized) return false;+ try {+ final kits = await LegacyKitService.instance.getKits();+ return kits.isNotEmpty;+ } catch (e, s) {+ _logger.warning("Failed to fetch legacy kits for banner", e, s);+ return false;+ }+ }++ void _onSetup() {+ unawaited(openLegacyPage(context));+ }++ Future<void> _onDismiss() async {+ setState(() => _shouldShow = false);+ await LocalSettings.instance.setLegacySetupBannerDismissed(true);+ }++ @override+ Widget build(BuildContext context) {+ if (!_shouldShow) return const SizedBox.shrink();+ final colors = context.componentColors;+ final l10n = context.l10n;++ return MediaQuery.withClampedTextScaling(+ maxScaleFactor: 1.3,+ child: Padding(+ padding: const EdgeInsets.only(bottom: Spacing.xl),+ child: GestureDetector(+ onTap: _onSetup,+ child: Container(+ width: double.infinity,+ clipBehavior: Clip.hardEdge,+ decoration: BoxDecoration(+ color: colors.primary,+ borderRadius: BorderRadius.circular(20),+ ),+ child: Stack(+ children: [+ Positioned(+ right: -8,+ bottom: -8,+ child: IgnorePointer(+ child: Image.asset(+ "assets/legacy_banner.png",+ width: _illustrationWidth,+ fit: BoxFit.contain,+ ),+ ),+ ),+ Padding(+ padding: const EdgeInsets.fromLTRB(+ 17,+ 20,+ _contentRightReserve,+ 19,+ ),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ l10n.shareYourLegacyBannerTitle,+ style: _titleStyle.copyWith(color: colors.specialWhite),+ ),+ const SizedBox(height: 12),+ Text(+ l10n.shareYourLegacyBannerDescription,+ style: _descriptionStyle.copyWith(+ color: colors.specialWhite.withValues(alpha: 0.79),+ ),+ ),+ const SizedBox(height: 16),+ _SetupButton(label: l10n.setupLegacy, onTap: _onSetup),+ ],+ ),+ ),+ Positioned(+ top: 18,+ right: 16,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: _onDismiss,+ child: HugeIcon(+ icon: HugeIcons.strokeRoundedCancel01,+ color: colors.specialWhite,+ size: 18,+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ ),+ );+ }+}++class _SetupButton extends StatelessWidget {+ const _SetupButton({required this.label, required this.onTap});++ final String label;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ return GestureDetector(+ onTap: onTap,+ behavior: HitTestBehavior.opaque,+ child: Container(+ padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 11),+ decoration: BoxDecoration(+ color: context.componentColors.specialWhite,+ borderRadius: BorderRadius.circular(12),+ ),+ child: Text(label, style: _buttonStyle.copyWith(color: Colors.black)),+ ),+ );+ }+}diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dartindex 2934f4681b..0dd8829304 100644--- a/mobile/apps/locker/lib/ui/pages/home_page.dart+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart@@ -23,6 +23,7 @@ import 'package:locker/services/files/sync/models/file.dart';import "package:locker/states/user_details_state.dart";import "package:locker/ui/components/empty_state_widget.dart";import "package:locker/ui/components/home_empty_state_widget.dart";+import "package:locker/ui/components/legacy_setup_banner.dart";import 'package:locker/ui/components/recents_section_widget.dart';import 'package:locker/ui/components/search_result_view.dart';import "package:locker/ui/drawer/drawer_page.dart";@@ -723,6 +724,7 @@ class _HomePageState extends UploaderPageState<HomePage>child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [+ const LegacySetupBanner(),RecentsSectionWidget(collections: _collections,recentFiles: _recentFiles,