This commit is contained in:
Felipe
2024-02-27 17:32:16 -05:00
parent 906ebb4330
commit a71fc9efb6
17 changed files with 1189 additions and 526 deletions
+116 -85
View File
@@ -24,6 +24,7 @@ class _SignInScreenState extends State<SignInScreen> {
@override
Widget build(BuildContext context) {
final width = MediaQuery.of(context).size.width;
return BlocListener<SignInBloc, SignInState>(
listener: (context, state) {
if (state is SignInSuccess) {
@@ -41,103 +42,133 @@ class _SignInScreenState extends State<SignInScreen> {
});
}
},
child: Form(
key: _formKey,
child: Column(
children: [
const SizedBox(height: 20),
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: MyTextField(
controller: emailController,
hintText: 'Email',
obscureText: false,
keyboardType: TextInputType.emailAddress,
prefixIcon: Icon(
CupertinoIcons.mail_solid,
color: Colors.grey[600],
),
child: Column(
children: [
SizedBox(
width: double.infinity,
child: Row(
children: [
IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(
CupertinoIcons.arrow_left,
size: 30,
),
),
Text(
'Iniciar sesión',
style: TextStyle(
// fontSize: 30,
fontSize: width * 0.08,
fontWeight: FontWeight.bold,
),
),
],
),
),
Form(
key: _formKey,
child: Column(
children: [
const SizedBox(height: 20),
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: MyTextField(
controller: emailController,
hintText: 'Email',
obscureText: false,
keyboardType: TextInputType.emailAddress,
prefixIcon: Icon(
CupertinoIcons.mail_solid,
color: Colors.grey[600],
),
errorMsg: _errorMsg,
validator: (val) {
if (val!.isEmpty) {
return 'Please fill in this field';
} else if (!emailRexExp.hasMatch(val)) {
return 'Please enter a valid email';
}
return null;
}),
),
const SizedBox(height: 10),
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: MyTextField(
controller: passwordController,
hintText: 'Password',
obscureText: obscurePassword,
keyboardType: TextInputType.visiblePassword,
prefixIcon:
Icon(CupertinoIcons.lock_fill, color: Colors.grey[600]),
errorMsg: _errorMsg,
validator: (val) {
if (val!.isEmpty) {
return 'Please fill in this field';
} else if (!emailRexExp.hasMatch(val)) {
return 'Please enter a valid email';
} else if (!passwordRexExp.hasMatch(val)) {
return 'Please enter a valid password';
}
return null;
}),
),
const SizedBox(height: 10),
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: MyTextField(
controller: passwordController,
hintText: 'Password',
obscureText: obscurePassword,
keyboardType: TextInputType.visiblePassword,
prefixIcon:
Icon(CupertinoIcons.lock_fill, color: Colors.grey[600]),
errorMsg: _errorMsg,
validator: (val) {
if (val!.isEmpty) {
return 'Please fill in this field';
} else if (!passwordRexExp.hasMatch(val)) {
return 'Please enter a valid password';
}
return null;
},
suffixIcon: IconButton(
onPressed: () {
setState(() {
obscurePassword = !obscurePassword;
if (obscurePassword) {
iconPassword = CupertinoIcons.eye_fill;
} else {
iconPassword = CupertinoIcons.eye_slash_fill;
}
});
},
icon: Icon(iconPassword, color: Colors.grey[600]),
suffixIcon: IconButton(
onPressed: () {
setState(() {
obscurePassword = !obscurePassword;
if (obscurePassword) {
iconPassword = CupertinoIcons.eye_fill;
} else {
iconPassword = CupertinoIcons.eye_slash_fill;
}
});
},
icon: Icon(iconPassword, color: Colors.grey[600]),
),
),
),
),
const SizedBox(height: 20),
!signInRequired
? SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
height: 50,
child: TextButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
context.read<SignInBloc>().add(SignInRequired(
emailController.text, passwordController.text));
}
},
style: TextButton.styleFrom(
elevation: 3.0,
backgroundColor:
Theme.of(context).colorScheme.primary,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(60))),
child: const Padding(
padding:
EdgeInsets.symmetric(horizontal: 25, vertical: 5),
child: Text(
'Iniciar Sesión',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600,
const SizedBox(height: 20),
!signInRequired
? SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
height: 50,
child: TextButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
context.read<SignInBloc>().add(SignInRequired(
emailController.text,
passwordController.text));
}
},
style: TextButton.styleFrom(
elevation: 3.0,
backgroundColor:
Theme.of(context).colorScheme.primary,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(60))),
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: 25, vertical: 5),
child: Text(
'Iniciar Sesión',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
),
),
)
: const CircularProgressIndicator()
],
)),
)
: const CircularProgressIndicator()
],
),
),
],
),
);
}
}