Skip to content

Commit 383e43e

Browse files
author
Enguerrand ARMINJON
committed
Feature: Custoom profile page
1 parent 1a7104f commit 383e43e

3 files changed

Lines changed: 29 additions & 14 deletions

File tree

packages/firebase_ui_auth/lib/src/screens/profile_screen.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,9 @@ class ProfileScreen extends MultiProviderScreen {
754754
/// {@macro ui.auth.widgets.delete_account_button.show_delete_confirmation_dialog}
755755
final bool showDeleteConfirmationDialog;
756756

757+
/// {@macro ui.auth.widgets.delete_account_button.delete_confirmation}
758+
final Future<bool> Function(BuildContext context)? deleteConfirmation;
759+
757760
const ProfileScreen({
758761
super.key,
759762
super.auth,
@@ -770,6 +773,7 @@ class ProfileScreen extends MultiProviderScreen {
770773
this.showMFATile = false,
771774
this.showUnlinkConfirmationDialog = false,
772775
this.showDeleteConfirmationDialog = false,
776+
this.deleteConfirmation,
773777
});
774778

775779
Future<bool> _reauthenticate(BuildContext context) {
@@ -931,6 +935,7 @@ class ProfileScreen extends MultiProviderScreen {
931935
DeleteAccountButton(
932936
auth: auth,
933937
showDeleteConfirmationDialog: showDeleteConfirmationDialog,
938+
deleteConfirmation: deleteConfirmation,
934939
onSignInRequired: () {
935940
return _reauthenticate(context);
936941
},

packages/firebase_ui_auth/lib/src/styling/theme.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ StylesMap _buildStylesMap(Set<FirebaseUIStyle> styles) {
2222
/// Shouldn't be used if you're using pre-built screens, but could be used
2323
/// if you're building your own and using only widgets from the FirebaseUI.
2424
class FirebaseUITheme extends InheritedModel {
25-
/// A set of styles that need to be provded down the widget tree.
25+
/// A set of styles that need to be provided down the widget tree.
2626
final Set<FirebaseUIStyle> styles;
2727

2828
const FirebaseUITheme({

packages/firebase_ui_auth/lib/src/widgets/delete_account_button.dart

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class DeleteAccountButton extends StatefulWidget {
6363
/// {@endtemplate}
6464
final bool showDeleteConfirmationDialog;
6565

66+
/// {@template ui.auth.widgets.delete_account_button.delete_confirmation}
67+
/// A callback to replace the default account deletion modal.
68+
/// {@endtemplate}
69+
final Future<bool> Function(BuildContext context)? deleteConfirmation;
70+
6671
/// {@macro ui.auth.widgets.delete_account_button}
6772
const DeleteAccountButton({
6873
super.key,
@@ -71,6 +76,7 @@ class DeleteAccountButton extends StatefulWidget {
7176
this.onDeleteFailed,
7277
this.variant = ButtonVariant.filled,
7378
this.showDeleteConfirmationDialog = false,
79+
this.deleteConfirmation,
7480
});
7581

7682
@override
@@ -91,19 +97,23 @@ class _DeleteAccountButtonState extends State<DeleteAccountButton> {
9197
if (!confirmed) {
9298
final l = FirebaseUILocalizations.labelsOf(context);
9399

94-
confirmed = await showCupertinoDialog<bool?>(
95-
context: context,
96-
builder: (context) {
97-
return UniversalAlert(
98-
onConfirm: pop(context, true),
99-
onCancel: pop(context, false),
100-
title: l.confirmDeleteAccountAlertTitle,
101-
confirmButtonText: l.confirmDeleteAccountButtonLabel,
102-
cancelButtonText: l.cancelButtonLabel,
103-
message: l.confirmDeleteAccountAlertMessage,
104-
);
105-
},
106-
);
100+
if (widget.deleteConfirmation != null) {
101+
confirmed = await widget.deleteConfirmation!(context);
102+
} else {
103+
confirmed = await showCupertinoDialog<bool?>(
104+
context: context,
105+
builder: (context) {
106+
return UniversalAlert(
107+
onConfirm: pop(context, true),
108+
onCancel: pop(context, false),
109+
title: l.confirmDeleteAccountAlertTitle,
110+
confirmButtonText: l.confirmDeleteAccountButtonLabel,
111+
cancelButtonText: l.cancelButtonLabel,
112+
message: l.confirmDeleteAccountAlertMessage,
113+
);
114+
},
115+
);
116+
}
107117
}
108118

109119
if (!(confirmed ?? false)) return;

0 commit comments

Comments
 (0)