Last active
January 14, 2021 07:02
-
-
Save trongdth/d6ebd3ee31937edb9ed1b7d23386cb1f 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 BlocListener<LoginCubit, LoginState>( | |
listener: (context, state) { | |
if (state is LoginFailure) { | |
_scaffoldstate.currentState.showSnackBar(SnackBar(content: Text(state.error))); | |
} else if (state is LoginSuccess) { | |
context.read<AuthCubit>().appStarted(); | |
} | |
}, | |
child: Scaffold( | |
key: _scaffoldstate, | |
appBar: null, | |
body: Align( | |
alignment: Alignment.bottomCenter, | |
child: SingleChildScrollView( | |
padding: const EdgeInsets.fromLTRB(10, 10, 10, 30), | |
child: Form( | |
key: _formKey, | |
child: Column( | |
children: <Widget>[ | |
Align( | |
alignment: Alignment.centerLeft, | |
child: Text( | |
'Sign In', | |
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: 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('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( | |
key: Key('BtnLogin'), | |
onPressed: () => _handleLogin(), | |
title: 'LOGIN', | |
), | |
SizedBox( | |
height: 50, | |
), | |
Container( | |
child: Text( | |
'_____Or_____', | |
style: TextStyle( | |
fontSize: 13.0, | |
color: Theme.of(context).accentColor, | |
), | |
), | |
), | |
SizedBox( | |
height: 50, | |
), | |
ButtonIconWidget( | |
onPressed: _loadSignupScreen, | |
title: 'SIGNUP', | |
), | |
SizedBox( | |
height: 30, | |
), | |
], | |
), | |
), | |
), | |
), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment