Skip to content

Commit

Permalink
feat: add option to go back from user settings signup page by logging…
Browse files Browse the repository at this point in the history
… out (#1870)
  • Loading branch information
ggurdin authored Feb 20, 2025
1 parent 8a4ca7e commit 2012c45
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
4 changes: 3 additions & 1 deletion lib/pangea/login/pages/pangea_login_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ class PangeaLoginScaffold extends StatelessWidget {
final Uint8List? mainAssetBytes;
final List<Widget> children;
final bool showAppName;
final AppBar? customAppBar;

const PangeaLoginScaffold({
required this.children,
this.mainAssetPath = "assets/pangea/PangeaChat_Glow_Logo.png",
this.mainAssetBytes,
this.showAppName = true,
this.customAppBar,
super.key,
});

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(),
appBar: customAppBar ?? AppBar(),
body: LayoutBuilder(
builder: (context, constraints) {
return SingleChildScrollView(
Expand Down
9 changes: 9 additions & 0 deletions lib/pangea/login/pages/user_settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:fluffychat/pangea/login/pages/pangea_login_scaffold.dart';
import 'package:fluffychat/pangea/login/pages/user_settings.dart';
import 'package:fluffychat/pangea/login/widgets/full_width_button.dart';
import 'package:fluffychat/pangea/login/widgets/tos_checkbox.dart';
import 'package:fluffychat/pangea/user/utils/p_logout.dart';

class UserSettingsView extends StatelessWidget {
final UserSettingsState controller;
Expand Down Expand Up @@ -69,6 +70,14 @@ class UserSettingsView extends StatelessWidget {
return Form(
key: controller.formKey,
child: PangeaLoginScaffold(
customAppBar: AppBar(
leading: BackButton(
onPressed: () => pLogoutAction(
context,
bypassWarning: true,
),
),
),
showAppName: false,
mainAssetPath: controller.selectedAvatarPath ?? "",
mainAssetBytes: controller.avatar,
Expand Down
29 changes: 18 additions & 11 deletions lib/pangea/user/utils/p_logout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.
import 'package:fluffychat/widgets/future_loading_dialog.dart';
import 'package:fluffychat/widgets/matrix.dart';

void pLogoutAction(BuildContext context, {bool? isDestructiveAction}) async {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context).areYouSureYouWantToLogout,
message: L10n.of(context).dontForgetPassword,
okLabel: L10n.of(context).logout,
cancelLabel: L10n.of(context).cancel,
) ==
OkCancelResult.cancel) {
return;
void pLogoutAction(
BuildContext context, {
bool? isDestructiveAction,
bool bypassWarning = false,
}) async {
if (!bypassWarning) {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context).areYouSureYouWantToLogout,
message: L10n.of(context).dontForgetPassword,
okLabel: L10n.of(context).logout,
cancelLabel: L10n.of(context).cancel,
) ==
OkCancelResult.cancel) {
return;
}
}

final matrix = Matrix.of(context);

// before wiping out locally cached construct data, save it to the server
Expand Down

0 comments on commit 2012c45

Please sign in to comment.