@onekeyfe/react-native-device-utils 1.1.17 → 1.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/src/main/java/com/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtils.kt
CHANGED
|
@@ -786,17 +786,22 @@ class ReactNativeDeviceUtils : HybridReactNativeDeviceUtilsSpec(), LifecycleEven
|
|
|
786
786
|
|
|
787
787
|
// MARK: - User Interface Style
|
|
788
788
|
|
|
789
|
-
override fun setUserInterfaceStyle(style:
|
|
789
|
+
override fun setUserInterfaceStyle(style: UserInterfaceStyle) {
|
|
790
|
+
val styleString = when (style) {
|
|
791
|
+
UserInterfaceStyle.LIGHT -> "light"
|
|
792
|
+
UserInterfaceStyle.DARK -> "dark"
|
|
793
|
+
UserInterfaceStyle.UNSPECIFIED -> "unspecified"
|
|
794
|
+
}
|
|
790
795
|
try {
|
|
791
796
|
val context = NitroModules.applicationContext
|
|
792
797
|
if (context != null) {
|
|
793
798
|
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
|
794
|
-
prefs.edit().putString(PREF_KEY_UI_STYLE,
|
|
799
|
+
prefs.edit().putString(PREF_KEY_UI_STYLE, styleString).apply()
|
|
795
800
|
}
|
|
796
801
|
} catch (e: Exception) {
|
|
797
802
|
// Ignore save errors
|
|
798
803
|
}
|
|
799
|
-
applyUserInterfaceStyle(
|
|
804
|
+
applyUserInterfaceStyle(styleString)
|
|
800
805
|
}
|
|
801
806
|
|
|
802
807
|
// MARK: - Background Color
|
|
@@ -69,9 +69,9 @@ class ReactNativeDeviceUtils: HybridReactNativeDeviceUtilsSpec {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
public func setUserInterfaceStyle(style:
|
|
73
|
-
UserDefaults.standard.set(style, forKey: ReactNativeDeviceUtils.userInterfaceStyleKey)
|
|
74
|
-
applyUserInterfaceStyle(style)
|
|
72
|
+
public func setUserInterfaceStyle(style: UserInterfaceStyle) throws -> Void {
|
|
73
|
+
UserDefaults.standard.set(style.stringValue, forKey: ReactNativeDeviceUtils.userInterfaceStyleKey)
|
|
74
|
+
applyUserInterfaceStyle(style.stringValue)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
public func changeBackgroundColor(r: Double, g: Double, b: Double, a: Double) throws -> Void {
|