Skip to content
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

Compose: provide the way to get the end of the sequentially showed balloons. Still not working after 1.6.3 #549

Open
Monabr opened this issue Dec 1, 2023 · 3 comments
Labels
compose Jetpack Compose Issue

Comments

@Monabr
Copy link

Monabr commented Dec 1, 2023

Please complete the following information:

  • Library Version 1.6.3

Describe the Bug:

After update to 1.6.3 setOnBalloonDismissListener still not working. Here is my way of using it.

  1. Get all BalloonWindow by callback from views to parent view class-helper fields
  2. In LaunchEffect check if they all are not null
  3. Show them one after one and after all is shown get action from setOnBalloonDismissListener

So here are examples.

onBalloonWindowReady = {
      onboardingBalloonHelper.value.dateWindow = it
}
class OnboardingBalloonHelper {
    var dateWindow: BalloonWindow? = null
    . . .
LaunchedEffect(
        onboardingBalloonHelper.value.categoryWindow,
        onboardingBalloonHelper.value.switchWindow,
        onboardingBalloonHelper.value.dateWindow
    ) {
        if (
            onboardingBalloonHelper.value.categoryWindow != null &&
            onboardingBalloonHelper.value.switchWindow != null &&
            onboardingBalloonHelper.value.dateWindow != null
        ) {
            onboardingBalloonHelper.value.categoryWindow?.awaitAlignTop()
            onboardingBalloonHelper.value.switchWindow?.awaitAlignBottom()
            onboardingBalloonHelper.value.dateWindow?.let {
                it.setOnBalloonDismissListener {
                    log("OnBalloonDismissListene")
                }
                it.awaitAlignBottom()
            }
        }
    }

Expected Behavior:

setOnBalloonDismissListener works

@Monabr
Copy link
Author

Monabr commented Dec 2, 2023

I found on that there is 2 setOnBalloonDismissListener exists: for Balloon and for BalloonWindow, and the second one is not working. I make it work by using listener for the first one. However the docs tells nothing about that. This happened because my deep dive into source code but normally I should be able to get this info from docs.

@kpetriv
Copy link

kpetriv commented Dec 4, 2023

I'm not sure if it fits your case, but it works when doing the balloons with a state in the parent composable.

enum class Tutorial(val step: Int?) {
 None(0),
 ShowX(1),
 ShowY(2),
 Close(null),
}

Then have the state at the top

var tutorialStep by remember { mutableStateOf(Tutorial.NONE) }

Implement the logic for increasing the steps and have helper method Tutorial.next()

Add the LaunchedEffect at the end of the parent composable

LaunchedEffect(tutorialStep) {
        if (tutorialStep == Tutorial.NONE) tutorialStep = tutorialStep.next()
    }

When you want to skip the tutorial or close it at the very end all you need to do is set the tutorialStep = null

At least this works for me as I am building a sequence of balloons and I think this should be slightly less bulky than all the conditional statements you have there and easier to understand

@Alembertcn
Copy link

The kotlin version of our project is only 1.5.0 but your latest version is 1.9.0. What if you fix some bugs in the latest version and I have to use the older version

@skydoves skydoves added the compose Jetpack Compose Issue label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compose Jetpack Compose Issue
Projects
None yet
Development

No branches or pull requests

4 participants