Skip to content

Commit

Permalink
feat: add signout dialog (#4557)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 authored Jan 30, 2024
1 parent 18c7fff commit f6242f1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ class MobileHiddenGroup extends StatelessWidget {
),
onTap: () => showFlowyMobileConfirmDialog(
context,
title: LocaleKeys.board_mobile_unhideGroup.tr(),
content: LocaleKeys.board_mobile_unhideGroupContent.tr(),
title: FlowyText(LocaleKeys.board_mobile_unhideGroup.tr()),
content: FlowyText(
LocaleKeys.board_mobile_unhideGroupContent.tr(),
),
actionButtonTitle: LocaleKeys.button_yes.tr(),
actionButtonColor: Theme.of(context).colorScheme.primary,
onActionButtonPressed: () => context.read<BoardBloc>().add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:appflowy/mobile/presentation/widgets/widgets.dart';
import 'package:appflowy/plugins/trash/application/prelude.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:fluttertoast/fluttertoast.dart';
Expand Down Expand Up @@ -107,12 +108,16 @@ class _TrashActionAllButton extends StatelessWidget {
context.pop();
showFlowyMobileConfirmDialog(
context,
title: isDeleteAll
? LocaleKeys.trash_confirmDeleteAll_title.tr()
: LocaleKeys.trash_restoreAll.tr(),
content: isDeleteAll
? LocaleKeys.trash_confirmDeleteAll_caption.tr()
: LocaleKeys.trash_confirmRestoreAll_caption.tr(),
title: FlowyText(
isDeleteAll
? LocaleKeys.trash_confirmDeleteAll_title.tr()
: LocaleKeys.trash_restoreAll.tr(),
),
content: FlowyText(
isDeleteAll
? LocaleKeys.trash_confirmDeleteAll_caption.tr()
: LocaleKeys.trash_confirmRestoreAll_caption.tr(),
),
actionButtonTitle: isDeleteAll
? LocaleKeys.trash_deleteAll.tr()
: LocaleKeys.trash_restoreAll.tr(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/widgets/show_flowy_mobile_confirm_dialog.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/user/application/auth/auth_service.dart';
import 'package:appflowy/user/application/sign_in_bloc.dart';
Expand Down Expand Up @@ -44,8 +45,18 @@ class UserSessionSettingGroup extends StatelessWidget {
MobileSignInOrLogoutButton(
labelText: LocaleKeys.settings_menu_logout.tr(),
onPressed: () async {
await getIt<AuthService>().signOut();
await runAppFlowy();
await showFlowyMobileConfirmDialog(
context,
content: FlowyText(
LocaleKeys.settings_menu_logoutPrompt.tr(),
),
actionButtonTitle: LocaleKeys.button_yes.tr(),
actionButtonColor: Theme.of(context).colorScheme.error,
onActionButtonPressed: () async {
await getIt<AuthService>().signOut();
await runAppFlowy();
},
);
},
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'package:flutter/material.dart';
///[onActionButtonPressed] and [onCancelButtonPressed] end with close the dialog
Future<T?> showFlowyMobileConfirmDialog<T>(
BuildContext context, {
String? title,
String? content,
Widget? title,
Widget? content,
required String actionButtonTitle,
Color? actionButtonColor,
String? cancelButtonTitle,
Expand All @@ -18,13 +18,9 @@ Future<T?> showFlowyMobileConfirmDialog<T>(
context: context,
builder: (dialogContext) {
final foregroundColor = Theme.of(context).colorScheme.onSurface;
return AlertDialog(
title: Text(
title ?? "",
),
content: Text(
content ?? "",
),
return AlertDialog.adaptive(
title: title,
content: content,
actions: [
TextButton(
child: Text(
Expand All @@ -36,9 +32,7 @@ Future<T?> showFlowyMobileConfirmDialog<T>(
onPressed: () {
onActionButtonPressed?.call();
// we cannot use dialogContext.pop() here because this is no GoRouter in dialogContext. Use Navigator instead to close the dialog.
Navigator.of(
dialogContext,
).pop();
Navigator.of(dialogContext).pop();
},
),
TextButton(
Expand All @@ -50,9 +44,7 @@ Future<T?> showFlowyMobileConfirmDialog<T>(
),
onPressed: () {
onCancelButtonPressed?.call();
Navigator.of(
dialogContext,
).pop();
Navigator.of(dialogContext).pop();
},
),
],
Expand Down

0 comments on commit f6242f1

Please sign in to comment.