Skip to content

Commit a4f6467

Browse files
committed
refactor(auth): Improve linking context navigation
- Pass context as query param - Enable system back navigation
1 parent 935ab10 commit a4f6467

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

lib/authentication/view/authentication_page.dart

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,18 @@ class AuthenticationPage extends StatelessWidget {
4848
backgroundColor: Colors.transparent,
4949
elevation: 0,
5050
// Conditionally add the leading close button only in linking context
51-
leading:
52-
isLinkingContext
53-
? IconButton(
54-
icon: const Icon(Icons.close),
55-
tooltip:
56-
MaterialLocalizations.of(
57-
context,
58-
).closeButtonTooltip, // Accessibility
59-
onPressed: () {
60-
// Navigate back to the account page when close is pressed
61-
context.goNamed(Routes.accountName);
62-
},
63-
)
64-
: null, // No leading button if not linking (relies on system back if pushed)
51+
leading: isLinkingContext
52+
? IconButton(
53+
icon: const Icon(Icons.close),
54+
tooltip: MaterialLocalizations.of(
55+
context,
56+
).closeButtonTooltip, // Accessibility
57+
onPressed: () {
58+
// Navigate back to the account page when close is pressed
59+
context.goNamed(Routes.accountName);
60+
},
61+
)
62+
: null, // No leading button if not linking (relies on system back if pushed)
6563
),
6664
body: SafeArea(
6765
child: BlocConsumer<AuthenticationBloc, AuthenticationState>(
@@ -130,15 +128,16 @@ class AuthenticationPage extends StatelessWidget {
130128
// --- Email Sign-In Button ---
131129
ElevatedButton.icon(
132130
icon: const Icon(Icons.email_outlined),
133-
onPressed:
134-
isLoading
135-
? null
136-
: () {
137-
context.goNamed(
138-
Routes.requestCodeName,
139-
extra: isLinkingContext,
140-
);
141-
},
131+
onPressed: isLoading
132+
? null
133+
: () {
134+
context.goNamed(
135+
Routes.requestCodeName,
136+
queryParameters: isLinkingContext
137+
? {'context': 'linking'}
138+
: const {},
139+
);
140+
},
142141
label: Text(l10n.authenticationEmailSignInButton),
143142
style: ElevatedButton.styleFrom(
144143
padding: const EdgeInsets.symmetric(
@@ -153,12 +152,11 @@ class AuthenticationPage extends StatelessWidget {
153152
if (showAnonymousButton) ...[
154153
OutlinedButton.icon(
155154
icon: const Icon(Icons.person_outline),
156-
onPressed:
157-
isLoading
158-
? null
159-
: () => context.read<AuthenticationBloc>().add(
160-
const AuthenticationAnonymousSignInRequested(),
161-
),
155+
onPressed: isLoading
156+
? null
157+
: () => context.read<AuthenticationBloc>().add(
158+
const AuthenticationAnonymousSignInRequested(),
159+
),
162160
label: Text(l10n.authenticationAnonymousSignInButton),
163161
style: OutlinedButton.styleFrom(
164162
padding: const EdgeInsets.symmetric(

0 commit comments

Comments
 (0)