-
-
Save egorikftp/e3a0e8a041a7a65bfbda21e567dcc10c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Listen app theme mode (dark, light) | |
private val selectedThemeChannel: ConflatedBroadcastChannel<String> by lazy { | |
ConflatedBroadcastChannel<String>().also { channel -> | |
channel.trySend(selectedTheme) | |
} | |
} | |
private val changeListener = SharedPreferences.OnSharedPreferenceChangeListener { _, key -> | |
when (key) { | |
PREF_DARK_MODE_ENABLED -> selectedThemeChannel.trySend(selectedTheme) | |
} | |
} | |
val selectedThemeFlow: Flow<String> | |
get() = selectedThemeChannel.asFlow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment