react-native-unistyles 2.3.0-beta.2 → 2.4.0-rc.0
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +1 -0
- package/android/src/main/cxx/cpp-adapter.cpp +10 -16
- package/android/src/main/cxx/helpers.cpp +79 -0
- package/android/src/main/cxx/helpers.h +9 -0
- package/android/src/main/java/com/unistyles/Platform.kt +92 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +23 -32
- package/cxx/UnistylesRuntime.cpp +25 -1
- package/cxx/UnistylesRuntime.h +14 -3
- package/ios/UnistylesModule.mm +3 -1
- package/ios/platform/Platform_iOS.h +3 -0
- package/ios/platform/Platform_iOS.mm +28 -1
- package/ios/platform/Platform_macOS.h +3 -0
- package/ios/platform/Platform_macOS.mm +28 -1
- package/lib/commonjs/core/UnistylesModule.js +14 -0
- package/lib/commonjs/core/UnistylesModule.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +16 -0
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/core/UnistylesModule.js +14 -0
- package/lib/module/core/UnistylesModule.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +16 -0
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +10 -0
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/types/unistyles.d.ts +12 -0
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +2 -3
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/UnistylesModule.ts +15 -1
- package/src/core/UnistylesRuntime.ts +16 -0
- package/src/types/unistyles.ts +14 -0
- package/src/types/variants.ts +7 -8
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.h +24 -2
package/android/CMakeLists.txt
CHANGED
@@ -1,24 +1,14 @@
|
|
1
1
|
#include <jni.h>
|
2
2
|
#include <jsi/jsi.h>
|
3
|
+
#include <map>
|
3
4
|
#include "UnistylesRuntime.h"
|
5
|
+
#include "helpers.h"
|
4
6
|
|
5
7
|
using namespace facebook;
|
6
8
|
|
7
9
|
static jobject unistylesModule = nullptr;
|
8
10
|
std::shared_ptr<UnistylesRuntime> unistylesRuntime = nullptr;
|
9
11
|
|
10
|
-
void throwKotlinException(
|
11
|
-
JNIEnv *env,
|
12
|
-
const char *message
|
13
|
-
) {
|
14
|
-
jclass runtimeExceptionClass = env->FindClass("java/lang/RuntimeException");
|
15
|
-
|
16
|
-
if (runtimeExceptionClass != nullptr) {
|
17
|
-
env->ThrowNew(runtimeExceptionClass, message);
|
18
|
-
env->DeleteLocalRef(runtimeExceptionClass);
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
12
|
extern "C"
|
23
13
|
JNIEXPORT void JNICALL
|
24
14
|
Java_com_unistyles_UnistylesModule_nativeInstall(
|
@@ -28,7 +18,9 @@ Java_com_unistyles_UnistylesModule_nativeInstall(
|
|
28
18
|
jint screenWidth,
|
29
19
|
jint screenHeight,
|
30
20
|
jstring colorScheme,
|
31
|
-
jstring contentSizeCategory
|
21
|
+
jstring contentSizeCategory,
|
22
|
+
jobject insets,
|
23
|
+
jobject statusBar
|
32
24
|
) {
|
33
25
|
auto runtime = reinterpret_cast<facebook::jsi::Runtime *>(jsi);
|
34
26
|
|
@@ -52,7 +44,9 @@ Java_com_unistyles_UnistylesModule_nativeInstall(
|
|
52
44
|
screenWidth,
|
53
45
|
screenHeight,
|
54
46
|
colorSchemeStr,
|
55
|
-
contentSizeCategoryStr
|
47
|
+
contentSizeCategoryStr,
|
48
|
+
jobjectToStdMap(env, insets),
|
49
|
+
jobjectToStdMap(env, statusBar)
|
56
50
|
);
|
57
51
|
|
58
52
|
unistylesRuntime->onThemeChange([=](const std::string &theme) {
|
@@ -109,9 +103,9 @@ Java_com_unistyles_UnistylesModule_nativeDestroy(JNIEnv *env, jobject thiz) {
|
|
109
103
|
|
110
104
|
extern "C"
|
111
105
|
JNIEXPORT void JNICALL
|
112
|
-
Java_com_unistyles_UnistylesModule_nativeOnOrientationChange(JNIEnv *env, jobject thiz, jint width, jint height) {
|
106
|
+
Java_com_unistyles_UnistylesModule_nativeOnOrientationChange(JNIEnv *env, jobject thiz, jint width, jint height, jobject insets, jobject statusBar) {
|
113
107
|
if (unistylesRuntime != nullptr) {
|
114
|
-
unistylesRuntime->handleScreenSizeChange(width, height);
|
108
|
+
unistylesRuntime->handleScreenSizeChange(width, height, jobjectToStdMap(env, insets), jobjectToStdMap(env, statusBar));
|
115
109
|
}
|
116
110
|
}
|
117
111
|
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#include "helpers.h"
|
2
|
+
|
3
|
+
int jobjectToInt(JNIEnv *env, jobject integer) {
|
4
|
+
jclass integerClass = env->FindClass("java/lang/Integer");
|
5
|
+
jmethodID intValueMethod = env->GetMethodID(integerClass, "intValue", "()I");
|
6
|
+
int value = env->CallIntMethod(integer, intValueMethod);
|
7
|
+
|
8
|
+
env->DeleteLocalRef(integerClass);
|
9
|
+
|
10
|
+
return value;
|
11
|
+
}
|
12
|
+
|
13
|
+
std::string jstringToStdString(JNIEnv *env, jstring jStr) {
|
14
|
+
if (!jStr) {
|
15
|
+
return "";
|
16
|
+
}
|
17
|
+
|
18
|
+
const jclass stringClass = env->GetObjectClass(jStr);
|
19
|
+
const jmethodID getBytes = env->GetMethodID(stringClass, "getBytes", "(Ljava/lang/String;)[B");
|
20
|
+
const jbyteArray stringJbytes = (jbyteArray) env->CallObjectMethod(jStr, getBytes, env->NewStringUTF("UTF-8"));
|
21
|
+
|
22
|
+
size_t length = (size_t) env->GetArrayLength(stringJbytes);
|
23
|
+
jbyte* pBytes = env->GetByteArrayElements(stringJbytes, NULL);
|
24
|
+
|
25
|
+
std::string ret = std::string((char *)pBytes, length);
|
26
|
+
env->ReleaseByteArrayElements(stringJbytes, pBytes, JNI_ABORT);
|
27
|
+
|
28
|
+
env->DeleteLocalRef(stringJbytes);
|
29
|
+
env->DeleteLocalRef(stringClass);
|
30
|
+
|
31
|
+
return ret;
|
32
|
+
}
|
33
|
+
|
34
|
+
std::map<std::string, int> jobjectToStdMap(JNIEnv *env, jobject map) {
|
35
|
+
std::map<std::string, int> result;
|
36
|
+
|
37
|
+
jclass setClass = env->FindClass("java/util/Set");
|
38
|
+
jclass iteratorClass = env->FindClass("java/util/Iterator");
|
39
|
+
jmethodID entrySetMethod = env->GetMethodID(env->GetObjectClass(map), "entrySet", "()Ljava/util/Set;");
|
40
|
+
jmethodID iteratorMethod = env->GetMethodID(setClass, "iterator", "()Ljava/util/Iterator;");
|
41
|
+
jobject set = env->CallObjectMethod(map, entrySetMethod);
|
42
|
+
jobject iterator = env->CallObjectMethod(set, iteratorMethod);
|
43
|
+
jmethodID hasNextMethod = env->GetMethodID(iteratorClass, "hasNext", "()Z");
|
44
|
+
jmethodID nextMethod = env->GetMethodID(iteratorClass, "next", "()Ljava/lang/Object;");
|
45
|
+
|
46
|
+
while (env->CallBooleanMethod(iterator, hasNextMethod)) {
|
47
|
+
jobject entry = env->CallObjectMethod(iterator, nextMethod);
|
48
|
+
|
49
|
+
jmethodID getKeyMethod = env->GetMethodID(env->GetObjectClass(entry), "getKey", "()Ljava/lang/Object;");
|
50
|
+
jmethodID getValueMethod = env->GetMethodID(env->GetObjectClass(entry), "getValue", "()Ljava/lang/Object;");
|
51
|
+
jstring key = (jstring) env->CallObjectMethod(entry, getKeyMethod);
|
52
|
+
jobject value = env->CallObjectMethod(entry, getValueMethod);
|
53
|
+
|
54
|
+
result[jstringToStdString(env, key)] = jobjectToInt(env, value);
|
55
|
+
|
56
|
+
env->DeleteLocalRef(entry);
|
57
|
+
env->DeleteLocalRef(key);
|
58
|
+
env->DeleteLocalRef(value);
|
59
|
+
}
|
60
|
+
|
61
|
+
env->DeleteLocalRef(set);
|
62
|
+
env->DeleteLocalRef(iterator);
|
63
|
+
env->DeleteLocalRef(setClass);
|
64
|
+
env->DeleteLocalRef(iteratorClass);
|
65
|
+
|
66
|
+
return result;
|
67
|
+
}
|
68
|
+
|
69
|
+
void throwKotlinException(
|
70
|
+
JNIEnv *env,
|
71
|
+
const char *message
|
72
|
+
) {
|
73
|
+
jclass runtimeExceptionClass = env->FindClass("java/lang/RuntimeException");
|
74
|
+
|
75
|
+
if (runtimeExceptionClass != nullptr) {
|
76
|
+
env->ThrowNew(runtimeExceptionClass, message);
|
77
|
+
env->DeleteLocalRef(runtimeExceptionClass);
|
78
|
+
}
|
79
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#include <jni.h>
|
2
|
+
#include <string>
|
3
|
+
#include <map>
|
4
|
+
|
5
|
+
int jobjectToInt(JNIEnv *env, jobject integer);
|
6
|
+
std::string jstringToStdString(JNIEnv *env, jstring jStr);
|
7
|
+
std::map<std::string, int> jobjectToStdMap(JNIEnv *env, jobject map);
|
8
|
+
|
9
|
+
void throwKotlinException(JNIEnv *env, const char *message);
|
@@ -0,0 +1,92 @@
|
|
1
|
+
package com.unistyles
|
2
|
+
|
3
|
+
import android.annotation.SuppressLint
|
4
|
+
import android.content.res.Configuration
|
5
|
+
import android.os.Build
|
6
|
+
import android.view.WindowInsets
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
8
|
+
|
9
|
+
class Platform(private val reactApplicationContext: ReactApplicationContext) {
|
10
|
+
@SuppressLint("InternalInsetResource", "DiscouragedApi", "ObsoleteSdkInt")
|
11
|
+
fun getConfig(): Map<String, Any> {
|
12
|
+
val displayMetrics = reactApplicationContext.resources.displayMetrics
|
13
|
+
val fontScale = reactApplicationContext.resources.configuration.fontScale
|
14
|
+
val screenWidth = (displayMetrics.widthPixels / displayMetrics.density).toInt()
|
15
|
+
val screenHeight = (displayMetrics.heightPixels / displayMetrics.density).toInt()
|
16
|
+
|
17
|
+
return mapOf(
|
18
|
+
"width" to screenWidth,
|
19
|
+
"height" to screenHeight,
|
20
|
+
"colorScheme" to getColorScheme(),
|
21
|
+
"contentSizeCategory" to getContentSizeCategory(fontScale),
|
22
|
+
"insets" to getScreenInsets(displayMetrics.density),
|
23
|
+
"statusBar" to mapOf(
|
24
|
+
"height" to getStatusBarHeight(displayMetrics.density),
|
25
|
+
"width" to screenWidth
|
26
|
+
)
|
27
|
+
)
|
28
|
+
}
|
29
|
+
|
30
|
+
private fun getContentSizeCategory(fontScale: Float): String {
|
31
|
+
val contentSizeCategory = when {
|
32
|
+
fontScale <= 0.85f -> "Small"
|
33
|
+
fontScale <= 1.0f -> "Default"
|
34
|
+
fontScale <= 1.15f -> "Large"
|
35
|
+
fontScale <= 1.3f -> "ExtraLarge"
|
36
|
+
else -> "Huge"
|
37
|
+
}
|
38
|
+
|
39
|
+
return contentSizeCategory
|
40
|
+
}
|
41
|
+
|
42
|
+
private fun getColorScheme(): String {
|
43
|
+
val colorScheme = when (reactApplicationContext.resources.configuration.uiMode.and(Configuration.UI_MODE_NIGHT_MASK)) {
|
44
|
+
Configuration.UI_MODE_NIGHT_YES -> "dark"
|
45
|
+
Configuration.UI_MODE_NIGHT_NO -> "light"
|
46
|
+
else -> "unspecified"
|
47
|
+
}
|
48
|
+
|
49
|
+
return colorScheme
|
50
|
+
}
|
51
|
+
|
52
|
+
@Suppress("DEPRECATION")
|
53
|
+
private fun getScreenInsets(density: Float): Map<String, Int> {
|
54
|
+
val insets = mutableMapOf(
|
55
|
+
"top" to 0,
|
56
|
+
"bottom" to 0,
|
57
|
+
"left" to 0,
|
58
|
+
"right" to 0
|
59
|
+
)
|
60
|
+
|
61
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
62
|
+
val systemInsets = reactApplicationContext.currentActivity?.window?.decorView?.rootWindowInsets?.getInsets(WindowInsets.Type.displayCutout())
|
63
|
+
|
64
|
+
insets["top"] = ((systemInsets?.top ?: 0) / density).toInt()
|
65
|
+
insets["bottom"] = ((systemInsets?.bottom ?: 0) / density).toInt()
|
66
|
+
insets["left"] = ((systemInsets?.left ?: 0) / density).toInt()
|
67
|
+
insets["right"] = ((systemInsets?.right ?: 0) / density).toInt()
|
68
|
+
|
69
|
+
return insets
|
70
|
+
}
|
71
|
+
|
72
|
+
val systemInsets = reactApplicationContext.currentActivity?.window?.decorView?.rootWindowInsets
|
73
|
+
|
74
|
+
insets["top"] = ((systemInsets?.systemWindowInsetTop ?: 0) / density).toInt()
|
75
|
+
insets["bottom"] = ((systemInsets?.systemWindowInsetBottom ?: 0) / density).toInt()
|
76
|
+
insets["left"] = ((systemInsets?.systemWindowInsetLeft ?: 0) / density).toInt()
|
77
|
+
insets["right"] = ((systemInsets?.systemWindowInsetRight ?: 0) / density).toInt()
|
78
|
+
|
79
|
+
return insets
|
80
|
+
}
|
81
|
+
|
82
|
+
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
83
|
+
private fun getStatusBarHeight(density: Float): Int {
|
84
|
+
val heightResId = reactApplicationContext.resources.getIdentifier("status_bar_height", "dimen", "android")
|
85
|
+
|
86
|
+
if (heightResId > 0) {
|
87
|
+
return (reactApplicationContext.resources.getDimensionPixelSize(heightResId) / density).toInt()
|
88
|
+
}
|
89
|
+
|
90
|
+
return 0
|
91
|
+
}
|
92
|
+
}
|
@@ -4,7 +4,6 @@ import android.content.BroadcastReceiver
|
|
4
4
|
import android.content.Context
|
5
5
|
import android.content.Intent
|
6
6
|
import android.content.IntentFilter
|
7
|
-
import android.content.res.Configuration
|
8
7
|
import android.os.Handler
|
9
8
|
import android.os.Looper
|
10
9
|
import android.util.Log
|
@@ -15,8 +14,9 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
15
14
|
import com.facebook.react.bridge.ReactMethod
|
16
15
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
17
16
|
|
18
|
-
|
19
17
|
class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext), LifecycleEventListener {
|
18
|
+
private val platform: Platform = Platform(reactContext)
|
19
|
+
|
20
20
|
private val configurationChangeReceiver = object : BroadcastReceiver() {
|
21
21
|
override fun onReceive(context: Context, intent: Intent) {
|
22
22
|
if (intent.action == Intent.ACTION_CONFIGURATION_CHANGED) {
|
@@ -37,6 +37,7 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
37
37
|
reactApplicationContext.registerReceiver(configurationChangeReceiver, IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED))
|
38
38
|
}
|
39
39
|
|
40
|
+
@Deprecated("Deprecated in Java")
|
40
41
|
override fun onCatalystInstanceDestroy() {
|
41
42
|
reactApplicationContext.unregisterReceiver(configurationChangeReceiver)
|
42
43
|
this.nativeDestroy()
|
@@ -44,13 +45,16 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
44
45
|
|
45
46
|
//endregion
|
46
47
|
//region Event handlers
|
48
|
+
@Suppress("UNCHECKED_CAST")
|
47
49
|
private fun onConfigChange() {
|
48
|
-
val config =
|
50
|
+
val config = platform.getConfig()
|
49
51
|
|
50
52
|
reactApplicationContext.runOnJSQueueThread {
|
51
53
|
this.nativeOnOrientationChange(
|
52
54
|
config["width"] as Int,
|
53
|
-
config["height"] as Int
|
55
|
+
config["height"] as Int,
|
56
|
+
config["insets"] as Map<String, Int>,
|
57
|
+
config["statusBar"] as Map<String, Int>
|
54
58
|
)
|
55
59
|
this.nativeOnAppearanceChange(
|
56
60
|
config["colorScheme"] as String
|
@@ -59,37 +63,14 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
59
63
|
}
|
60
64
|
}
|
61
65
|
|
62
|
-
private fun getConfig(): Map<String, Any> {
|
63
|
-
val displayMetrics = reactApplicationContext.resources.displayMetrics
|
64
|
-
val colorScheme = when (reactApplicationContext.resources.configuration.uiMode.and(Configuration.UI_MODE_NIGHT_MASK)) {
|
65
|
-
Configuration.UI_MODE_NIGHT_YES -> "dark"
|
66
|
-
Configuration.UI_MODE_NIGHT_NO -> "light"
|
67
|
-
else -> "unspecified"
|
68
|
-
}
|
69
|
-
val fontScale = reactApplicationContext.resources.configuration.fontScale
|
70
|
-
val contentSizeCategory = when {
|
71
|
-
fontScale <= 0.85f -> "Small"
|
72
|
-
fontScale <= 1.0f -> "Default"
|
73
|
-
fontScale <= 1.15f -> "Large"
|
74
|
-
fontScale <= 1.3f -> "ExtraLarge"
|
75
|
-
else -> "Huge"
|
76
|
-
}
|
77
|
-
|
78
|
-
return mapOf(
|
79
|
-
"width" to (displayMetrics.widthPixels / displayMetrics.density).toInt(),
|
80
|
-
"height" to (displayMetrics.heightPixels / displayMetrics.density).toInt(),
|
81
|
-
"colorScheme" to colorScheme,
|
82
|
-
"contentSizeCategory" to contentSizeCategory
|
83
|
-
)
|
84
|
-
}
|
85
|
-
|
86
66
|
//endregion
|
87
67
|
//region Core
|
68
|
+
@Suppress("UNCHECKED_CAST")
|
88
69
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
89
70
|
fun install(): Boolean {
|
90
71
|
return try {
|
91
72
|
System.loadLibrary("unistyles")
|
92
|
-
val config =
|
73
|
+
val config = platform.getConfig()
|
93
74
|
|
94
75
|
this.reactApplicationContext.javaScriptContextHolder?.let {
|
95
76
|
this.nativeInstall(
|
@@ -97,7 +78,9 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
97
78
|
config["width"] as Int,
|
98
79
|
config["height"] as Int,
|
99
80
|
config["colorScheme"] as String,
|
100
|
-
config["contentSizeCategory"] as String
|
81
|
+
config["contentSizeCategory"] as String,
|
82
|
+
config["insets"] as Map<String, Int>,
|
83
|
+
config["statusBar"] as Map<String, Int>
|
101
84
|
)
|
102
85
|
|
103
86
|
Log.i(NAME, "Installed Unistyles \uD83E\uDD84!")
|
@@ -111,9 +94,17 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
111
94
|
}
|
112
95
|
}
|
113
96
|
|
114
|
-
private external fun nativeInstall(
|
97
|
+
private external fun nativeInstall(
|
98
|
+
jsi: Long,
|
99
|
+
width: Int,
|
100
|
+
height: Int,
|
101
|
+
colorScheme: String,
|
102
|
+
contentSizeCategory: String,
|
103
|
+
insets: Map<String, Int>,
|
104
|
+
statusBar: Map<String, Int>
|
105
|
+
)
|
115
106
|
private external fun nativeDestroy()
|
116
|
-
private external fun nativeOnOrientationChange(width: Int, height: Int)
|
107
|
+
private external fun nativeOnOrientationChange(width: Int, height: Int, insets: Map<String, Int>, statusBar: Map<String, Int>)
|
117
108
|
private external fun nativeOnAppearanceChange(colorScheme: String)
|
118
109
|
private external fun nativeOnContentSizeCategoryChange(contentSizeCategory: String)
|
119
110
|
|
package/cxx/UnistylesRuntime.cpp
CHANGED
@@ -25,6 +25,8 @@ std::vector<jsi::PropNameID> UnistylesRuntime::getPropertyNames(jsi::Runtime& ru
|
|
25
25
|
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("addPlugin")));
|
26
26
|
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("removePlugin")));
|
27
27
|
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("enabledPlugins")));
|
28
|
+
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("insets")));
|
29
|
+
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("statusBar")));
|
28
30
|
|
29
31
|
// setters
|
30
32
|
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("themes")));
|
@@ -233,6 +235,26 @@ jsi::Value UnistylesRuntime::get(jsi::Runtime& runtime, const jsi::PropNameID& p
|
|
233
235
|
}
|
234
236
|
);
|
235
237
|
}
|
238
|
+
|
239
|
+
if (propName == "insets") {
|
240
|
+
auto insets = jsi::Object(runtime);
|
241
|
+
|
242
|
+
insets.setProperty(runtime, "top", this->insets.at("top"));
|
243
|
+
insets.setProperty(runtime, "bottom", this->insets.at("bottom"));
|
244
|
+
insets.setProperty(runtime, "left", this->insets.at("left"));
|
245
|
+
insets.setProperty(runtime, "right", this->insets.at("right"));
|
246
|
+
|
247
|
+
return insets;
|
248
|
+
}
|
249
|
+
|
250
|
+
if (propName == "statusBar") {
|
251
|
+
auto statusBar = jsi::Object(runtime);
|
252
|
+
|
253
|
+
statusBar.setProperty(runtime, "height", this->statusBar.at("height"));
|
254
|
+
statusBar.setProperty(runtime, "width", this->statusBar.at("width"));
|
255
|
+
|
256
|
+
return statusBar;
|
257
|
+
}
|
236
258
|
|
237
259
|
return jsi::Value::undefined();
|
238
260
|
}
|
@@ -286,13 +308,15 @@ std::string UnistylesRuntime::getBreakpointFromScreenWidth(int width, const std:
|
|
286
308
|
return sortedBreakpointPairs.empty() ? "" : sortedBreakpointPairs.back().first;
|
287
309
|
}
|
288
310
|
|
289
|
-
void UnistylesRuntime::handleScreenSizeChange(int width, int height) {
|
311
|
+
void UnistylesRuntime::handleScreenSizeChange(int width, int height, std::map<std::string, int> insets, std::map<std::string, int> statusBar) {
|
290
312
|
std::string breakpoint = this->getBreakpointFromScreenWidth(width, this->sortedBreakpointPairs);
|
291
313
|
bool shouldNotify = this->breakpoint != breakpoint || this->screenWidth != width || this->screenHeight != height;
|
292
314
|
|
293
315
|
this->breakpoint = breakpoint;
|
294
316
|
this->screenWidth = width;
|
295
317
|
this->screenHeight = height;
|
318
|
+
this->insets = insets;
|
319
|
+
this->statusBar = statusBar;
|
296
320
|
|
297
321
|
std::string orientation = width > height
|
298
322
|
? UnistylesOrientationLandscape
|
package/cxx/UnistylesRuntime.h
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
#include <jsi/jsi.h>
|
4
4
|
#include <vector>
|
5
|
+
#include <map>
|
5
6
|
|
6
7
|
using namespace facebook;
|
7
8
|
|
@@ -33,8 +34,15 @@ public:
|
|
33
34
|
int screenWidth,
|
34
35
|
int screenHeight,
|
35
36
|
std::string colorScheme,
|
36
|
-
std::string contentSizeCategory
|
37
|
-
|
37
|
+
std::string contentSizeCategory,
|
38
|
+
std::map<std::string, int> insets,
|
39
|
+
std::map<std::string, int> statusBar
|
40
|
+
): screenWidth(screenWidth),
|
41
|
+
screenHeight(screenHeight),
|
42
|
+
colorScheme(colorScheme),
|
43
|
+
contentSizeCategory(contentSizeCategory),
|
44
|
+
insets(insets),
|
45
|
+
statusBar(statusBar) {}
|
38
46
|
|
39
47
|
bool hasAdaptiveThemes;
|
40
48
|
bool supportsAutomaticColorScheme;
|
@@ -44,6 +52,9 @@ public:
|
|
44
52
|
std::vector<std::string> pluginNames;
|
45
53
|
std::vector<std::string> themes;
|
46
54
|
std::vector<std::pair<std::string, double>> sortedBreakpointPairs;
|
55
|
+
|
56
|
+
std::map<std::string, int> insets;
|
57
|
+
std::map<std::string, int> statusBar;
|
47
58
|
|
48
59
|
void onThemeChange(std::function<void(std::string)> callback) {
|
49
60
|
this->onThemeChangeCallback = callback;
|
@@ -65,7 +76,7 @@ public:
|
|
65
76
|
void set(jsi::Runtime& runtime, const jsi::PropNameID& propNameId, const jsi::Value& value) override;
|
66
77
|
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override;
|
67
78
|
|
68
|
-
void handleScreenSizeChange(int width, int height);
|
79
|
+
void handleScreenSizeChange(int width, int height, std::map<std::string, int> insets, std::map<std::string, int> statusBar);
|
69
80
|
void handleAppearanceChange(std::string colorScheme);
|
70
81
|
void handleContentSizeCategoryChange(std::string contentSizeCategory);
|
71
82
|
|
package/ios/UnistylesModule.mm
CHANGED
@@ -75,7 +75,9 @@ void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSel
|
|
75
75
|
(int)weakSelf.platform.initialWidth,
|
76
76
|
(int)weakSelf.platform.initialHeight,
|
77
77
|
weakSelf.platform.initialColorScheme,
|
78
|
-
weakSelf.platform.initialContentSizeCategory
|
78
|
+
weakSelf.platform.initialContentSizeCategory,
|
79
|
+
weakSelf.platform.initialInsets,
|
80
|
+
weakSelf.platform.initialStatusBar
|
79
81
|
);
|
80
82
|
|
81
83
|
unistylesRuntime.get()->onThemeChange([=](std::string theme) {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#include <string>
|
2
|
+
#include <map>
|
2
3
|
|
3
4
|
@interface Platform : NSObject
|
4
5
|
|
@@ -6,6 +7,8 @@
|
|
6
7
|
@property (nonatomic, assign) CGFloat initialHeight;
|
7
8
|
@property (nonatomic, assign) std::string initialColorScheme;
|
8
9
|
@property (nonatomic, assign) std::string initialContentSizeCategory;
|
10
|
+
@property (nonatomic, assign) std::map<std::string, int> initialInsets;
|
11
|
+
@property (nonatomic, assign) std::map<std::string, int> initialStatusBar;
|
9
12
|
@property (nonatomic, assign) void* unistylesRuntime;
|
10
13
|
|
11
14
|
- (instancetype)init;
|
@@ -16,6 +16,8 @@
|
|
16
16
|
self.initialHeight = screen.bounds.size.height;
|
17
17
|
self.initialColorScheme = [self getColorScheme];
|
18
18
|
self.initialContentSizeCategory = [self getContentSizeCategory:contentSizeCategory];
|
19
|
+
self.initialStatusBar = [self getStatusBarDimensions];
|
20
|
+
self.initialInsets = [self getInsets];
|
19
21
|
|
20
22
|
[self setupListeners];
|
21
23
|
}
|
@@ -74,9 +76,11 @@
|
|
74
76
|
UIScreen *screen = [UIScreen mainScreen];
|
75
77
|
CGFloat screenWidth = screen.bounds.size.width;
|
76
78
|
CGFloat screenHeight = screen.bounds.size.height;
|
79
|
+
std::map<std::string, int> insets = [self getInsets];
|
80
|
+
std::map<std::string, int> statusBar = [self getStatusBarDimensions];
|
77
81
|
|
78
82
|
if (self.unistylesRuntime != nullptr) {
|
79
|
-
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange((int)screenWidth, (int)screenHeight);
|
83
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange((int)screenWidth, (int)screenHeight, insets, statusBar);
|
80
84
|
}
|
81
85
|
});
|
82
86
|
}
|
@@ -95,6 +99,29 @@
|
|
95
99
|
}
|
96
100
|
}
|
97
101
|
|
102
|
+
- (std::map<std::string, int>)getInsets {
|
103
|
+
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
|
104
|
+
UIEdgeInsets safeArea = window.safeAreaInsets;
|
105
|
+
std::map<std::string, int> insets;
|
106
|
+
|
107
|
+
insets.insert({ "top", safeArea.top });
|
108
|
+
insets.insert({ "bottom", safeArea.bottom });
|
109
|
+
insets.insert({ "left", safeArea.left });
|
110
|
+
insets.insert({ "right", safeArea.right });
|
111
|
+
|
112
|
+
return insets;
|
113
|
+
}
|
114
|
+
|
115
|
+
- (std::map<std::string, int>)getStatusBarDimensions {
|
116
|
+
CGRect statusBarFrame = UIApplication.sharedApplication.statusBarFrame;
|
117
|
+
std::map<std::string, int> statusBar;
|
118
|
+
|
119
|
+
statusBar.insert({ "height", statusBarFrame.size.height });
|
120
|
+
statusBar.insert({ "width", statusBarFrame.size.width });
|
121
|
+
|
122
|
+
return statusBar;
|
123
|
+
}
|
124
|
+
|
98
125
|
- (std::string)getContentSizeCategory:(UIContentSizeCategory)contentSizeCategory {
|
99
126
|
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraExtraLarge]) {
|
100
127
|
return std::string([@"xxxLarge" UTF8String]);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#include <string>
|
2
|
+
#include <map>
|
2
3
|
|
3
4
|
@interface Platform : NSObject
|
4
5
|
|
@@ -6,6 +7,8 @@
|
|
6
7
|
@property (nonatomic, assign) CGFloat initialHeight;
|
7
8
|
@property (nonatomic, assign) std::string initialColorScheme;
|
8
9
|
@property (nonatomic, assign) std::string initialContentSizeCategory;
|
10
|
+
@property (nonatomic, assign) std::map<std::string, int> initialInsets;
|
11
|
+
@property (nonatomic, assign) std::map<std::string, int> initialStatusBar;
|
9
12
|
@property (nonatomic, assign) void* unistylesRuntime;
|
10
13
|
|
11
14
|
- (instancetype)init;
|
@@ -15,6 +15,8 @@
|
|
15
15
|
self.initialHeight = window.frame.size.height;
|
16
16
|
self.initialContentSizeCategory = std::string([@"unspecified" UTF8String]);
|
17
17
|
self.initialColorScheme = [self getColorScheme];
|
18
|
+
self.initialStatusBar = [self getStatusBarDimensions];
|
19
|
+
self.initialInsets = [self getInsets];
|
18
20
|
|
19
21
|
[self setupListeners];
|
20
22
|
}
|
@@ -64,7 +66,12 @@
|
|
64
66
|
CGFloat screenHeight = window.frame.size.height;
|
65
67
|
|
66
68
|
if (self.unistylesRuntime != nullptr) {
|
67
|
-
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange(
|
69
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange(
|
70
|
+
(int)screenWidth,
|
71
|
+
(int)screenHeight,
|
72
|
+
self.initialInsets,
|
73
|
+
self.initialStatusBar
|
74
|
+
);
|
68
75
|
}
|
69
76
|
}
|
70
77
|
|
@@ -78,6 +85,26 @@
|
|
78
85
|
return UnistylesLightScheme;
|
79
86
|
}
|
80
87
|
|
88
|
+
- (std::map<std::string, int>)getInsets {
|
89
|
+
std::map<std::string, int> insets;
|
90
|
+
|
91
|
+
insets.insert({ "top", 0 });
|
92
|
+
insets.insert({ "bottom", 0 });
|
93
|
+
insets.insert({ "left", 0 });
|
94
|
+
insets.insert({ "right", 0 });
|
95
|
+
|
96
|
+
return insets;
|
97
|
+
}
|
98
|
+
|
99
|
+
- (std::map<std::string, int>)getStatusBarDimensions {
|
100
|
+
std::map<std::string, int> statusBar;
|
101
|
+
|
102
|
+
statusBar.insert({ "height", 0 });
|
103
|
+
statusBar.insert({ "width", 0 });
|
104
|
+
|
105
|
+
return statusBar;
|
106
|
+
}
|
107
|
+
|
81
108
|
@end
|
82
109
|
|
83
110
|
#endif
|
@@ -22,6 +22,16 @@ class UnistylesBridgeWeb {
|
|
22
22
|
#sortedBreakpointPairs = [];
|
23
23
|
#breakpoint = '';
|
24
24
|
#contentSizeCategory = 'unspecified';
|
25
|
+
#insets = {
|
26
|
+
top: 0,
|
27
|
+
right: 0,
|
28
|
+
bottom: 0,
|
29
|
+
left: 0
|
30
|
+
};
|
31
|
+
#statusBar = {
|
32
|
+
height: 0,
|
33
|
+
width: 0
|
34
|
+
};
|
25
35
|
constructor() {
|
26
36
|
if (!_common.isServer) {
|
27
37
|
this.setupListeners();
|
@@ -55,6 +65,10 @@ class UnistylesBridgeWeb {
|
|
55
65
|
return this.#enabledPlugins;
|
56
66
|
case 'colorScheme':
|
57
67
|
return this.#colorScheme;
|
68
|
+
case 'insets':
|
69
|
+
return this.#insets;
|
70
|
+
case 'statusBar':
|
71
|
+
return this.#statusBar;
|
58
72
|
case 'useTheme':
|
59
73
|
return themeName => this.useTheme(themeName);
|
60
74
|
case 'updateTheme':
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_plugins","_common","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","isServer","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","normalizeWebStylesPlugin","name","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","sortedBreakpointPairs","breakpoint","contentSizeCategory","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","updateTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","
|
1
|
+
{"version":3,"names":["_reactNative","require","_plugins","_common","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","isServer","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","normalizeWebStylesPlugin","name","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","sortedBreakpointPairs","breakpoint","contentSizeCategory","insets","top","right","bottom","left","statusBar","height","width","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","updateTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","find","value","index","otherBreakpoints","minVal","maxVal","emit","type","payload","orientation","screen","exports","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAGC,gBAAQ,GAAGJ,SAAS,GAAGK,MAAM,CAACC,UAAU;EACvD,CAACC,YAAY,GAAGH,gBAAQ,GAAGJ,SAAS,GAAGK,MAAM,CAACG,WAAW;EACzD,CAACC,MAAM,GAAiC,EAAE;EAC1C,CAACC,WAAW,GAAyB,CAAC,CAAC;EACvC,CAACC,WAAW,GAAoB,IAAI,CAACC,uBAAuB,CAAC,CAAC;EAC9D,CAACC,SAAS,GAA0B,EAAE;EACtC,CAACC,cAAc,GAAkB,CAACC,iCAAwB,CAACC,IAAI,CAAC;EAChE,CAACC,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;EAClE,CAACC,qBAAqB,GAAgD,EAAE;EACxE,CAACC,UAAU,GAA+B,EAAE;EAC5C,CAACC,mBAAmB,GAAW,aAAa;EAC5C,CAACC,MAAM,GAAiB;IACpBC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACTC,IAAI,EAAE;EACV,CAAC;EACD,CAACC,SAAS,GAAwB;IAC9BC,MAAM,EAAE,CAAC;IACTC,KAAK,EAAE;EACX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B,EAAE;MAC9CC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE;QACL9D,UAAU,EAAE,IAAI,CAAC,CAACA,UAAU;QAC5B+D,WAAW,EAAG,IAAI,CAAC,CAAClF,WAAW,GAAe,IAAI,CAAC,CAACI,YAAuB,GACrE,WAAW,GACX,UAAU;QAChB+E,MAAM,EAAE;UACJvD,KAAK,EAAE,IAAI,CAAC,CAAC5B,WAAW;UACxB2B,MAAM,EAAE,IAAI,CAAC,CAACvB;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACgF,OAAA,CAAAzF,kBAAA,GAAAA,kBAAA;AAEM,MAAM0F,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAG,IAAI1F,kBAAkB,CAAC,CAAC"}
|
@@ -81,6 +81,22 @@ class UnistylesRuntime {
|
|
81
81
|
};
|
82
82
|
}
|
83
83
|
|
84
|
+
/**
|
85
|
+
* Get the safe area insets
|
86
|
+
* @returns - The safe area insets { top, bottom, left, right }
|
87
|
+
*/
|
88
|
+
get insets() {
|
89
|
+
return this.unistylesBridge.insets;
|
90
|
+
}
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Get the status bar info
|
94
|
+
* @returns - The status bar size { width, height }
|
95
|
+
*/
|
96
|
+
get statusBar() {
|
97
|
+
return this.unistylesBridge.statusBar;
|
98
|
+
}
|
99
|
+
|
84
100
|
/**
|
85
101
|
* Get the screen orientation
|
86
102
|
* @returns - The screen orientation
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_common","require","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","contentSizeCategory","breakpoint","breakpoints","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","updateTheme","updater","getTheme","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin","exports"],"sourceRoot":"../../../src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
+
{"version":3,"names":["_common","require","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","contentSizeCategory","breakpoint","breakpoints","enabledPlugins","screen","width","screenWidth","height","screenHeight","insets","statusBar","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","updateTheme","updater","getTheme","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin","exports"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA;AACA;AACA;AACO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;EAAG;;EAEpG;AACJ;AACA;AACA;EACI,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACJ,eAAe,CAACI,SAAS;EACzC;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,mBAAmBA,CAAA,EAAG;IAC7B,OAAO,IAAI,CAACL,eAAe,CAACK,mBAAmB;EACnD;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACN,eAAe,CAACM,UAAU;EAC1C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACN,iBAAiB,CAACM,WAAW;EAC7C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,cAAc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,CAACR,IAAI,CAAC,CAAC,CAAC;EAC5F,CAAC;;EAED;AACJ;AACA;AACA;EACWS,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC/B,eAAe,CAACgC,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;;EAED;AACJ;AACA;AACA;EACWE,SAAS,GAAIC,MAAuB,IAAK;IAC5C,IAAI,CAACjC,iBAAiB,CAACgC,SAAS,CAACC,MAAM,CAAC;EAC5C,CAAC;;EAED;AACJ;AACA;AACA;EACWC,YAAY,GAAID,MAAuB,IAAK;IAC/C,IAAI,CAACjC,iBAAiB,CAACkC,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL;AAACE,OAAA,CAAAtC,gBAAA,GAAAA,gBAAA"}
|
@@ -16,6 +16,16 @@ export class UnistylesBridgeWeb {
|
|
16
16
|
#sortedBreakpointPairs = [];
|
17
17
|
#breakpoint = '';
|
18
18
|
#contentSizeCategory = 'unspecified';
|
19
|
+
#insets = {
|
20
|
+
top: 0,
|
21
|
+
right: 0,
|
22
|
+
bottom: 0,
|
23
|
+
left: 0
|
24
|
+
};
|
25
|
+
#statusBar = {
|
26
|
+
height: 0,
|
27
|
+
width: 0
|
28
|
+
};
|
19
29
|
constructor() {
|
20
30
|
if (!isServer) {
|
21
31
|
this.setupListeners();
|
@@ -49,6 +59,10 @@ export class UnistylesBridgeWeb {
|
|
49
59
|
return this.#enabledPlugins;
|
50
60
|
case 'colorScheme':
|
51
61
|
return this.#colorScheme;
|
62
|
+
case 'insets':
|
63
|
+
return this.#insets;
|
64
|
+
case 'statusBar':
|
65
|
+
return this.#statusBar;
|
52
66
|
case 'useTheme':
|
53
67
|
return themeName => this.useTheme(themeName);
|
54
68
|
case 'updateTheme':
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","normalizeWebStylesPlugin","isServer","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","name","unistylesEvents","Unistyles","sortedBreakpointPairs","breakpoint","contentSizeCategory","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","updateTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","normalizeWebStylesPlugin","isServer","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","name","unistylesEvents","Unistyles","sortedBreakpointPairs","breakpoint","contentSizeCategory","insets","top","right","bottom","left","statusBar","height","width","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","updateTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","find","value","index","otherBreakpoints","minVal","maxVal","emit","type","payload","orientation","screen","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,SAASC,wBAAwB,QAAQ,YAAY;AACrD,SAASC,QAAQ,QAAQ,WAAW;AAEpC,OAAO,MAAMC,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,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|
77
77
|
|
78
|
+
/**
|
79
|
+
* Get the safe area insets
|
80
|
+
* @returns - The safe area insets { top, bottom, left, right }
|
81
|
+
*/
|
82
|
+
get insets() {
|
83
|
+
return this.unistylesBridge.insets;
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Get the status bar info
|
88
|
+
* @returns - The status bar size { width, height }
|
89
|
+
*/
|
90
|
+
get statusBar() {
|
91
|
+
return this.unistylesBridge.statusBar;
|
92
|
+
}
|
93
|
+
|
78
94
|
/**
|
79
95
|
* Get the screen orientation
|
80
96
|
* @returns - The screen orientation
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","contentSizeCategory","breakpoint","breakpoints","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","updateTheme","updater","getTheme","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;EAAG;;EAEpG;AACJ;AACA;AACA;EACI,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACJ,eAAe,CAACI,SAAS;EACzC;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,mBAAmBA,CAAA,EAAG;IAC7B,OAAO,IAAI,CAACL,eAAe,CAACK,mBAAmB;EACnD;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACN,eAAe,CAACM,UAAU;EAC1C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACN,iBAAiB,CAACM,WAAW;EAC7C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,cAAcA,CAAA,EAAG;IACxB,OAAO,IAAI,CAACR,eAAe,CAACQ,cAAc;EAC9C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO;MACHC,KAAK,EAAE,IAAI,CAACV,eAAe,CAACW,WAAW;MACvCC,MAAM,EAAE,IAAI,CAACZ,eAAe,CAACa;IACjC,CAAC;EACL;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,WAAWA,CAAA,EAAG;IACrB,MAAM;
|
1
|
+
{"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","contentSizeCategory","breakpoint","breakpoints","enabledPlugins","screen","width","screenWidth","height","screenHeight","insets","statusBar","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","updateTheme","updater","getTheme","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KA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/core/UnistylesModule.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;;;
|
1
|
+
{"version":3,"file":"UnistylesModule.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;;;IAkCpB,OAAO;IAqEd,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,gBAAgB;CAe3B;AAED,eAAO,MAAM,eAAe,oBAA2B,CAAA"}
|
@@ -51,6 +51,16 @@ export declare class UnistylesRuntime {
|
|
51
51
|
width: number;
|
52
52
|
height: number;
|
53
53
|
};
|
54
|
+
/**
|
55
|
+
* Get the safe area insets
|
56
|
+
* @returns - The safe area insets { top, bottom, left, right }
|
57
|
+
*/
|
58
|
+
get insets(): import("../types").ScreenInsets;
|
59
|
+
/**
|
60
|
+
* Get the status bar info
|
61
|
+
* @returns - The status bar size { width, height }
|
62
|
+
*/
|
63
|
+
get statusBar(): import("../types").StatusBarDimensions;
|
54
64
|
/**
|
55
65
|
* Get the screen orientation
|
56
66
|
* @returns - The screen orientation
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBA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B;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,mBAAmB,gGAE7B;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,MAAM,oCAEhB;IAED;;;OAGG;IACH,IAAW,SAAS,2CAEnB;IAED;;;OAGG;IACH,IAAW,WAAW,6BAQrB;IAED;;;;OAIG;IACI,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAED;;;;;OAKG;IACI,WAAW,SAAU,MAAM,eAAe,mBAAmB,eAAe,CAAC,MAAM,eAAe,CAAC,KAAK,eAAe,CAAC,MAAM,eAAe,CAAC,UAEpJ;IAED;;;OAGG;IACI,iBAAiB,WAAY,OAAO,UAE1C;IAED;;;OAGG;IACI,SAAS,WAAY,eAAe,UAE1C;IAED;;;OAGG;IACI,YAAY,WAAY,eAAe,UAE7C;CACJ"}
|
@@ -3,6 +3,16 @@ import type { UnistylesThemes, UnistylesBreakpoints } from '../global';
|
|
3
3
|
import type { ScreenSize } from './core';
|
4
4
|
import type { UnistylesPlugin } from './plugin';
|
5
5
|
export type ColorSchemeName = 'light' | 'dark' | 'unspecified';
|
6
|
+
export type ScreenInsets = {
|
7
|
+
top: number;
|
8
|
+
right: number;
|
9
|
+
bottom: number;
|
10
|
+
left: number;
|
11
|
+
};
|
12
|
+
export type StatusBarDimensions = {
|
13
|
+
height: number;
|
14
|
+
width: number;
|
15
|
+
};
|
6
16
|
export type UnistylesConfig = {
|
7
17
|
adaptiveThemes?: boolean;
|
8
18
|
initialTheme?: keyof UnistylesThemes;
|
@@ -19,6 +29,8 @@ export type UnistylesBridge = {
|
|
19
29
|
colorScheme: ColorSchemeName;
|
20
30
|
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory;
|
21
31
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
|
32
|
+
insets: ScreenInsets;
|
33
|
+
statusBar: StatusBarDimensions;
|
22
34
|
themes: Array<keyof UnistylesThemes>;
|
23
35
|
useBreakpoints(breakpoints: UnistylesBreakpoints): void;
|
24
36
|
useTheme(name: keyof UnistylesThemes): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACrH,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAA;AAE9D,MAAM,MAAM,eAAe,GAAG;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,eAAe,CAAC;IACrC,OAAO,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACjC,2BAA2B,CAAC,EAAE,OAAO,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAE1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,MAAM,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,WAAW,EA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C/B,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IACxC,IAAI,EAAE,kBAAkB,CAAC,eAAe,CAAC;IACzC,OAAO,EAAE;QACL,mBAAmB,EAAE,sBAAsB,GAAG,0BAA0B,CAAA;KAC3E,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,oBAAoB,GAAG,6BAA6B,CAAA"}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
export type ExtractVariantNames<T> = T extends (...args: any) => infer R ? ExtractVariantKeys<R> : ExtractVariantKeys<T>;
|
2
2
|
type ExtractVariantKeys<T> = T extends object ? ExtractVariant<T[keyof T]> : never;
|
3
|
-
type
|
4
|
-
type
|
5
|
-
type ExtractSubVariantKeys<T> = T extends object ? [HasTrue<T>, HasFalse<T>] extends [true, true] ? keyof Omit<T, 'default'> | boolean | undefined : [HasTrue<T>] extends [true] ? keyof Omit<T, 'default'> | true | undefined : [HasFalse<T>] extends [true] ? keyof Omit<T, 'default'> | false | undefined : keyof Omit<T, 'default'> : never;
|
3
|
+
type HasBooleanVariants<T> = T extends Record<'true', any> ? true : T extends Record<'false', any> ? true : false;
|
4
|
+
type ExtractSubVariantKeys<T> = T extends object ? HasBooleanVariants<T> extends true ? keyof Omit<T, 'default'> | boolean | undefined : keyof Omit<T, 'default'> | undefined : never;
|
6
5
|
type ExtractVariant<T> = T extends (...args: any) => infer R ? R extends {
|
7
6
|
variants: infer V;
|
8
7
|
} ? {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/types/variants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GAClE,kBAAkB,CAAC,CAAC,CAAC,GACrB,kBAAkB,CAAC,CAAC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,CAAC;CAAE,GACpD,KAAK,GACT,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3B;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACpD,KAAK,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { NativeEventEmitter, NativeModules } from 'react-native'
|
2
2
|
import type { UnistylesThemes, UnistylesBreakpoints } from 'react-native-unistyles'
|
3
|
-
import type { ColorSchemeName } from '../types'
|
3
|
+
import type { ColorSchemeName, ScreenInsets, StatusBarDimensions } from '../types'
|
4
4
|
import { normalizeWebStylesPlugin } from '../plugins'
|
5
5
|
import { isServer } from '../common'
|
6
6
|
|
@@ -19,6 +19,16 @@ export class UnistylesBridgeWeb {
|
|
19
19
|
#sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, number]> = []
|
20
20
|
#breakpoint: keyof UnistylesBreakpoints = '' as keyof UnistylesBreakpoints
|
21
21
|
#contentSizeCategory: string = 'unspecified'
|
22
|
+
#insets: ScreenInsets = {
|
23
|
+
top: 0,
|
24
|
+
right: 0,
|
25
|
+
bottom: 0,
|
26
|
+
left: 0
|
27
|
+
}
|
28
|
+
#statusBar: StatusBarDimensions = {
|
29
|
+
height: 0,
|
30
|
+
width: 0
|
31
|
+
}
|
22
32
|
|
23
33
|
constructor() {
|
24
34
|
if (!isServer) {
|
@@ -54,6 +64,10 @@ export class UnistylesBridgeWeb {
|
|
54
64
|
return this.#enabledPlugins
|
55
65
|
case 'colorScheme':
|
56
66
|
return this.#colorScheme
|
67
|
+
case 'insets':
|
68
|
+
return this.#insets
|
69
|
+
case 'statusBar':
|
70
|
+
return this.#statusBar
|
57
71
|
case 'useTheme':
|
58
72
|
return (themeName: keyof UnistylesThemes) => this.useTheme(themeName)
|
59
73
|
case 'updateTheme':
|
@@ -76,6 +76,22 @@ export class UnistylesRuntime {
|
|
76
76
|
}
|
77
77
|
}
|
78
78
|
|
79
|
+
/**
|
80
|
+
* Get the safe area insets
|
81
|
+
* @returns - The safe area insets { top, bottom, left, right }
|
82
|
+
*/
|
83
|
+
public get insets() {
|
84
|
+
return this.unistylesBridge.insets
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Get the status bar info
|
89
|
+
* @returns - The status bar size { width, height }
|
90
|
+
*/
|
91
|
+
public get statusBar() {
|
92
|
+
return this.unistylesBridge.statusBar
|
93
|
+
}
|
94
|
+
|
79
95
|
/**
|
80
96
|
* Get the screen orientation
|
81
97
|
* @returns - The screen orientation
|
package/src/types/unistyles.ts
CHANGED
@@ -5,6 +5,18 @@ import type { UnistylesPlugin } from './plugin'
|
|
5
5
|
|
6
6
|
export type ColorSchemeName = 'light' | 'dark' | 'unspecified'
|
7
7
|
|
8
|
+
export type ScreenInsets = {
|
9
|
+
top: number,
|
10
|
+
right: number,
|
11
|
+
bottom: number,
|
12
|
+
left: number
|
13
|
+
}
|
14
|
+
|
15
|
+
export type StatusBarDimensions = {
|
16
|
+
height: number,
|
17
|
+
width: number
|
18
|
+
}
|
19
|
+
|
8
20
|
export type UnistylesConfig = {
|
9
21
|
adaptiveThemes?: boolean,
|
10
22
|
initialTheme?: keyof UnistylesThemes,
|
@@ -23,6 +35,8 @@ export type UnistylesBridge = {
|
|
23
35
|
colorScheme: ColorSchemeName,
|
24
36
|
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory,
|
25
37
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>,
|
38
|
+
insets: ScreenInsets,
|
39
|
+
statusBar: StatusBarDimensions,
|
26
40
|
|
27
41
|
// setters
|
28
42
|
themes: Array<keyof UnistylesThemes>,
|
package/src/types/variants.ts
CHANGED
@@ -6,17 +6,16 @@ type ExtractVariantKeys<T> = T extends object
|
|
6
6
|
? ExtractVariant<T[keyof T]>
|
7
7
|
: never
|
8
8
|
|
9
|
-
type
|
10
|
-
|
9
|
+
type HasBooleanVariants<T> = T extends Record<'true', any>
|
10
|
+
? true
|
11
|
+
: T extends Record<'false', any>
|
12
|
+
? true
|
13
|
+
: false
|
11
14
|
|
12
15
|
type ExtractSubVariantKeys<T> = T extends object
|
13
|
-
?
|
16
|
+
? HasBooleanVariants<T> extends true
|
14
17
|
? keyof Omit<T, 'default'> | boolean | undefined
|
15
|
-
:
|
16
|
-
? keyof Omit<T, 'default'> | true | undefined
|
17
|
-
: [HasFalse<T>] extends [true]
|
18
|
-
? keyof Omit<T, 'default'> | false | undefined
|
19
|
-
: keyof Omit<T, 'default'>
|
18
|
+
: keyof Omit<T, 'default'> | undefined
|
20
19
|
: never
|
21
20
|
|
22
21
|
type ExtractVariant<T> = T extends (...args: any) => infer R
|
@@ -39,7 +39,7 @@ struct Unistyles {
|
|
39
39
|
auto bounds = Window::Current().Bounds();
|
40
40
|
|
41
41
|
if (this->unistylesRuntime != nullptr) {
|
42
|
-
((UnistylesRuntime*)this->unistylesRuntime)->handleScreenSizeChange((int)bounds.Width, (int)bounds.Height);
|
42
|
+
((UnistylesRuntime*)this->unistylesRuntime)->handleScreenSizeChange((int)bounds.Width, (int)bounds.Height, this.getInsets(), this.getStatusBarDimensions());
|
43
43
|
}
|
44
44
|
}));
|
45
45
|
|
@@ -94,7 +94,9 @@ struct Unistyles {
|
|
94
94
|
uiInfo.screenWidth,
|
95
95
|
uiInfo.screenHeight,
|
96
96
|
uiInfo.colorScheme,
|
97
|
-
uiInfo.contentSizeCategory
|
97
|
+
uiInfo.contentSizeCategory,
|
98
|
+
this->getInsets(),
|
99
|
+
this->getStatusBarDimensions()
|
98
100
|
);
|
99
101
|
|
100
102
|
unistylesRuntime->onThemeChange([this](std::string theme) {
|
@@ -192,6 +194,26 @@ struct Unistyles {
|
|
192
194
|
|
193
195
|
return UnistylesUnspecifiedScheme;
|
194
196
|
}
|
197
|
+
|
198
|
+
std::map<std::string, int>getInsets() {
|
199
|
+
std::map<std::string, int> insets;
|
200
|
+
|
201
|
+
insets.insert({ "top", 0 });
|
202
|
+
insets.insert({ "bottom", 0 });
|
203
|
+
insets.insert({ "left", 0 });
|
204
|
+
insets.insert({ "right", 0 });
|
205
|
+
|
206
|
+
return insets;
|
207
|
+
}
|
208
|
+
|
209
|
+
std::map<std::string, int>getStatusBarDimensions() {
|
210
|
+
std::map<std::string, int> statusBar;
|
211
|
+
|
212
|
+
statusBar.insert({ "height", 0 });
|
213
|
+
statusBar.insert({ "width", 0 });
|
214
|
+
|
215
|
+
return statusBar;
|
216
|
+
}
|
195
217
|
};
|
196
218
|
|
197
219
|
} // namespace winrt::ReactNativeUnistyles
|