adrielcafe / voyager

🛸 A pragmatic navigation library for Jetpack Compose
https://voyager.adriel.cafe
MIT License
2.58k stars 136 forks source link

Hilt integration doesn't support Screen classes #15

Closed xinkev closed 3 years ago

xinkev commented 3 years ago

I don't if that is intentional.Hilt integration only works with AndroidScreen. Also, docs seems incomplete... There is a sample project for that though.

programadorthi commented 3 years ago

Hi @isshindev we didn't know that Hilt works in another stack instead of Android only. Can you share what stack is your project? The main reason that HIlt doesn't works with Screen is because Hilt needs Android context and that is provided by an AndroidScreen only. Screen was projected to work in KMM projects and Hilt doesn't works with KMM projects until now.

xinkev commented 3 years ago

Sorry, I didn't know about that. I was only using Screen all along. Now that I think about it, it's true that hilt works with Android only. Then, documentation seems a little miss leading since Screen was used in the examples.

Here's one thing I'm really curious though. You said Android context is only provided by AndroidScreen. But we can get also get it inside any Composable functions with LocalContext.current. So, what's the different?

Thanks!

Tolriq commented 3 years ago

Another side effect of this is that hilt integration does not work in TabNavigator as the Tab expands Screen and not AndroidScreen.

xinkev commented 3 years ago

Good point! I didn't notice because I was only using empty tabs with a Navigator inside them.

programadorthi commented 3 years ago

Hi guys, there was a misunderstood here. I was thinking that we were talking about Androidx ViewModel. There is no need to Hilt and ScreenModel be exclusive to AndroidScreen really. It was a mistake because first purpose was to create an integration with Androix ViewModel. We have fixed here #18

adrielcafe commented 3 years ago

Fixed on 1.0.0-beta13, feel free to reopen if the issue persists.