File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
lib/android/app/src/main/java/com/reactnativenavigation/utils Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,18 @@ package com.reactnativenavigation.utils
22
33import android.content.Context
44import android.content.res.Configuration
5- import android.content.res.Configuration.UI_MODE_NIGHT_YES
5+ import androidx.appcompat.app.AppCompatDelegate
66import com.facebook.react.ReactApplication
77import com.reactnativenavigation.NavigationApplication
88
99fun Context.isDebug (): Boolean {
1010 return (applicationContext as ReactApplication ).reactNativeHost.useDeveloperSupport
1111}
1212fun isDarkMode () = NavigationApplication .instance.isDarkMode()
13- fun Context.isDarkMode (): Boolean =
14- (resources.configuration.uiMode and Configuration .UI_MODE_NIGHT_MASK ) == UI_MODE_NIGHT_YES
15- fun Configuration.isDarkMode () = (uiMode and Configuration .UI_MODE_NIGHT_MASK ) == UI_MODE_NIGHT_YES
13+ fun Context.isDarkMode (): Boolean = when (AppCompatDelegate .getDefaultNightMode()) {
14+ AppCompatDelegate .MODE_NIGHT_YES -> true
15+ AppCompatDelegate .MODE_NIGHT_NO -> false
16+ else -> resources.configuration.isDarkMode()
17+ }
18+ fun Configuration.isDarkMode () =
19+ (uiMode and Configuration .UI_MODE_NIGHT_MASK ) == Configuration .UI_MODE_NIGHT_YES
You can’t perform that action at this time.
0 commit comments