@@ -7,45 +7,35 @@ class PasswordField extends StatelessWidget {
77
88 @override
99 Widget build (BuildContext context) {
10- // [BlocSelector] is not used because widget depends on both
11- // [state.isPasswordFocused] and [state.obscurePassword].
12- return BlocBuilder <LoginBloc , LoginState >(
13- builder: (context, state) {
14- return Stack (
15- alignment: Alignment .centerRight,
16- children: < Widget > [
17- TextInput (
18- action: TextInputAction .done,
19- hint: 'Password' ,
20- keyboard: TextInputType .visiblePassword,
21- obscureText: state.obscurePassword,
22- onChanged: (value) =>
23- context.read <LoginBloc >().add (PasswordInput (value)),
24- prefix: Padding (
25- padding: EdgeInsets .symmetric (
26- horizontal: 8. r,
27- vertical: 10. r,
28- ),
29- child: SvgPicture .asset (
30- AppAssets .lock,
31- // TODO(BURG3R5): Deal with Focus transfer.
32- color: (state.isPasswordFocused)
33- ? AppColors .primary
34- : AppColors .grey1,
35- ),
36- ),
10+ return BlocSelector <LoginBloc , LoginState , bool >(
11+ selector: (state) => state.obscurePassword,
12+ builder: (context, obscurePassword) {
13+ return TextInput (
14+ action: TextInputAction .done,
15+ hint: 'Password' ,
16+ keyboard: TextInputType .visiblePassword,
17+ obscureText: obscurePassword,
18+ onChanged: (value) =>
19+ context.read <LoginBloc >().add (PasswordInput (value)),
20+ prefix: Padding (
21+ padding: EdgeInsets .symmetric (
22+ horizontal: 8. r,
23+ vertical: 10. r,
24+ ),
25+ // TODO(BURG3R5): Deal with Focus transfer.
26+ child: const ImageIcon (
27+ Svg (AppAssets .lock),
3728 ),
38- IconButton (
39- icon: SvgPicture .asset (
40- (state.obscurePassword) ? AppAssets .eyeOff : AppAssets .eyeOn,
41- color: state.isPasswordFocused
42- ? AppColors .primary
43- : AppColors .grey1,
29+ ),
30+ suffix: IconButton (
31+ icon: ImageIcon (
32+ Svg (
33+ obscurePassword ? AppAssets .eyeOff : AppAssets .eyeOn,
4434 ),
45- onPressed: () =>
46- context.read <LoginBloc >().add (const ToggleObscure ()),
4735 ),
48- ],
36+ onPressed: () =>
37+ context.read <LoginBloc >().add (const ToggleObscure ()),
38+ ),
4939 );
5040 },
5141 );
@@ -59,25 +49,18 @@ class UsernameField extends StatelessWidget {
5949
6050 @override
6151 Widget build (BuildContext context) {
62- return BlocSelector <LoginBloc , LoginState , bool >(
63- selector: (state) => state.isUsernameFocused,
64- builder: (context, isUsernameFocused) {
65- return TextInput (
66- hint: 'Username' ,
67- onChanged: (value) =>
68- context.read <LoginBloc >().add (UsernameInput (value)),
69- prefix: Padding (
70- padding: EdgeInsets .symmetric (
71- horizontal: 8. r,
72- vertical: 10. r,
73- ),
74- child: SvgPicture .asset (
75- AppAssets .person,
76- color: isUsernameFocused ? AppColors .primary : AppColors .grey1,
77- ),
78- ),
79- );
80- },
52+ return TextInput (
53+ hint: 'Username' ,
54+ onChanged: (value) => context.read <LoginBloc >().add (UsernameInput (value)),
55+ prefix: Padding (
56+ padding: EdgeInsets .symmetric (
57+ horizontal: 8. r,
58+ vertical: 10. r,
59+ ),
60+ child: const ImageIcon (
61+ Svg (AppAssets .person),
62+ ),
63+ ),
8164 );
8265 }
8366}
0 commit comments