Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1942: Change the design of log out dialog #1952

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3112,5 +3112,6 @@
"type": "int"
}
}
}
},
"logoutDialogWarning": "You will lose access to encrypted messages. We recommend that you enable chat backups before logging out"
}
11 changes: 6 additions & 5 deletions lib/pages/settings_dashboard/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:fluffychat/presentation/enum/settings/settings_enum.dart';
import 'package:fluffychat/presentation/extensions/client_extension.dart';
import 'package:fluffychat/utils/dialog/twake_dialog.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/responsive/responsive_utils.dart';
import 'package:fluffychat/utils/url_launcher.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:fluffychat/widgets/twake_app.dart';
Expand Down Expand Up @@ -40,6 +41,7 @@ class SettingsController extends State<Settings> with ConnectPageMixin {
final ValueNotifier<String?> displayNameNotifier = ValueNotifier('');

final tomConfigurationRepository = getIt.get<ToMConfigurationsRepository>();
final _responsiveUtils = getIt.get<ResponsiveUtils>();

StreamSubscription? onAccountDataSubscription;

Expand Down Expand Up @@ -69,23 +71,22 @@ class SettingsController extends State<Settings> with ConnectPageMixin {
settingEnum == optionsSelectNotifier.value;

void logoutAction() async {
final noBackup = showChatBackupSwitch.value == true;
final twakeContext = TwakeApp.routerKey.currentContext;
if (twakeContext == null) {
Logs().e(
'SettingsController()::logoutAction - Twake context is null',
);
}
if (await showOkCancelAlertDialog(
if (await showConfirmAlertDialog(
useRootNavigator: false,
context: twakeContext!,
responsiveUtils: _responsiveUtils,
title: L10n.of(context)!.areYouSureYouWantToLogout,
message: L10n.of(context)!.noBackupWarning,
isDestructiveAction: noBackup,
message: L10n.of(context)!.logoutDialogWarning,
okLabel: L10n.of(context)!.logout,
cancelLabel: L10n.of(context)!.cancel,
) ==
OkCancelResult.cancel) {
ConfirmResult.cancel) {
return;
}
if (PlatformInfos.isMobile) {
Expand Down
208 changes: 208 additions & 0 deletions lib/utils/dialog/twake_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import 'dart:async';
import 'package:animations/animations.dart';
import 'package:fluffychat/pages/bootstrap/init_client_dialog.dart';
import 'package:fluffychat/resource/image_paths.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/responsive/responsive_utils.dart';
import 'package:fluffychat/widgets/twake_app.dart';
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:fluffychat/widgets/twake_components/twake_text_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
Expand Down Expand Up @@ -227,3 +231,207 @@ class ProgressDialog extends StatelessWidget {
);
}
}

enum ConfirmResult {
ok,
cancel,
}

Future<ConfirmResult> showConfirmAlertDialog({
required BuildContext context,
required ResponsiveUtils responsiveUtils,
bool useRootNavigator = true,
bool barrierDismissible = true,
bool isDestructiveAction = false,
String? title,
String? message,
String? okLabel,
String? cancelLabel,
void Function()? onClose,
}) async {
final result = await showModal<ConfirmResult>(
context: context,
configuration: FadeScaleTransitionConfiguration(
barrierDismissible: barrierDismissible,
),
useRootNavigator: useRootNavigator,
builder: (context) {
return GestureDetector(
onTap: () => Navigator.of(context).pop(ConfirmResult.cancel),
child: Material(
type: MaterialType.transparency,
child: Container(
height: double.infinity,
width: double.infinity,
color: Colors.transparent,
child: Center(
child: Container(
width:
responsiveUtils.isMobile(context) ? double.infinity : 448,
margin: EdgeInsets.symmetric(
horizontal: responsiveUtils.isMobile(context) ? 24.0 : 36,
),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.all(Radius.circular(16)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
blurRadius: 8,
offset: const Offset(0, 4),
spreadRadius: 3,
),
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 3,
offset: const Offset(0, 1),
),
],
),
nqhhdev marked this conversation as resolved.
Show resolved Hide resolved
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (responsiveUtils.isMobile(context)) ...[
const SizedBox(height: 24),
] else
Padding(
padding: const EdgeInsets.only(
top: 8,
right: 8,
),
child: Align(
alignment: Alignment.topRight,
child: TwakeIconButton(
icon: Icons.close,
iconColor: isDestructiveAction
? CupertinoColors.destructiveRed
: LinagoraSysColors.material().onSurfaceVariant,
onTap: () {
Navigator.of(context).pop(ConfirmResult.cancel);
onClose?.call();
},
),
),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal:
responsiveUtils.isMobile(context) ? 24.0 : 36,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title != null)
Text(
title,
style: responsiveUtils.isMobile(context)
? Theme.of(context)
.textTheme
.headlineSmall
?.copyWith(
color: LinagoraSysColors.material()
.onSurfaceVariant,
)
: Theme.of(context)
.textTheme
.titleLarge
?.copyWith(
color: LinagoraSysColors.material()
.onSurfaceVariant,
),
),
SizedBox(
height: responsiveUtils.isMobile(context) ? 16 : 27,
),
if (message != null)
Text(
message,
style: responsiveUtils.isMobile(context)
? Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(
color: LinagoraSysColors.material()
.onSurfaceVariant,
)
: Theme.of(context)
.textTheme
.titleSmall
?.copyWith(
color: LinagoraSysColors.material()
.onSurfaceVariant,
),
),
SizedBox(
height: responsiveUtils.isMobile(context) ? 24 : 65,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TwakeTextButton(
margin: const EdgeInsetsDirectional.symmetric(
horizontal: 24.0,
),
message:
cancelLabel ?? L10n.of(context)!.cancel,
styleMessage: Theme.of(context)
.textTheme
.labelLarge
?.copyWith(
color:
Theme.of(context).colorScheme.primary,
),
hoverColor: Colors.transparent,
onTap: () {
Navigator.of(context)
.pop(ConfirmResult.cancel);
onClose?.call();
},
),
const SizedBox(width: 8),
TwakeTextButton(
buttonDecoration: BoxDecoration(
color: LinagoraSysColors.material().primary,
borderRadius: const BorderRadius.all(
Radius.circular(100),
),
),
margin: const EdgeInsetsDirectional.symmetric(
horizontal: 24.0,
),
message: okLabel ?? L10n.of(context)!.ok,
styleMessage: Theme.of(context)
.textTheme
.labelLarge
?.copyWith(
color: LinagoraSysColors.material()
.onPrimary,
),
hoverColor: Colors.transparent,
onTap: () {
Navigator.of(context).pop(ConfirmResult.ok);
onClose?.call();
},
),
],
),
SizedBox(
height:
responsiveUtils.isMobile(context) ? 24.0 : 36,
),
],
),
),
],
),
),
),
),
),
);
},
);

return result ?? ConfirmResult.cancel;
}
25 changes: 14 additions & 11 deletions lib/widgets/twake_components/twake_text_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,23 @@ class TwakeTextButton extends StatelessWidget {
hoverColor: hoverColor,
borderRadius: BorderRadius.circular(borderHover ?? 0),
child: Container(
height: 48,
padding: margin,
decoration:
buttonDecoration ?? const BoxDecoration(shape: BoxShape.circle),
child: Tooltip(
preferBelow: preferBelow,
message: message,
child: Padding(
padding: EdgeInsets.all(paddingAll ?? 8.0),
child: Text(
message,
style: styleMessage ??
Theme.of(context).textTheme.labelLarge?.copyWith(
color: LinagoraSysColors.material().onPrimary,
),
child: Center(
child: Tooltip(
preferBelow: preferBelow,
message: message,
child: Padding(
padding: EdgeInsets.all(paddingAll ?? 8.0),
child: Text(
message,
style: styleMessage ??
Theme.of(context).textTheme.labelLarge?.copyWith(
color: LinagoraSysColors.material().onPrimary,
),
),
),
),
),
Expand Down