a
This commit is contained in:
@@ -1,16 +1,22 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class GenderDropdown extends StatefulWidget {
|
class GenderDropdown extends StatefulWidget {
|
||||||
final Function(String) onChanged;
|
final TextEditingController controller;
|
||||||
|
|
||||||
const GenderDropdown({super.key, required this.onChanged});
|
const GenderDropdown({super.key, required this.controller});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<GenderDropdown> createState() => _GenderDropdownState();
|
State<GenderDropdown> createState() => _GenderDropdownState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GenderDropdownState extends State<GenderDropdown> {
|
class _GenderDropdownState extends State<GenderDropdown> {
|
||||||
String? selectedGender;
|
late TextEditingController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
controller = widget.controller;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -28,15 +34,14 @@ class _GenderDropdownState extends State<GenderDropdown> {
|
|||||||
child: DropdownButtonHideUnderline(
|
child: DropdownButtonHideUnderline(
|
||||||
child: DropdownButton<String>(
|
child: DropdownButton<String>(
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: selectedGender,
|
value: controller.text,
|
||||||
hint: const Text(
|
hint: const Text(
|
||||||
'Selecciona tu género',
|
'Selecciona tu género',
|
||||||
style: TextStyle(fontSize: 16.0),
|
style: TextStyle(fontSize: 16.0),
|
||||||
),
|
),
|
||||||
onChanged: (String? newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedGender = newValue;
|
controller.text = newValue!;
|
||||||
widget.onChanged(selectedGender!);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: ['Masculino', 'Femenino', 'Otro']
|
items: ['Masculino', 'Femenino', 'Otro']
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@@ -24,6 +23,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
final TextEditingController _phoneController = TextEditingController();
|
final TextEditingController _phoneController = TextEditingController();
|
||||||
final TextEditingController _birthdayController = TextEditingController();
|
final TextEditingController _birthdayController = TextEditingController();
|
||||||
final TextEditingController _genderController = TextEditingController();
|
final TextEditingController _genderController = TextEditingController();
|
||||||
|
|
||||||
XFile? _imageFile;
|
XFile? _imageFile;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
|
||||||
@@ -46,7 +46,6 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
} else if (state is UpdateUserInfoSuccess) {
|
} else if (state is UpdateUserInfoSuccess) {
|
||||||
// Snack bar
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||||
content: Text('Información actualizada'),
|
content: Text('Información actualizada'),
|
||||||
));
|
));
|
||||||
@@ -74,92 +73,101 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
_nameController.text = state.user!.name ?? '';
|
_nameController.text = state.user!.name ?? '';
|
||||||
_emailController.text = state.user!.email ?? '';
|
_emailController.text = state.user!.email ?? '';
|
||||||
_phoneController.text = state.user!.phone ?? '';
|
_phoneController.text = state.user!.phone ?? '';
|
||||||
|
_birthdayController.text = state.user!.birthday ?? '';
|
||||||
|
_genderController.text = state.user!.gender ?? '';
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(horizontal: 40, vertical: 20),
|
const EdgeInsets.symmetric(horizontal: 40, vertical: 20),
|
||||||
child: Column(
|
child: Stack(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
children: [
|
||||||
pictureWidget(state, context),
|
Column(
|
||||||
const SizedBox(height: 20.0),
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
TextFormField(
|
children: [
|
||||||
controller: _nameController,
|
pictureWidget(state, context),
|
||||||
decoration: const InputDecoration(
|
const SizedBox(height: 20.0),
|
||||||
labelText: 'Nombre',
|
TextFormField(
|
||||||
prefixIcon: Icon(Icons.person),
|
controller: _nameController,
|
||||||
hintText: 'Nombre (obligatorio)',
|
decoration: const InputDecoration(
|
||||||
border: OutlineInputBorder(
|
labelText: 'Nombre',
|
||||||
borderRadius: BorderRadius.all(
|
prefixIcon: Icon(Icons.person),
|
||||||
Radius.circular(10.0),
|
hintText: 'Nombre (obligatorio)',
|
||||||
)),
|
border: OutlineInputBorder(
|
||||||
errorBorder: OutlineInputBorder(
|
borderRadius: BorderRadius.all(
|
||||||
borderSide: BorderSide(color: Colors.red),
|
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;
|
||||||
|
},
|
||||||
),
|
),
|
||||||
focusedErrorBorder: OutlineInputBorder(
|
const SizedBox(height: 20.0),
|
||||||
borderSide: BorderSide(color: Colors.red, width: 2.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),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 20.0),
|
||||||
validator: (value) {
|
TextFormField(
|
||||||
if (value == null || value.isEmpty) {
|
controller: _phoneController,
|
||||||
return 'Por favor, ingrese su nombre';
|
decoration: const InputDecoration(
|
||||||
}
|
labelText: 'Número de Teléfono',
|
||||||
return null;
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
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),
|
|
||||||
),
|
|
||||||
focusedErrorBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.red, width: 2.0),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20.0),
|
|
||||||
BirthdayPicker(
|
|
||||||
onDateSelected: (birthDay) {
|
|
||||||
_birthdayController.text =
|
|
||||||
DateFormat('dd/MM/yyyy').format(birthDay);
|
|
||||||
},
|
|
||||||
controller: _birthdayController,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20.0),
|
|
||||||
GenderDropdown(onChanged: (selectedGender) {
|
|
||||||
_genderController.text = selectedGender;
|
|
||||||
}),
|
|
||||||
const SizedBox(height: 60.0),
|
|
||||||
saveButton(state, context),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -198,17 +206,16 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
// Navigator.pop(context);
|
// Navigator.pop(context);
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.blue, // Color de fondo
|
backgroundColor: Colors.blue,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(20), // Radio de borde
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
shadowColor: Colors.grey, // Sombra
|
shadowColor: Colors.grey,
|
||||||
elevation: 5, // Elevación
|
elevation: 5,
|
||||||
),
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(maxWidth: 300.0, minHeight: 50.0),
|
||||||
maxWidth: 300.0, minHeight: 50.0), // Ajustes de tamaño
|
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: isLoading
|
child: isLoading
|
||||||
? const CircularProgressIndicator(
|
? const CircularProgressIndicator(
|
||||||
@@ -219,7 +226,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold, // Texto audaz
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user