Thread
#compose
    manueldidonna

    manueldidonna

    1 year ago
    I'm exploring the navigation library with compose, I get that the navigation is string based, so any arguments I want to pass to the composable must be inserted in the route string. I have 2 screens. In the first screen the user creates a
    SearchRequest
    to pass to the second screen that uses it to fetch the items from a web server.
    data class SearchRequest(
        val departFrom: String,
        val arriveAt: String,
        val departureTime: Time, // data class with day, month and year
        val departureDate: Date // data class with minute and hour
    )
    What's the best way to translate this object to a route without parcelizing it?
    Rajan Kali

    Rajan Kali

    1 year ago
    If you do not want to use Parcel, then I would suggest to go for JSON String , convert it to json and pass it as String and parse it back to class
    manueldidonna

    manueldidonna

    1 year ago
    Here is what I've done
    // route = "solutions/{departure}/{arrival}/{datetime}"
    val navigationArguments = navBackStackEntry.arguments ?: bundleOf()
    val departure = navigationArguments.getString("departure", "")
    val arrival = navigationArguments.getString("arrival", "")
    val datetime = LocalDateTime.parse(navigationArguments.getString("datetime", ""))