add city
This commit is contained in:
@@ -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);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user