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.

In app dark mode setting is ignored & missing manual dark mode override

See original GitHub issue

Situation / problem: I’m currently using Compose in conjunction with views and I’m utilizing my already defined Material Design theme via the MDC-Android Compose Theme Adapter. This works actually great, except for a dark mode applied in app via AppCompatDelegate.setDefaultNightMode(darkMode) and not system wide. The app always stays in the system wide defined theme. That makes actually sense as the ComponentActivity isn’t aware of the AppCompat part.

Fix idea: It would be great if this could “just work” somehow, but I’m unaware if this is somehow possible. As an easy fix and addition to this library it would be great to just have a switch for the MdcTheme() constructor or the createMdcTheme() method, to manually set the mode to dark or light.

Used library version: 1.0.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

2reactions
Frank1234commented, Jun 3, 2022

Thank you. I don’t think you even need to override the darkmode colors manually? I got it working like this, I believe:


                val (colorScheme, typography) = createMdcTheme(
                    context = context, LayoutDirection.Ltr
                )

                MaterialTheme(
                    colors = colorScheme!!,
                    typography = typography!!,
                ) {
                    ... composable content here
                }

setDefaultNightMode is taken into account, it takes the correct colors from my -night theme.

1reaction
Boehrsicommented, Jun 9, 2022

@Frank1234 I just double checked this in the project where I initially had the problem. I can confirm everything is working now. Closing this as it’s working as intended now (tested with version 1.1.5).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable dark mode in iOS
Set Appearance (UIUserInterfaceStyle) key to Light will disable dark mode for an entire app.
Read more >
Dark theme | Android Developers
Dark theme applies to both the Android system UI and apps running on the device. There are three ways to enable Dark theme...
Read more >
Choosing a Specific Interface Style for Your iOS App
Adopt a specific interface style for your views, view controllers, or app when it is inappropriate to support both light and dark variants....
Read more >
Overriding Dark Mode
A quick review and practical example of overriding the device appearance (dark mode) setting for a view, view controller or entire App.
Read more >
javascript - how to prevent force dark mode by system?
Google has released an article explaining different methods for enabling forced dark mode, and strategies to handle dem both by JavaScript ...
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