Skip to content

Commit 478b449

Browse files
committed
refactor(authentication): implement AuthLayout widget
- Replace custom layout with AuthLayout widget - Simplify UI structure and improve code readability - Enhance maintainability and consistency of authentication page
1 parent d8de5be commit 478b449

File tree

1 file changed

+48
-59
lines changed

1 file changed

+48
-59
lines changed

lib/authentication/view/authentication_page.dart

Lines changed: 48 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:flutter_news_app_web_dashboard_full_source_code/authentication/bloc/authentication_bloc.dart';
4+
import 'package:flutter_news_app_web_dashboard_full_source_code/authentication/widgets/auth_layout.dart';
45
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
56
import 'package:flutter_news_app_web_dashboard_full_source_code/router/routes.dart';
67
import 'package:go_router/go_router.dart';
@@ -52,68 +53,56 @@ class AuthenticationPage extends StatelessWidget {
5253
state.status == AuthenticationStatus.loading ||
5354
state.status == AuthenticationStatus.requestCodeLoading;
5455

55-
return Padding(
56-
padding: const EdgeInsets.all(AppSpacing.paddingLarge),
57-
child: Center(
58-
child: SingleChildScrollView(
59-
child: Column(
60-
mainAxisAlignment: MainAxisAlignment.center,
61-
crossAxisAlignment: CrossAxisAlignment.stretch,
62-
children: [
63-
// --- Icon ---
64-
Padding(
65-
padding: const EdgeInsets.only(bottom: AppSpacing.xl),
66-
child: Icon(
67-
Icons.newspaper,
68-
size: AppSpacing.xxl * 2,
69-
color: colorScheme.primary,
70-
),
71-
),
72-
// --- Headline and Subheadline ---
73-
Text(
74-
l10n.authenticationPageHeadline,
75-
style: textTheme.headlineMedium?.copyWith(
76-
fontWeight: FontWeight.bold,
77-
),
78-
textAlign: TextAlign.center,
79-
),
80-
const SizedBox(height: AppSpacing.md),
81-
Text(
82-
l10n.authenticationPageSubheadline,
83-
style: textTheme.bodyLarge?.copyWith(
84-
color: colorScheme.onSurfaceVariant,
85-
),
86-
textAlign: TextAlign.center,
87-
),
88-
const SizedBox(height: AppSpacing.xxl),
56+
return AuthLayout(
57+
child: Column(
58+
mainAxisAlignment: MainAxisAlignment.center,
59+
crossAxisAlignment: CrossAxisAlignment.stretch,
60+
children: [
61+
// --- Icon ---
62+
Padding(
63+
padding: const EdgeInsets.only(bottom: AppSpacing.xl),
64+
child: Icon(
65+
Icons.newspaper,
66+
size: AppSpacing.xxl * 2,
67+
color: colorScheme.primary,
68+
),
69+
),
70+
// --- Headline and Subheadline ---
71+
Text(
72+
l10n.authenticationPageHeadline,
73+
style: textTheme.headlineMedium?.copyWith(
74+
fontWeight: FontWeight.bold,
75+
),
76+
textAlign: TextAlign.center,
77+
),
78+
const SizedBox(height: AppSpacing.md),
79+
Text(
80+
l10n.authenticationPageSubheadline,
81+
style: textTheme.bodyLarge?.copyWith(
82+
color: colorScheme.onSurfaceVariant,
83+
),
84+
textAlign: TextAlign.center,
85+
),
86+
const SizedBox(height: AppSpacing.xxl),
8987

90-
// --- Email Sign-In Button ---
91-
ElevatedButton.icon(
92-
icon: const Icon(Icons.email_outlined),
93-
onPressed: isLoading
94-
? null
95-
: () {
96-
context.goNamed(Routes.requestCodeName);
97-
},
98-
label: Text(l10n.authenticationEmailSignInButton),
99-
style: ElevatedButton.styleFrom(
100-
padding: const EdgeInsets.symmetric(
101-
vertical: AppSpacing.md,
102-
),
103-
textStyle: textTheme.labelLarge,
104-
),
88+
// --- Email Sign-In Button ---
89+
ElevatedButton.icon(
90+
icon: const Icon(Icons.email_outlined),
91+
onPressed: isLoading
92+
? null
93+
: () => context.goNamed(Routes.requestCodeName),
94+
label: Text(l10n.authenticationEmailSignInButton),
95+
style: ElevatedButton.styleFrom(
96+
padding: const EdgeInsets.symmetric(
97+
vertical: AppSpacing.md,
10598
),
106-
const SizedBox(height: AppSpacing.lg),
107-
108-
// --- Loading Indicator ---
109-
if (isLoading)
110-
const Padding(
111-
padding: EdgeInsets.only(top: AppSpacing.xl),
112-
child: Center(child: CircularProgressIndicator()),
113-
),
114-
],
99+
textStyle: textTheme.labelLarge,
100+
),
115101
),
116-
),
102+
const SizedBox(height: AppSpacing.lg),
103+
if (isLoading)
104+
const Center(child: CircularProgressIndicator()),
105+
],
117106
),
118107
);
119108
},

0 commit comments

Comments
 (0)