Giter VIP home page Giter VIP logo

Comments (6)

raamcosta avatar raamcosta commented on May 29, 2024 1

@stanleyguevara please try 1.10.2. Thank you again so much for reporting this! 👍

from compose-destinations.

raamcosta avatar raamcosta commented on May 29, 2024

Hi @stanleyguevara !

I have no idea how this was like this for so long, thank you so much for taking the time to report 🙇
Indeed there's an issue specifically with ArrayList.

I will fix it and release a new version, today still. In the meantime, as you found, Array work fine until that is done!

from compose-destinations.

ehammo avatar ehammo commented on May 29, 2024

Hey @raamcosta just to let you know there is still a problem in 1.10.2 when passing an ArrayList and the list is empty.
When the list is empty I get this crash:

java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.lang.String.substring(String.java:2064)
at java.lang.String.subSequence(String.java:2107)
at com.ramcosta.composedestinations.navargs.primitives.arraylist.DestinationsEnumArrayListNavType.parseValue(DestinationsEnumArrayListNavType.kt:31

Not sure why. My current solution is to make it nullable, and pass null when empty.

from compose-destinations.

raamcosta avatar raamcosta commented on May 29, 2024

Hi @ehammo

I cannot reproduce this on my machine. Can you tell me more about the nav arguments of this destination? Is it the only nav arg?
It would also be nice if you could go into DestinationsNavController.navigate method and place a breakpoint in there and tell me how the route parameter looks like.

Thank you!

from compose-destinations.

ehammo avatar ehammo commented on May 29, 2024

This is how the code looks like:

data class MyCustomNavArg(
val optionalString: String? = null,
val listOfEnum: ArrayList = ArrayList(),
) : Parcelable

data class AnotherDataClass(
val optionalString: String? = null,
val listOfEnum: List = listOf(),
) : Parcelable

@destination(navArgsDelegate = MyCustomNavArg::class)
@composable
fun MyCustomDestination(...

@destination
@composable
fun AnotherDestination(
navigator: DestinationsNavigator,
) {
data: AnotherDataClass = AnotherDataClass(optionalString = "String")
navigator.navigate(
MyCustomDestination(
optionalString = data.optionalString,
listOfEnum = ArrayList(data.list)
)
)
}

Route looks like this:
"my_custom_destination?optionalString=String&listOfEnum="

from compose-destinations.

raamcosta avatar raamcosta commented on May 29, 2024

I still can't reproduce it.

Here is the exact code I'm using.

@Parcelize
data class MyCustomNavArg(
    val optionalString: String? = null,
    val listOfEnum: ArrayList<Stuff> = ArrayList(),
) : Parcelable

@Parcelize
data class AnotherDataClass(
    val optionalString: String? = null,
    val listOfEnum: List<Stuff> = listOf(),
) : Parcelable

@Destination(navArgsDelegate = MyCustomNavArg::class)
@Composable
fun MyCustom(navArgs: MyCustomNavArg) {
    Text(navArgs.toString())
}

@Destination
@Composable
fun Another(
    navigator: DestinationsNavigator,
) {
    val data = remember { AnotherDataClass(optionalString = "String") }
    LaunchedEffect(data) {
        delay(500)
        navigator.navigate(
            MyCustomDestination(
                optionalString = data.optionalString,
                listOfEnum = ArrayList(data.listOfEnum)
            )
        )
    }
}

The route is my_custom?optionalString=String&listOfEnum=[]. I am navigating to the "AnotherDestination" which then automatically navigates to "MyCustomDestination" after 500ms.

Stuff is a enum class.

from compose-destinations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.