feat: Implement profile visibility update feedback and localization updates

This commit is contained in:
Achintha Isuru
2026-02-18 16:30:22 -05:00
parent 7ce1c6f6e3
commit 3f3579067c
7 changed files with 81 additions and 38 deletions

View File

@@ -1131,13 +1131,16 @@
"legal_section": "Legal",
"profile_visibility": {
"title": "Profile Visibility",
"subtitle": "Show your profile to other users"
"subtitle": "Let clients see your profile"
},
"terms_of_service": {
"title": "Terms of Service"
},
"privacy_policy": {
"title": "Privacy Policy"
},
"success": {
"profile_visibility_updated": "Profile visibility updated successfully!"
}
},
"success": {

View File

@@ -1131,13 +1131,16 @@
"legal_section": "Legal",
"profile_visibility": {
"title": "Visibilidad del Perfil",
"subtitle": "Mostrar tu perfil a otros usuarios"
"subtitle": "Deja que los clientes vean tu perfil"
},
"terms_of_service": {
"title": "Términos de Servicio"
},
"privacy_policy": {
"title": "Política de Privacidad"
},
"success": {
"profile_visibility_updated": "¡Visibilidad del perfil actualizada exitosamente!"
}
},
"success": {

View File

@@ -31,6 +31,7 @@ class PrivacySecurityBloc
on<UpdateProfileVisibilityEvent>(_onUpdateProfileVisibility);
on<FetchTermsEvent>(_onFetchTerms);
on<FetchPrivacyPolicyEvent>(_onFetchPrivacyPolicy);
on<ClearProfileVisibilityUpdatedEvent>(_onClearProfileVisibilityUpdated);
}
Future<void> _onFetchProfileVisibility(
@@ -61,7 +62,7 @@ class PrivacySecurityBloc
UpdateProfileVisibilityEvent event,
Emitter<PrivacySecurityState> emit,
) async {
emit(state.copyWith(isUpdating: true, error: null));
emit(state.copyWith(isUpdating: true, error: null, profileVisibilityUpdated: false));
try {
final bool isVisible = await _updateProfileVisibilityUseCase.call(
@@ -71,6 +72,7 @@ class PrivacySecurityBloc
state.copyWith(
isUpdating: false,
isProfileVisible: isVisible,
profileVisibilityUpdated: true,
),
);
} catch (e) {
@@ -78,6 +80,7 @@ class PrivacySecurityBloc
state.copyWith(
isUpdating: false,
error: 'Failed to update profile visibility',
profileVisibilityUpdated: false,
),
);
}
@@ -130,4 +133,11 @@ class PrivacySecurityBloc
);
}
}
void _onClearProfileVisibilityUpdated(
ClearProfileVisibilityUpdatedEvent event,
Emitter<PrivacySecurityState> emit,
) {
emit(state.copyWith(profileVisibilityUpdated: false));
}
}

View File

@@ -34,3 +34,7 @@ class FetchPrivacyPolicyEvent extends PrivacySecurityEvent {
const FetchPrivacyPolicyEvent();
}
/// Event to clear the profile visibility updated flag after showing snackbar
class ClearProfileVisibilityUpdatedEvent extends PrivacySecurityEvent {
const ClearProfileVisibilityUpdatedEvent();
}

View File

@@ -11,6 +11,9 @@ class PrivacySecurityState extends Equatable {
/// Whether profile visibility is currently being updated
final bool isUpdating;
/// Whether the profile visibility was just successfully updated
final bool profileVisibilityUpdated;
/// Terms of service content
final String? termsContent;
@@ -30,6 +33,7 @@ class PrivacySecurityState extends Equatable {
this.isProfileVisible = true,
this.isLoading = false,
this.isUpdating = false,
this.profileVisibilityUpdated = false,
this.termsContent,
this.isLoadingTerms = false,
this.privacyPolicyContent,
@@ -42,6 +46,7 @@ class PrivacySecurityState extends Equatable {
bool? isProfileVisible,
bool? isLoading,
bool? isUpdating,
bool? profileVisibilityUpdated,
String? termsContent,
bool? isLoadingTerms,
String? privacyPolicyContent,
@@ -52,6 +57,7 @@ class PrivacySecurityState extends Equatable {
isProfileVisible: isProfileVisible ?? this.isProfileVisible,
isLoading: isLoading ?? this.isLoading,
isUpdating: isUpdating ?? this.isUpdating,
profileVisibilityUpdated: profileVisibilityUpdated ?? this.profileVisibilityUpdated,
termsContent: termsContent ?? this.termsContent,
isLoadingTerms: isLoadingTerms ?? this.isLoadingTerms,
privacyPolicyContent: privacyPolicyContent ?? this.privacyPolicyContent,
@@ -66,6 +72,7 @@ class PrivacySecurityState extends Equatable {
isProfileVisible,
isLoading,
isUpdating,
profileVisibilityUpdated,
termsContent,
isLoadingTerms,
privacyPolicyContent,

View File

@@ -23,7 +23,7 @@ class LegalSectionWidget extends StatelessWidget {
// Legal Section Header
SettingsSectionHeader(
title: t.staff_privacy_security.legal_section,
icon: Icons.shield,
icon: UiIcons.shield,
),
Container(

View File

@@ -13,42 +13,58 @@ class PrivacySectionWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<PrivacySecurityBloc, PrivacySecurityState>(
builder: (BuildContext context, PrivacySecurityState state) {
return Column(
children: <Widget>[
// Privacy Section Header
SettingsSectionHeader(
title: t.staff_privacy_security.privacy_section,
icon: UiIcons.eye,
),
const SizedBox(height: 12.0),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(UiConstants.radiusBase),
border: Border.all(
color: UiColors.border,
return BlocListener<PrivacySecurityBloc, PrivacySecurityState>(
listener: (BuildContext context, PrivacySecurityState state) {
// Show success message when profile visibility update just completed
if (state.profileVisibilityUpdated && state.error == null) {
UiSnackbar.show(
context,
message: t.staff_privacy_security.success.profile_visibility_updated,
type: UiSnackbarType.success,
);
// Clear the flag after showing the snackbar
context.read<PrivacySecurityBloc>().add(
const ClearProfileVisibilityUpdatedEvent(),
);
}
},
child: BlocBuilder<PrivacySecurityBloc, PrivacySecurityState>(
builder: (BuildContext context, PrivacySecurityState state) {
return Column(
children: <Widget>[
// Privacy Section Header
SettingsSectionHeader(
title: t.staff_privacy_security.privacy_section,
icon: UiIcons.eye,
),
const SizedBox(height: 12.0),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(UiConstants.radiusBase),
border: Border.all(
color: UiColors.border,
),
),
child: Column(
children: <Widget>[
SettingsSwitchTile(
title: t.staff_privacy_security.profile_visibility.title,
subtitle: t.staff_privacy_security.profile_visibility.subtitle,
value: state.isProfileVisible,
onChanged: (bool value) {
BlocProvider.of<PrivacySecurityBloc>(context).add(
UpdateProfileVisibilityEvent(isVisible: value),
);
},
),
],
),
),
child: Column(
children: <Widget>[
SettingsSwitchTile(
title: t.staff_privacy_security.profile_visibility.title,
subtitle: t.staff_privacy_security.profile_visibility.subtitle,
value: state.isProfileVisible,
onChanged: (bool value) {
BlocProvider.of<PrivacySecurityBloc>(context).add(
UpdateProfileVisibilityEvent(isVisible: value),
);
},
),
],
),
),
],
);
},
],
);
},
),
);
}
}