Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show preview of VideoEditScreen #23

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

l2hyunwoo
Copy link

Issue

Current preview of VideoEditScreen can't be rendered due to initialization of viewmodel in screen composable function.

    val viewModel: VideoEditScreenViewModel = hiltViewModel()

Solution

I separate initialization logic to screen wrapper composable's input parameter. As I moved the ViewModel towards the input parameter of the Wrapper composable, I found that the state within the existing function also needed to be moved towards the wrapper.

Changed

  • Before
스크린샷 2024-02-15 오후 7 07 39
  • After
스크린샷 2024-02-15 오후 7 07 59

) {
val context = LocalContext.current

val viewModel: VideoEditScreenViewModel = hiltViewModel()
viewModel.setChatId(chatId)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic can replace with ViewModel's SavedStateHandle.get

Comment on lines +102 to +104
if (isFinishedEditing) {
navController.popBackStack("chat/$chatId", false)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I this logic should be considered as side-effect caused by isFinishedEditing, so I think it should be isolated by LaunchedEffect

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