Check out example codes for "kotlin detect dark mode". It will help you in understanding the concepts better.

Code Example 1

val mode = context?.resources?.configuration?.uiMode?.and(Configuration.UI_MODE_NIGHT_MASK)
    when (mode) {
        Configuration.UI_MODE_NIGHT_YES -> {}
        Configuration.UI_MODE_NIGHT_NO -> {}
        Configuration.UI_MODE_NIGHT_UNDEFINED -> {}
    }

Learn ReactJs, React Native from akashmittal.com