π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
refactor: Update bottom sheet implementations for consistency and improved UI structure
AmanRajSinghMourya81587d5166fc
diff --git a/mobile/packages/legacy/lib/pages/select_contact_page.dart b/mobile/packages/legacy/lib/pages/select_contact_page.dartindex 372ba8944a..74e3fe7e24 100644--- a/mobile/packages/legacy/lib/pages/select_contact_page.dart+++ b/mobile/packages/legacy/lib/pages/select_contact_page.dart@@ -17,7 +17,6 @@ import "package:ente_ui/components/menu_item_widget_v2.dart";import "package:ente_ui/theme/colors.dart";import "package:ente_ui/theme/ente_theme.dart";import "package:ente_ui/theme/text_style.dart";-import "package:ente_ui/utils/dialog_util.dart";import "package:flutter/material.dart";import "package:logging/logging.dart";@@ -331,23 +330,16 @@ class _AddContactSheetState extends State<AddContactSheet> {_selectedRecoveryDays,);if (confirmed == true) {- final dialog = createProgressDialog(- context,- context.strings.pleaseWait,- );- await dialog.show();try {- final r = await EmergencyContactService.instance.addContact(+ final success = await EmergencyContactService.instance.addContact(context,emailToAdd,_selectedRecoveryDays,);- await dialog.hide();- if (r && mounted) {+ if (success && mounted) {Navigator.of(context).pop(true);}} catch (e) {- await dialog.hide();_logger.severe("Failed to add contact", e);if (mounted) {await showAlertBottomSheet(diff --git a/mobile/packages/legacy/lib/services/emergency_service.dart b/mobile/packages/legacy/lib/services/emergency_service.dartindex afc0a7cba5..d85ccba34e 100644--- a/mobile/packages/legacy/lib/services/emergency_service.dart+++ b/mobile/packages/legacy/lib/services/emergency_service.dart@@ -14,6 +14,7 @@ import "package:ente_network/network.dart";import "package:ente_sharing/components/invite_dialog.dart";import "package:ente_strings/ente_strings.dart";import "package:ente_ui/components/alert_bottom_sheet.dart";+import "package:ente_ui/utils/dialog_util.dart";import "package:ente_utils/email_util.dart";import "package:flutter/material.dart";import "package:logging/logging.dart";@@ -56,7 +57,8 @@ class EmergencyContactService {assetPath: "assets/warning-blue.png",);return false;- } else if (email.trim() == _config.getEmail()) {+ }+ if (email.trim() == _config.getEmail()) {await showAlertBottomSheet(context,title: context.strings.oops,@@ -65,25 +67,37 @@ class EmergencyContactService {);return false;}- final String? publicKey = await _userService.getPublicKey(email);- if (publicKey == null) {- await showInviteSheet(context, email: email);- return false;++ final dialog = createProgressDialog(context, context.strings.pleaseWait);+ await dialog.show();++ try {+ final String? publicKey = await _userService.getPublicKey(email);+ if (publicKey == null) {+ await dialog.hide();+ await showInviteSheet(context, email: email);+ return false;+ }++ final Uint8List recoveryKey = _config.getRecoveryKey();+ final encryptedKey = CryptoUtil.sealSync(+ recoveryKey,+ CryptoUtil.base642bin(publicKey),+ );+ await _enteDio.post(+ "/emergency-contacts/add",+ data: {+ "email": email.trim(),+ "encryptedKey": CryptoUtil.bin2base64(encryptedKey),+ "recoveryNoticeInDays": recoveryNoticeInDays,+ },+ );+ await dialog.hide();+ return true;+ } catch (e) {+ await dialog.hide();+ rethrow;}- final Uint8List recoveryKey = _config.getRecoveryKey();- final encryptedKey = CryptoUtil.sealSync(- recoveryKey,- CryptoUtil.base642bin(publicKey),- );- await _enteDio.post(- "/emergency-contacts/add",- data: {- "email": email.trim(),- "encryptedKey": CryptoUtil.bin2base64(encryptedKey),- "recoveryNoticeInDays": recoveryNoticeInDays,- },- );- return true;}Future<EmergencyInfo> getInfo() async {diff --git a/mobile/packages/sharing/lib/components/invite_dialog.dart b/mobile/packages/sharing/lib/components/invite_dialog.dartindex 04b0e3ed3e..2b6225174f 100644--- a/mobile/packages/sharing/lib/components/invite_dialog.dart+++ b/mobile/packages/sharing/lib/components/invite_dialog.dart@@ -1,28 +1,28 @@import "package:ente_sharing/components/gradient_button.dart";import "package:ente_strings/ente_strings.dart";-import "package:ente_ui/components/close_icon_button.dart";-import "package:ente_ui/theme/colors.dart";+import "package:ente_ui/components/base_bottom_sheet.dart";import "package:ente_ui/theme/ente_theme.dart";-import "package:ente_ui/theme/text_style.dart";import "package:ente_utils/share_utils.dart";import "package:flutter/material.dart";-/// Shows the invite dialog bottom sheet when a user doesn't have an Ente account+/// Shows the invite sheet when a user doesn't have an Ente accountFuture<void> showInviteSheet(BuildContext context, {required String email,}) {- return showModalBottomSheet<void>(- context: context,- isScrollControlled: true,- builder: (context) => InviteDialog(email: email),+ return showBaseBottomSheet<void>(+ context,+ title: context.strings.inviteToEnte,+ headerSpacing: 20,+ crossAxisAlignment: CrossAxisAlignment.center,+ child: InviteSheet(email: email),);}-class InviteDialog extends StatelessWidget {+class InviteSheet extends StatelessWidget {final String email;- const InviteDialog({+ const InviteSheet({super.key,required this.email,});@@ -32,53 +32,6 @@ class InviteDialog extends StatelessWidget {final colorScheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);- return Container(- decoration: BoxDecoration(- color: colorScheme.backgroundElevated2,- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(24),- topRight: Radius.circular(24),- ),- ),- child: SafeArea(- top: false,- child: Padding(- padding: const EdgeInsets.all(16),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- _buildHeader(context, colorScheme, textTheme),- const SizedBox(height: 20),- _buildContent(context, colorScheme, textTheme),- ],- ),- ),- ),- );- }-- Widget _buildHeader(- BuildContext context,- EnteColorScheme colorScheme,- EnteTextTheme textTheme,- ) {- return Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Text(- context.strings.inviteToEnte,- style: textTheme.largeBold,- ),- const CloseIconButton(),- ],- );- }-- Widget _buildContent(- BuildContext context,- EnteColorScheme colorScheme,- EnteTextTheme textTheme,- ) {return Column(mainAxisSize: MainAxisSize.min,children: [diff --git a/mobile/packages/sharing/lib/verify_identity_dialog.dart b/mobile/packages/sharing/lib/verify_identity_dialog.dartindex 723ea34413..f797d0109d 100644--- a/mobile/packages/sharing/lib/verify_identity_dialog.dart+++ b/mobile/packages/sharing/lib/verify_identity_dialog.dart@@ -6,7 +6,7 @@ import "package:ente_accounts/services/user_service.dart";import "package:ente_configuration/base_configuration.dart";import "package:ente_sharing/components/gradient_button.dart";import "package:ente_strings/ente_strings.dart";-import "package:ente_ui/components/close_icon_button.dart";+import "package:ente_ui/components/base_bottom_sheet.dart";import "package:ente_ui/components/loading_widget.dart";import "package:ente_ui/theme/ente_theme.dart";import "package:ente_utils/share_utils.dart";@@ -21,20 +21,19 @@ Future<void> showVerifyIdentitySheet(required BaseConfiguration config,String? title,}) {- return showModalBottomSheet<void>(- context: context,- isScrollControlled: true,- backgroundColor: Colors.transparent,- builder: (context) => VerifyIdentityDialog(+ return showBaseBottomSheet<void>(+ context,+ title: title ?? context.strings.verify,+ headerSpacing: 20,+ child: VerifyIdentitySheet(self: self,email: email,config: config,- title: title,),);}-class VerifyIdentityDialog extends StatefulWidget {+class VerifyIdentitySheet extends StatefulWidget {// email id of the user who's verification ID is being displayed for// verificationfinal String email;@@ -43,15 +42,11 @@ class VerifyIdentityDialog extends StatefulWidget {final bool self;final BaseConfiguration config;- // Optional custom title, defaults to context.strings.verify if not provided- final String? title;-- VerifyIdentityDialog({+ VerifyIdentitySheet({super.key,required this.self,this.email = '',required this.config,- this.title,}) {if (!self && email.isEmpty) {throw ArgumentError("email cannot be empty when self is false");@@ -59,10 +54,10 @@ class VerifyIdentityDialog extends StatefulWidget {}@override- State<VerifyIdentityDialog> createState() => _VerifyIdentityDialogState();+ State<VerifyIdentitySheet> createState() => _VerifyIdentitySheetState();}-class _VerifyIdentityDialogState extends State<VerifyIdentityDialog> {+class _VerifyIdentitySheetState extends State<VerifyIdentitySheet> {@overrideWidget build(BuildContext context) {final colorScheme = getEnteColorScheme(context);@@ -74,97 +69,66 @@ class _VerifyIdentityDialogState extends State<VerifyIdentityDialog> {? context.strings.someoneSharingAlbumsWithYouShouldSeeTheSameId: context.strings.howToViewShareeVerificationID;- return Container(- decoration: BoxDecoration(- color: colorScheme.backgroundElevated2,- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(24),- topRight: Radius.circular(24),- ),- ),- child: SafeArea(- top: false,- child: Padding(- padding: const EdgeInsets.all(16),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Text(- widget.title ?? context.strings.verify,- style: textStyle.largeBold,- ),- const CloseIconButton(),- ],- ),- const SizedBox(height: 20),- FutureBuilder<String>(- future: _getPublicKey(),- builder: (context, snapshot) {- if (snapshot.hasData) {- final publicKey = snapshot.data!;- if (publicKey.isEmpty) {- return Column(- mainAxisSize: MainAxisSize.min,- children: [- Text(- context.strings.emailNoEnteAccount(widget.email),- style: textStyle.small- .copyWith(color: colorScheme.textMuted),- ),- const SizedBox(height: 20),- GradientButton(- text: context.strings.sendInvite,- onTap: () {- shareText(- context.strings.shareTextRecommendUsingEnte,- );- },- ),- ],- );- } else {- return Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- children: [- Text(- subTitle,- style: textStyle.small- .copyWith(color: colorScheme.textMuted),- ),- const SizedBox(height: 20),- _verificationIDWidget(context, publicKey),- const SizedBox(height: 20),- Text(- bottomText,- style: textStyle.small- .copyWith(color: colorScheme.textMuted),- ),- ],- );- }- } else if (snapshot.hasError) {- Logger("VerificationID")- .severe("failed to end userID", snapshot.error);- return Text(- context.strings.somethingWentWrong,- style: textStyle.bodyMuted,+ return FutureBuilder<String>(+ future: _getPublicKey(),+ builder: (context, snapshot) {+ if (snapshot.hasData) {+ final publicKey = snapshot.data!;+ if (publicKey.isEmpty) {+ return Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ context.strings.emailNoEnteAccount(widget.email),+ style:+ textStyle.small.copyWith(color: colorScheme.textMuted),+ ),+ const SizedBox(height: 20),+ GradientButton(+ text: context.strings.sendInvite,+ onTap: () {+ shareText(+ context.strings.shareTextRecommendUsingEnte,);- } else {- return const SizedBox(- height: 200,- child: EnteLoadingWidget(),- );- }- },- ),- ],- ),- ),- ),+ },+ ),+ ],+ );+ } else {+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ subTitle,+ style:+ textStyle.small.copyWith(color: colorScheme.textMuted),+ ),+ const SizedBox(height: 20),+ _verificationIDWidget(context, publicKey),+ const SizedBox(height: 20),+ Text(+ bottomText,+ style:+ textStyle.small.copyWith(color: colorScheme.textMuted),+ ),+ ],+ );+ }+ } else if (snapshot.hasError) {+ Logger("VerificationID")+ .severe("failed to end userID", snapshot.error);+ return Text(+ context.strings.somethingWentWrong,+ style: textStyle.bodyMuted,+ );+ } else {+ return const SizedBox(+ height: 200,+ child: EnteLoadingWidget(),+ );+ }+ },);}