question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dark mode demo not working

See original GitHub issue

Captura de pantalla 2021-03-08 a las 9 26 04

Hi.

I’m using this code to change (and animate) dark mode from a debug drawer:

@Composable
fun RestaurantMenuNumbersTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    darkThemeState: MutableState<Boolean> = remember { mutableStateOf(darkTheme) },
    content: @Composable (MutableState<Boolean>) -> Unit,
) {

    val transition = updateTransition(targetState = darkThemeState.value)

    val colors = if (darkThemeState.value) {
        DarkColorPalette
    } else {
        LightColorPalette
    }

    val animateColors = Colors(
        primary = transition.animateColor { colors.primary }.value,
        primaryVariant = transition.animateColor { colors.primaryVariant }.value,
        secondary = transition.animateColor { colors.secondary }.value,
        secondaryVariant = transition.animateColor { colors.secondaryVariant }.value,
        background = transition.animateColor { colors.background }.value,
        surface = transition.animateColor { colors.surface }.value,
        error = transition.animateColor { colors.error }.value,
        onPrimary = transition.animateColor { colors.onPrimary }.value,
        onSecondary = transition.animateColor { colors.onSecondary }.value,
        onBackground = transition.animateColor { colors.onBackground }.value,
        onSurface = transition.animateColor { colors.onSurface }.value,
        onError = transition.animateColor { colors.onError }.value,
        isLight = colors.isLight,
    )

    MaterialTheme(
        colors = animateColors,
        typography = Typography,
        shapes = Shapes,
        content = { content(darkThemeState) }
    )
}

So, showkase not shows the dark mode / l right mode correctly

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18

github_iconTop GitHub Comments

1reaction
alormacommented, Mar 17, 2021

Uhmmm, I think yes … but no worry, feel free to close this issue

0reactions
vinaygabacommented, Mar 16, 2021

I think this is because in the last screenshot, you have enabled dark mode system wide. That forces the other previews to also render what its supposed to render in dark mode. Was dark mode enabled system wide when you took the 3rd screenshot? @alorma

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Fyne error: Failed to set dark mode" loading fyne_demo · ...
I have my windows install running in dark mode. The Fyne demo loads in dark mode for me with this set. Changing it...
Read more >
A Complete Guide to Dark Mode on the Web
Let's combine everything and create a working demo that: Automatically loads a dark or light theme based on system preferences; Allows the user ......
Read more >
Not able to achieve dark mode using SwiftUI [duplicate]
I am using the above code to achieve dark mode on my demo project but its not working. Any help or insight would...
Read more >
HubSpot | Dark Mode Demo
Demonstration on how one can implement a dark mode on a site using css variables ... Necessitatibus praesentium deserunt non ad, voluptatibus error...
Read more >
Dark theme | Android Developers
Dark theme applies to both the Android system UI and apps running on the device. ... Other OEMs may or may not support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found