react-native-unistyles 2.8.2 → 2.8.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -1
- package/android/src/main/java/com/unistyles/Platform.kt +47 -9
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +53 -1
- package/cxx/UnistylesModel.cpp +0 -8
- package/cxx/UnistylesModel.h +0 -1
- package/lib/commonjs/common.js +0 -1
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js +19 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js.map +1 -1
- package/lib/commonjs/hooks/useUnistyles.js +1 -8
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/module/common.js +0 -1
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/mocks/UnistylesMockedRuntime.js +19 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js.map +1 -1
- package/lib/module/hooks/useUnistyles.js +1 -8
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/typescript/src/common.d.ts +1 -2
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts +25 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts +0 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/unistyles.d.ts +1 -7
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +1 -2
- package/src/core/mocks/UnistylesMockedRuntime.ts +20 -0
- package/src/hooks/useUnistyles.ts +2 -9
- package/src/types/unistyles.ts +1 -8
package/README.md
CHANGED
@@ -72,7 +72,6 @@ npx expo prebuild
|
|
72
72
|
<img src="https://avatars.githubusercontent.com/u/686823?v=4" height="70px" width="70px" alt="mwarger" />
|
73
73
|
</a>
|
74
74
|
|
75
|
-
|
76
75
|
## Past sponsors
|
77
76
|
|
78
77
|
<a href="https://github.com/kmartinezmedia">
|
@@ -108,6 +107,10 @@ Your support is greatly appreciated and helps me dedicate more time and resource
|
|
108
107
|
<img src="https://raw.githubusercontent.com/grapp-dev/stacks/main/assets/stacks-logo.png" height="70px" width="70px" alt="Stacks" />
|
109
108
|
</a>
|
110
109
|
|
110
|
+
## Plugins
|
111
|
+
|
112
|
+
[eslint-plugin-react-native-unistyles](https://github.com/RodSarhan/eslint-plugin-react-native-unistyles)
|
113
|
+
|
111
114
|
## Discord
|
112
115
|
Looking for help or you want to chat with me?
|
113
116
|
|
@@ -1,9 +1,11 @@
|
|
1
1
|
package com.unistyles
|
2
2
|
|
3
|
+
import android.content.Context
|
3
4
|
import android.content.res.Configuration
|
4
5
|
import android.graphics.Color
|
5
6
|
import android.graphics.Rect
|
6
7
|
import android.os.Build
|
8
|
+
import android.util.DisplayMetrics
|
7
9
|
import android.util.Log
|
8
10
|
import android.view.View
|
9
11
|
import android.view.Window
|
@@ -22,13 +24,38 @@ class Platform(private val reactApplicationContext: ReactApplicationContext) {
|
|
22
24
|
|
23
25
|
var orientation: Int = reactApplicationContext.resources.configuration.orientation
|
24
26
|
|
27
|
+
@Suppress("DEPRECATION")
|
25
28
|
fun getScreenDimensions(): Screen {
|
29
|
+
// function takes in count edge-to-edge layout
|
26
30
|
val displayMetrics = reactApplicationContext.resources.displayMetrics
|
27
31
|
val fontScale = reactApplicationContext.resources.configuration.fontScale
|
28
|
-
val screenWidth = (displayMetrics.widthPixels / displayMetrics.density).roundToInt()
|
29
|
-
val screenHeight = (displayMetrics.heightPixels / displayMetrics.density).roundToInt()
|
30
32
|
|
31
|
-
|
33
|
+
when {
|
34
|
+
Build.VERSION.SDK_INT < Build.VERSION_CODES.R -> {
|
35
|
+
val windowManager = reactApplicationContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
36
|
+
val metrics = DisplayMetrics()
|
37
|
+
|
38
|
+
windowManager.defaultDisplay.getRealMetrics(metrics)
|
39
|
+
|
40
|
+
val screenWidth = (metrics.widthPixels / metrics.density).roundToInt()
|
41
|
+
val screenHeight = (metrics.heightPixels / metrics.density).roundToInt()
|
42
|
+
|
43
|
+
return Screen(screenWidth, screenHeight, metrics.density, fontScale)
|
44
|
+
}
|
45
|
+
else -> {
|
46
|
+
reactApplicationContext.currentActivity?.windowManager?.currentWindowMetrics?.bounds?.let {
|
47
|
+
val boundsWidth = (it.width() / displayMetrics.density).roundToInt()
|
48
|
+
val boundsHeight = (it.height() / displayMetrics.density).roundToInt()
|
49
|
+
|
50
|
+
return Screen(boundsWidth, boundsHeight, displayMetrics.density, fontScale)
|
51
|
+
} ?: run {
|
52
|
+
val screenWidth = (displayMetrics.widthPixels / displayMetrics.density).roundToInt()
|
53
|
+
val screenHeight = (displayMetrics.heightPixels / displayMetrics.density).roundToInt()
|
54
|
+
|
55
|
+
return Screen(screenWidth, screenHeight, displayMetrics.density, fontScale)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
32
59
|
}
|
33
60
|
|
34
61
|
fun getColorScheme(): String {
|
@@ -73,7 +100,7 @@ class Platform(private val reactApplicationContext: ReactApplicationContext) {
|
|
73
100
|
return contentSizeCategory
|
74
101
|
}
|
75
102
|
|
76
|
-
fun setInsetsCompat(insetsCompat: WindowInsetsCompat, window: Window) {
|
103
|
+
fun setInsetsCompat(insetsCompat: WindowInsetsCompat, window: Window, animatedBottomInsets: Int?) {
|
77
104
|
// below Android 11, we need to use window flags to detect status bar visibility
|
78
105
|
val isStatusBarVisible = when(Build.VERSION.SDK_INT) {
|
79
106
|
in 30..Int.MAX_VALUE -> {
|
@@ -98,13 +125,24 @@ class Platform(private val reactApplicationContext: ReactApplicationContext) {
|
|
98
125
|
}
|
99
126
|
|
100
127
|
val insets = insetsCompat.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout())
|
101
|
-
|
102
|
-
// reports inset bottom as 0 when keyboard is visible
|
103
|
-
// otherwise it will break other libraries that manipulates bottom insets
|
104
128
|
val imeInsets = insetsCompat.getInsets(WindowInsetsCompat.Type.ime())
|
105
|
-
val insetsBottom = if (imeInsets.bottom > 0) 0 else insets.bottom
|
106
129
|
|
107
|
-
|
130
|
+
// Android 10 and below - set bottom insets to 0 while keyboard is visible and use default bottom insets otherwise
|
131
|
+
// Android 11 and above - animate bottom insets while keyboard is appearing and disappearing
|
132
|
+
val insetBottom = when(imeInsets.bottom > 0) {
|
133
|
+
true -> {
|
134
|
+
if (Build.VERSION.SDK_INT >= 30 && animatedBottomInsets != null) {
|
135
|
+
animatedBottomInsets
|
136
|
+
} else {
|
137
|
+
0
|
138
|
+
}
|
139
|
+
}
|
140
|
+
else -> {
|
141
|
+
insets.bottom
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
this.insets = Insets(statusBarTopInset, insetBottom, insets.left, insets.right)
|
108
146
|
}
|
109
147
|
|
110
148
|
fun getInsets(): Insets {
|
@@ -4,17 +4,21 @@ 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.os.Build
|
7
8
|
import android.os.Handler
|
8
9
|
import android.os.Looper
|
9
10
|
import android.util.Log
|
10
11
|
import android.view.View
|
11
12
|
import androidx.core.view.ViewCompat
|
12
13
|
import androidx.core.view.WindowCompat
|
14
|
+
import androidx.core.view.WindowInsetsAnimationCompat
|
15
|
+
import androidx.core.view.WindowInsetsCompat
|
13
16
|
import com.facebook.react.bridge.LifecycleEventListener
|
14
17
|
import com.facebook.react.bridge.ReactApplicationContext
|
15
18
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
16
19
|
import com.facebook.react.bridge.ReactMethod
|
17
20
|
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
|
21
|
+
import kotlin.math.roundToInt
|
18
22
|
|
19
23
|
class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext), LifecycleEventListener {
|
20
24
|
private var isCxxReady: Boolean = false
|
@@ -141,7 +145,7 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
141
145
|
this.reactApplicationContext.currentActivity?.let { activity ->
|
142
146
|
activity.findViewById<View>(android.R.id.content)?.let { mainView ->
|
143
147
|
ViewCompat.setOnApplyWindowInsetsListener(mainView) { _, insets ->
|
144
|
-
this.platform.setInsetsCompat(insets, activity.window)
|
148
|
+
this.platform.setInsetsCompat(insets, activity.window, null)
|
145
149
|
|
146
150
|
if (this.isCxxReady) {
|
147
151
|
this.onLayoutConfigChange()
|
@@ -149,6 +153,53 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
149
153
|
|
150
154
|
insets
|
151
155
|
}
|
156
|
+
|
157
|
+
if (Build.VERSION.SDK_INT >= 30) {
|
158
|
+
ViewCompat.setWindowInsetsAnimationCallback(
|
159
|
+
mainView,
|
160
|
+
object : WindowInsetsAnimationCompat.Callback(DISPATCH_MODE_STOP) {
|
161
|
+
var initialBottomInsets = 0
|
162
|
+
var isGoingUp = false
|
163
|
+
|
164
|
+
override fun onPrepare(animation: WindowInsetsAnimationCompat) {
|
165
|
+
val insets = ViewCompat.getRootWindowInsets(mainView)
|
166
|
+
val isKeyboardVisible = insets?.isVisible(WindowInsetsCompat.Type.ime()) ?: false
|
167
|
+
|
168
|
+
if (!isKeyboardVisible) {
|
169
|
+
val density = reactApplicationContext.resources.displayMetrics.density
|
170
|
+
|
171
|
+
initialBottomInsets = (this@UnistylesModule.platform.getInsets().bottom * density).roundToInt()
|
172
|
+
}
|
173
|
+
|
174
|
+
isGoingUp = !isKeyboardVisible
|
175
|
+
}
|
176
|
+
|
177
|
+
override fun onProgress(
|
178
|
+
insets: WindowInsetsCompat,
|
179
|
+
runningAnimations: List<WindowInsetsAnimationCompat>
|
180
|
+
): WindowInsetsCompat {
|
181
|
+
runningAnimations.firstOrNull()?.let { animation ->
|
182
|
+
val progress = animation.fraction
|
183
|
+
val nextBottomInset = if (isGoingUp) {
|
184
|
+
(initialBottomInsets - (progress * initialBottomInsets).roundToInt())
|
185
|
+
} else {
|
186
|
+
// enable this in Unistyles 3.0 to get real time bottom insets
|
187
|
+
// initialBottomInsets - (initialBottomInsets - (progress * initialBottomInsets).roundToInt())
|
188
|
+
initialBottomInsets
|
189
|
+
}
|
190
|
+
|
191
|
+
this@UnistylesModule.platform.setInsetsCompat(insets, activity.window, nextBottomInset)
|
192
|
+
|
193
|
+
if (!isGoingUp) {
|
194
|
+
this@UnistylesModule.onLayoutConfigChange()
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
return insets
|
199
|
+
}
|
200
|
+
}
|
201
|
+
)
|
202
|
+
}
|
152
203
|
}
|
153
204
|
}
|
154
205
|
}
|
@@ -157,6 +208,7 @@ class UnistylesModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
157
208
|
this.reactApplicationContext.currentActivity?.let { activity ->
|
158
209
|
activity.window?.decorView?.let { view ->
|
159
210
|
ViewCompat.setOnApplyWindowInsetsListener(view, null)
|
211
|
+
ViewCompat.setWindowInsetsAnimationCallback(view, null)
|
160
212
|
}
|
161
213
|
}
|
162
214
|
}
|
package/cxx/UnistylesModel.cpp
CHANGED
@@ -67,7 +67,6 @@ void UnistylesModel::handleContentSizeCategoryChange(std::string contentSizeCate
|
|
67
67
|
}
|
68
68
|
|
69
69
|
this->contentSizeCategory = contentSizeCategory;
|
70
|
-
this->onContentSizeCategoryChange(contentSizeCategory);
|
71
70
|
}
|
72
71
|
|
73
72
|
jsi::Value UnistylesModel::getThemeOrFail(jsi::Runtime& runtime) {
|
@@ -144,13 +143,6 @@ void UnistylesModel::onThemeChange(std::string themeName) {
|
|
144
143
|
this->emitDeviceEvent("theme", payload);
|
145
144
|
}
|
146
145
|
|
147
|
-
void UnistylesModel::onContentSizeCategoryChange(std::string contentSizeCategory) {
|
148
|
-
EventPayload payload;
|
149
|
-
payload["contentSizeCategory"] = contentSizeCategory;
|
150
|
-
|
151
|
-
this->emitDeviceEvent("dynamicTypeSize", payload);
|
152
|
-
}
|
153
|
-
|
154
146
|
void UnistylesModel::onPluginChange() {
|
155
147
|
this->emitDeviceEvent("plugin", {});
|
156
148
|
}
|
package/cxx/UnistylesModel.h
CHANGED
@@ -50,7 +50,6 @@ struct UnistylesModel {
|
|
50
50
|
void emitDeviceEvent(const std::string eventType, EventPayload payload);
|
51
51
|
void onThemeChange(std::string themeName);
|
52
52
|
void onPluginChange();
|
53
|
-
void onContentSizeCategoryChange(std::string contentSizeCategory);
|
54
53
|
void onLayoutChange();
|
55
54
|
jsi::Object parseEventPayload(EventPayload payload);
|
56
55
|
jsi::Object parseEventNestedPayload(EventNestedValue payload);
|
package/lib/commonjs/common.js
CHANGED
@@ -50,7 +50,6 @@ let UnistylesEventType = exports.UnistylesEventType = /*#__PURE__*/function (Uni
|
|
50
50
|
UnistylesEventType["Theme"] = "theme";
|
51
51
|
UnistylesEventType["Layout"] = "layout";
|
52
52
|
UnistylesEventType["Plugin"] = "plugin";
|
53
|
-
UnistylesEventType["DynamicTypeSize"] = "dynamicTypeSize";
|
54
53
|
return UnistylesEventType;
|
55
54
|
}({});
|
56
55
|
let UnistylesError = exports.UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","warn","message","console","exports","isWeb","Platform","OS","isIOS","isAndroid","isMobile","isServer","window","isDev","process","env","NODE_ENV","isTest","JEST_WORKER_ID","undefined","jest","ScreenOrientation","Landscape","Portrait","IOSContentSizeCategory","AndroidContentSizeCategory","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAC,gCAAgCC,OAAO,EAAE,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA;AAEM,MAAMI,KAAK,G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B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAAA,OAA1BA,0BAA0B;AAAA;AAAA,IAU1BC,kBAAkB,GAAAtB,OAAA,CAAAsB,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;
|
1
|
+
{"version":3,"names":["_reactNative","require","warn","message","console","exports","isWeb","Platform","OS","isIOS","isAndroid","isMobile","isServer","window","isDev","process","env","NODE_ENV","isTest","JEST_WORKER_ID","undefined","jest","ScreenOrientation","Landscape","Portrait","IOSContentSizeCategory","AndroidContentSizeCategory","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAC,gCAAgCC,OAAO,EAAE,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA;AAEM,MAAMI,KAAK,GAAAD,OAAA,CAAAC,KAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMC,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,SAAS,GAAAL,OAAA,CAAAK,SAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMG,QAAQ,GAAAN,OAAA,CAAAM,QAAA,GAAGF,KAAK,IAAIC,SAAS;AACnC,MAAME,QAAQ,GAAAP,OAAA,CAAAO,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;AAC9C,MAAMC,KAAK,GAAAT,OAAA,CAAAS,KAAA,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AACnD,MAAMC,MAAM,GAAAb,OAAA,CAAAa,MAAA,GAAGH,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAA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
15
15
|
}
|
16
|
+
get miniRuntime() {
|
17
|
+
return {
|
18
|
+
contentSizeCategory: this.contentSizeCategory,
|
19
|
+
breakpoint: this.breakpoint,
|
20
|
+
screen: this.screen,
|
21
|
+
insets: this.insets,
|
22
|
+
statusBar: {
|
23
|
+
width: this.statusBar.width,
|
24
|
+
height: this.statusBar.height
|
25
|
+
},
|
26
|
+
navigationBar: {
|
27
|
+
width: this.navigationBar.width,
|
28
|
+
height: this.navigationBar.height
|
29
|
+
},
|
30
|
+
orientation: this.orientation,
|
31
|
+
pixelRatio: this.pixelRatio,
|
32
|
+
fontScale: this.fontScale
|
33
|
+
};
|
34
|
+
}
|
16
35
|
get colorScheme() {
|
17
36
|
return 'dark';
|
18
37
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_common","require","UnistylesMockedRuntime","constructor","unistylesBridge","unistylesRegistry","
|
1
|
+
{"version":3,"names":["_common","require","UnistylesMockedRuntime","constructor","unistylesBridge","unistylesRegistry","miniRuntime","contentSizeCategory","breakpoint","screen","insets","statusBar","width","height","navigationBar","orientation","pixelRatio","fontScale","colorScheme","hasAdaptiveThemes","themeName","themeNames","length","at","undefined","sortedBreakpointPairs","firstBreakpoint","breakpoints","enabledPlugins","plugins","top","right","bottom","left","setColor","setHidden","ScreenOrientation","Portrait","setTheme","name","updateTheme","theme","setAdaptiveThemes","enabled","addPlugin","plugin","removePlugin","setRootViewBackgroundColor","color","setImmersiveMode","isEnabled","exports"],"sourceRoot":"../../../../src","sources":["core/mocks/UnistylesMockedRuntime.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AADA;;AAOO,MAAMC,sBAAsB,CAAC;EAGhCC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;IAC7F,IAAI,CAACA,iBAAiB,GAAGA,iBAAuD;EACpF;EAEA,IAAWC,W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MAAuB,IAAK,CAAC,CAAC;EAC9CE,0BAA0B,GAAIC,KAAsB,IAAK,CAAC,CAAC;EAC3DC,gBAAgB,GAAIC,SAAkB,IAAK,CAAC,CAAC;AACxD;AAACC,OAAA,CAAAjD,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
@@ -12,7 +12,6 @@ const unistylesEvents = new _reactNative.NativeEventEmitter(_reactNative.NativeM
|
|
12
12
|
const useUnistyles = () => {
|
13
13
|
const [plugins, setPlugins] = (0, _react.useState)(_core.unistyles.runtime.enabledPlugins);
|
14
14
|
const [theme, setTheme] = (0, _react.useState)(_core.unistyles.registry.getTheme(_core.unistyles.runtime.themeName));
|
15
|
-
const [contentSizeCategory, setContentSizeCategory] = (0, _react.useState)(_core.unistyles.runtime.contentSizeCategory);
|
16
15
|
const [layout, setLayout] = (0, _react.useState)({
|
17
16
|
breakpoint: _core.unistyles.runtime.breakpoint,
|
18
17
|
orientation: _core.unistyles.runtime.orientation,
|
@@ -59,11 +58,6 @@ const useUnistyles = () => {
|
|
59
58
|
{
|
60
59
|
return setPlugins(_core.unistyles.runtime.enabledPlugins);
|
61
60
|
}
|
62
|
-
case _common.UnistylesEventType.DynamicTypeSize:
|
63
|
-
{
|
64
|
-
const dynamicTypeSizeEvent = event;
|
65
|
-
return setContentSizeCategory(dynamicTypeSizeEvent.payload.contentSizeCategory);
|
66
|
-
}
|
67
61
|
default:
|
68
62
|
return;
|
69
63
|
}
|
@@ -73,8 +67,7 @@ const useUnistyles = () => {
|
|
73
67
|
return {
|
74
68
|
plugins,
|
75
69
|
theme,
|
76
|
-
layout
|
77
|
-
contentSizeCategory
|
70
|
+
layout
|
78
71
|
};
|
79
72
|
};
|
80
73
|
exports.useUnistyles = useUnistyles;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","_core","_common","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","plugins","setPlugins","useState","unistyles","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_core","_common","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","plugins","setPlugins","useState","unistyles","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","layout","setLayout","breakpoint","orientation","screen","width","height","statusBar","navigationBar","insets","top","bottom","left","right","useEffect","subscription","addListener","event","type","UnistylesEventType","Theme","themeEvent","payload","Layout","layoutEvent","Plugin","remove","exports"],"sourceRoot":"../../../src","sources":["hooks/useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAGA,MAAMI,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;AAEhE,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAACC,eAAS,CAACC,OAAO,CAACC,cAAc,CAAC;EACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAL,eAAQ,EAACC,eAAS,CAACK,QAAQ,CAACC,QAAQ,CAACN,eAAS,CAACC,OAAO,CAACM,SAAS,CAAC,CAAC;EAC5F,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAV,eAAQ,EAAC;IACjCW,UAAU,EAAEV,eAAS,CAACC,OAAO,CAACS,UAAU;IACxCC,WAAW,EAAEX,eAAS,CAACC,OAAO,CAACU,WAAW;IAC1CC,MAAM,EAAE;MACJC,KAAK,EAAEb,eAAS,CAACC,OAAO,CAACW,MAAM,CAACC,KAAK;MACrCC,MAAM,EAAEd,eAAS,CAACC,OAAO,CAACW,MAAM,CAACE;IACrC,CAAC;IACDC,SAAS,EAAE;MACPF,KAAK,EAAEb,eAAS,CAACC,OAAO,CAACc,SAAS,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ClCD,aAAa,EAAEgB,WAAW,CAACF,OAAO,CAACd;YACvC,CAAC,CAAC;UACN;QACA,KAAKW,0BAAkB,CAACM,MAAM;UAAE;YAC5B,OAAOnC,UAAU,CAACE,eAAS,CAACC,OAAO,CAACC,cAAc,CAAC;UACvD;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOqB,YAAY,CAACW,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACHrC,OAAO;IACPM,KAAK;IACLK;EACJ,CAAC;AACL,CAAC;AAAA2B,OAAA,CAAAvC,YAAA,GAAAA,YAAA","ignoreList":[]}
|
package/lib/module/common.js
CHANGED
@@ -43,7 +43,6 @@ export let UnistylesEventType = /*#__PURE__*/function (UnistylesEventType) {
|
|
43
43
|
UnistylesEventType["Theme"] = "theme";
|
44
44
|
UnistylesEventType["Layout"] = "layout";
|
45
45
|
UnistylesEventType["Plugin"] = "plugin";
|
46
|
-
UnistylesEventType["DynamicTypeSize"] = "dynamicTypeSize";
|
47
46
|
return UnistylesEventType;
|
48
47
|
}({});
|
49
48
|
export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
package/lib/module/common.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","isDev","process","env","NODE_ENV","isTest","JEST_WORKER_ID","undefined","jest","ScreenOrientation","Landscape","Portrait","IOSContentSizeCategory","AndroidContentSizeCategory","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAC,gCAAgCC,OAAO,EAAE,CAAC;AAC3D,CAAC;AAED,OAAO,MAAME,KAAK,GAAGJ,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,SAAS,GAAGP,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMG,QAAQ,GAAGF,KAAK,IAAIC,SAAS;AAC1C,OAAO,MAAME,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AACrD,OAAO,MAAMC,KAAK,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAC1D,OAAO,MAAMC,MAAM,GAAGH,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,IAAIF,OAAO,CAACC,GAAG,CAACG,cAAc,KAAKC,SAAS,IAAI,OAAOC,IAAI,KAAK,WAAW;AAEhI,OAAO,MAAMC,iBAAiB,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAEV,WAAYC,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAgBlC,WAAYC,0BAA0B,0BAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAAA,OAA1BA,0BAA0B;AAAA;AAUtC,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;
|
1
|
+
{"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","isDev","process","env","NODE_ENV","isTest","JEST_WORKER_ID","undefined","jest","ScreenOrientation","Landscape","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;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAAA,OAA1BA,0BAA0B;AAAA;AAUtC,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAM9B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
|
@@ -6,6 +6,25 @@ export class UnistylesMockedRuntime {
|
|
6
6
|
this.unistylesRegistry = unistylesRegistry;
|
7
7
|
this.unistylesRegistry = unistylesRegistry;
|
8
8
|
}
|
9
|
+
get miniRuntime() {
|
10
|
+
return {
|
11
|
+
contentSizeCategory: this.contentSizeCategory,
|
12
|
+
breakpoint: this.breakpoint,
|
13
|
+
screen: this.screen,
|
14
|
+
insets: this.insets,
|
15
|
+
statusBar: {
|
16
|
+
width: this.statusBar.width,
|
17
|
+
height: this.statusBar.height
|
18
|
+
},
|
19
|
+
navigationBar: {
|
20
|
+
width: this.navigationBar.width,
|
21
|
+
height: this.navigationBar.height
|
22
|
+
},
|
23
|
+
orientation: this.orientation,
|
24
|
+
pixelRatio: this.pixelRatio,
|
25
|
+
fontScale: this.fontScale
|
26
|
+
};
|
27
|
+
}
|
9
28
|
get colorScheme() {
|
10
29
|
return 'dark';
|
11
30
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ScreenOrientation","UnistylesMockedRuntime","constructor","unistylesBridge","unistylesRegistry","
|
1
|
+
{"version":3,"names":["ScreenOrientation","UnistylesMockedRuntime","constructor","unistylesBridge","unistylesRegistry","miniRuntime","contentSizeCategory","breakpoint","screen","insets","statusBar","width","height","navigationBar","orientation","pixelRatio","fontScale","colorScheme","hasAdaptiveThemes","themeName","themeNames","length","at","undefined","sortedBreakpointPairs","firstBreakpoint","breakpoints","enabledPlugins","plugins","top","right","bottom","left","setColor","setHidden","Portrait","setTheme","name","updateTheme","theme","setAdaptiveThemes","enabled","addPlugin","plugin","removePlugin","setRootViewBackgroundColor","color","setImmersiveMode","isEnabled"],"sourceRoot":"../../../../src","sources":["core/mocks/UnistylesMockedRuntime.ts"],"mappings":"AAAA;AACA,SAASA,iBAAiB,QAAQ,cAAc;AAMhD,OAAO,MAAMC,sBAAsB,CAAC;EAGhCC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;IAC7F,IAAI,CAACA,iBAAiB,GAAGA,iBAAuD;EACpF;EAEA,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO;MACHC,mBAAmB,EAAE,IAAI,CAACA,mBAAmB;MAC7CC,UAAU,EAAE,IAAI,CAACA,UAAU;MAC3BC,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBC,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBC,SAAS,EAAE;QACPC,KAAK,EAAE,IAAI,CAACD,SAAS,CAACC,KAAK;QAC3BC,MAAM,EAAE,IAAI,CAACF,SAAS,CAACE;MAC3B,CAAC;MACDC,aAAa,EAAE;QACXF,KAAK,EAAE,IAAI,CAACE,aAAa,CAACF,KAAK;QAC/BC,MAAM,EAAE,IAAI,CAACC,aAAa,CAACD;MAC/B,CAAC;MACDE,WAAW,EAAE,IAAI,CAACA,WAAW;MAC7BC,UAAU,EAAE,IAAI,CAACA,UAAU;MAC3BC,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL;EAEA,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,MAAM;EACjB;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI;EACf;EAEA,I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C;MAClBC,SAAS,EAAEA,CAAA,KAAM,CAAC;IACtB,CAAC;EACL;EAEA,IAAWrB,aAAaA,CAAA,EAAG;IACvB,OAAO;MACHD,MAAM,EAAE,CAAC;MACTD,KAAK,EAAE,CAAC;MACRsB,QAAQ,EAAEA,CAAA,KAAM,CAAC,CAAC;MAClBC,SAAS,EAAEA,CAAA,KAAM,CAAC;IACtB,CAAC;EACL;EAEA,IAAWpB,WAAWA,CAAA,EAAG;IACrB,OAAOd,iBAAiB,CAACmC,QAAQ;EACrC;EAEOC,QAAQ,GAAIC,IAA2B,IAAK,IAAI;EAChDC,WAAW,GAAGA,CAACD,IAA2B,EAAEE,KAA6C,KAAK,CAAC,CAAC;EAChGC,iBAAiB,GAAIC,OAAgB,IAAK,CAAC,CAAC;EAC5CC,SAAS,GAAIC,MAAuB,IAAK,CAAC,CAAC;EAC3CC,YAAY,GAAID,MAAuB,IAAK,CAAC,CAAC;EAC9CE,0BAA0B,GAAIC,KAAsB,IAAK,CAAC,CAAC;EAC3DC,gBAAgB,GAAIC,SAAkB,IAAK,CAAC,CAAC;AACxD","ignoreList":[]}
|
@@ -6,7 +6,6 @@ const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
|
|
6
6
|
export const useUnistyles = () => {
|
7
7
|
const [plugins, setPlugins] = useState(unistyles.runtime.enabledPlugins);
|
8
8
|
const [theme, setTheme] = useState(unistyles.registry.getTheme(unistyles.runtime.themeName));
|
9
|
-
const [contentSizeCategory, setContentSizeCategory] = useState(unistyles.runtime.contentSizeCategory);
|
10
9
|
const [layout, setLayout] = useState({
|
11
10
|
breakpoint: unistyles.runtime.breakpoint,
|
12
11
|
orientation: unistyles.runtime.orientation,
|
@@ -53,11 +52,6 @@ export const useUnistyles = () => {
|
|
53
52
|
{
|
54
53
|
return setPlugins(unistyles.runtime.enabledPlugins);
|
55
54
|
}
|
56
|
-
case UnistylesEventType.DynamicTypeSize:
|
57
|
-
{
|
58
|
-
const dynamicTypeSizeEvent = event;
|
59
|
-
return setContentSizeCategory(dynamicTypeSizeEvent.payload.contentSizeCategory);
|
60
|
-
}
|
61
55
|
default:
|
62
56
|
return;
|
63
57
|
}
|
@@ -67,8 +61,7 @@ export const useUnistyles = () => {
|
|
67
61
|
return {
|
68
62
|
plugins,
|
69
63
|
theme,
|
70
|
-
layout
|
71
|
-
contentSizeCategory
|
64
|
+
layout
|
72
65
|
};
|
73
66
|
};
|
74
67
|
//# sourceMappingURL=useUnistyles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","unistyles","UnistylesEventType","unistylesEvents","Unistyles","useUnistyles","plugins","setPlugins","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","unistyles","UnistylesEventType","unistylesEvents","Unistyles","useUnistyles","plugins","setPlugins","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","layout","setLayout","breakpoint","orientation","screen","width","height","statusBar","navigationBar","insets","top","bottom","left","right","subscription","addListener","event","type","Theme","themeEvent","payload","Layout","layoutEvent","Plugin","remove"],"sourceRoot":"../../../src","sources":["hooks/useUnistyles.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,kBAAkB,QAAQ,WAAW;AAG9C,MAAMC,eAAe,GAAG,IAAIN,kBAAkB,CAACC,aAAa,CAACM,SAAS,CAAC;AAEvE,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGP,QAAQ,CAACC,SAAS,CAACO,OAAO,CAACC,cAAc,CAAC;EACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGX,QAAQ,CAACC,SAAS,CAACW,QAAQ,CAACC,QA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ACW,QAAQ,CAACC,QAAQ,CAACqB,UAAU,CAACC,OAAO,CAACrB,SAAS,CAAC,CAAC;UAC9E;QACA,KAAKZ,kBAAkB,CAACkC,MAAM;UAAE;YAC5B,MAAMC,WAAW,GAAGN,KAAmC;YAEvD,OAAOf,SAAS,CAAC;cACbC,UAAU,EAAEoB,WAAW,CAACF,OAAO,CAAClB,UAAU;cAC1CC,WAAW,EAAEmB,WAAW,CAACF,OAAO,CAACjB,WAAW;cAC5CC,MAAM,EAAEkB,WAAW,CAACF,OAAO,CAAChB,MAAM;cAClCG,SAAS,EAAEe,WAAW,CAACF,OAAO,CAACb,SAAS;cACxCE,MAAM,EAAEa,WAAW,CAACF,OAAO,CAACX,MAAM;cAClCD,aAAa,EAAEc,WAAW,CAACF,OAAO,CAACZ;YACvC,CAAC,CAAC;UACN;QACA,KAAKrB,kBAAkB,CAACoC,MAAM;UAAE;YAC5B,OAAO/B,UAAU,CAACN,SAAS,CAACO,OAAO,CAACC,cAAc,CAAC;UACvD;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOoB,YAAY,CAACU,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACHjC,OAAO;IACPI,KAAK;IACLK;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -37,8 +37,7 @@ export declare enum AndroidContentSizeCategory {
|
|
37
37
|
export declare enum UnistylesEventType {
|
38
38
|
Theme = "theme",
|
39
39
|
Layout = "layout",
|
40
|
-
Plugin = "plugin"
|
41
|
-
DynamicTypeSize = "dynamicTypeSize"
|
40
|
+
Plugin = "plugin"
|
42
41
|
}
|
43
42
|
export declare enum UnistylesError {
|
44
43
|
RuntimeUnavailable = "Unistyles runtime is not available. Make sure you followed the installation instructions",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AA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MAAM,iBAAiB;;;CAGpB,CAAA;AAEV,oBAAY,sBAAsB;IAC9B,iCAAiC,sCAAsC;IACvE,4BAA4B,iCAAiC;IAC7D,uBAAuB,4BAA4B;IACnD,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;IAC3C,oBAAoB,aAAa;IACjC,eAAe,YAAY;IAC3B,UAAU,WAAW;IACrB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,UAAU,WAAW;IACrB,WAAW,gBAAgB;CAC9B;AAED,oBAAY,0BAA0B;IAClC,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,UAAU,eAAe;IACzB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,cAAc,mBAAmB;CACpC;AAED,oBAAY,kBAAkB;IAC1B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,6FAA6F;IAC/G,aAAa,gFAAgF;IAC7F,kBAAkB,iFAAiF;IACnG,gBAAgB,wEAAyE;IACzF,mBAAmB,mDAAmD;IACtE,wBAAwB,wDAAwD;IAChF,4BAA4B,mEAAoE;IAChG,iBAAiB,6DAA8D;IAC/E,mBAAmB,+EAA+E;IAClG,wBAAwB,0DAA0D;CACrF"}
|
@@ -6,6 +6,31 @@ export declare class UnistylesMockedRuntime {
|
|
6
6
|
private unistylesRegistry;
|
7
7
|
private unistylesRegistry;
|
8
8
|
constructor(unistylesBridge: UnistylesBridge, unistylesRegistry: UnistyleRegistry);
|
9
|
+
get miniRuntime(): {
|
10
|
+
contentSizeCategory: string;
|
11
|
+
breakpoint: number | keyof import("../../global").UnistylesBreakpoints | undefined;
|
12
|
+
screen: {
|
13
|
+
width: number;
|
14
|
+
height: number;
|
15
|
+
};
|
16
|
+
insets: {
|
17
|
+
top: number;
|
18
|
+
right: number;
|
19
|
+
bottom: number;
|
20
|
+
left: number;
|
21
|
+
};
|
22
|
+
statusBar: {
|
23
|
+
width: number;
|
24
|
+
height: number;
|
25
|
+
};
|
26
|
+
navigationBar: {
|
27
|
+
width: number;
|
28
|
+
height: number;
|
29
|
+
};
|
30
|
+
orientation: "portrait";
|
31
|
+
pixelRatio: number;
|
32
|
+
fontScale: number;
|
33
|
+
};
|
9
34
|
get colorScheme(): string;
|
10
35
|
get hasAdaptiveThemes(): boolean;
|
11
36
|
get themeName(): undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistylesMockedRuntime.d.ts","sourceRoot":"","sources":["../../../../../src/core/mocks/UnistylesMockedRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,qBAAa,sBAAsB;IAGnB,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;IAF/E,OAAO,CAAC,iBAAiB,CAAyB;gBAE9B,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAIjG,IAAW,WAAW,WAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,SAAS,cAInB;IAED,IAAW,mBAAmB,WAE7B;IAED,IAAW,UAAU,2EAUpB;IAED,IAAW,WAAW,gDAErB;IAED,IAAW,cAAc,sBAExB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,MAAM;;;;;MAOhB;IAED,IAAW,UAAU,WAEpB;IAED,IAAW,SAAS,WAEnB;IAED,IAAW,SAAS;;;;;MAOnB;IAED,IAAW,aAAa;;;;;MAOvB;IAED,IAAW,WAAW,eAErB;IAEM,QAAQ,SAAU,MAAM,eAAe,aAAS;IAChD,WAAW,SAAU,MAAM,eAAe,SAAS,eAAe,CAAC,MAAM,eAAe,CAAC,UAAO;IAChG,iBAAiB,YAAa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AY,eAAe,UAAO;IAC9C,0BAA0B,WAAY,KAAK,GAAG,MAAM,UAAO;IAC3D,gBAAgB,cAAe,OAAO,UAAO;CACvD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY
|
1
|
+
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;CAiExB,CAAA"}
|
@@ -74,11 +74,5 @@ export type UnistylesMobileLayoutEvent = {
|
|
74
74
|
export type UnistylesPluginEvent = {
|
75
75
|
type: UnistylesEventType.Plugin;
|
76
76
|
};
|
77
|
-
export type
|
78
|
-
type: UnistylesEventType.DynamicTypeSize;
|
79
|
-
payload: {
|
80
|
-
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory;
|
81
|
-
};
|
82
|
-
};
|
83
|
-
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent | UnistylesDynamicTypeSizeEvent;
|
77
|
+
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent;
|
84
78
|
//# sourceMappingURL=unistyles.d.ts.map
|
@@ -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,CAA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AAI,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;IAC/C,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACzC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACrD,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,0BAA0B,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjE,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAA;IAG1C,6BAA6B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACtD,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC;IAC/B,OAAO,EAAE;QACL,SAAS,EAAE,MAAM,eAAe,CAAA;KACnC,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC;QACnB,SAAS,EAAE,gBAAgB,CAAC;QAC5B,aAAa,EAAE,gBAAgB,CAAC;QAChC,MAAM,EAAE,YAAY,CAAC;QACrB,UAAU,EAAE,MAAM,oBAAoB,CAAC;QACvC,WAAW,EAAE,OAAO,iBAAiB,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAA;KACxE,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,oBAAoB,CAAA"}
|
package/package.json
CHANGED
package/src/common.ts
CHANGED
@@ -12,6 +12,26 @@ export class UnistylesMockedRuntime {
|
|
12
12
|
this.unistylesRegistry = unistylesRegistry as unknown as UnistylesMockedRegistry
|
13
13
|
}
|
14
14
|
|
15
|
+
public get miniRuntime() {
|
16
|
+
return {
|
17
|
+
contentSizeCategory: this.contentSizeCategory,
|
18
|
+
breakpoint: this.breakpoint,
|
19
|
+
screen: this.screen,
|
20
|
+
insets: this.insets,
|
21
|
+
statusBar: {
|
22
|
+
width: this.statusBar.width,
|
23
|
+
height: this.statusBar.height
|
24
|
+
},
|
25
|
+
navigationBar: {
|
26
|
+
width: this.navigationBar.width,
|
27
|
+
height: this.navigationBar.height
|
28
|
+
},
|
29
|
+
orientation: this.orientation,
|
30
|
+
pixelRatio: this.pixelRatio,
|
31
|
+
fontScale: this.fontScale
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
15
35
|
public get colorScheme() {
|
16
36
|
return 'dark'
|
17
37
|
}
|
@@ -2,14 +2,13 @@ import { NativeEventEmitter, NativeModules } from 'react-native'
|
|
2
2
|
import { useEffect, useState } from 'react'
|
3
3
|
import { unistyles } from '../core'
|
4
4
|
import { UnistylesEventType } from '../common'
|
5
|
-
import type {
|
5
|
+
import type { UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types'
|
6
6
|
|
7
7
|
const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
|
8
8
|
|
9
9
|
export const useUnistyles = () => {
|
10
10
|
const [plugins, setPlugins] = useState(unistyles.runtime.enabledPlugins)
|
11
11
|
const [theme, setTheme] = useState(unistyles.registry.getTheme(unistyles.runtime.themeName))
|
12
|
-
const [contentSizeCategory, setContentSizeCategory] = useState(unistyles.runtime.contentSizeCategory)
|
13
12
|
const [layout, setLayout] = useState({
|
14
13
|
breakpoint: unistyles.runtime.breakpoint,
|
15
14
|
orientation: unistyles.runtime.orientation,
|
@@ -58,11 +57,6 @@ export const useUnistyles = () => {
|
|
58
57
|
case UnistylesEventType.Plugin: {
|
59
58
|
return setPlugins(unistyles.runtime.enabledPlugins)
|
60
59
|
}
|
61
|
-
case UnistylesEventType.DynamicTypeSize: {
|
62
|
-
const dynamicTypeSizeEvent = event as UnistylesDynamicTypeSizeEvent
|
63
|
-
|
64
|
-
return setContentSizeCategory(dynamicTypeSizeEvent.payload.contentSizeCategory)
|
65
|
-
}
|
66
60
|
default:
|
67
61
|
return
|
68
62
|
}
|
@@ -75,7 +69,6 @@ export const useUnistyles = () => {
|
|
75
69
|
return {
|
76
70
|
plugins,
|
77
71
|
theme,
|
78
|
-
layout
|
79
|
-
contentSizeCategory
|
72
|
+
layout
|
80
73
|
}
|
81
74
|
}
|
package/src/types/unistyles.ts
CHANGED
@@ -90,11 +90,4 @@ export type UnistylesPluginEvent = {
|
|
90
90
|
type: UnistylesEventType.Plugin
|
91
91
|
}
|
92
92
|
|
93
|
-
export type
|
94
|
-
type: UnistylesEventType.DynamicTypeSize,
|
95
|
-
payload: {
|
96
|
-
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent | UnistylesDynamicTypeSizeEvent
|
93
|
+
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent
|