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 committed Dec 12, 2024
1 parent 5f1e8ee commit 5e9acf8
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 23 deletions.
5 changes: 3 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,6 @@
"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": "Are you sure you want to delete your account? This action cannot be undone, and all your data will be permanently removed."
}
29 changes: 29 additions & 0 deletions lib/pages/settings_dashboard/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';

import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart';
import 'package:url_launcher/url_launcher.dart';

import 'settings_view.dart';

Expand All @@ -43,6 +44,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 +58,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 +262,30 @@ 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)!.deleteAccount,
titleColor: Theme.of(context).colorScheme.error,
message: L10n.of(context)!.deleteAccountMessage,
okLabel: L10n.of(context)!.next,
cancelLabel: L10n.of(context)!.cancel,
maxLinesMessage: 5,
) ==
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
17 changes: 11 additions & 6 deletions lib/pages/settings_dashboard/settings/settings_item_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ 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 @@ -16,6 +18,8 @@ class SettingsItemBuilder extends StatelessWidget {
required this.onTap,
this.isHideTrailingIcon = false,
this.isSelected = false,
this.trailingIconColor,
this.titleColor,
});

@override
Expand All @@ -35,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 @@ -51,9 +53,12 @@ class SettingsItemBuilder extends StatelessWidget {
children: [
Text(
title,
style: ListItemStyle.titleTextStyle(
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
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;
}
14 changes: 9 additions & 5 deletions lib/utils/dialog/twake_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,11 @@ Future<ConfirmResult> showConfirmAlertDialog({
bool barrierDismissible = true,
bool isDestructiveAction = false,
String? title,
Color? titleColor,
String? message,
String? okLabel,
String? cancelLabel,
int? maxLinesMessage,
void Function()? onClose,
}) async {
final result = await showModal<ConfirmResult>(
Expand Down Expand Up @@ -376,15 +378,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 +414,7 @@ Future<ConfirmResult> showConfirmAlertDialog({
color: LinagoraSysColors.material()
.onSurfaceVariant,
),
maxLines: 3,
maxLines: maxLinesMessage,
overflow: TextOverflow.ellipsis,
),
SizedBox(
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 5e9acf8

Please sign in to comment.