Skip to content

Commit 98b6801

Browse files
committed
refactor(authentication): implement AuthLayout in RequestCodePage
This refactoring: - Introduces AuthLayout to wrap the content of _RequestCodeView - Removes redundant padding and center alignment - Simplifies the layout structure
1 parent 57194f2 commit 98b6801

File tree

1 file changed

+55
-62
lines changed

1 file changed

+55
-62
lines changed

lib/authentication/view/request_code_page.dart

Lines changed: 55 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
88
import 'package:flutter_news_app_web_dashboard_full_source_code/app/bloc/app_bloc.dart';
99
import 'package:flutter_news_app_web_dashboard_full_source_code/app/config/config.dart';
1010
import 'package:flutter_news_app_web_dashboard_full_source_code/authentication/bloc/authentication_bloc.dart';
11+
import 'package:flutter_news_app_web_dashboard_full_source_code/authentication/widgets/auth_layout.dart';
1112
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
1213
import 'package:flutter_news_app_web_dashboard_full_source_code/router/routes.dart';
1314
import 'package:go_router/go_router.dart';
@@ -101,69 +102,61 @@ class _RequestCodeView extends StatelessWidget {
101102
final isLoading =
102103
state.status == AuthenticationStatus.requestCodeLoading;
103104

104-
return Padding(
105-
padding: const EdgeInsets.all(AppSpacing.paddingLarge),
106-
child: Center(
107-
child: SingleChildScrollView(
108-
child: Column(
109-
mainAxisAlignment: MainAxisAlignment.center,
110-
crossAxisAlignment: CrossAxisAlignment.stretch,
111-
children: [
112-
// --- Icon ---
113-
Padding(
114-
padding: const EdgeInsets.only(bottom: AppSpacing.xl),
115-
child: Icon(
116-
Icons.email_outlined,
117-
size: AppSpacing.xxl * 2,
118-
color: colorScheme.primary,
119-
),
120-
),
121-
// const SizedBox(height: AppSpacing.lg),
122-
// --- Explanation Text ---
123-
Text(
124-
l10n.requestCodePageHeadline,
125-
style: textTheme.headlineSmall?.copyWith(
126-
fontWeight: FontWeight.bold,
127-
),
128-
textAlign: TextAlign.center,
129-
),
130-
const SizedBox(height: AppSpacing.md),
131-
Text(
132-
l10n.requestCodePageSubheadline,
133-
style: textTheme.bodyLarge?.copyWith(
134-
color: colorScheme.onSurfaceVariant,
135-
),
136-
textAlign: TextAlign.center,
137-
),
138-
// Display demo email if in demo environment
139-
BlocSelector<AppBloc, AppState, AppEnvironment?>(
140-
selector: (state) => state.environment,
141-
builder: (context, environment) {
142-
if (environment == AppEnvironment.demo) {
143-
return Padding(
144-
padding: const EdgeInsets.only(
145-
top: AppSpacing.lg,
146-
),
147-
child: Text(
148-
l10n.demoEmailHint(
149-
'admin@example.com | publisher@example.com',
150-
),
151-
style: textTheme.bodyMedium?.copyWith(
152-
color: colorScheme.secondary,
153-
fontWeight: FontWeight.bold,
154-
),
155-
textAlign: TextAlign.center,
156-
),
157-
);
158-
}
159-
return const SizedBox.shrink();
160-
},
161-
),
162-
const SizedBox(height: AppSpacing.xxl),
163-
_EmailLinkForm(isLoading: isLoading),
164-
],
105+
return AuthLayout(
106+
child: Column(
107+
mainAxisAlignment: MainAxisAlignment.center,
108+
crossAxisAlignment: CrossAxisAlignment.stretch,
109+
children: [
110+
// --- Icon ---
111+
Padding(
112+
padding: const EdgeInsets.only(bottom: AppSpacing.xl),
113+
child: Icon(
114+
Icons.email_outlined,
115+
size: AppSpacing.xxl * 2,
116+
color: colorScheme.primary,
117+
),
118+
),
119+
// --- Explanation Text ---
120+
Text(
121+
l10n.requestCodePageHeadline,
122+
style: textTheme.headlineSmall?.copyWith(
123+
fontWeight: FontWeight.bold,
124+
),
125+
textAlign: TextAlign.center,
126+
),
127+
const SizedBox(height: AppSpacing.md),
128+
Text(
129+
l10n.requestCodePageSubheadline,
130+
style: textTheme.bodyLarge?.copyWith(
131+
color: colorScheme.onSurfaceVariant,
132+
),
133+
textAlign: TextAlign.center,
134+
),
135+
// Display demo email if in demo environment
136+
BlocSelector<AppBloc, AppState, AppEnvironment?>(
137+
selector: (state) => state.environment,
138+
builder: (context, environment) {
139+
if (environment == AppEnvironment.demo) {
140+
return Padding(
141+
padding: const EdgeInsets.only(top: AppSpacing.lg),
142+
child: Text(
143+
l10n.demoEmailHint(
144+
'admin@example.com | publisher@example.com',
145+
),
146+
style: textTheme.bodyMedium?.copyWith(
147+
color: colorScheme.secondary,
148+
fontWeight: FontWeight.bold,
149+
),
150+
textAlign: TextAlign.center,
151+
),
152+
);
153+
}
154+
return const SizedBox.shrink();
155+
},
165156
),
166-
),
157+
const SizedBox(height: AppSpacing.xxl),
158+
_EmailLinkForm(isLoading: isLoading),
159+
],
167160
),
168161
);
169162
},

0 commit comments

Comments
 (0)