-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
screen model doesn't survive the configuration changes #62
Comments
I think Hilt has nothing to do with it. I tried to do it without Hilt and still the ScreenModel is recreated. Maybe I'm not understanding correctly and it should be recreated when the phone rotates? |
I'm completely bewildered right now. I run the sample application and it works as it should. I completely copy the Activity, Screen, ScreenModel code in my app (where I want to migrate to voyager) and the screenmodel starts recreating when I flip the phone. Can anyone help me ? |
Try this, I only use object screens when there will be no view/screen models, and when using a regular Screen you should set the id like |
Where i need to use It started with Navigator(HiltListScreen()) |
Something like Its a safeguard because Compose can re-create classes based on parent composables. |
Here is cleaned project to show my problem: Here is Activity: When i rotate phone i see that screen is not recreated. But screen model is recreated. |
I tried with remember. Same result ;( |
Ok I did some testing and this bug seems to be related to the changes done in 1.0.0-rc01, it doesnt happen in 1.0.0-beta16. So I guess use 1.0.0-beta16 for now until its fixed |
You are right! Thanks! On 1.0.0-beta16 it works good. My problem is i started sample app from main branch where issue solved already. |
I've commented on #66 about a refactoring I'm doing that should solve all Android related issues (including configuration changes). It may take a while but will be worth it. |
@Anton111111 |
* Settings: M3 and two pane ui * TrackingLoginDialog: Move close button * Use small top bar * Revert "Update voyager to v1.0.0-rc02" This reverts commit 570fec6. adrielcafe/voyager#62 (cherry picked from commit 5c5468f) # Conflicts: # app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt # app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt # app/src/main/java/eu/kanade/presentation/more/settings/widget/TextPreferenceWidget.kt
I try use Screen + ScreenModel + Hilt.
I create Screen like this:
And my ScreenModel:
But when i rotate my phone screen model recreated. Shouldn't the screen model survive the configuration changes? OR am I doing something wrong?
The text was updated successfully, but these errors were encountered: