Refactor HomeScreen to consume granular state flows#89
Draft
NiazSagor wants to merge 4 commits into
Draft
Conversation
…tailsUiState - Remove the monolithic `UserDetailsUiState` data class and the associated `combine` logic in `HomeScreenViewModel`. - Expose individual UI states from `HomeScreenViewModel` as separate `StateFlow` properties with private backing fields. - Decompose `HomeScreen.kt` by introducing `HomeTopBar` and `HomeContent` components to improve modularity and state handling. - Refactor `UserProfileContent` to accept individual state parameters instead of a single UI state object. - Update `PreviewUserDetails` to reflect the updated component signatures and state structure.
- Replace manual `MutableStateFlow` and `collect` logic for `isWeeklyGoalSet` with a reactive `StateFlow` derived from `goalRepository.weeklyGoal` using `stateIn`. - Simplify ViewModel initialization and `refreshUiState` by removing the redundant `getWeeklyGoalStatus` function.
- Convert `userBasicInfo`, `userContestInfo`, `userProblemSolvedInfo`, and `dailyProblem` from manual `MutableStateFlow` updates to `StateFlow` using the `stateIn` operator. - Implement `SharingStarted.WhileSubscribed(5000)` strategy to improve resource management and handle configuration changes efficiently. - Remove redundant manual flow collection logic and coroutine launches from the `init` block.
…encies - Hoist state collection from `HomeScreenViewModel` to the top-level `HomeScreen` composable using `collectAsStateWithLifecycle`. - Update `HomeLayout`, `HomeTopBar`, and `HomeContent` to accept explicit state parameters instead of a `ViewModel` instance. - Pass individual state properties, including `userBasicInfo`, `userContestInfo`, `userSubmissionState`, and `difficultyStat`, down the composable tree. - Improve component testability and separation of concerns by removing internal `ViewModel` dependencies within sub-composables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UserDetailsUiStatedata class and the associatedcombinelogic inHomeScreenViewModel.HomeScreenViewModelas separateStateFlowproperties with private backing fields.HomeScreen.ktby introducingHomeTopBarandHomeContentcomponents to improve modularity and state handling.UserProfileContentto accept individual state parameters instead of a single UI state object.PreviewUserDetailsto reflect the updated component signatures and state structure.