skydoves / Balloon

:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
https://skydoves.github.io/libraries/balloon/html/balloon/com.skydoves.balloon/index.html
Apache License 2.0
3.7k stars 289 forks source link

Balloon content not visible in dark theme #660

Closed Breens-Mbaka closed 2 months ago

Breens-Mbaka commented 3 months ago

Please complete the following information:

Describe the Bug: The content of the balloon isn't visible in the dark theme

Expected Behavior: The content of the ballon should be visible both in dark and light theme

skydoves commented 3 months ago

Hey @Breens-Mbaka, would you describe the details? It would be good if you can contain several code snippets and the result (screenshot). Also, do you use Compose or XML?

skydoves commented 3 months ago

The demo project works well in dark theme since I've only used dark theme on my devices.

Breens-Mbaka commented 3 months ago

Hi @skydoves I'm using Compose and the issue comes up when I change from light theme to dark theme.

here is the code and screenshot of the balloon not adapting to the dark theme:

Screenshot 2024-06-24 at 08 44 19 Screenshot 2024-06-24 at 08 51 34
skydoves commented 3 months ago

They @Breens-Mbaka, Balloon doesn't apply any Compose theme (Material, Material3, or custom themes), due to providing flexibility to users. So you should apply background color or text color depending on your theme.

balloonContent = {
 Box(modifier = Modifier.background(MaterialTheme.colors.background)) {
  Text(
      color = //
   )
 }
}

The most recommended way is setting the colors when you build the Balloon.Builder like the example below:

      val background = MaterialTheme.colors.background
      val textColor = if (isSystemInDarkTheme()) {
        Color.White
      } else {
        Color.Black
      }

      val builder = rememberBalloonBuilder {
        setBackgroundColor(background)
        setTextColor(textColor)
        setArrowSize(10)
Breens-Mbaka commented 3 months ago

Thanks @skydoves it has worked. I propose maybe this can be explicitly added to the README if it doesn't exist, so that people who have a challenge like mine will be helped and avoid raising the same issue again. What do you think ?

skydoves commented 2 months ago

Hey @Breens-Mbaka, thank you for your report and feedback!