-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathContext.kt
More file actions
19 lines (17 loc) · 789 Bytes
/
Context.kt
File metadata and controls
19 lines (17 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.reactnativenavigation.utils
import android.content.Context
import android.content.res.Configuration
import androidx.appcompat.app.AppCompatDelegate
import com.facebook.react.ReactApplication
import com.reactnativenavigation.NavigationApplication
fun Context.isDebug(): Boolean {
return (applicationContext as ReactApplication).reactNativeHost.useDeveloperSupport
}
fun isDarkMode() = NavigationApplication.instance.isDarkMode()
fun Context.isDarkMode(): Boolean = when (AppCompatDelegate.getDefaultNightMode()) {
AppCompatDelegate.MODE_NIGHT_YES -> true
AppCompatDelegate.MODE_NIGHT_NO -> false
else -> resources.configuration.isDarkMode()
}
fun Configuration.isDarkMode() =
(uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES