This commit is contained in:
Felipe
2024-04-05 11:56:45 -05:00
parent f46450e5db
commit e82c7c3afd
18 changed files with 1297 additions and 546 deletions
+194 -175
View File
@@ -98,180 +98,201 @@ class _ProfileScreenState extends State<ProfileScreen> {
_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),
),
focusedErrorBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.red, width: 2.0),
),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Por favor, ingrese su nombre';
}
return null;
},
),
const SizedBox(height: 20.0),
TextFormField(
controller: _cityController,
readOnly: true,
onTap: () async {
final cityName = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const CityListScreen();
return Column(
children: [
Expanded(
child: 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),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red, width: 2.0),
),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Por favor, ingrese su nombre';
}
return null;
},
),
);
const SizedBox(height: 20.0),
TextFormField(
controller: _cityController,
readOnly: true,
onTap: () async {
final cityName = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const CityListScreen();
},
),
);
if (cityName != null) {
_cityController.text = cityName;
}
},
decoration: const InputDecoration(
labelText: 'Ciudad',
prefixIcon: Icon(Icons.near_me_rounded),
hintText: 'Selecciona tu ciudad',
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 nombre';
}
return null;
},
),
_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,
if (cityName != null) {
_cityController.text = cityName;
}
},
decoration: const InputDecoration(
labelText: 'Ciudad',
prefixIcon: Icon(Icons.near_me_rounded),
hintText: 'Selecciona tu ciudad',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
)),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
const SizedBox(height: 20.0),
GenderDropdown(
controller: _genderController,
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.red, width: 2.0),
),
],
)
: const SizedBox(),
const SizedBox(height: 20),
ProfileItem(
title: 'Configurar inicio de sesión con correo',
subtitle: _emailController.text,
leading: Icons.email_rounded,
onTap: () {
if (state.user!.name == null ||
state.user!.name == '') {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Por favor, ingrese su nombre')));
return;
}
if (state.user!.city == null ||
state.user!.city == '') {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Por favor, ingrese su nombre')));
return;
}
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) =>
_emailController.text.isEmpty
? ProfileRegisterEmailScreen()
: ProfileUpdatePasswordScreen(
email: _emailController.text)),
);
},
),
const SizedBox(height: 20),
ProfileItem(
title: 'Configurar inicio de sesión con celular',
subtitle: _phoneController.text,
leading: Icons.phone_iphone_rounded,
onTap: () {
if (state.user!.name == null ||
state.user!.name == '') {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Por favor, ingrese su nombre')));
return;
}
if (state.user!.city == null ||
state.user!.city == '') {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Por favor, ingrese su nombre')));
return;
}
if (_phoneController.text.isEmpty) {
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) =>
const ProfileRegisterPhoneScreen(),
),
);
}
},
validator: (value) {
if (value == null || value.isEmpty) {
return 'Por favor, ingrese su nombre';
}
return null;
},
),
_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: 20),
ProfileItem(
title: 'Configurar inicio de sesión con correo',
subtitle: _emailController.text,
leading: Icons.email_rounded,
onTap: () {
if (state.user!.name == null ||
state.user!.name == '') {
ScaffoldMessenger.of(context)
.clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Por favor, ingrese su nombre')));
return;
}
if (state.user!.city == null ||
state.user!.city == '') {
ScaffoldMessenger.of(context)
.clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Por favor, ingrese su ciudad')));
return;
}
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) => _emailController
.text.isEmpty
? ProfileRegisterEmailScreen()
: ProfileUpdatePasswordScreen(
email: _emailController.text)),
);
},
),
const SizedBox(height: 20),
ProfileItem(
title:
'Configurar inicio de sesión con celular',
subtitle: _phoneController.text,
leading: Icons.phone_iphone_rounded,
onTap: () {
if (state.user!.name == null ||
state.user!.name == '') {
ScaffoldMessenger.of(context)
.clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Por favor, ingrese su nombre')));
return;
}
if (state.user!.city == null ||
state.user!.city == '') {
ScaffoldMessenger.of(context)
.clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Por favor, ingrese su nombre')));
return;
}
if (_phoneController.text.isEmpty) {
Navigator.push(
context,
CupertinoPageRoute(
builder: (context) =>
const ProfileRegisterPhoneScreen(),
),
);
}
},
),
const SizedBox(height: 10),
],
),
),
const SizedBox(height: 60.0),
saveButton(state, context),
],
),
),
),
const Divider(
height: 1,
thickness: 0.5,
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 15,
),
child: saveButton(state, context),
),
],
);
} else {
return const Center(child: CircularProgressIndicator());
@@ -302,6 +323,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Por favor, ingrese su ciudad')));
return;
}
final myUser = state.user!.copyWith(
@@ -325,17 +348,14 @@ class _ProfileScreenState extends State<ProfileScreen> {
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
padding: const EdgeInsets.symmetric(vertical: 5),
style: FilledButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
padding: const EdgeInsets.symmetric(vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
borderRadius: BorderRadius.circular(10),
),
shadowColor: Colors.grey,
// elevation: 0,
),
child: Container(
constraints: const BoxConstraints(maxWidth: 300.0, minHeight: 50.0),
alignment: Alignment.center,
child: isLoading
? const CircularProgressIndicator(
@@ -345,8 +365,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
'Actualizar',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),