From 5daab68181e797b677478f8b8ff250400d676351 Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Thu, 12 Dec 2024 15:03:18 +0700 Subject: [PATCH] TW-2181: Fix apple reject 10 Dec --- assets/l10n/intl_en.arb | 7 ++- .../settings_dashboard/settings/settings.dart | 35 +++++++++++ .../settings/settings_item_builder.dart | 19 +++--- .../settings/settings_view.dart | 4 +- .../settings/settings_view_style.dart | 2 + .../enum/settings/settings_enum.dart | 28 ++++++++- lib/utils/dialog/twake_dialog.dart | 58 ++++++++++++++----- lib/utils/permission_dialog.dart | 18 +++--- 8 files changed, 136 insertions(+), 35 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 73e5f7c4ed..4403d4574d 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -691,7 +691,7 @@ "type": "text", "placeholders": {} }, - "deleteAccount": "Delete account", + "deleteAccount": "Delete Account", "@deleteAccount": { "type": "text", "placeholders": {} @@ -3099,5 +3099,8 @@ "copyNumber": "Copy number", "callViaCarrier": "Call via Carrier", "scanQrCodeToJoin": "Installation of the mobile application will allow you to contact people from your phone's address book, your chats will be synchronised between devices", - "thisFieldCannotBeBlank": "This field cannot be blank" + "thisFieldCannotBeBlank": "This field cannot be blank", + "deleteAccountMessage": "Groups chats that you have created will remain unadministered unless you have given another user administrator rights. Users will still have a history of messages with you. Deleting the account won't help.", + "deleteLater": "Delete later", + "areYouSureYouWantToDeleteAccount": "Are you sure you want to delete account?" } diff --git a/lib/pages/settings_dashboard/settings/settings.dart b/lib/pages/settings_dashboard/settings/settings.dart index 4efa0be7e6..b4f40067c2 100644 --- a/lib/pages/settings_dashboard/settings/settings.dart +++ b/lib/pages/settings_dashboard/settings/settings.dart @@ -5,6 +5,7 @@ import 'package:fluffychat/di/global/get_it_initializer.dart'; import 'package:fluffychat/domain/repository/tom_configurations_repository.dart'; import 'package:fluffychat/event/twake_inapp_event_types.dart'; import 'package:fluffychat/pages/bootstrap/bootstrap_dialog.dart'; +import 'package:fluffychat/pages/settings_dashboard/settings/settings_view_style.dart'; import 'package:fluffychat/presentation/mixins/connect_page_mixin.dart'; import 'package:fluffychat/presentation/enum/settings/settings_enum.dart'; import 'package:fluffychat/presentation/extensions/client_extension.dart'; @@ -20,7 +21,9 @@ import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:go_router/go_router.dart'; +import 'package:linagora_design_flutter/linagora_design_flutter.dart'; import 'package:matrix/matrix.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'settings_view.dart'; @@ -43,6 +46,9 @@ class SettingsController extends State with ConnectPageMixin { final tomConfigurationRepository = getIt.get(); final _responsiveUtils = getIt.get(); + static const String generateEmailSubject = + 'Request for Deletion of Twake Chat Account'; + StreamSubscription? onAccountDataSubscription; final List getListSettingItem = [ @@ -54,6 +60,7 @@ class SettingsController extends State with ConnectPageMixin { SettingEnum.help, SettingEnum.about, SettingEnum.logout, + if (PlatformInfos.isIOS) SettingEnum.deleteAccount, ]; final ValueNotifier optionsSelectNotifier = ValueNotifier(null); @@ -257,6 +264,34 @@ class SettingsController extends State with ConnectPageMixin { PlatformInfos.showAboutDialogFullScreen(); case SettingEnum.logout: logoutAction(); + break; + case SettingEnum.deleteAccount: + if (await showConfirmAlertDialog( + useRootNavigator: false, + context: context, + responsiveUtils: _responsiveUtils, + title: L10n.of(context)!.areYouSureYouWantToDeleteAccount, + message: L10n.of(context)!.deleteAccountMessage, + okLabel: L10n.of(context)!.continueProcess, + okLabelButtonColor: Colors.transparent, + okTextColor: LinagoraSysColors.material().primary, + cancelLabel: L10n.of(context)!.deleteLater, + cancelLabelButtonColor: LinagoraSysColors.material().primary, + cancelTextColor: LinagoraSysColors.material().onPrimary, + maxWidthCancelButton: SettingsViewStyle.maxWidthCancelButton, + maxLinesMessage: 7, + ) == + ConfirmResult.cancel) { + return; + } + + final emailUri = Uri.parse( + 'mailto:software@linagora.com?subject=${Uri.encodeComponent(generateEmailSubject)}', + ); + if (await canLaunchUrl(emailUri)) { + await launchUrl(emailUri); + } + break; default: break; diff --git a/lib/pages/settings_dashboard/settings/settings_item_builder.dart b/lib/pages/settings_dashboard/settings/settings_item_builder.dart index 01a675e228..112cceb3bf 100644 --- a/lib/pages/settings_dashboard/settings/settings_item_builder.dart +++ b/lib/pages/settings_dashboard/settings/settings_item_builder.dart @@ -1,10 +1,11 @@ import 'package:fluffychat/pages/settings_dashboard/settings/settings_view_style.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; import 'package:linagora_design_flutter/linagora_design_flutter.dart'; class SettingsItemBuilder extends StatelessWidget { final String title; + final Color? titleColor; + final Color? trailingIconColor; final IconData leading; final VoidCallback onTap; final bool isHideTrailingIcon; @@ -17,6 +18,8 @@ class SettingsItemBuilder extends StatelessWidget { required this.onTap, this.isHideTrailingIcon = false, this.isSelected = false, + this.trailingIconColor, + this.titleColor, }); @override @@ -36,9 +39,7 @@ class SettingsItemBuilder extends StatelessWidget { child: Icon( leading, size: SettingsViewStyle.iconSize, - color: isHideTrailingIcon - ? Theme.of(context).colorScheme.error - : LinagoraRefColors.material().tertiary[30], + color: trailingIconColor, ), ), Expanded( @@ -52,10 +53,12 @@ class SettingsItemBuilder extends StatelessWidget { children: [ Text( title, - style: ListItemStyle.titleTextStyle( - fontFamily: - GoogleFonts.inter().fontFamily ?? 'Inter', - ), + style: LinagoraTextStyle.material() + .bodyMedium2 + .copyWith( + color: titleColor, + fontFamily: 'Inter', + ), maxLines: 2, overflow: TextOverflow.ellipsis, ), diff --git a/lib/pages/settings_dashboard/settings/settings_view.dart b/lib/pages/settings_dashboard/settings/settings_view.dart index 27f1dbfac2..07a6f33937 100644 --- a/lib/pages/settings_dashboard/settings/settings_view.dart +++ b/lib/pages/settings_dashboard/settings/settings_view.dart @@ -182,13 +182,15 @@ class SettingsView extends StatelessWidget { padding: SettingsViewStyle.bodySettingsScreenPadding, child: SettingsItemBuilder( title: item.titleSettings(context), + titleColor: item.titleColor(context), leading: item.iconLeading(), onTap: () => controller.onClickToSettingsItem(item), isHideTrailingIcon: item.isHideTrailingIcon, + trailingIconColor: item.iconColor(context), isSelected: controller.optionSelected(item), ), ), - item.index == SettingEnum.logout.index + item.index == SettingEnum.deleteAccount.index ? const SizedBox() : Padding( padding: diff --git a/lib/pages/settings_dashboard/settings/settings_view_style.dart b/lib/pages/settings_dashboard/settings/settings_view_style.dart index fb92330748..d83ddf3adc 100644 --- a/lib/pages/settings_dashboard/settings/settings_view_style.dart +++ b/lib/pages/settings_dashboard/settings/settings_view_style.dart @@ -45,4 +45,6 @@ class SettingsViewStyle { right: responsiveUtils.isMobile(context) ? 0 : 16.0, ); static const double settingsItemHeight = 80; + + static const double maxWidthCancelButton = 127; } diff --git a/lib/presentation/enum/settings/settings_enum.dart b/lib/presentation/enum/settings/settings_enum.dart index eca27efc05..6081a981fd 100644 --- a/lib/presentation/enum/settings/settings_enum.dart +++ b/lib/presentation/enum/settings/settings_enum.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:linagora_design_flutter/linagora_design_flutter.dart'; enum SettingEnum { profile, @@ -11,6 +12,7 @@ enum SettingEnum { devices, help, about, + deleteAccount, logout; String titleSettings(BuildContext context) { @@ -31,6 +33,8 @@ enum SettingEnum { return L10n.of(context)!.help; case SettingEnum.about: return L10n.of(context)!.about; + case SettingEnum.deleteAccount: + return L10n.of(context)!.deleteAccount; case SettingEnum.logout: return L10n.of(context)!.logout; default: @@ -56,6 +60,8 @@ enum SettingEnum { return Icons.question_mark; case SettingEnum.about: return Icons.privacy_tip_outlined; + case SettingEnum.deleteAccount: + return Icons.delete_outline; case SettingEnum.logout: return Icons.logout_outlined; default: @@ -63,5 +69,25 @@ enum SettingEnum { } } - bool get isHideTrailingIcon => this == SettingEnum.logout; + Color? iconColor(BuildContext context) { + switch (this) { + case SettingEnum.deleteAccount: + case SettingEnum.logout: + return Theme.of(context).colorScheme.error; + default: + return LinagoraRefColors.material().tertiary[30]; + } + } + + Color? titleColor(BuildContext context) { + switch (this) { + case SettingEnum.deleteAccount: + return Theme.of(context).colorScheme.error; + default: + return LinagoraSysColors.material().onSurface; + } + } + + bool get isHideTrailingIcon => + this == SettingEnum.logout || this == SettingEnum.deleteAccount; } diff --git a/lib/utils/dialog/twake_dialog.dart b/lib/utils/dialog/twake_dialog.dart index fbcb902f37..20caf2fdc3 100644 --- a/lib/utils/dialog/twake_dialog.dart +++ b/lib/utils/dialog/twake_dialog.dart @@ -29,6 +29,8 @@ class TwakeDialog { static const double maxWidthDialogButtonWeb = 128; + static const int defaultMaxLinesMessage = 3; + static void hideLoadingDialog(BuildContext context) { if (PlatformInfos.isWeb) { if (TwakeApp.routerKey.currentContext != null) { @@ -290,10 +292,18 @@ Future showConfirmAlertDialog({ bool barrierDismissible = true, bool isDestructiveAction = false, String? title, + Color? titleColor, String? message, String? okLabel, String? cancelLabel, + int? maxLinesMessage, void Function()? onClose, + Color? okLabelButtonColor, + Color? cancelLabelButtonColor, + Color? okTextColor, + Color? cancelTextColor, + double? maxWidthOkButton, + double? maxWidthCancelButton, }) async { final result = await showModal( context: context, @@ -376,15 +386,17 @@ Future showConfirmAlertDialog({ .textTheme .headlineSmall ?.copyWith( - color: LinagoraSysColors.material() - .onSurfaceVariant, + color: titleColor ?? + LinagoraSysColors.material() + .onSurfaceVariant, ) : Theme.of(context) .textTheme .titleLarge ?.copyWith( - color: LinagoraSysColors.material() - .onSurfaceVariant, + color: titleColor ?? + LinagoraSysColors.material() + .onSurfaceVariant, ), maxLines: 2, overflow: TextOverflow.ellipsis, @@ -410,7 +422,8 @@ Future showConfirmAlertDialog({ color: LinagoraSysColors.material() .onSurfaceVariant, ), - maxLines: 3, + maxLines: maxLinesMessage ?? + TwakeDialog.defaultMaxLinesMessage, overflow: TextOverflow.ellipsis, ), SizedBox( @@ -423,18 +436,28 @@ Future showConfirmAlertDialog({ margin: const EdgeInsetsDirectional.symmetric( horizontal: 24.0, ), + buttonDecoration: BoxDecoration( + color: cancelLabelButtonColor ?? + LinagoraSysColors.material().onPrimary, + borderRadius: const BorderRadius.all( + Radius.circular(100), + ), + ), message: cancelLabel ?? L10n.of(context)!.cancel, constraints: BoxConstraints( - maxWidth: responsiveUtils.isMobile(context) - ? TwakeDialog.maxWidthDialogButtonMobile - : TwakeDialog.maxWidthDialogButtonWeb, + maxWidth: maxWidthCancelButton ?? + (responsiveUtils.isMobile(context) + ? TwakeDialog + .maxWidthDialogButtonMobile + : TwakeDialog + .maxWidthDialogButtonWeb), ), styleMessage: Theme.of(context) .textTheme .labelLarge ?.copyWith( - color: + color: cancelTextColor ?? Theme.of(context).colorScheme.primary, ), hoverColor: Colors.transparent, @@ -447,15 +470,19 @@ Future showConfirmAlertDialog({ const SizedBox(width: 8), TwakeTextButton( buttonDecoration: BoxDecoration( - color: LinagoraSysColors.material().primary, + color: okLabelButtonColor ?? + LinagoraSysColors.material().primary, borderRadius: const BorderRadius.all( Radius.circular(100), ), ), constraints: BoxConstraints( - maxWidth: responsiveUtils.isMobile(context) - ? TwakeDialog.maxWidthDialogButtonMobile - : TwakeDialog.maxWidthDialogButtonWeb, + maxWidth: maxWidthOkButton ?? + (responsiveUtils.isMobile(context) + ? TwakeDialog + .maxWidthDialogButtonMobile + : TwakeDialog + .maxWidthDialogButtonWeb), ), margin: const EdgeInsetsDirectional.symmetric( horizontal: 24.0, @@ -465,8 +492,9 @@ Future showConfirmAlertDialog({ .textTheme .labelLarge ?.copyWith( - color: LinagoraSysColors.material() - .onPrimary, + color: okTextColor ?? + LinagoraSysColors.material() + .onPrimary, ), hoverColor: Colors.transparent, onTap: () { diff --git a/lib/utils/permission_dialog.dart b/lib/utils/permission_dialog.dart index 75c823cc29..2ea29ebc70 100644 --- a/lib/utils/permission_dialog.dart +++ b/lib/utils/permission_dialog.dart @@ -1,3 +1,4 @@ +import 'package:fluffychat/utils/platform_infos.dart'; import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -73,14 +74,15 @@ class _PermissionDialogState extends State Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - _PermissionTextButton( - context: context, - text: L10n.of(context)!.deny, - onPressed: () { - widget.onRefuseTap?.call(); - Navigator.of(context).pop(); - }, - ), + if (!PlatformInfos.isIOS) + _PermissionTextButton( + context: context, + text: L10n.of(context)!.deny, + onPressed: () { + widget.onRefuseTap?.call(); + Navigator.of(context).pop(); + }, + ), _PermissionTextButton( context: context, text: L10n.of(context)!.next,