Refactor: Change profile tab cancel actions to reset form state instead of navigating, and adjust agent availability UI.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.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/features/profile/presentation/providers/profile_provider.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),
|
||||
ProfileActionButtons(
|
||||
onSave: _changePassword,
|
||||
onCancel: () => context.go('/home'),
|
||||
onCancel: () {
|
||||
_currentPasswordController.clear();
|
||||
_newPasswordController.clear();
|
||||
_confirmPasswordController.clear();
|
||||
setState(() {
|
||||
_showCurrentPassword = false;
|
||||
_showNewPassword = false;
|
||||
_showConfirmPassword = false;
|
||||
});
|
||||
},
|
||||
isSaving: _isChangingPassword,
|
||||
saveLabel: 'Update Password',
|
||||
),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.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/features/profile/presentation/providers/profile_provider.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),
|
||||
ProfileActionButtons(
|
||||
onSave: _saveNotificationSettings,
|
||||
onCancel: () => context.go('/home'),
|
||||
onCancel: () {
|
||||
_notificationsLoaded = false;
|
||||
_loadNotificationPreferences();
|
||||
},
|
||||
isSaving: _isSavingNotifications,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.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/features/auth/presentation/providers/auth_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),
|
||||
ProfileActionButtons(
|
||||
onSave: _savePrivacyPreferences,
|
||||
onCancel: () => context.go('/home'),
|
||||
onCancel: () {
|
||||
_privacyLoaded = false;
|
||||
_loadPrivacyPreferences();
|
||||
},
|
||||
isSaving: _isSavingPrivacy),
|
||||
const SizedBox(height: 24),
|
||||
ProfileSectionCard(
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'dart:io';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:real_estate_mobile/core/constants/app_colors.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),
|
||||
ProfileActionButtons(
|
||||
onSave: _saveProfileSettings,
|
||||
onCancel: () => context.go('/home'),
|
||||
onCancel: _resetForm,
|
||||
isSaving: profileState.isSaving,
|
||||
),
|
||||
],
|
||||
@@ -337,6 +336,16 @@ class _ProfileSettingsTabState extends ConsumerState<ProfileSettingsTab> {
|
||||
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() {
|
||||
final profileState = ref.read(profileProvider);
|
||||
final isAgent = profileState.isAgent;
|
||||
|
||||
Reference in New Issue
Block a user