@@ -2,6 +2,8 @@ part of 'signup_widgets.dart';
22
33Widget _pageOne () {
44 return BlocBuilder <SignUpBloc , SignUpState >(
5+ buildWhen: (previous, current) =>
6+ previous.isEmailUnique ^ current.isEmailUnique,
57 builder: (context, state) {
68 return Column (
79 crossAxisAlignment: CrossAxisAlignment .start,
@@ -27,46 +29,55 @@ Widget _pageOne() {
2729 'Institute (optional)' ,
2830 style: AppStyles .h4.copyWith (fontWeight: FontWeight .w900),
2931 ),
32+ _buildInstituteInput (),
3033 SizedBox (height: 8. r),
31- TypeAheadFormField <String >(
32- onSuggestionSelected: (value) =>
33- context.read <SignUpBloc >().add (InstituteInput (value)),
34- itemBuilder: (context, suggestion) =>
35- ListTile (title: Text (suggestion)),
36- textFieldConfiguration: TextFieldConfiguration (
37- onChanged: (value) =>
38- context.read <SignUpBloc >().add (InstituteInput (value)),
39- controller: state.instituteController,
40- decoration: InputDecoration (
41- hintText: 'Enter the name of your institute' ,
42- hintStyle: AppStyles .h6,
43- border: OutlineInputBorder (
44- borderRadius: BorderRadius .circular (2. r),
45- borderSide: const BorderSide (color: AppColors .primary),
46- ),
47- focusedBorder: const OutlineInputBorder (
48- borderSide: BorderSide (
49- color: AppColors .primary,
50- width: 1.5 ,
51- ),
52- ),
34+ ],
35+ );
36+ },
37+ );
38+ }
39+
40+ Widget _buildInstituteInput () {
41+ return BlocSelector <SignUpBloc , SignUpState , TextEditingController ?>(
42+ selector: (state) => state.instituteController,
43+ builder: (context, controller) {
44+ return TypeAheadFormField <String >(
45+ onSuggestionSelected: (value) =>
46+ context.read <SignUpBloc >().add (InstituteInput (value)),
47+ itemBuilder: (context, suggestion) => ListTile (title: Text (suggestion)),
48+ textFieldConfiguration: TextFieldConfiguration (
49+ onSubmitted: (value) =>
50+ context.read <SignUpBloc >().add (InstituteInput (value)),
51+ controller: controller,
52+ decoration: InputDecoration (
53+ hintText: 'Enter the name of your institute' ,
54+ hintStyle: AppStyles .h6,
55+ border: OutlineInputBorder (
56+ borderRadius: BorderRadius .circular (2. r),
57+ borderSide: const BorderSide (color: AppColors .primary),
58+ ),
59+ focusedBorder: const OutlineInputBorder (
60+ borderSide: BorderSide (
61+ color: AppColors .primary,
62+ width: 1.5 ,
5363 ),
5464 ),
55- suggestionsCallback: (pattern) {
56- pattern = pattern.toLowerCase ();
57- return SignUpBloc .institutes.where (
58- (element) => element.toLowerCase ().contains (pattern),
59- );
60- },
6165 ),
62- ],
66+ ),
67+ suggestionsCallback: (pattern) {
68+ pattern = pattern.toLowerCase ();
69+ return SignUpBloc .institutes.where (
70+ (element) => element.toLowerCase ().contains (pattern),
71+ );
72+ },
6373 );
6474 },
6575 );
6676}
6777
6878Widget _pageTwo () {
6979 return BlocBuilder <SignUpBloc , SignUpState >(
80+ buildWhen: (previous, current) => false ,
7081 builder: (context, state) {
7182 return Column (
7283 crossAxisAlignment: CrossAxisAlignment .start,
@@ -199,7 +210,7 @@ Widget _pageThree() {
199210 border: Border .all (color: AppColors .grey1),
200211 borderRadius: BorderRadius .circular (90. r),
201212 ),
202- child: SvgPicture .asset (
213+ child: svg. SvgPicture .asset (
203214 AppAssets .defaultUserIcon,
204215 fit: BoxFit .fill,
205216 ),
@@ -245,6 +256,8 @@ Widget _pageThree() {
245256
246257Widget _pageFour () {
247258 return BlocBuilder <SignUpBloc , SignUpState >(
259+ buildWhen: (previous, current) =>
260+ previous.obscurePassword ^ current.obscurePassword,
248261 builder: (context, state) {
249262 return Column (
250263 crossAxisAlignment: CrossAxisAlignment .start,
@@ -266,50 +279,38 @@ Widget _pageFour() {
266279 horizontal: 8. r,
267280 vertical: 10. r,
268281 ),
269- child: SvgPicture .asset (
270- AppAssets .person,
271- color: state.isUsernameFocused
272- ? AppColors .primary
273- : AppColors .grey1,
282+ child: const ImageIcon (
283+ Svg (AppAssets .person),
274284 ),
275285 ),
276286 ),
277287 SizedBox (height: 34. r),
278- Stack (
279- alignment: Alignment .centerRight,
280- children: < Widget > [
281- TextInput (
282- action: TextInputAction .done,
283- hint: 'Password' ,
284- keyboard: TextInputType .visiblePassword,
285- obscureText: state.obscurePassword,
286- controller: state.passwordController,
287- onChanged: (value) =>
288- context.read <SignUpBloc >().add (PasswordInput (value)),
289- prefix: Padding (
290- padding: EdgeInsets .symmetric (
291- horizontal: 8. r,
292- vertical: 10. r,
293- ),
294- child: SvgPicture .asset (
295- AppAssets .lock,
296- color: (state.isPasswordFocused)
297- ? AppColors .primary
298- : AppColors .grey1,
299- ),
300- ),
288+ TextInput (
289+ action: TextInputAction .done,
290+ hint: 'Password' ,
291+ keyboard: TextInputType .visiblePassword,
292+ obscureText: state.obscurePassword,
293+ controller: state.passwordController,
294+ onChanged: (value) =>
295+ context.read <SignUpBloc >().add (PasswordInput (value)),
296+ prefix: Padding (
297+ padding: EdgeInsets .symmetric (
298+ horizontal: 8. r,
299+ vertical: 10. r,
301300 ),
302- IconButton (
303- icon: SvgPicture .asset (
304- (state.obscurePassword) ? AppAssets .eyeOff : AppAssets .eyeOn,
305- color: state.isPasswordFocused
306- ? AppColors .primary
307- : AppColors .grey1,
301+ child: const ImageIcon (
302+ Svg (AppAssets .lock),
303+ ),
304+ ),
305+ suffix: IconButton (
306+ icon: ImageIcon (
307+ Svg (
308+ state.obscurePassword ? AppAssets .eyeOff : AppAssets .eyeOn,
308309 ),
309- onPressed: () =>
310- context.read <SignUpBloc >().add (const ToggleObscure ()),
311310 ),
312- ],
311+ onPressed: () =>
312+ context.read <SignUpBloc >().add (const ToggleObscure ()),
313+ ),
313314 ),
314315 ],
315316 );
0 commit comments