Refactor: Change profile tab cancel actions to reset form state instead of navigating, and adjust agent availability UI.
This commit is contained in:
@@ -438,16 +438,7 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
if (_isTogglingAvailability && !isActive)
|
if (isActive)
|
||||||
const SizedBox(
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
strokeWidth: 2,
|
|
||||||
color: AppColors.accentOrange,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else if (isActive)
|
|
||||||
Text(
|
Text(
|
||||||
'Active',
|
'Active',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||||||
import 'package:real_estate_mobile/features/profile/presentation/providers/profile_provider.dart';
|
import 'package:real_estate_mobile/features/profile/presentation/providers/profile_provider.dart';
|
||||||
import 'package:real_estate_mobile/features/profile/presentation/widgets/profile_shared_widgets.dart';
|
import 'package:real_estate_mobile/features/profile/presentation/widgets/profile_shared_widgets.dart';
|
||||||
@@ -90,7 +89,16 @@ class _ChangePasswordTabState extends ConsumerState<ChangePasswordTab> {
|
|||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
ProfileActionButtons(
|
ProfileActionButtons(
|
||||||
onSave: _changePassword,
|
onSave: _changePassword,
|
||||||
onCancel: () => context.go('/home'),
|
onCancel: () {
|
||||||
|
_currentPasswordController.clear();
|
||||||
|
_newPasswordController.clear();
|
||||||
|
_confirmPasswordController.clear();
|
||||||
|
setState(() {
|
||||||
|
_showCurrentPassword = false;
|
||||||
|
_showNewPassword = false;
|
||||||
|
_showConfirmPassword = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
isSaving: _isChangingPassword,
|
isSaving: _isChangingPassword,
|
||||||
saveLabel: 'Update Password',
|
saveLabel: 'Update Password',
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||||||
import 'package:real_estate_mobile/features/profile/presentation/providers/profile_provider.dart';
|
import 'package:real_estate_mobile/features/profile/presentation/providers/profile_provider.dart';
|
||||||
import 'package:real_estate_mobile/features/profile/presentation/widgets/profile_shared_widgets.dart';
|
import 'package:real_estate_mobile/features/profile/presentation/widgets/profile_shared_widgets.dart';
|
||||||
@@ -144,7 +143,10 @@ class _NotificationsTabState extends ConsumerState<NotificationsTab> {
|
|||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
ProfileActionButtons(
|
ProfileActionButtons(
|
||||||
onSave: _saveNotificationSettings,
|
onSave: _saveNotificationSettings,
|
||||||
onCancel: () => context.go('/home'),
|
onCancel: () {
|
||||||
|
_notificationsLoaded = false;
|
||||||
|
_loadNotificationPreferences();
|
||||||
|
},
|
||||||
isSaving: _isSavingNotifications,
|
isSaving: _isSavingNotifications,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||||||
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
|
import 'package:real_estate_mobile/features/auth/presentation/providers/auth_provider.dart';
|
||||||
import 'package:real_estate_mobile/features/profile/presentation/providers/profile_provider.dart';
|
import 'package:real_estate_mobile/features/profile/presentation/providers/profile_provider.dart';
|
||||||
@@ -150,7 +149,10 @@ class _PrivacyTabState extends ConsumerState<PrivacyTab> {
|
|||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
ProfileActionButtons(
|
ProfileActionButtons(
|
||||||
onSave: _savePrivacyPreferences,
|
onSave: _savePrivacyPreferences,
|
||||||
onCancel: () => context.go('/home'),
|
onCancel: () {
|
||||||
|
_privacyLoaded = false;
|
||||||
|
_loadPrivacyPreferences();
|
||||||
|
},
|
||||||
isSaving: _isSavingPrivacy),
|
isSaving: _isSavingPrivacy),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
ProfileSectionCard(
|
ProfileSectionCard(
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'dart:io';
|
|||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||||||
import 'package:real_estate_mobile/core/utils/image_url_resolver.dart';
|
import 'package:real_estate_mobile/core/utils/image_url_resolver.dart';
|
||||||
@@ -261,7 +260,7 @@ class _ProfileSettingsTabState extends ConsumerState<ProfileSettingsTab> {
|
|||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
ProfileActionButtons(
|
ProfileActionButtons(
|
||||||
onSave: _saveProfileSettings,
|
onSave: _saveProfileSettings,
|
||||||
onCancel: () => context.go('/home'),
|
onCancel: _resetForm,
|
||||||
isSaving: profileState.isSaving,
|
isSaving: profileState.isSaving,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -337,6 +336,16 @@ class _ProfileSettingsTabState extends ConsumerState<ProfileSettingsTab> {
|
|||||||
if (mounted) _showSnackBar('Avatar deleted');
|
if (mounted) _showSnackBar('Avatar deleted');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _resetForm() {
|
||||||
|
_controllersInitialized = false;
|
||||||
|
_localAvatarFile = null;
|
||||||
|
final profileState = ref.read(profileProvider);
|
||||||
|
if (profileState.profile.isNotEmpty) {
|
||||||
|
_initControllersFromProfile(profileState);
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
void _saveProfileSettings() {
|
void _saveProfileSettings() {
|
||||||
final profileState = ref.read(profileProvider);
|
final profileState = ref.read(profileProvider);
|
||||||
final isAgent = profileState.isAgent;
|
final isAgent = profileState.isAgent;
|
||||||
|
|||||||
Reference in New Issue
Block a user