This commit is contained in:
Felipe
2024-03-13 14:38:47 -05:00
parent a25bc6a987
commit 6806703360
4 changed files with 68 additions and 16 deletions
+4 -2
View File
@@ -64,7 +64,8 @@ class _CityScreenState extends State<CityScreen> {
_isLoading
? _buildShimmerEffect()
: Expanded(
child: _filteredCities != null && _filteredCities!.isNotEmpty
child: _filteredCities != null &&
_filteredCities!.isNotEmpty
? ListView.builder(
itemCount: _filteredCities!.length,
itemBuilder: (BuildContext context, int index) {
@@ -81,7 +82,8 @@ class _CityScreenState extends State<CityScreen> {
style: const TextStyle(color: Colors.black54),
),
onTap: () {
// Handle city selection
Navigator.pop(context,
_filteredCities![index].cityName);
},
);
},
+40 -11
View File
@@ -25,6 +25,7 @@ class ProfileScreen extends StatefulWidget {
class _ProfileScreenState extends State<ProfileScreen> {
final TextEditingController _nameController = TextEditingController();
final TextEditingController _cityController = TextEditingController();
final TextEditingController _emailController = TextEditingController();
final TextEditingController _newEmailController = TextEditingController();
final TextEditingController _phoneController = TextEditingController();
@@ -46,12 +47,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
@override
void dispose() {
_nameController.dispose();
_cityController.dispose();
_emailController.dispose();
_newEmailController.dispose();
_phoneController.dispose();
_birthdayController.dispose();
_genderController.dispose();
_passwordController.dispose();
_newEmailController.dispose();
super.dispose();
}
@@ -131,10 +133,10 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
const SizedBox(height: 20.0),
TextFormField(
// controller: _nameController,
controller: _cityController,
readOnly: true,
onTap: () {
Navigator.push(
onTap: () async {
final cityName = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
@@ -142,6 +144,10 @@ class _ProfileScreenState extends State<ProfileScreen> {
},
),
);
if (cityName != null) {
_cityController.text = cityName;
}
},
decoration: const InputDecoration(
labelText: 'Ciudad',
@@ -194,6 +200,17 @@ class _ProfileScreenState extends State<ProfileScreen> {
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(
@@ -220,6 +237,17 @@ class _ProfileScreenState extends State<ProfileScreen> {
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(
@@ -263,16 +291,19 @@ class _ProfileScreenState extends State<ProfileScreen> {
if (_nameController.text.isEmpty) {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Por favor, ingrese su nombre')),
);
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Por favor, ingrese su nombre')));
return;
}
if (_cityController.text.isEmpty) {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Por favor, ingrese su ciudad')));
}
final myUser = state.user!.copyWith(
name: _nameController.text,
city: _cityController.text,
nickname: _nameController.text.trim().toLowerCase(),
email: _emailController.text,
phone: _phoneController.text,
@@ -280,9 +311,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
gender: _genderController.text,
);
context
.read<ProfileBloc>()
.add(UpdateUserInfo(myUser: myUser, filePicture: _imageFile?.path));
context.read<ProfileBloc>().add(UpdateUserInfo(myUser: myUser, filePicture: _imageFile?.path));
Navigator.pop(context);
},