π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Minor fixes
AmanRajSinghMourya878109ad7348
diff --git a/mobile/apps/locker/lib/ui/components/alert_bottom_sheet.dart b/mobile/apps/locker/lib/ui/components/alert_bottom_sheet.dartindex aed2e2040b..6782c2608e 100644--- a/mobile/apps/locker/lib/ui/components/alert_bottom_sheet.dart+++ b/mobile/apps/locker/lib/ui/components/alert_bottom_sheet.dart@@ -1,43 +1,37 @@import "package:ente_ui/theme/ente_theme.dart";import "package:flutter/material.dart";-import "package:locker/ui/components/gradient_button.dart";-Future<bool?> showAlertBottomSheet(+Future<T?> showAlertBottomSheet<T>(BuildContext context, {required String title,required String message,required String assetPath,- required String confirmButtonText,- required VoidCallback onConfirm,+ List<Widget>? buttons,}) {- return showModalBottomSheet<bool>(+ return showModalBottomSheet<T>(context: context,isScrollControlled: true,isDismissible: true,- backgroundColor: Colors.transparent,- builder: (context) => AlertBottomSheet(+ builder: (context) => AlertBottomSheet<T>(title: title,message: message,assetPath: assetPath,- confirmButtonText: confirmButtonText,- onConfirm: onConfirm,+ buttons: buttons,),);}-class AlertBottomSheet extends StatelessWidget {+class AlertBottomSheet<T> extends StatelessWidget {final String title;final String message;final String assetPath;- final String confirmButtonText;- final VoidCallback onConfirm;+ final List<Widget>? buttons;const AlertBottomSheet({required this.title,required this.message,required this.assetPath,- required this.confirmButtonText,- required this.onConfirm,+ this.buttons,super.key,});@@ -55,7 +49,6 @@ class AlertBottomSheet extends StatelessWidget {),),child: SafeArea(- top: false,child: Padding(padding: const EdgeInsets.all(16),child: Column(@@ -79,18 +72,13 @@ class AlertBottomSheet extends StatelessWidget {),textAlign: TextAlign.center,),- const SizedBox(height: 20),- SizedBox(- width: double.infinity,- child: GradientButton(- text: confirmButtonText,- backgroundColor: colorScheme.warning400,- onTap: () {- onConfirm();- Navigator.of(context).pop(true);- },- ),- ),+ if (buttons != null && buttons!.isNotEmpty) ...[+ const SizedBox(height: 20),+ for (int i = 0; i < buttons!.length; i++) ...[+ buttons![i],+ if (i < buttons!.length - 1) const SizedBox(height: 12),+ ],+ ],],),),@@ -105,7 +93,7 @@ class AlertBottomSheet extends StatelessWidget {mainAxisAlignment: MainAxisAlignment.end,children: [GestureDetector(- onTap: () => Navigator.of(context).pop(false),+ onTap: () => Navigator.of(context).pop(),child: Container(decoration: BoxDecoration(shape: BoxShape.circle,diff --git a/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dartindex 4c12354589..b666e91146 100644--- a/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart+++ b/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart@@ -379,9 +379,18 @@ class _ShareCollectionBottomSheetStatemessage: context.l10n.cannotAddMoreFilesAfterBecomingViewer(user.displayName ?? user.email,),+ buttons: [+ SizedBox(+ child: GradientButton(+ backgroundColor: getEnteColorScheme(context).warning400,+ text: context.l10n.yesConvertToViewer,+ onTap: () {+ Navigator.of(context).pop(true);+ },+ ),+ ),+ ],assetPath: "assets/warning-grey.png",- confirmButtonText: context.l10n.remove,- onConfirm: () {},);if (confirmed != true) {@@ -411,8 +420,17 @@ class _ShareCollectionBottomSheetStateuser.displayName ?? user.email,),assetPath: "assets/warning-grey.png",- confirmButtonText: context.l10n.remove,- onConfirm: () {},+ buttons: [+ SizedBox(+ child: GradientButton(+ backgroundColor: getEnteColorScheme(context).warning400,+ text: context.l10n.yesRemove,+ onTap: () {+ Navigator.of(context).pop(true);+ },+ ),+ ),+ ],);if (confirmed == true && mounted) {diff --git a/mobile/apps/locker/lib/utils/collection_actions.dart b/mobile/apps/locker/lib/utils/collection_actions.dartindex 6739cf6ea7..31d840cbfb 100644--- a/mobile/apps/locker/lib/utils/collection_actions.dart+++ b/mobile/apps/locker/lib/utils/collection_actions.dart@@ -1,17 +1,15 @@import "dart:async";import "package:ente_accounts/services/user_service.dart";+import "package:ente_sharing/components/invite_dialog.dart";import "package:ente_sharing/models/user.dart";import "package:ente_ui/components/action_sheet_widget.dart";import 'package:ente_ui/components/buttons/button_widget.dart';import 'package:ente_ui/components/buttons/models/button_type.dart';-import "package:ente_ui/components/dialog_widget.dart";import "package:ente_ui/components/progress_dialog.dart";-import "package:ente_ui/components/user_dialogs.dart";import 'package:ente_ui/utils/dialog_util.dart';import "package:ente_ui/utils/toast_util.dart";import "package:ente_utils/email_util.dart";-import "package:ente_utils/share_utils.dart";import 'package:flutter/material.dart';import "package:locker/core/errors.dart";import 'package:locker/l10n/l10n.dart';@@ -20,7 +18,9 @@ import 'package:locker/services/collections/collections_service.dart';import 'package:locker/services/collections/models/collection.dart';import "package:locker/services/configuration.dart";import "package:locker/services/trash/trash_service.dart";+import "package:locker/ui/components/alert_bottom_sheet.dart";import "package:locker/ui/components/delete_confirmation_dialog.dart";+import "package:locker/ui/components/gradient_button.dart";import "package:locker/ui/components/input_dialog_sheet.dart";import "package:locker/ui/components/subscription_required_dialog.dart";import 'package:logging/logging.dart';@@ -330,44 +330,39 @@ class CollectionActions {Collection collection, {VoidCallback? onSuccess,}) async {- final actionResult = await showActionSheet(- context: context,+ final confirmed = await showAlertBottomSheet(+ context,+ title: context.l10n.leaveCollection,+ message: context.l10n.filesAddedByYouWillBeRemovedFromTheCollection,+ assetPath: "assets/warning-red.png",buttons: [- ButtonWidget(- buttonType: ButtonType.critical,- isInAlert: true,- shouldStickToDarkTheme: true,- buttonAction: ButtonAction.first,- shouldSurfaceExecutionStates: true,- labelText: context.l10n.leaveCollection,- onTap: () async {- await CollectionApiClient.instance.leaveCollection(collection);- },- ),- ButtonWidget(- buttonType: ButtonType.secondary,- buttonAction: ButtonAction.cancel,- isInAlert: true,- shouldStickToDarkTheme: true,- labelText: context.l10n.cancel,+ SizedBox(+ child: GradientButton(+ text: context.l10n.leaveCollection,+ onTap: () => Navigator.of(context).pop(true),+ ),),],- title: context.l10n.leaveCollection,- body: context.l10n.filesAddedByYouWillBeRemovedFromTheCollection,);- if (actionResult?.action != null && context.mounted) {- if (actionResult!.action == ButtonAction.error) {- await showGenericErrorDialog(- context: context,- error: actionResult.exception,- );- } else if (actionResult.action == ButtonAction.first) {- onSuccess?.call();- Navigator.of(context).pop();- showToast(- context,- "Leave collection successfully",- );+ if (confirmed == true) {+ try {+ await CollectionApiClient.instance.leaveCollection(collection);+ if (context.mounted) {+ onSuccess?.call();+ Navigator.of(context).pop();+ showToast(+ context,+ "Leave collection successfully",+ );+ }+ } catch (e) {+ _logger.severe("Failed to leave collection", e);+ if (context.mounted) {+ showToast(+ context,+ context.l10n.somethingWentWrong,+ );+ }}}}@@ -514,7 +509,7 @@ class CollectionActions {if (publicKey == null || publicKey == '') {// todo: neeraj replace this as per the design where a new screen// is used for error. Do this change along with handling of network errors- await showInviteDialog(context, email);+ await showInviteSheet(context, email: email);return false;} else {return true;@@ -530,17 +525,19 @@ class CollectionActions {bool showProgress = false,}) async {if (!isValidEmail(email)) {- await showErrorDialog(+ await showAlertBottomSheet(context,- context.l10n.invalidEmailAddress,- context.l10n.enterValidEmail,+ title: context.l10n.invalidEmailAddress,+ message: context.l10n.enterValidEmail,+ assetPath: "assets/warning-blue.png",);return false;} else if (email.trim() == Configuration.instance.getEmail()) {- await showErrorDialog(+ await showAlertBottomSheet(context,- context.l10n.oops,- context.l10n.youCannotShareWithYourself,+ title: context.l10n.oops,+ message: context.l10n.youCannotShareWithYourself,+ assetPath: "assets/warning-blue.png",);return false;}@@ -567,30 +564,8 @@ class CollectionActions {// getPublicKey can return null when no user is associated with given// email idif (publicKey == null || publicKey == '') {- // todo: neeraj replace this as per the design where a new screen- // is used for error. Do this change along with handling of network errors- await showDialogWidget(- context: context,- title: context.l10n.inviteToEnte,- icon: Icons.info_outline,- body: context.l10n.emailNoEnteAccount(email),- isDismissible: true,- buttons: [- ButtonWidget(- buttonType: ButtonType.neutral,- icon: Icons.adaptive.share,- labelText: context.l10n.sendInvite,- isInAlert: true,- onTap: () async {- unawaited(- shareText(- context.l10n.shareTextRecommendUsingEnte,- ),- );- },- ),- ],- );+ await dialog?.hide();+ await showInviteSheet(context, email: email);return false;} else {try {