-
Notifications
You must be signed in to change notification settings - Fork 1
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
Navigation is a pain with Navigation Compose API #149
Comments
Probably using https://github.com/slackhq/circuit is a good idea, but that would mean using MVP? Need to explore |
As a temporary workaround will serialize the concrete data types into JSON format and then deserialize them back into their original concrete types. val fromStopItem: StopItem? = backStackEntry.savedStateHandle.get<String>(SearchStopFieldType.FROM.key)
?.let { fromJsonString(it) }
val toStopItem: StopItem? = backStackEntry.savedStateHandle.get<String>(SearchStopFieldType.TO.key)
?.let { fromJsonString(it) } This creates a core problem, that now values are nullable and it needs to be handled. We should be able to pass data around, and ensure it will be non null. |
Two major issues with using Navigation Compose API:
|
Another problem: I had to create two different variables for saving one thing. In this PR #168 , // This holds Arguments value
val fromArg = backStackEntry.savedStateHandle.get<String>(SearchStopFieldType.FROM.key)?.let { fromJsonString(it) }
val toArg = backStackEntry.savedStateHandle.get<String>(SearchStopFieldType.TO.key)?.let { fromJsonString(it) }
// This holds state value for Screen
var fromStopItem: StopItem? by rememberSaveable { mutableStateOf(fromArg) }
var toStopItem: StopItem? by rememberSaveable { mutableStateOf(toArg) } The first variable When reverse button is clicked, then the data has to be changed twice because of two variables requirement. Timber.d("onReverseButtonClick:")
val bufferStop = fromStopItem
backStackEntry.savedStateHandle[SearchStopFieldType.FROM.key] = toStopItem?.toJsonString()
backStackEntry.savedStateHandle[SearchStopFieldType.TO.key] = bufferStop?.toJsonString()
fromStopItem = toStopItem
toStopItem = bufferStop
|
Exploring Circuit here - https://github.com/ksharma-xyz/Circuit-Demo |
I would really like to pass some data around different screens such as
StopItem
, but need to implementParcelable
for all data types used.I am unable to do this:
The text was updated successfully, but these errors were encountered: