pushpalroy / JetLime

A Kotlin Multiplatform library to display a timeline view. 🍋
https://jetlime.pushpalroy.com
MIT License
461 stars 24 forks source link

Way to click/interact with JetLimeItem? #11

Closed MauResendez closed 9 months ago

MauResendez commented 2 years ago

Is there a way to be able to click on a JetLimeItem? I'm currently looking to add a dialog once the user clicks on a JetLimeItem to display the route's information and to navigate to a map screen.

pushpalroy commented 9 months ago

Will add support for this soon.

pushpalroy commented 9 months ago

Right now with the release v1.0.6 this can be only achieved using the content parameter of JetLimeItem which is a Composable lambda. We can drop all other arguments of JetLimeItem and pass only the content like this:

JetLimeItem {
      val context = LocalContext.current
      Text(
        text = "Click me to show a toast",
        style = JetLimeTypography.body1,
        modifier = Modifier
          .clickable {
          Toast.makeText(context, "This item has been clicked", Toast.LENGTH_SHORT).show()
        }
      )
    }

Note this is not the best solution as right now it's impossible to add a click listener to the entire JetLimeItem by design. The only solution is the one that I just mentioned above.

I have created a separate issue here to make this library more flexible and redesign its API: https://github.com/pushpalroy/jetlime/issues/18

I will close this issue for now and track this on the new issue created.

pushpalroy commented 9 months ago

Closing this issue as this will be further tracked in https://github.com/pushpalroy/jetlime/issues/18