Skip to content

Commit

Permalink
TW-2181: Fix apple reject 10 Dec
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored and hoangdat committed Dec 17, 2024
1 parent f7c44a5 commit 8cff86b
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 35 deletions.
7 changes: 5 additions & 2 deletions assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
"type": "text",
"placeholders": {}
},
"deleteAccount": "Delete account",
"deleteAccount": "Delete Account",
"@deleteAccount": {
"type": "text",
"placeholders": {}
Expand Down Expand Up @@ -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?"
}
35 changes: 35 additions & 0 deletions lib/pages/settings_dashboard/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';

Expand All @@ -43,6 +46,9 @@ class SettingsController extends State<Settings> with ConnectPageMixin {
final tomConfigurationRepository = getIt.get<ToMConfigurationsRepository>();
final _responsiveUtils = getIt.get<ResponsiveUtils>();

static const String generateEmailSubject =
'Request for Deletion of Twake Chat Account';

StreamSubscription? onAccountDataSubscription;

final List<SettingEnum> getListSettingItem = [
Expand All @@ -54,6 +60,7 @@ class SettingsController extends State<Settings> with ConnectPageMixin {
SettingEnum.help,
SettingEnum.about,
SettingEnum.logout,
if (PlatformInfos.isIOS) SettingEnum.deleteAccount,
];

final ValueNotifier<SettingEnum?> optionsSelectNotifier = ValueNotifier(null);
Expand Down Expand Up @@ -257,6 +264,34 @@ class SettingsController extends State<Settings> 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:[email protected]?subject=${Uri.encodeComponent(generateEmailSubject)}',
);
if (await canLaunchUrl(emailUri)) {
await launchUrl(emailUri);
}

break;
default:
break;
Expand Down
19 changes: 11 additions & 8 deletions lib/pages/settings_dashboard/settings/settings_item_builder.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,6 +18,8 @@ class SettingsItemBuilder extends StatelessWidget {
required this.onTap,
this.isHideTrailingIcon = false,
this.isSelected = false,
this.trailingIconColor,
this.titleColor,
});

@override
Expand All @@ -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(
Expand All @@ -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,
),
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/settings_dashboard/settings/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ class SettingsViewStyle {
right: responsiveUtils.isMobile(context) ? 0 : 16.0,
);
static const double settingsItemHeight = 80;

static const double maxWidthCancelButton = 127;
}
28 changes: 27 additions & 1 deletion lib/presentation/enum/settings/settings_enum.dart
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -11,6 +12,7 @@ enum SettingEnum {
devices,
help,
about,
deleteAccount,
logout;

String titleSettings(BuildContext context) {
Expand All @@ -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:
Expand All @@ -56,12 +60,34 @@ 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:
return Icons.person_outline;
}
}

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;
}
58 changes: 43 additions & 15 deletions lib/utils/dialog/twake_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -290,10 +292,18 @@ Future<ConfirmResult> 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<ConfirmResult>(
context: context,
Expand Down Expand Up @@ -376,15 +386,17 @@ Future<ConfirmResult> 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,
Expand All @@ -410,7 +422,8 @@ Future<ConfirmResult> showConfirmAlertDialog({
color: LinagoraSysColors.material()
.onSurfaceVariant,
),
maxLines: 3,
maxLines: maxLinesMessage ??
TwakeDialog.defaultMaxLinesMessage,
overflow: TextOverflow.ellipsis,
),
SizedBox(
Expand All @@ -423,18 +436,28 @@ Future<ConfirmResult> 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,
Expand All @@ -447,15 +470,19 @@ Future<ConfirmResult> 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,
Expand All @@ -465,8 +492,9 @@ Future<ConfirmResult> showConfirmAlertDialog({
.textTheme
.labelLarge
?.copyWith(
color: LinagoraSysColors.material()
.onPrimary,
color: okTextColor ??
LinagoraSysColors.material()
.onPrimary,
),
hoverColor: Colors.transparent,
onTap: () {
Expand Down
18 changes: 10 additions & 8 deletions lib/utils/permission_dialog.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -73,14 +74,15 @@ class _PermissionDialogState extends State<PermissionDialog>
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,
Expand Down

0 comments on commit 8cff86b

Please sign in to comment.