Last active
January 14, 2021 07:04
-
-
Save trongdth/b5a1a9280595ec8ea9c8cbca402f4745 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return MultiBlocListener( | |
listeners: [ | |
BlocListener<SignupCubit, SignupState>( | |
listener: (context, state) { | |
if (state is SignupSuccess) { | |
context.read<AuthCubit>().appStarted(); | |
} | |
}, | |
), | |
BlocListener<AuthCubit, AuthenticationState>( | |
listener: (context, state) { | |
if (state is AuthenticationAuthenticated) { | |
Navigator.pushNamedAndRemoveUntil(context, ScreenRouter.ROOT, (route) => false); | |
} | |
}, | |
), | |
], | |
child: Scaffold( | |
appBar: null, | |
body: Form( | |
key: formKey, | |
child: Center( | |
child: SingleChildScrollView( | |
padding: const EdgeInsets.all(10), | |
child: Column( | |
children: <Widget>[ | |
Align( | |
alignment: Alignment.centerLeft, | |
child: Text( | |
'Sign Up', | |
style: Theme.of(context).textTheme.headline5, | |
), | |
), | |
SizedBox( | |
height: 10, | |
), | |
Container( | |
decoration: BoxDecoration( | |
border: Border.all(color: Theme.of(context).accentColor), | |
borderRadius: BorderRadius.all(Radius.circular(4.0)), | |
), | |
child: Padding( | |
padding: const EdgeInsets.fromLTRB(10, 0, 0, 0), | |
child: TextFormField( | |
key: Key('Username'), | |
validator: NameFieldValidator.validate, | |
onSaved: (value) => _username = value, | |
decoration: InputDecoration( | |
border: InputBorder.none, | |
hintText: 'Username', | |
), | |
), | |
), | |
), | |
SizedBox( | |
height: 20, | |
), | |
Container( | |
decoration: BoxDecoration( | |
border: Border.all(color: Theme.of(context).accentColor), | |
borderRadius: BorderRadius.all(Radius.circular(4.0)), | |
), | |
child: Padding( | |
padding: const EdgeInsets.fromLTRB(10, 0, 0, 0), | |
child: TextFormField( | |
key: Key('Email'), | |
validator: EmailFieldValidator.validate, | |
onSaved: (value) => _email = value, | |
decoration: InputDecoration( | |
border: InputBorder.none, | |
hintText: 'Email', | |
), | |
), | |
), | |
), | |
SizedBox( | |
height: 20, | |
), | |
Container( | |
decoration: BoxDecoration( | |
border: Border.all(color: Theme.of(context).accentColor), | |
borderRadius: BorderRadius.all(Radius.circular(4.0)), | |
), | |
child: Row( | |
children: <Widget>[ | |
Expanded( | |
flex: 8, | |
child: Padding( | |
padding: const EdgeInsets.fromLTRB(10, 0, 0, 0), | |
child: TextFormField( | |
key: Key('Password'), | |
validator: PasswordFieldValidator.validate, | |
onSaved: (value) => _password = value, | |
obscureText: (_isShowPwd) ? false : true, | |
decoration: InputDecoration( | |
border: InputBorder.none, | |
hintText: 'Your Password', | |
), | |
), | |
), | |
), | |
Expanded( | |
flex: 2, | |
child: Container( | |
height: 30, | |
margin: const EdgeInsets.symmetric(horizontal: 10), | |
decoration: BoxDecoration( | |
color: Color(0xFFF5F5F5), | |
border: Border.all(color: Color(0xFFF5F5F5)), | |
borderRadius: BorderRadius.all(Radius.circular(4.0)), | |
), | |
child: Center( | |
child: InkWell( | |
onTap: () { | |
setState(() { | |
_isShowPwd = !_isShowPwd; | |
}); | |
}, | |
child: Text( | |
'SHOW', | |
style: TextStyle( | |
fontSize: 12.0, | |
fontWeight: FontWeight.w500, | |
color: Color(0xFF003BFF), | |
), | |
), | |
), | |
), | |
), | |
), | |
], | |
), | |
), | |
SizedBox( | |
height: 40, | |
), | |
ButtonWidget( | |
onPressed: _handleSignup, | |
title: 'SIGN UP', | |
), | |
SizedBox( | |
height: 40, | |
), | |
InkWell( | |
onTap: () => Navigator.pop(context), | |
child: RichText( | |
text: TextSpan( | |
text: 'Already have an account? ', | |
style: Theme.of(context).textTheme.headline4, | |
children: <TextSpan>[ | |
TextSpan( | |
text: 'Sign in', | |
style: TextStyle(decoration: TextDecoration.underline, fontWeight: FontWeight.bold), | |
), | |
], | |
), | |
), | |
), | |
], | |
), | |
), | |
), | |
), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment