11import 'package:flutter/material.dart' ;
2- import 'package:flutter/services.dart' ;
32import 'package:flutter_bloc/flutter_bloc.dart' ;
43import 'package:flutter_news_app_web_dashboard_full_source_code/app/bloc/app_bloc.dart' ;
54import 'package:flutter_news_app_web_dashboard_full_source_code/app/config/config.dart' ;
65import 'package:flutter_news_app_web_dashboard_full_source_code/authentication/bloc/authentication_bloc.dart' ;
76import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart' ;
7+ import 'package:pinput/pinput.dart' ;
88import 'package:ui_kit/ui_kit.dart' ;
99
1010/// {@template email_code_verification_page}
@@ -131,10 +131,12 @@ class _EmailCodeVerificationFormState
131131 extends State <_EmailCodeVerificationForm > {
132132 final _formKey = GlobalKey <FormState >();
133133 final _codeController = TextEditingController ();
134+ final _focusNode = FocusNode ();
134135
135136 @override
136137 void dispose () {
137138 _codeController.dispose ();
139+ _focusNode.dispose ();
138140 super .dispose ();
139141 }
140142
@@ -153,39 +155,48 @@ class _EmailCodeVerificationFormState
153155 Widget build (BuildContext context) {
154156 final l10n = AppLocalizationsX (context).l10n;
155157 final textTheme = Theme .of (context).textTheme;
158+ final colorScheme = Theme .of (context).colorScheme;
159+
160+ final defaultPinTheme = PinTheme (
161+ width: 56 ,
162+ height: 60 ,
163+ textStyle: textTheme.headlineSmall,
164+ decoration: BoxDecoration (
165+ color: colorScheme.surface,
166+ borderRadius: BorderRadius .circular (8 ),
167+ border: Border .all (color: colorScheme.onSurface.withOpacity (0.12 )),
168+ ),
169+ );
156170
157171 return Form (
158172 key: _formKey,
159173 child: Column (
160174 mainAxisSize: MainAxisSize .min,
161175 children: [
162- Padding (
163- // No horizontal padding needed if column is stretched
164- // padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md),
165- padding: EdgeInsets .zero,
166- child: TextFormField (
167- controller: _codeController,
168- decoration: InputDecoration (
169- labelText: l10n.emailCodeVerificationHint,
170- // border: const OutlineInputBorder(),
171- counterText: '' ,
176+ Pinput (
177+ length: 6 ,
178+ controller: _codeController,
179+ focusNode: _focusNode,
180+ defaultPinTheme: defaultPinTheme,
181+ onCompleted: (pin) => _submitForm (),
182+ validator: (value) {
183+ if (value == null || value.isEmpty) {
184+ return l10n.emailCodeValidationEmptyError;
185+ }
186+ if (value.length != 6 ) {
187+ return l10n.emailCodeValidationLengthError;
188+ }
189+ return null ;
190+ },
191+ focusedPinTheme: defaultPinTheme.copyWith (
192+ decoration: defaultPinTheme.decoration! .copyWith (
193+ border: Border .all (color: colorScheme.primary),
194+ ),
195+ ),
196+ errorPinTheme: defaultPinTheme.copyWith (
197+ decoration: defaultPinTheme.decoration! .copyWith (
198+ border: Border .all (color: colorScheme.error),
172199 ),
173- keyboardType: TextInputType .number,
174- inputFormatters: [FilteringTextInputFormatter .digitsOnly],
175- maxLength: 6 ,
176- textAlign: TextAlign .center,
177- style: textTheme.headlineSmall,
178- enabled: ! widget.isLoading,
179- validator: (value) {
180- if (value == null || value.isEmpty) {
181- return l10n.emailCodeValidationEmptyError;
182- }
183- if (value.length != 6 ) {
184- return l10n.emailCodeValidationLengthError;
185- }
186- return null ;
187- },
188- onFieldSubmitted: widget.isLoading ? null : (_) => _submitForm (),
189200 ),
190201 ),
191202 const SizedBox (height: AppSpacing .xxl),
0 commit comments