Skip to content

Commit

Permalink
TW-1942: Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
hieutbui committed Jul 16, 2024
1 parent 827e0a1 commit 94fd5c8
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/pages/settings_dashboard/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,25 @@ class SettingsController extends State<Settings> with ConnectPageMixin {
'SettingsController()::logoutAction - Twake context is null',
);
}
if (await showOkCancelAlertDialog(
useRootNavigator: false,
// if (await showOkCancelAlertDialog(
// useRootNavigator: false,
// context: twakeContext!,
// title: L10n.of(context)!.areYouSureYouWantToLogout,
// message: L10n.of(context)!.noBackupWarning,
// isDestructiveAction: noBackup,
// okLabel: L10n.of(context)!.logout,
// cancelLabel: L10n.of(context)!.cancel,
// ) ==
// OkCancelResult.cancel) {
// return;
// }
if (await showConfirmAlertDialog(
context: twakeContext!,
title: L10n.of(context)!.areYouSureYouWantToLogout,
message: L10n.of(context)!.noBackupWarning,
isDestructiveAction: noBackup,
okLabel: L10n.of(context)!.logout,
cancelLabel: L10n.of(context)!.cancel,
useRootNavigator: false,
) ==
OkCancelResult.cancel) {
ConfirmResult.cancel) {
return;
}
if (PlatformInfos.isMobile) {
Expand Down
60 changes: 60 additions & 0 deletions lib/utils/dialog/twake_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
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/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 +230,60 @@ class ProgressDialog extends StatelessWidget {
);
}
}

enum ConfirmResult {
ok,
cancel,
}

Future<ConfirmResult> showConfirmAlertDialog({
required BuildContext context,
bool useRootNavigator = true,
String? title,
String? message,
String? okLabel,
String? cancelLabel,
bool barrierDismissible = true,
void Function()? onClose,
}) async {
final result = await showModal<ConfirmResult>(
context: context,
configuration: FadeScaleTransitionConfiguration(
barrierDismissible: barrierDismissible,
),
useRootNavigator: useRootNavigator,
builder: (context) {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: AlertDialog(
title: title != null ? Text(title) : null,
content: message != null ? Text(message) : null,
icon: Align(
alignment: Alignment.topRight,
child: TwakeIconButton(
icon: Icons.close,
size: 48.0,
iconColor: Theme.of(context).colorScheme.onSurfaceVariant,
onTap: () {
Navigator.of(context).pop(ConfirmResult.cancel);
onClose?.call();
},
),
),
actions: [
TwakeTextButton(
message: okLabel ?? L10n.of(context)!.ok,
onTap: () => Navigator.of(context).pop(ConfirmResult.ok),
),
TwakeTextButton(
message: cancelLabel ?? L10n.of(context)!.cancel,
onTap: () => Navigator.of(context).pop(ConfirmResult.cancel),
),
],
),
);
},
);

return result ?? ConfirmResult.cancel;
}

0 comments on commit 94fd5c8

Please sign in to comment.