From 49d30a1e0d671c5683f9288ac5ffade3bfa1e393 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Tue, 14 Apr 2026 13:05:58 +0530 Subject: [PATCH] refactor: remove location field and related logic from profile settings tab --- .../widgets/profile_settings_tab.dart | 44 +------------------ 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/lib/features/profile/presentation/widgets/profile_settings_tab.dart b/lib/features/profile/presentation/widgets/profile_settings_tab.dart index c1ba43d..e0edc22 100644 --- a/lib/features/profile/presentation/widgets/profile_settings_tab.dart +++ b/lib/features/profile/presentation/widgets/profile_settings_tab.dart @@ -23,7 +23,6 @@ class _ProfileSettingsTabState extends ConsumerState { late TextEditingController _titleController; late TextEditingController _emailController; late TextEditingController _phoneController; - late TextEditingController _locationController; bool _controllersInitialized = false; bool _isUploadingAvatar = false; @@ -37,12 +36,10 @@ class _ProfileSettingsTabState extends ConsumerState { _titleController = TextEditingController(); _emailController = TextEditingController(); _phoneController = TextEditingController(); - _locationController = TextEditingController(); // Listen for changes to enable/disable Cancel & Save buttons _fullNameController.addListener(_onFieldChanged); _titleController.addListener(_onFieldChanged); _phoneController.addListener(_onFieldChanged); - _locationController.addListener(_onFieldChanged); } void _onFieldChanged() { @@ -54,12 +51,10 @@ class _ProfileSettingsTabState extends ConsumerState { _fullNameController.removeListener(_onFieldChanged); _titleController.removeListener(_onFieldChanged); _phoneController.removeListener(_onFieldChanged); - _locationController.removeListener(_onFieldChanged); _fullNameController.dispose(); _titleController.dispose(); _emailController.dispose(); _phoneController.dispose(); - _locationController.dispose(); super.dispose(); } @@ -83,17 +78,8 @@ class _ProfileSettingsTabState extends ConsumerState { final agentType = profile['agentType'] as Map?; _titleController.text = agentType?['name'] as String? ?? profile['bio'] as String? ?? ''; - final serviceAreas = profile['serviceAreas']; - if (serviceAreas is List && serviceAreas.isNotEmpty) { - _locationController.text = serviceAreas.first.toString(); - } } else { _titleController.text = profile['headline'] as String? ?? ''; - final city = profile['city'] as String? ?? ''; - final stateName = profile['state'] as String? ?? ''; - final country = profile['country'] as String? ?? ''; - final parts = [stateName, city, country].where((s) => s.isNotEmpty); - _locationController.text = parts.join(', '); } _savedValues = { @@ -101,15 +87,13 @@ class _ProfileSettingsTabState extends ConsumerState { 'title': _titleController.text, 'email': _emailController.text, 'phone': _phoneController.text, - 'location': _locationController.text, }; } bool get _hasChanges { return _fullNameController.text != (_savedValues['fullName'] ?? '') || _titleController.text != (_savedValues['title'] ?? '') || - _phoneController.text != (_savedValues['phone'] ?? '') || - _locationController.text != (_savedValues['location'] ?? ''); + _phoneController.text != (_savedValues['phone'] ?? ''); } @override @@ -282,12 +266,6 @@ class _ProfileSettingsTabState extends ConsumerState { controller: _phoneController, keyboardType: TextInputType.phone, textCapitalization: TextCapitalization.none), - const SizedBox(height: 24), - ProfileFormField( - label: isAgent ? 'Service Areas' : 'Location', - controller: _locationController, - prefixIcon: Icons.location_on, - ), const SizedBox(height: 30), ProfileActionButtons( onSave: _saveProfileSettings, @@ -375,14 +353,10 @@ class _ProfileSettingsTabState extends ConsumerState { _fullNameController.text = _savedValues['fullName'] ?? ''; _titleController.text = _savedValues['title'] ?? ''; _phoneController.text = _savedValues['phone'] ?? ''; - _locationController.text = _savedValues['location'] ?? ''; setState(() {}); } Future _saveProfileSettings() async { - final profileState = ref.read(profileProvider); - final isAgent = profileState.isAgent; - final nameParts = _fullNameController.text.trim().split(RegExp(r'\s+')); final firstName = nameParts.first; final lastName = @@ -394,21 +368,6 @@ class _ProfileSettingsTabState extends ConsumerState { 'phone': _phoneController.text.trim(), }; - if (isAgent) { - final location = _locationController.text.trim(); - if (location.isNotEmpty) data['serviceAreas'] = [location]; - } else { - final locationParts = _locationController.text - .split(',') - .map((s) => s.trim()) - .where((s) => s.isNotEmpty) - .toList(); - // Display order is state first, then city, then country — parse in the same order - if (locationParts.isNotEmpty) data['state'] = locationParts[0]; - if (locationParts.length > 1) data['city'] = locationParts[1]; - if (locationParts.length > 2) data['country'] = locationParts[2]; - } - await ref.read(profileProvider.notifier).updateProfile(data); // Update saved values so Cancel won't revert after successful save @@ -419,7 +378,6 @@ class _ProfileSettingsTabState extends ConsumerState { 'title': _titleController.text, 'email': _emailController.text, 'phone': _phoneController.text, - 'location': _locationController.text, }; }); }