Implement the public section in the Share tab#77
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements the public section functionality in the Share tab, allowing users to control which profile information from their Gravatar is shared publicly. The implementation adds toggle switches for various profile fields like name, location, job title, organization, description, and profile URL, with state management handled through a new UserSharePreferences data class.
Key changes:
- Added
UserSharePreferencesmodel to manage public sharing preferences for different profile fields - Created UI components for displaying and controlling public profile information sharing
- Integrated the public section into the existing Share screen with proper state management
Reviewed Changes
Copilot reviewed 13 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
UserSharePreferences.kt |
New data class defining boolean preferences for sharing profile fields |
SharePublicRow.kt |
UI component for individual profile field sharing controls with label, value, and toggle |
SharePublicContactInfo.kt |
Main component organizing all public profile fields with their sharing controls |
ShareUiState.kt |
Enhanced state management with user preferences and field type definitions |
ShareViewModel.kt |
Added event handling for user preference changes |
ShareScreen.kt |
Integrated public contact info section into the main share screen |
ItemDivider.kt |
Utility component for visual separation between sections |
| Test files | Comprehensive unit and UI tests for the new components and functionality |
| userSharePreferences = userSharePreferences.copy( | ||
| name = if (shareFieldType is ShareFieldType.Name) shareFieldType.checked else userSharePreferences.name, | ||
| location = if (shareFieldType is ShareFieldType.Location) shareFieldType.checked else userSharePreferences.location, | ||
| title = if (shareFieldType is ShareFieldType.Title) shareFieldType.checked else userSharePreferences.title, | ||
| organization = if (shareFieldType is ShareFieldType.Organization) shareFieldType.checked else userSharePreferences.organization, | ||
| description = if (shareFieldType is ShareFieldType.Description) shareFieldType.checked else userSharePreferences.description, | ||
| profileUrl = if (shareFieldType is ShareFieldType.ProfileUrl) shareFieldType.checked else userSharePreferences.profileUrl, | ||
| ) |
There was a problem hiding this comment.
The copyWithUserSharePreferences function uses repetitive if-else chains that could be simplified. Consider using a when expression or extracting the logic into the ShareFieldType sealed class to reduce code duplication and improve maintainability.
| userSharePreferences = userSharePreferences.copy( | |
| name = if (shareFieldType is ShareFieldType.Name) shareFieldType.checked else userSharePreferences.name, | |
| location = if (shareFieldType is ShareFieldType.Location) shareFieldType.checked else userSharePreferences.location, | |
| title = if (shareFieldType is ShareFieldType.Title) shareFieldType.checked else userSharePreferences.title, | |
| organization = if (shareFieldType is ShareFieldType.Organization) shareFieldType.checked else userSharePreferences.organization, | |
| description = if (shareFieldType is ShareFieldType.Description) shareFieldType.checked else userSharePreferences.description, | |
| profileUrl = if (shareFieldType is ShareFieldType.ProfileUrl) shareFieldType.checked else userSharePreferences.profileUrl, | |
| ) | |
| userSharePreferences = shareFieldType.updatePreferences(userSharePreferences) |
homeUi/src/test/kotlin/com/gravatar/app/homeUi/presentation/home/share/ShareViewModelTest.kt
Show resolved
Hide resolved
.../kotlin/com/gravatar/app/homeUi/presentation/home/share/components/SharePublicContactInfo.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Those two were being generated for a while, I've decided to push them and hope this will stop.
Description
This PR implements the public section in the Share tab.
I've put the
UserSharePreferencesin the:userComponentmodule, as we will have to get that info from there anyway.No local persistence layer, so the state will be lost when the app is killed.
Testing Steps