From ae4dc866b03d4206a1c6c111d98fe56206d7c484 Mon Sep 17 00:00:00 2001 From: Felipe Date: Wed, 13 Mar 2024 15:09:41 -0500 Subject: [PATCH] fix city --- lib/blocs/profile_bloc/profile_bloc.dart | 1 - lib/screens/city/city_screen.dart | 125 +++++++++++++---------- lib/screens/profile/profile_screen.dart | 16 ++- 3 files changed, 85 insertions(+), 57 deletions(-) diff --git a/lib/blocs/profile_bloc/profile_bloc.dart b/lib/blocs/profile_bloc/profile_bloc.dart index 641e08d..a1b2e96 100644 --- a/lib/blocs/profile_bloc/profile_bloc.dart +++ b/lib/blocs/profile_bloc/profile_bloc.dart @@ -1,6 +1,5 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:equatable/equatable.dart'; -import 'package:prosappco/blocs/auth_bloc/auth_bloc.dart'; import 'package:user_repository/user_repository.dart'; part 'profile_event.dart'; diff --git a/lib/screens/city/city_screen.dart b/lib/screens/city/city_screen.dart index 459e055..f10cd8d 100644 --- a/lib/screens/city/city_screen.dart +++ b/lib/screens/city/city_screen.dart @@ -48,16 +48,19 @@ class _CityScreenState extends State { ), body: Column( children: [ - Padding( - padding: const EdgeInsets.only(left: 15, right: 15, bottom: 15), - child: TextField( - controller: _searchController, - onChanged: (value) { - _filterCities(value); - }, - decoration: const InputDecoration( - hintText: 'Busca una ciudad', - prefixIcon: Icon(Icons.search), + TextField( + controller: _searchController, + onChanged: (value) { + _filterCities(value); + }, + decoration: const InputDecoration( + hintText: 'Busca una ciudad', + prefixIcon: Icon(Icons.search), + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide(color: Colors.grey), + ), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: Colors.grey), ), ), ), @@ -69,22 +72,31 @@ class _CityScreenState extends State { ? ListView.builder( itemCount: _filteredCities!.length, itemBuilder: (BuildContext context, int index) { - return ListTile( - title: Text( - _filteredCities![index].cityName, - style: const TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black87, + return Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Colors.grey.withOpacity(0.2)), ), ), - subtitle: Text( - "${_filteredCities![index].stateOfCity}, ${_filteredCities![index].countryOfCity}", - style: const TextStyle(color: Colors.black54), + child: ListTile( + title: Text( + _filteredCities![index].cityName, + style: const TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black87, + ), + ), + subtitle: Text( + "${_filteredCities![index].stateOfCity}, ${_filteredCities![index].countryOfCity}", + style: + const TextStyle(color: Colors.black54), + ), + onTap: () { + Navigator.pop(context, + _filteredCities![index].cityName); + }, ), - onTap: () { - Navigator.pop(context, - _filteredCities![index].cityName); - }, ); }, ) @@ -128,39 +140,46 @@ class ListTileShimmer extends StatelessWidget { @override Widget build(BuildContext context) { - return ListTile( - title: Row( - children: [ - Container( - width: MediaQuery.of(context).size.width * 0.8, - height: 18.0, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - ), - ), - ], + return Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide(color: Colors.grey.withOpacity(0.4)), + ), ), - subtitle: Row( - children: [ - Container( - width: MediaQuery.of(context).size.width * 0.3, - height: 15.0, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), + child: ListTile( + title: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.8, + height: 20.0, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), ), - ), - const SizedBox(width: 5), - Container( - width: MediaQuery.of(context).size.width * 0.3, - height: 15.0, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), + ], + ), + subtitle: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.3, + height: 15.0, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), ), - ) - ], + const SizedBox(width: 5), + Container( + width: MediaQuery.of(context).size.width * 0.3, + height: 15.0, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), + ) + ], + ), ), ); } diff --git a/lib/screens/profile/profile_screen.dart b/lib/screens/profile/profile_screen.dart index ed6266d..b89b9b8 100644 --- a/lib/screens/profile/profile_screen.dart +++ b/lib/screens/profile/profile_screen.dart @@ -92,6 +92,7 @@ class _ProfileScreenState extends State { builder: (context, state) { if (state.status == MyUserStatus.success) { _nameController.text = state.user!.name ?? ''; + _cityController.text = state.user!.city ?? ''; _emailController.text = state.user!.email ?? ''; _phoneController.text = state.user!.phone ?? ''; _birthdayController.text = state.user!.birthday ?? ''; @@ -291,14 +292,16 @@ class _ProfileScreenState extends State { 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'))); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Por favor, ingrese su ciudad'))); } final myUser = state.user!.copyWith( @@ -311,7 +314,14 @@ class _ProfileScreenState extends State { gender: _genderController.text, ); - context.read().add(UpdateUserInfo(myUser: myUser, filePicture: _imageFile?.path)); + context + .read() + .add(UpdateUserInfo(myUser: myUser, filePicture: _imageFile?.path)); + + ScaffoldMessenger.of(context).clearSnackBars(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Información actualizada...')), + ); Navigator.pop(context); },