Skip to content

Commit 57194f2

Browse files
committed
refactor(authentication): migrate to AuthLayout and simplify UI code
- Replace custom layout with AuthLayout widget - Remove nested padding and center widgets - Simplify column structure and reduce indentation - Adjust spacing and alignment using AuthLayout
1 parent 478b449 commit 57194f2

File tree

1 file changed

+52
-58
lines changed

1 file changed

+52
-58
lines changed

lib/authentication/view/email_code_verification_page.dart

Lines changed: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:flutter_news_app_web_dashboard_full_source_code/app/bloc/app_bloc.dart';
44
import 'package:flutter_news_app_web_dashboard_full_source_code/app/config/config.dart';
55
import 'package:flutter_news_app_web_dashboard_full_source_code/authentication/bloc/authentication_bloc.dart';
6+
import 'package:flutter_news_app_web_dashboard_full_source_code/authentication/widgets/auth_layout.dart';
67
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
78
import 'package:pinput/pinput.dart';
89
import 'package:ui_kit/ui_kit.dart';
@@ -45,65 +46,58 @@ class EmailCodeVerificationPage extends StatelessWidget {
4546
builder: (context, state) {
4647
final isLoading = state.status == AuthenticationStatus.loading;
4748

48-
return Padding(
49-
padding: const EdgeInsets.all(AppSpacing.paddingLarge),
50-
child: Center(
51-
child: SingleChildScrollView(
52-
child: Column(
53-
mainAxisAlignment: MainAxisAlignment.center,
54-
crossAxisAlignment: CrossAxisAlignment.stretch,
55-
children: [
56-
Icon(
57-
Icons.mark_email_read_outlined,
58-
size: AppSpacing.xxl * 2,
59-
color: colorScheme.primary,
60-
),
61-
const SizedBox(height: AppSpacing.xl),
62-
Text(
63-
l10n.emailCodeSentConfirmation(email),
64-
style: textTheme.headlineSmall?.copyWith(
65-
fontWeight: FontWeight.bold,
66-
),
67-
textAlign: TextAlign.center,
68-
),
69-
const SizedBox(height: AppSpacing.lg),
70-
Text(
71-
l10n.emailCodeSentInstructions,
72-
style: textTheme.bodyLarge?.copyWith(
73-
color: colorScheme.onSurfaceVariant,
74-
),
75-
textAlign: TextAlign.center,
76-
),
77-
// Display demo code if in demo environment
78-
BlocSelector<AppBloc, AppState, AppEnvironment?>(
79-
selector: (state) => state.environment,
80-
builder: (context, environment) {
81-
if (environment == AppEnvironment.demo) {
82-
return Column(
83-
children: [
84-
const SizedBox(height: AppSpacing.md),
85-
Text(
86-
l10n.demoCodeHint('123456'),
87-
style: textTheme.bodyMedium?.copyWith(
88-
color: colorScheme.secondary,
89-
fontWeight: FontWeight.bold,
90-
),
91-
textAlign: TextAlign.center,
92-
),
93-
],
94-
);
95-
}
96-
return const SizedBox.shrink();
97-
},
98-
),
99-
const SizedBox(height: AppSpacing.xl),
100-
_EmailCodeVerificationForm(
101-
email: email,
102-
isLoading: isLoading,
103-
),
104-
],
49+
return AuthLayout(
50+
child: Column(
51+
mainAxisAlignment: MainAxisAlignment.center,
52+
crossAxisAlignment: CrossAxisAlignment.stretch,
53+
children: [
54+
Icon(
55+
Icons.mark_email_read_outlined,
56+
size: AppSpacing.xxl * 2,
57+
color: colorScheme.primary,
10558
),
106-
),
59+
const SizedBox(height: AppSpacing.xl),
60+
Text(
61+
l10n.emailCodeSentConfirmation(email),
62+
style: textTheme.headlineSmall?.copyWith(
63+
fontWeight: FontWeight.bold,
64+
),
65+
textAlign: TextAlign.center,
66+
),
67+
const SizedBox(height: AppSpacing.lg),
68+
Text(
69+
l10n.emailCodeSentInstructions,
70+
style: textTheme.bodyLarge?.copyWith(
71+
color: colorScheme.onSurfaceVariant,
72+
),
73+
textAlign: TextAlign.center,
74+
),
75+
// Display demo code if in demo environment
76+
BlocSelector<AppBloc, AppState, AppEnvironment?>(
77+
selector: (state) => state.environment,
78+
builder: (context, environment) {
79+
if (environment == AppEnvironment.demo) {
80+
return Padding(
81+
padding: const EdgeInsets.only(top: AppSpacing.md),
82+
child: Text(
83+
l10n.demoCodeHint('123456'),
84+
style: textTheme.bodyMedium?.copyWith(
85+
color: colorScheme.secondary,
86+
fontWeight: FontWeight.bold,
87+
),
88+
textAlign: TextAlign.center,
89+
),
90+
);
91+
}
92+
return const SizedBox.shrink();
93+
},
94+
),
95+
const SizedBox(height: AppSpacing.xl),
96+
_EmailCodeVerificationForm(
97+
email: email,
98+
isLoading: isLoading,
99+
),
100+
],
107101
),
108102
);
109103
},

0 commit comments

Comments
 (0)