Conversation
Collaborator
Author
fun navigate(tab: MainTab) {
val navOptions = navOptions {
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
when (tab) {
MainTab.HOME -> navController.navigateToHome(navOptions)
MainTab.UPLOAD_PHOTO -> navController.navigateToUploadPhoto(navOptions)
MainTab.MY_PAGE -> navController.navigateToMyPage(navOptions)
}
}Navigation Bar 에서 아이콘을 눌렀을 경우엔 해당 로직을 타는데, saveState 와 restoreState 옵션이 활성화 되어있어서 화면에 다시 돌아올 경우 이전의 상태를 저장하고, 이를 복원하여 기존의 인스턴스를 재사용하는 식인것으로 보임. 따라서 다른 화면들과 다르게 화면을 벗어나도, 뷰모델이 파괴되지않고 유지되는듯 |
josushell
approved these changes
Mar 31, 2024
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.
다만 지금 슬랙에 언급한 API 관련 문제가 존재하여 해당 문제를 먼저 해결해야할듯(서버 데이터 관련 문제)