Skip to content

Refactor HomeScreen to consume granular state flows#89

Draft
NiazSagor wants to merge 4 commits into
masterfrom
improve-ui-performance
Draft

Refactor HomeScreen to consume granular state flows#89
NiazSagor wants to merge 4 commits into
masterfrom
improve-ui-performance

Conversation

@NiazSagor

Copy link
Copy Markdown
Collaborator
  • 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.

…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.
@NiazSagor NiazSagor marked this pull request as draft May 24, 2026 15:16
NiazSagor added 3 commits May 25, 2026 20:49
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant