π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
locker: show changelog sheet on startup and sign in
AmanRajSinghMourya73afd536f9d7
diff --git a/mobile/apps/locker/lib/app.dart b/mobile/apps/locker/lib/app.dartindex d0cd4dbdf6..4efe6d760c 100644--- a/mobile/apps/locker/lib/app.dart+++ b/mobile/apps/locker/lib/app.dart@@ -16,8 +16,11 @@ import 'package:locker/core/locale.dart';import 'package:locker/l10n/l10n.dart';import 'package:locker/services/collections/collections_service.dart';import 'package:locker/services/configuration.dart';+import "package:locker/services/update_service.dart";import 'package:locker/ui/pages/home_page.dart';import 'package:locker/ui/pages/onboarding_page.dart';+import "package:locker/ui/settings/widgets/app_update_dialog.dart";+import "package:locker/ui/settings/widgets/change_log_sheet.dart";import 'package:tray_manager/tray_manager.dart';import 'package:window_manager/window_manager.dart';@@ -75,11 +78,57 @@ class _AppState extends State<App>if (mounted) {setState(() {});}+ unawaited(_showChangeLogIfNeeded());});locale = widget.locale;+ unawaited(_runStartupPrompts());super.initState();}+ Future<void> _runStartupPrompts() async {+ await Future<void>.delayed(Duration.zero);+ if (!mounted) {+ return;+ }+ final didShowUpdatePrompt = await _checkForAppUpdates();+ if (!mounted || didShowUpdatePrompt) {+ return;+ }+ await _showChangeLogIfNeeded();+ }++ Future<bool> _checkForAppUpdates() async {+ final shouldShow =+ await UpdateService.instance.shouldShowUpdateNotification();+ if (!shouldShow || !mounted) {+ return false;+ }++ final latestVersion = UpdateService.instance.getLatestVersionInfo();+ if (latestVersion == null) {+ return false;+ }++ await showAppUpdateBottomSheet(+ context,+ latestVersionInfo: latestVersion,+ );+ await UpdateService.instance.markUpdateNotificationShown();+ return true;+ }++ Future<void> _showChangeLogIfNeeded() async {+ if (!mounted || !Configuration.instance.hasConfiguredAccount()) {+ return;+ }+ final shouldShow = await UpdateService.instance.shouldShowChangeLog();+ if (!shouldShow || !mounted) {+ return;+ }+ await showChangeLogSheet(context);+ await UpdateService.instance.markChangeLogShown();+ }+@overridevoid dispose() {super.dispose();diff --git a/mobile/apps/locker/lib/ui/settings/widgets/change_log_sheet.dart b/mobile/apps/locker/lib/ui/settings/widgets/change_log_sheet.dartnew file mode 100644index 0000000000..a7e819d5ef--- /dev/null+++ b/mobile/apps/locker/lib/ui/settings/widgets/change_log_sheet.dart@@ -0,0 +1,115 @@+import "package:ente_ui/components/base_bottom_sheet.dart";+import "package:ente_ui/theme/ente_theme.dart";+import "package:flutter/material.dart";+import "package:locker/ui/components/gradient_button.dart";+import "package:locker/ui/settings/widgets/change_log_strings.dart";++class _ChangeLogEntry {+ final String title;+ final String description;++ const _ChangeLogEntry(this.title, this.description);+}++Future<void> showChangeLogSheet(BuildContext context) {+ final strings = ChangeLogStrings.forLocale(Localizations.localeOf(context));+ return showBaseBottomSheet<void>(+ context,+ title: strings.sheetTitle,+ showCloseButton: true,+ headerSpacing: 20,+ child: _ChangeLogSheetBody(strings: strings),+ );+}++class _ChangeLogSheetBody extends StatelessWidget {+ final ChangeLogStrings strings;++ const _ChangeLogSheetBody({required this.strings});++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+ final maxHeight = MediaQuery.sizeOf(context).height * 0.5;+ final entries = <_ChangeLogEntry>[+ _ChangeLogEntry(strings.title1, strings.desc1),+ _ChangeLogEntry(strings.title2, strings.desc2),+ _ChangeLogEntry(strings.title3, strings.desc3),+ ]+ .where(+ (entry) =>+ entry.title.trim().isNotEmpty ||+ entry.description.trim().isNotEmpty,+ )+ .toList(growable: false);++ return Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ strings.sheetSubtitle,+ style: textTheme.body.copyWith(color: colorScheme.textMuted),+ ),+ const SizedBox(height: 16),+ ConstrainedBox(+ constraints: BoxConstraints(maxHeight: maxHeight),+ child: ListView.separated(+ shrinkWrap: true,+ physics: const BouncingScrollPhysics(),+ itemBuilder: (context, index) {+ final entry = entries[index];+ return _ChangeLogEntryTile(entry: entry);+ },+ separatorBuilder: (_, __) => const SizedBox(height: 12),+ itemCount: entries.length,+ ),+ ),+ const SizedBox(height: 20),+ SizedBox(+ width: double.infinity,+ child: GradientButton(+ text: strings.continueLabel,+ onTap: () => Navigator.of(context).pop(),+ ),+ ),+ ],+ );+ }+}++class _ChangeLogEntryTile extends StatelessWidget {+ final _ChangeLogEntry entry;++ const _ChangeLogEntryTile({required this.entry});++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);++ return Container(+ width: double.infinity,+ padding: const EdgeInsets.all(14),+ decoration: BoxDecoration(+ color: colorScheme.fillFaint,+ borderRadius: BorderRadius.circular(12),+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ entry.title,+ style: textTheme.bodyBold.copyWith(color: colorScheme.textBase),+ ),+ const SizedBox(height: 6),+ Text(+ entry.description,+ style: textTheme.small.copyWith(color: colorScheme.textMuted),+ ),+ ],+ ),+ );+ }+}diff --git a/mobile/apps/locker/lib/ui/settings/widgets/change_log_strings.dart b/mobile/apps/locker/lib/ui/settings/widgets/change_log_strings.dartnew file mode 100644index 0000000000..c8d56b0146--- /dev/null+++ b/mobile/apps/locker/lib/ui/settings/widgets/change_log_strings.dart@@ -0,0 +1,49 @@+import "dart:ui";++class ChangeLogStrings {+ final String sheetTitle;+ final String sheetSubtitle;+ final String continueLabel;+ final String title1;+ final String desc1;+ final String title2;+ final String desc2;+ final String title3;+ final String desc3;++ const ChangeLogStrings({+ required this.sheetTitle,+ required this.sheetSubtitle,+ required this.continueLabel,+ required this.title1,+ required this.desc1,+ required this.title2,+ required this.desc2,+ required this.title3,+ required this.desc3,+ });++ static ChangeLogStrings forLocale(Locale locale) {+ final key = locale.countryCode != null && locale.countryCode!.isNotEmpty+ ? "${locale.languageCode}_${locale.countryCode}"+ : locale.languageCode;++ return _translations[key] ??+ _translations[locale.languageCode] ??+ _translations["en"]!;+ }++ static const Map<String, ChangeLogStrings> _translations = {+ "en": ChangeLogStrings(+ sheetTitle: "What's new",+ sheetSubtitle: "",+ continueLabel: "Continue",+ title1: "",+ desc1: "",+ title2: "",+ desc2: "",+ title3: "",+ desc3: "",+ ),+ };+}