Skip to content

Conversation

@zachseidner1
Copy link
Collaborator

@zachseidner1 zachseidner1 commented Mar 27, 2025

Overview

Before every time we changed destinations via navigation, the page would refresh. This is because the ViewModels were scoped to their Composables so they would get deconstructed and reinitialized whenever we switched between tabs. This change makes it so the view models are now scoped to the root composable of the app instead of their screen composables. ViewModels are no longer reinitialized when switching between tabs from the bottom bar, which corrects the ViewModel refresh issue.

Fixes #35

Changes made

  • Change view model for past and home screen to root composable
  • Reorganize navigation to improve code readability

Demo

Screens don't refresh:
Screen_recording_20250326_213404.webm

@zachseidner1 zachseidner1 linked an issue Apr 8, 2025 that may be closed by this pull request
@zachseidner1 zachseidner1 marked this pull request as ready for review April 9, 2025 19:09
# Conflicts:
#	app/src/main/java/com/cornellappdev/score/nav/root/RootNavigation.kt
@zachseidner1 zachseidner1 enabled auto-merge (squash) April 15, 2025 02:33
@zachseidner1 zachseidner1 disabled auto-merge April 15, 2025 02:33
@zachseidner1 zachseidner1 merged commit fe78600 into main Apr 15, 2025
@zachseidner1 zachseidner1 deleted the ViewModelScopeAndRefresh branch April 15, 2025 02:33
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.

Stop refresh on navigate

2 participants