comp
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ProfileItem extends StatelessWidget {
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final IconData? leading;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const ProfileItem({
|
||||
super.key,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.leading,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
),
|
||||
color: Colors.grey.shade100,
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
subtitle: subtitle == null
|
||||
? null
|
||||
: Text(
|
||||
subtitle ?? '',
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
leading: leading == null
|
||||
? null
|
||||
: Icon(
|
||||
leading,
|
||||
color: Colors.black,
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: Colors.black,
|
||||
),
|
||||
onTap: onTap,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
|
||||
|
||||
class ProfileEmailScreen extends StatefulWidget {
|
||||
const ProfileEmailScreen({super.key});
|
||||
|
||||
@override
|
||||
State<ProfileEmailScreen> createState() => _ProfileEmailScreenState();
|
||||
}
|
||||
|
||||
class _ProfileEmailScreenState extends State<ProfileEmailScreen> {
|
||||
final TextEditingController _emailController = TextEditingController();
|
||||
final TextEditingController _passwordController = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<MyUserBloc, MyUserState>(
|
||||
builder: (context, state) {
|
||||
if (state.status == MyUserStatus.success) {
|
||||
_emailController.text = state.user!.email ?? '';
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
_emailController.text.isEmpty
|
||||
? 'Agregar correo'
|
||||
: 'Actualizar correo',
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
// Centro del contenido
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 40, vertical: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
prefixIcon: Icon(Icons.email_rounded),
|
||||
hintText: 'Email',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10.0),
|
||||
)),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.red, width: 2.0),
|
||||
),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Por favor, ingrese su contraseña';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Contraseña',
|
||||
prefixIcon: Icon(Icons.lock_rounded),
|
||||
hintText: 'Contraseña',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10.0),
|
||||
)),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.red, width: 2.0),
|
||||
),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Por favor, ingrese su contraseña';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
ElevatedButton(
|
||||
onPressed: () {},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.blue,
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
shadowColor: Colors.grey,
|
||||
elevation: 5,
|
||||
),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 300.0, minHeight: 50.0),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'Actualizar',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
|
||||
|
||||
class ProfilePhoneScreen extends StatefulWidget {
|
||||
const ProfilePhoneScreen({super.key});
|
||||
|
||||
@override
|
||||
State<ProfilePhoneScreen> createState() => _ProfilePhoneScreenState();
|
||||
}
|
||||
|
||||
class _ProfilePhoneScreenState extends State<ProfilePhoneScreen> {
|
||||
final TextEditingController _phoneController = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_phoneController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<MyUserBloc, MyUserState>(
|
||||
builder: (context, state) {
|
||||
if (state.status == MyUserStatus.success) {
|
||||
_phoneController.text = state.user!.phone ?? '';
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
_phoneController.text.isEmpty
|
||||
? 'Agregar telefono'
|
||||
: 'Actualizar telefono',
|
||||
),
|
||||
),
|
||||
body: const Placeholder(),
|
||||
);
|
||||
} else {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:prosappco/blocs/auth_bloc/auth_bloc.dart';
|
||||
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
|
||||
import 'package:prosappco/blocs/profile_bloc/profile_bloc.dart';
|
||||
import 'package:prosappco/components/birthday_picker.dart';
|
||||
import 'package:prosappco/components/gender_dropdown.dart';
|
||||
import 'package:prosappco/src/components/pop_appbar.dart';
|
||||
import 'package:prosappco/screens/profile/components/profile_item.dart';
|
||||
import 'package:prosappco/screens/profile/profile_email_screen.dart';
|
||||
import 'package:prosappco/screens/profile/profile_phone_screen.dart';
|
||||
|
||||
class ProfileScreen extends StatefulWidget {
|
||||
const ProfileScreen({super.key});
|
||||
@@ -20,13 +24,19 @@ class ProfileScreen extends StatefulWidget {
|
||||
class _ProfileScreenState extends State<ProfileScreen> {
|
||||
final TextEditingController _nameController = TextEditingController();
|
||||
final TextEditingController _emailController = TextEditingController();
|
||||
final TextEditingController _newEmailController = TextEditingController();
|
||||
final TextEditingController _phoneController = TextEditingController();
|
||||
final TextEditingController _birthdayController = TextEditingController();
|
||||
final TextEditingController _genderController = TextEditingController();
|
||||
final TextEditingController _passwordController = TextEditingController();
|
||||
|
||||
XFile? _imageFile;
|
||||
bool isLoading = false;
|
||||
|
||||
bool enableLoginWithEmail = false;
|
||||
bool obscurePassword = true;
|
||||
IconData iconPassword = CupertinoIcons.eye_fill;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
@@ -34,149 +44,356 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
_phoneController.dispose();
|
||||
_birthdayController.dispose();
|
||||
_genderController.dispose();
|
||||
_passwordController.dispose();
|
||||
_newEmailController.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<ProfileBloc, ProfileState>(
|
||||
listener: (context, state) {
|
||||
if (state is UpdateUserInfoLoading) {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
} else if (state is UpdateUserInfoSuccess) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('Información actualizada'),
|
||||
));
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
} else if (state is UpdateUserInfoFailure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('Error al actualizar la información'),
|
||||
));
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: PopAppbar(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
label: 'Perfil',
|
||||
),
|
||||
body: BlocBuilder<MyUserBloc, MyUserState>(
|
||||
builder: (context, state) {
|
||||
if (state.status == MyUserStatus.success) {
|
||||
_nameController.text = state.user!.name ?? '';
|
||||
_emailController.text = state.user!.email ?? '';
|
||||
_phoneController.text = state.user!.phone ?? '';
|
||||
_birthdayController.text = state.user!.birthday ?? '';
|
||||
_genderController.text = state.user!.gender ?? '';
|
||||
final authBloc = Injector.appInstance.get<AuthBloc>();
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 40, vertical: 20),
|
||||
child: Stack(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
pictureWidget(state, context),
|
||||
const SizedBox(height: 20.0),
|
||||
TextFormField(
|
||||
controller: _nameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nombre',
|
||||
prefixIcon: Icon(Icons.person),
|
||||
hintText: 'Nombre (obligatorio)',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10.0),
|
||||
)),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.red, width: 2.0),
|
||||
),
|
||||
return BlocProvider<AuthBloc>(
|
||||
create: (context) => authBloc,
|
||||
child: BlocListener<ProfileBloc, ProfileState>(
|
||||
listener: (context, state) {
|
||||
if (state is UpdateUserInfoLoading) {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
} else if (state is UpdateUserInfoSuccess) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('Información actualizada'),
|
||||
));
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
} else if (state is UpdateUserInfoFailure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('Error al actualizar la información'),
|
||||
));
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Perfil'),
|
||||
),
|
||||
body: BlocBuilder<MyUserBloc, MyUserState>(
|
||||
builder: (context, state) {
|
||||
if (state.status == MyUserStatus.success) {
|
||||
_nameController.text = state.user!.name ?? '';
|
||||
_emailController.text = state.user!.email ?? '';
|
||||
_phoneController.text = state.user!.phone ?? '';
|
||||
_birthdayController.text = state.user!.birthday ?? '';
|
||||
_genderController.text = state.user!.gender ?? '';
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 40, vertical: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
pictureWidget(state, context),
|
||||
const SizedBox(height: 30),
|
||||
TextFormField(
|
||||
controller: _nameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nombre',
|
||||
prefixIcon: Icon(Icons.person),
|
||||
hintText: 'Nombre (obligatorio)',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10.0),
|
||||
)),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Por favor, ingrese su nombre';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
prefixIcon: Icon(Icons.email_rounded),
|
||||
hintText: 'Email',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10.0),
|
||||
)),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.red, width: 2.0),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.red, width: 2.0),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
TextFormField(
|
||||
controller: _phoneController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Número de Teléfono',
|
||||
prefixIcon: Icon(Icons.phone_android_rounded),
|
||||
hintText: '+57',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10.0),
|
||||
)),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Por favor, ingrese su nombre';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ProfileItem(
|
||||
title: 'Iniciar sesión con correo',
|
||||
subtitle: _emailController.text,
|
||||
leading: Icons.email_rounded,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
const ProfileEmailScreen(),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.red, width: 2.0),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ProfileItem(
|
||||
title: 'Iniciar sesión con teléfono',
|
||||
subtitle: _phoneController.text,
|
||||
leading: Icons.phone_iphone_rounded,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
const ProfilePhoneScreen(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
BirthdayPicker(
|
||||
onDateSelected: (birthDay) {
|
||||
_birthdayController.text =
|
||||
DateFormat('dd/MM/yyyy').format(birthDay);
|
||||
},
|
||||
controller: _birthdayController,
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
GenderDropdown(
|
||||
controller: _genderController,
|
||||
),
|
||||
const SizedBox(height: 60.0),
|
||||
saveButton(state, context),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
// Column(
|
||||
// children: [
|
||||
// const SizedBox(height: 20.0),
|
||||
// TextFormField(
|
||||
// readOnly: true,
|
||||
// controller: _emailController,
|
||||
// decoration: const InputDecoration(
|
||||
// labelText: 'Email',
|
||||
// prefixIcon: Icon(Icons.email_rounded),
|
||||
// hintText: 'Email',
|
||||
// border: OutlineInputBorder(
|
||||
// borderRadius: BorderRadius.all(
|
||||
// Radius.circular(10.0),
|
||||
// )),
|
||||
// errorBorder: OutlineInputBorder(
|
||||
// borderSide: BorderSide(color: Colors.red),
|
||||
// ),
|
||||
// focusedErrorBorder: OutlineInputBorder(
|
||||
// borderSide: BorderSide(
|
||||
// color: Colors.red, width: 2.0),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// const SizedBox(height: 20.0),
|
||||
// TextFormField(
|
||||
// readOnly: true,
|
||||
// controller: _phoneController,
|
||||
// decoration: const InputDecoration(
|
||||
// labelText: 'Número de Teléfono',
|
||||
// prefixIcon: Icon(Icons.phone_android_rounded),
|
||||
// hintText: '+57',
|
||||
// border: OutlineInputBorder(
|
||||
// borderRadius: BorderRadius.all(
|
||||
// Radius.circular(10.0),
|
||||
// )),
|
||||
// errorBorder: OutlineInputBorder(
|
||||
// borderSide: BorderSide(color: Colors.red),
|
||||
// ),
|
||||
// focusedErrorBorder: OutlineInputBorder(
|
||||
// borderSide:
|
||||
// BorderSide(color: Colors.red, width: 2.0),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// _emailController.text.isEmpty
|
||||
// ? Column(
|
||||
// children: [
|
||||
// const SizedBox(height: 20.0),
|
||||
// GeneralCheckbox(
|
||||
// text:
|
||||
// 'Habilitar inicio de sesión con correo (Opcional)',
|
||||
// initialValue: enableLoginWithEmail,
|
||||
// onChanged: (value) {
|
||||
// setState(() {
|
||||
// enableLoginWithEmail = value;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// enableLoginWithEmail
|
||||
// ? Container(
|
||||
// decoration: BoxDecoration(
|
||||
// border: Border.all(
|
||||
// color: Colors.blue,
|
||||
// width: 0.5,
|
||||
// ),
|
||||
// borderRadius:
|
||||
// BorderRadius.circular(10),
|
||||
// ),
|
||||
// padding: const EdgeInsets.all(10),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// TextFormField(
|
||||
// controller:
|
||||
// _newEmailController,
|
||||
// validator: (String? value) {
|
||||
// if (enableLoginWithEmail) {
|
||||
// if (value == null ||
|
||||
// value.isEmpty) {
|
||||
// return 'Por favor ingrese un email';
|
||||
// }
|
||||
// final RegExp
|
||||
// emailRegExp =
|
||||
// RegExp(
|
||||
// r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
|
||||
// if (!emailRegExp
|
||||
// .hasMatch(value)) {
|
||||
// return 'Por favor ingrese un email válido';
|
||||
// }
|
||||
// return null;
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// },
|
||||
// decoration:
|
||||
// const InputDecoration(
|
||||
// prefixIcon: Icon(
|
||||
// Icons.email_rounded),
|
||||
// hintText: 'Email',
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 20.0),
|
||||
// TextFormField(
|
||||
// controller:
|
||||
// _passwordController,
|
||||
// obscureText:
|
||||
// obscurePassword,
|
||||
// validator: (value) {
|
||||
// if (enableLoginWithEmail) {
|
||||
// if (value == null ||
|
||||
// value.isEmpty) {
|
||||
// return 'Por favor ingrese una contraseña.';
|
||||
// }
|
||||
// if (value.length < 5) {
|
||||
// return 'Debe tener al menos 5 caracteres.';
|
||||
// }
|
||||
// return null;
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// },
|
||||
// decoration: InputDecoration(
|
||||
// prefixIcon: const Icon(
|
||||
// Icons.lock_rounded),
|
||||
// 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]),
|
||||
// ),
|
||||
// hintText: 'Contraseña',
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 20),
|
||||
// Container(
|
||||
// margin:
|
||||
// const EdgeInsets.only(
|
||||
// left: 5,
|
||||
// right: 5,
|
||||
// top: 5,
|
||||
// bottom: 5,
|
||||
// ),
|
||||
// padding: const EdgeInsets
|
||||
// .symmetric(
|
||||
// horizontal: 10,
|
||||
// vertical: 8,
|
||||
// ),
|
||||
// decoration: BoxDecoration(
|
||||
// color: const Color(
|
||||
// 0xFFD6F4FF),
|
||||
// borderRadius:
|
||||
// BorderRadius.circular(
|
||||
// 20),
|
||||
// boxShadow: [
|
||||
// BoxShadow(
|
||||
// color: Colors.grey
|
||||
// .withOpacity(0.5),
|
||||
// spreadRadius: 1,
|
||||
// blurRadius: 5,
|
||||
// offset: const Offset(
|
||||
// 1, 3),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// child: const Row(
|
||||
// children: [
|
||||
// Icon(
|
||||
// Icons.error_outline,
|
||||
// size: 20,
|
||||
// color: Colors.black54,
|
||||
// ),
|
||||
// SizedBox(width: 10),
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// 'Al habilitar el inicio de sesión con correo, se cerrara la sesión actual.',
|
||||
// style: TextStyle(
|
||||
// color: Colors
|
||||
// .black54,
|
||||
// fontSize: 13,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// )
|
||||
// : const SizedBox(),
|
||||
// ],
|
||||
// )
|
||||
// : const SizedBox(),
|
||||
_birthdayController.text.isEmpty &&
|
||||
_genderController.text.isEmpty
|
||||
? Column(
|
||||
children: [
|
||||
const SizedBox(height: 20.0),
|
||||
BirthdayPicker(
|
||||
onDateSelected: (birthDay) {
|
||||
_birthdayController.text =
|
||||
DateFormat('dd/MM/yyyy')
|
||||
.format(birthDay);
|
||||
},
|
||||
controller: _birthdayController,
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
GenderDropdown(
|
||||
controller: _genderController,
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox(),
|
||||
const SizedBox(height: 60.0),
|
||||
saveButton(state, context),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -189,6 +406,25 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (enableLoginWithEmail) {
|
||||
if (_newEmailController.text.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_passwordController.text.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.read<AuthBloc>().add(
|
||||
AuthEventAddEmailAndPassword(
|
||||
email: _newEmailController.text,
|
||||
password: _passwordController.text,
|
||||
),
|
||||
);
|
||||
|
||||
_emailController.text = _newEmailController.text;
|
||||
}
|
||||
|
||||
final myUser = state.user!.copyWith(
|
||||
name: _nameController.text,
|
||||
email: _emailController.text,
|
||||
@@ -209,7 +445,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.blue,
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user