react-native-unistyles 2.4.0 → 2.4.1
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/README.md +72 -26
- package/android/CMakeLists.txt +18 -2
- package/android/build.gradle +5 -1
- package/android/src/main/cxx/cpp-adapter.cpp +16 -80
- package/android/src/main/cxx/helpers.cpp +61 -0
- package/android/src/main/cxx/helpers.h +7 -0
- package/android/src/main/cxx/platform.cpp +170 -0
- package/android/src/main/cxx/platform.h +20 -0
- package/android/src/main/java/com/unistyles/Models.kt +12 -70
- package/android/src/main/java/com/unistyles/Platform.kt +311 -10
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +145 -153
- package/cxx/Macros.h +11 -0
- package/cxx/UnistylesImpl.cpp +310 -0
- package/cxx/UnistylesModel.cpp +234 -0
- package/cxx/UnistylesModel.h +141 -0
- package/cxx/UnistylesRuntime.cpp +17 -356
- package/cxx/UnistylesRuntime.h +71 -87
- package/ios/UnistylesModule.h +13 -0
- package/ios/UnistylesModule.mm +20 -90
- package/ios/platform/Platform_Shared.h +8 -0
- package/ios/platform/Platform_Shared.mm +160 -0
- package/ios/platform/Platform_iOS.h +6 -10
- package/ios/platform/Platform_iOS.mm +143 -93
- package/ios/platform/Platform_macOS.h +3 -7
- package/ios/platform/Platform_macOS.mm +52 -34
- package/ios/platform/Platform_tvOS.h +17 -0
- package/ios/platform/Platform_tvOS.mm +96 -0
- package/ios/platform/Platform_visionOS.h +20 -0
- package/ios/platform/Platform_visionOS.mm +120 -0
- package/lib/commonjs/UnistylesProvider.js +32 -0
- package/lib/commonjs/UnistylesProvider.js.map +1 -0
- package/lib/commonjs/common.js +3 -2
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +14 -4
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/Unistyles.js +7 -0
- package/lib/commonjs/core/Unistyles.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.js +52 -8
- package/lib/commonjs/core/UnistylesModule.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.native.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.windows.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +114 -4
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js +36 -0
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js +46 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js +122 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/commonjs/core/mocks/index.js +27 -0
- package/lib/commonjs/core/mocks/index.js.map +1 -0
- package/lib/commonjs/createStyleSheet.js.map +1 -1
- package/lib/commonjs/global.js.map +1 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useCSS.js.map +1 -1
- package/lib/commonjs/hooks/useCSS.native.js.map +1 -1
- package/lib/commonjs/hooks/useInitialTheme.js.map +1 -1
- package/lib/commonjs/hooks/useSharedContext.js +77 -0
- package/lib/commonjs/hooks/useSharedContext.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +18 -65
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/normalizer/index.js.map +1 -1
- package/lib/commonjs/normalizer/module.d.js.map +1 -1
- package/lib/commonjs/normalizer/normalizeStyle.js.map +1 -1
- package/lib/commonjs/normalizer/normalizer.js +1 -1
- package/lib/commonjs/normalizer/normalizer.js.map +1 -1
- package/lib/commonjs/normalizer/normalizer.macos.js.map +1 -1
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +1 -1
- package/lib/commonjs/plugins/index.js.map +1 -1
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -1
- package/lib/commonjs/types/breakpoints.js.map +1 -1
- package/lib/commonjs/types/color.js +2 -0
- package/lib/commonjs/types/color.js.map +1 -0
- package/lib/commonjs/types/common.js.map +1 -1
- package/lib/commonjs/types/core.js.map +1 -1
- package/lib/commonjs/types/index.js +11 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/normalizer.js.map +1 -1
- package/lib/commonjs/types/plugin.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/types/unistyles.js.map +1 -1
- package/lib/commonjs/types/variants.js.map +1 -1
- package/lib/commonjs/useStyles.js +1 -1
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/cssMediaQuery.js.map +1 -1
- package/lib/commonjs/utils/generateId.js.map +1 -1
- package/lib/commonjs/utils/hash32.js.map +1 -1
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/parseColor.js +35 -0
- package/lib/commonjs/utils/parseColor.js.map +1 -0
- package/lib/commonjs/utils/styles.js +15 -1
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/withPlugins.js.map +1 -1
- package/lib/module/UnistylesProvider.js +24 -0
- package/lib/module/UnistylesProvider.js.map +1 -0
- package/lib/module/common.js +2 -1
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +15 -5
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/Unistyles.js +8 -1
- package/lib/module/core/Unistyles.js.map +1 -1
- package/lib/module/core/UnistylesModule.js +52 -8
- package/lib/module/core/UnistylesModule.js.map +1 -1
- package/lib/module/core/UnistylesModule.native.js.map +1 -1
- package/lib/module/core/UnistylesModule.windows.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +115 -4
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/core/index.js +2 -1
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/mocks/UnistylesMockedBridge.js +29 -0
- package/lib/module/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js +39 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js +114 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/module/core/mocks/index.js +4 -0
- package/lib/module/core/mocks/index.js.map +1 -0
- package/lib/module/createStyleSheet.js.map +1 -1
- package/lib/module/global.js.map +1 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useCSS.js.map +1 -1
- package/lib/module/hooks/useCSS.native.js.map +1 -1
- package/lib/module/hooks/useInitialTheme.js.map +1 -1
- package/lib/module/hooks/useSharedContext.js +70 -0
- package/lib/module/hooks/useSharedContext.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +19 -66
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/hooks/useVariants.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/normalizer/index.js.map +1 -1
- package/lib/module/normalizer/module.d.js.map +1 -1
- package/lib/module/normalizer/normalizeStyle.js.map +1 -1
- package/lib/module/normalizer/normalizer.js.map +1 -1
- package/lib/module/normalizer/normalizer.macos.js.map +1 -1
- package/lib/module/plugins/cssMediaQueriesPlugin.js.map +1 -1
- package/lib/module/plugins/index.js.map +1 -1
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -1
- package/lib/module/types/breakpoints.js.map +1 -1
- package/lib/module/types/color.js +2 -0
- package/lib/module/types/color.js.map +1 -0
- package/lib/module/types/common.js.map +1 -1
- package/lib/module/types/core.js.map +1 -1
- package/lib/module/types/index.js +1 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/normalizer.js.map +1 -1
- package/lib/module/types/plugin.js.map +1 -1
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/types/unistyles.js.map +1 -1
- package/lib/module/types/variants.js.map +1 -1
- package/lib/module/useStyles.js +1 -1
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/cssMediaQuery.js.map +1 -1
- package/lib/module/utils/generateId.js.map +1 -1
- package/lib/module/utils/hash32.js.map +1 -1
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/parseColor.js +28 -0
- package/lib/module/utils/parseColor.js.map +1 -0
- package/lib/module/utils/styles.js +15 -1
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/withPlugins.js.map +1 -1
- package/lib/typescript/src/UnistylesProvider.d.ts +20 -0
- package/lib/typescript/src/UnistylesProvider.d.ts.map +1 -0
- package/lib/typescript/src/common.d.ts +3 -2
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.d.ts +1 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.windows.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +84 -8
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +3 -1
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts +28 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts +21 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts +79 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/index.d.ts +4 -0
- package/lib/typescript/src/core/mocks/index.d.ts.map +1 -0
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useSharedContext.d.ts +33 -0
- package/lib/typescript/src/hooks/useSharedContext.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +4 -19
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +7 -15
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +9 -8
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/color.d.ts +4 -0
- package/lib/typescript/src/types/color.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +2 -2
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +2 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/normalizer.d.ts +1 -1
- package/lib/typescript/src/types/normalizer.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +9 -6
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/types/unistyles.d.ts +20 -9
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts +1 -1
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
- package/lib/typescript/src/utils/parseColor.d.ts +3 -0
- package/lib/typescript/src/utils/parseColor.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +38 -25
- package/react-native-unistyles.podspec +4 -1
- package/src/UnistylesProvider.tsx +33 -0
- package/src/common.ts +3 -2
- package/src/core/UnistyleRegistry.ts +19 -5
- package/src/core/Unistyles.ts +10 -1
- package/src/core/UnistylesModule.ts +61 -14
- package/src/core/UnistylesRuntime.ts +120 -5
- package/src/core/index.ts +7 -1
- package/src/core/mocks/UnistylesMockedBridge.ts +30 -0
- package/src/core/mocks/UnistylesMockedRegistry.ts +47 -0
- package/src/core/mocks/UnistylesMockedRuntime.ts +144 -0
- package/src/core/mocks/index.ts +3 -0
- package/src/hooks/useSharedContext.ts +83 -0
- package/src/hooks/useUnistyles.ts +15 -71
- package/src/index.ts +10 -4
- package/src/types/breakpoints.ts +19 -9
- package/src/types/color.ts +26 -0
- package/src/types/core.ts +2 -2
- package/src/types/index.ts +5 -1
- package/src/types/normalizer.ts +1 -1
- package/src/types/stylesheet.ts +10 -7
- package/src/types/unistyles.ts +28 -12
- package/src/useStyles.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/parseColor.ts +33 -0
- package/src/utils/styles.ts +24 -1
- package/windows/ExperimentalFeatures.props +4 -4
- package/windows/NuGet.Config +0 -1
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.h +42 -118
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.vcxproj +7 -2
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.vcxproj.filters +6 -1
- package/windows/ReactNativeUnistyles/packages.lock.json +31 -31
- package/android/src/main/java/com/unistyles/Config.kt +0 -116
- package/android/src/main/java/com/unistyles/Insets.kt +0 -138
- package/ios/UnistylesHelpers.h +0 -3
- package/ios/UnistylesHelpers.mm +0 -5
package/ios/UnistylesModule.mm
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
#import "UnistylesModule.h"
|
2
|
-
#import "UnistylesHelpers.h"
|
3
2
|
#import "UnistylesRuntime.h"
|
4
|
-
|
5
3
|
#import <React/RCTBridge+Private.h>
|
6
4
|
#import <jsi/jsi.h>
|
7
5
|
|
@@ -17,10 +15,14 @@ RCT_EXPORT_MODULE(Unistyles)
|
|
17
15
|
if ((self = [super init])) {
|
18
16
|
self.platform = [[Platform alloc] init];
|
19
17
|
}
|
20
|
-
|
18
|
+
|
21
19
|
return self;
|
22
20
|
}
|
23
21
|
|
22
|
+
- (void)dealloc {
|
23
|
+
[self.platform clean];
|
24
|
+
}
|
25
|
+
|
24
26
|
+ (BOOL)requiresMainQueueSetup {
|
25
27
|
return YES;
|
26
28
|
}
|
@@ -47,106 +49,34 @@ RCT_EXPORT_MODULE(Unistyles)
|
|
47
49
|
#pragma mark - Core
|
48
50
|
|
49
51
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
if (
|
54
|
-
return @false;
|
55
|
-
}
|
56
|
-
|
57
|
-
auto jsiRuntime = (jsi::Runtime*)cxxBridge.runtime;
|
58
|
-
|
59
|
-
if (jsiRuntime == nil) {
|
52
|
+
UnistylesModule *__weak weakSelf = self;
|
53
|
+
RCTBridge *bridge = self.bridge;
|
54
|
+
|
55
|
+
if (bridge == nullptr) {
|
60
56
|
return @false;
|
61
57
|
}
|
62
58
|
|
63
|
-
|
64
|
-
UnistylesModule *__weak weakSelf = self;
|
65
|
-
|
66
|
-
registerUnistylesHostObject(runtime, weakSelf);
|
59
|
+
registerUnistylesHostObject(bridge, weakSelf);
|
67
60
|
|
68
61
|
NSLog(@"Installed Unistyles 🦄!");
|
69
62
|
|
70
63
|
return @true;
|
71
64
|
}
|
72
65
|
|
73
|
-
void registerUnistylesHostObject(
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
weakSelf.platform.initialInsets,
|
79
|
-
weakSelf.platform.initialStatusBar,
|
80
|
-
weakSelf.platform.initialNavigationBar
|
81
|
-
);
|
82
|
-
|
83
|
-
unistylesRuntime.get()->onThemeChange([=](std::string theme) {
|
84
|
-
NSDictionary *body = @{
|
85
|
-
@"type": @"theme",
|
86
|
-
@"payload": @{
|
87
|
-
@"themeName": cxxStringToNSString(theme)
|
88
|
-
}
|
89
|
-
};
|
90
|
-
|
91
|
-
[weakSelf emitEvent:@"__unistylesOnChange" withBody:body];
|
92
|
-
});
|
93
|
-
|
94
|
-
unistylesRuntime.get()->onLayoutChange([=](std::string breakpoint, std::string orientation, Dimensions& screen, Dimensions& statusBar, Insets& insets, Dimensions& navigationBar) {
|
95
|
-
NSDictionary *body = @{
|
96
|
-
@"type": @"layout",
|
97
|
-
@"payload": @{
|
98
|
-
@"breakpoint": cxxStringToNSString(breakpoint),
|
99
|
-
@"orientation": cxxStringToNSString(orientation),
|
100
|
-
@"screen": @{
|
101
|
-
@"width": @(screen.width),
|
102
|
-
@"height": @(screen.height)
|
103
|
-
},
|
104
|
-
@"statusBar": @{
|
105
|
-
@"width": @(statusBar.width),
|
106
|
-
@"height": @(statusBar.height)
|
107
|
-
},
|
108
|
-
@"navigationBar": @{
|
109
|
-
@"width": @(navigationBar.width),
|
110
|
-
@"height": @(navigationBar.height)
|
111
|
-
},
|
112
|
-
@"insets": @{
|
113
|
-
@"top": @(insets.top),
|
114
|
-
@"bottom": @(insets.bottom),
|
115
|
-
@"left": @(insets.left),
|
116
|
-
@"right": @(insets.right)
|
117
|
-
}
|
118
|
-
}
|
119
|
-
};
|
120
|
-
|
121
|
-
[weakSelf emitEvent:@"__unistylesOnChange" withBody:body];
|
122
|
-
});
|
66
|
+
void registerUnistylesHostObject(RCTBridge* bridge, UnistylesModule* weakSelf) {
|
67
|
+
std::shared_ptr<react::CallInvoker> callInvoker = bridge.jsCallInvoker;
|
68
|
+
auto runOnJSThread = [callInvoker](std::function<void(jsi::Runtime& rt)> &&callback){
|
69
|
+
callInvoker->invokeAsync(std::move(callback));
|
70
|
+
};
|
123
71
|
|
124
|
-
|
125
|
-
|
126
|
-
@"type": @"plugin"
|
127
|
-
};
|
128
|
-
|
129
|
-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
130
|
-
[weakSelf emitEvent:@"__unistylesOnChange" withBody:body];
|
131
|
-
});
|
132
|
-
});
|
133
|
-
|
134
|
-
unistylesRuntime.get()->onContentSizeCategoryChange([=](std::string contentSizeCategory) {
|
135
|
-
NSDictionary *body = @{
|
136
|
-
@"type": @"dynamicTypeSize",
|
137
|
-
@"payload": @{
|
138
|
-
@"contentSizeCategory": cxxStringToNSString(contentSizeCategory)
|
139
|
-
}
|
140
|
-
};
|
141
|
-
|
142
|
-
[weakSelf emitEvent:@"__unistylesOnChange" withBody:body];
|
143
|
-
});
|
72
|
+
jsi::Runtime* runtime = reinterpret_cast<jsi::Runtime*>(bridge.runtime);
|
73
|
+
auto unistylesRuntime = std::make_shared<UnistylesRuntime>(runOnJSThread);
|
144
74
|
|
145
|
-
weakSelf.platform
|
75
|
+
[weakSelf.platform makeShared:unistylesRuntime.get()];
|
146
76
|
|
147
|
-
auto hostObject = jsi::Object::createFromHostObject(runtime, unistylesRuntime);
|
77
|
+
auto hostObject = jsi::Object::createFromHostObject(*runtime, unistylesRuntime);
|
148
78
|
|
149
|
-
runtime
|
79
|
+
runtime->global().setProperty(*runtime, "__UNISTYLES__", std::move(hostObject));
|
150
80
|
}
|
151
81
|
|
152
82
|
@end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
#if TARGET_OS_TV || TARGET_OS_VISION || TARGET_OS_IOS
|
2
|
+
|
3
|
+
#include "Platform_Shared.h"
|
4
|
+
|
5
|
+
std::string getContentSizeCategory() {
|
6
|
+
UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
|
7
|
+
|
8
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraExtraLarge]) {
|
9
|
+
return std::string([@"xxxLarge" UTF8String]);
|
10
|
+
}
|
11
|
+
|
12
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraLarge]) {
|
13
|
+
return std::string([@"xxLarge" UTF8String]);
|
14
|
+
}
|
15
|
+
|
16
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraLarge]) {
|
17
|
+
return std::string([@"xLarge" UTF8String]);
|
18
|
+
}
|
19
|
+
|
20
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryLarge]) {
|
21
|
+
return std::string([@"Large" UTF8String]);
|
22
|
+
}
|
23
|
+
|
24
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryMedium]) {
|
25
|
+
return std::string([@"Medium" UTF8String]);
|
26
|
+
}
|
27
|
+
|
28
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategorySmall]) {
|
29
|
+
return std::string([@"Small" UTF8String]);
|
30
|
+
}
|
31
|
+
|
32
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraSmall]) {
|
33
|
+
return std::string([@"xSmall" UTF8String]);
|
34
|
+
}
|
35
|
+
|
36
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityMedium]) {
|
37
|
+
return std::string([@"accessibilityMedium" UTF8String]);
|
38
|
+
}
|
39
|
+
|
40
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityLarge]) {
|
41
|
+
return std::string([@"accessibilityLarge" UTF8String]);
|
42
|
+
}
|
43
|
+
|
44
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraLarge]) {
|
45
|
+
return std::string([@"accessibilityExtraLarge" UTF8String]);
|
46
|
+
}
|
47
|
+
|
48
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraLarge]) {
|
49
|
+
return std::string([@"accessibilityExtraExtraLarge" UTF8String]);
|
50
|
+
}
|
51
|
+
|
52
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraExtraLarge]) {
|
53
|
+
return std::string([@"accessibilityExtraExtraExtraLarge" UTF8String]);
|
54
|
+
}
|
55
|
+
|
56
|
+
return std::string([@"unspecified" UTF8String]);
|
57
|
+
}
|
58
|
+
|
59
|
+
// based on Apple Human Interface Guidelines
|
60
|
+
// https://developer.apple.com/design/human-interface-guidelines/typography#Specifications
|
61
|
+
float getFontScale() {
|
62
|
+
UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
|
63
|
+
float defaultMultiplier = 17.0;
|
64
|
+
|
65
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraExtraLarge]) {
|
66
|
+
return 23.0 / defaultMultiplier;
|
67
|
+
}
|
68
|
+
|
69
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraLarge]) {
|
70
|
+
return 21.0 / defaultMultiplier;
|
71
|
+
}
|
72
|
+
|
73
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraLarge]) {
|
74
|
+
return 19.0 / defaultMultiplier;
|
75
|
+
}
|
76
|
+
|
77
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryLarge]) {
|
78
|
+
return 17.0 / defaultMultiplier;
|
79
|
+
}
|
80
|
+
|
81
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryMedium]) {
|
82
|
+
return 16.0 / defaultMultiplier;
|
83
|
+
}
|
84
|
+
|
85
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategorySmall]) {
|
86
|
+
return 15.0 / defaultMultiplier;
|
87
|
+
}
|
88
|
+
|
89
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraSmall]) {
|
90
|
+
return 14.0 / defaultMultiplier;
|
91
|
+
}
|
92
|
+
|
93
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityMedium]) {
|
94
|
+
return 29.0 / defaultMultiplier;
|
95
|
+
}
|
96
|
+
|
97
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityLarge]) {
|
98
|
+
return 33.0 / defaultMultiplier;
|
99
|
+
}
|
100
|
+
|
101
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraLarge]) {
|
102
|
+
return 40.0 / defaultMultiplier;
|
103
|
+
}
|
104
|
+
|
105
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraLarge]) {
|
106
|
+
return 47.0 / defaultMultiplier;
|
107
|
+
}
|
108
|
+
|
109
|
+
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraExtraLarge]) {
|
110
|
+
return 53.0 / defaultMultiplier;
|
111
|
+
}
|
112
|
+
|
113
|
+
return 1.0;
|
114
|
+
}
|
115
|
+
|
116
|
+
std::string getColorScheme() {
|
117
|
+
#if !TARGET_OS_VISION
|
118
|
+
UIUserInterfaceStyle colorScheme = [UIScreen mainScreen].traitCollection.userInterfaceStyle;
|
119
|
+
|
120
|
+
switch (colorScheme) {
|
121
|
+
case UIUserInterfaceStyleLight:
|
122
|
+
return UnistylesLightScheme;
|
123
|
+
case UIUserInterfaceStyleDark:
|
124
|
+
return UnistylesDarkScheme;
|
125
|
+
case UIUserInterfaceStyleUnspecified:
|
126
|
+
default:
|
127
|
+
return UnistylesUnspecifiedScheme;
|
128
|
+
}
|
129
|
+
#endif
|
130
|
+
|
131
|
+
return UnistylesUnspecifiedScheme;
|
132
|
+
}
|
133
|
+
|
134
|
+
UIColor* colorFromHexString(NSString* hexString, float alpha) {
|
135
|
+
unsigned rgbValue = 0;
|
136
|
+
unsigned alphaValue = 0xFF;
|
137
|
+
|
138
|
+
NSScanner *scanner = [NSScanner scannerWithString:hexString];
|
139
|
+
|
140
|
+
if (![hexString hasPrefix:@"#"]) {
|
141
|
+
return nil;
|
142
|
+
}
|
143
|
+
|
144
|
+
[scanner setScanLocation:1];
|
145
|
+
|
146
|
+
if ((hexString.length == 9 && ![scanner scanHexInt:&alphaValue]) || ![scanner scanHexInt:&rgbValue]) {
|
147
|
+
return nil;
|
148
|
+
}
|
149
|
+
|
150
|
+
if (hexString.length == 9) {
|
151
|
+
alpha = alphaValue / 255.0;
|
152
|
+
}
|
153
|
+
|
154
|
+
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0
|
155
|
+
green:((rgbValue & 0x00FF00) >> 8) / 255.0
|
156
|
+
blue:(rgbValue & 0x0000FF) / 255.0
|
157
|
+
alpha:alpha];
|
158
|
+
}
|
159
|
+
|
160
|
+
#endif
|
@@ -1,25 +1,21 @@
|
|
1
1
|
#include <string>
|
2
2
|
#include <map>
|
3
3
|
#include <UnistylesRuntime.h>
|
4
|
+
#include "Platform_Shared.h"
|
4
5
|
|
5
6
|
@interface Platform : NSObject
|
6
7
|
|
7
|
-
@property (nonatomic, assign) Dimensions initialScreen;
|
8
|
-
@property (nonatomic, assign) std::string initialColorScheme;
|
9
|
-
@property (nonatomic, assign) std::string initialContentSizeCategory;
|
10
|
-
@property (nonatomic, assign) Insets initialInsets;
|
11
|
-
@property (nonatomic, assign) Dimensions initialStatusBar;
|
12
|
-
@property (nonatomic, assign) Dimensions initialNavigationBar;
|
13
8
|
@property (nonatomic, assign) void* unistylesRuntime;
|
14
9
|
|
15
10
|
- (instancetype)init;
|
16
11
|
|
12
|
+
- (void)clean;
|
17
13
|
- (void)setupListeners;
|
18
|
-
- (void)
|
14
|
+
- (void)makeShared:(void*)runtime;
|
15
|
+
- (void)onWindowChange:(NSNotification *)notification;
|
19
16
|
- (void)onAppearanceChange:(NSNotification *)notification;
|
20
17
|
- (void)onContentSizeCategoryChange:(NSNotification *)notification;
|
21
|
-
|
22
|
-
- (std::string)
|
23
|
-
- (std::string)getContentSizeCategory:(UIContentSizeCategory)contentSizeCategory;
|
18
|
+
- (void)setStatusBarHidden:(bool)isHidden;
|
19
|
+
- (void)setRootViewBackgroundColor:(std::string)color alpha:(float)alpha;
|
24
20
|
|
25
21
|
@end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
#if TARGET_OS_IOS
|
2
2
|
|
3
3
|
#import "Platform_iOS.h"
|
4
|
-
#import "UnistylesRuntime.h"
|
5
4
|
#import <React/RCTAppearance.h>
|
6
5
|
|
7
6
|
@implementation Platform
|
@@ -9,21 +8,16 @@
|
|
9
8
|
- (instancetype)init {
|
10
9
|
self = [super init];
|
11
10
|
if (self) {
|
12
|
-
UIScreen *screen = [UIScreen mainScreen];
|
13
|
-
UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
|
14
|
-
|
15
|
-
self.initialScreen = {(int)screen.bounds.size.width, (int)screen.bounds.size.height};
|
16
|
-
self.initialColorScheme = [self getColorScheme];
|
17
|
-
self.initialContentSizeCategory = [self getContentSizeCategory:contentSizeCategory];
|
18
|
-
self.initialStatusBar = [self getStatusBarDimensions];
|
19
|
-
self.initialInsets = [self getInsets];
|
20
|
-
|
21
11
|
[self setupListeners];
|
22
12
|
}
|
23
13
|
return self;
|
24
14
|
}
|
25
15
|
|
26
16
|
- (void)dealloc {
|
17
|
+
[self clean];
|
18
|
+
}
|
19
|
+
|
20
|
+
- (void)clean {
|
27
21
|
if (self.unistylesRuntime != nullptr) {
|
28
22
|
self.unistylesRuntime = nullptr;
|
29
23
|
}
|
@@ -32,17 +26,17 @@
|
|
32
26
|
name: UIContentSizeCategoryDidChangeNotification
|
33
27
|
object: nil];
|
34
28
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
35
|
-
name:
|
36
|
-
object:
|
29
|
+
name:RCTWindowFrameDidChangeNotification
|
30
|
+
object:nil];
|
37
31
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
38
|
-
name:
|
32
|
+
name: RCTUserInterfaceStyleDidChangeNotification
|
39
33
|
object: nil];
|
40
34
|
}
|
41
35
|
|
42
36
|
- (void)setupListeners {
|
43
37
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
44
|
-
selector:@selector(
|
45
|
-
name:
|
38
|
+
selector:@selector(onWindowChange:)
|
39
|
+
name:RCTWindowFrameDidChangeNotification
|
46
40
|
object:nil];
|
47
41
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
48
42
|
selector:@selector(onAppearanceChange:)
|
@@ -54,117 +48,173 @@
|
|
54
48
|
object:nil];
|
55
49
|
}
|
56
50
|
|
57
|
-
- (void)
|
58
|
-
|
51
|
+
- (void)makeShared:(void*)runtime {
|
52
|
+
self.unistylesRuntime = runtime;
|
53
|
+
|
54
|
+
auto unistylesRuntime = ((UnistylesRuntime*)self.unistylesRuntime);
|
55
|
+
|
56
|
+
unistylesRuntime->setScreenDimensionsCallback([self](){
|
57
|
+
return [self getScreenDimensions];
|
58
|
+
});
|
59
|
+
|
60
|
+
unistylesRuntime->setContentSizeCategoryCallback([](){
|
61
|
+
return getContentSizeCategory();
|
62
|
+
});
|
63
|
+
|
64
|
+
unistylesRuntime->setColorSchemeCallback([self](){
|
65
|
+
return getColorScheme();
|
66
|
+
});
|
67
|
+
|
68
|
+
unistylesRuntime->setStatusBarDimensionsCallback([self](){
|
69
|
+
return [self getStatusBarDimensions];
|
70
|
+
});
|
71
|
+
|
72
|
+
unistylesRuntime->setInsetsCallback([self](){
|
73
|
+
return [self getInsets];
|
74
|
+
});
|
59
75
|
|
76
|
+
unistylesRuntime->setStatusBarHiddenCallback([self](bool hidden){
|
77
|
+
return [self setStatusBarHidden:hidden];
|
78
|
+
});
|
79
|
+
|
80
|
+
unistylesRuntime->setImmersiveModeCallback([self](bool hidden){
|
81
|
+
return [self setStatusBarHidden:hidden];
|
82
|
+
});
|
83
|
+
|
84
|
+
unistylesRuntime->setRootViewBackgroundColorCallback([self](const std::string &color, float alpha){
|
85
|
+
return [self setRootViewBackgroundColor:color alpha:alpha];
|
86
|
+
});
|
87
|
+
|
88
|
+
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
89
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
90
|
+
Screen screen = [self getScreenDimensions];
|
91
|
+
|
92
|
+
unistylesRuntime->screen = Dimensions({ screen.width, screen.height });
|
93
|
+
unistylesRuntime->contentSizeCategory = getContentSizeCategory();
|
94
|
+
unistylesRuntime->colorScheme = getColorScheme();
|
95
|
+
unistylesRuntime->statusBar = [self getStatusBarDimensions];
|
96
|
+
unistylesRuntime->insets = [self getInsets];
|
97
|
+
unistylesRuntime->pixelRatio = screen.pixelRatio;
|
98
|
+
unistylesRuntime->fontScale = screen.fontScale;
|
99
|
+
unistylesRuntime->rtl = [self isRtl];
|
100
|
+
|
101
|
+
dispatch_semaphore_signal(semaphore);
|
102
|
+
});
|
103
|
+
|
104
|
+
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
105
|
+
}
|
106
|
+
|
107
|
+
- (void)onAppearanceChange:(NSNotification *)notification {
|
60
108
|
if (self.unistylesRuntime != nullptr) {
|
61
|
-
((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(
|
109
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(getColorScheme());
|
62
110
|
}
|
63
111
|
}
|
64
112
|
|
65
113
|
- (void)onContentSizeCategoryChange:(NSNotification *)notification {
|
66
|
-
UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
|
67
|
-
|
68
114
|
if (self.unistylesRuntime != nullptr) {
|
69
|
-
((UnistylesRuntime*)self.unistylesRuntime)->handleContentSizeCategoryChange(
|
115
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleContentSizeCategoryChange(getContentSizeCategory());
|
70
116
|
}
|
71
117
|
}
|
72
118
|
|
73
|
-
- (void)
|
119
|
+
- (void)onWindowChange:(NSNotification *)notification {
|
74
120
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
75
|
-
|
76
|
-
|
121
|
+
UIApplicationState appState = [UIApplication sharedApplication].applicationState;
|
122
|
+
|
123
|
+
if (appState != UIApplicationStateActive) {
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
|
127
|
+
Screen screen = [self getScreenDimensions];
|
77
128
|
Insets insets = [self getInsets];
|
78
129
|
Dimensions statusBar = [self getStatusBarDimensions];
|
79
|
-
Dimensions navigationBar = [self getNavigationBarDimensions];
|
80
130
|
|
81
131
|
if (self.unistylesRuntime != nullptr) {
|
82
|
-
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange(screen, insets, statusBar,
|
132
|
+
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange(screen, insets, statusBar, std::nullopt);
|
83
133
|
}
|
84
134
|
});
|
85
135
|
}
|
86
136
|
|
87
|
-
- (
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
return UnistylesUnspecifiedScheme;
|
137
|
+
- (UIWindow *)getMainWindow {
|
138
|
+
for (UIScene *scene in [UIApplication sharedApplication].connectedScenes) {
|
139
|
+
if ([scene isKindOfClass:[UIWindowScene class]]) {
|
140
|
+
UIWindowScene *windowScene = (UIWindowScene *)scene;
|
141
|
+
for (UIWindow *window in windowScene.windows) {
|
142
|
+
if (window.isKeyWindow) {
|
143
|
+
return window;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
98
147
|
}
|
148
|
+
|
149
|
+
return nil;
|
99
150
|
}
|
100
151
|
|
101
152
|
- (Insets)getInsets {
|
102
|
-
UIWindow *window =
|
153
|
+
UIWindow *window = [self getMainWindow];
|
154
|
+
|
155
|
+
if (window == nil) {
|
156
|
+
return {0, 0, 0, 0};
|
157
|
+
}
|
158
|
+
|
103
159
|
UIEdgeInsets safeArea = window.safeAreaInsets;
|
104
|
-
|
160
|
+
|
105
161
|
return {(int)safeArea.top, (int)safeArea.bottom, (int)safeArea.left, (int)safeArea.right};
|
106
162
|
}
|
107
163
|
|
108
164
|
- (Dimensions)getStatusBarDimensions {
|
109
|
-
|
110
|
-
|
165
|
+
UIWindow *window = [self getMainWindow];
|
166
|
+
|
167
|
+
if (window == nil) {
|
168
|
+
return {0, 0};
|
169
|
+
}
|
170
|
+
|
171
|
+
CGRect statusBarFrame = window.windowScene.statusBarManager.statusBarFrame;
|
172
|
+
|
111
173
|
return {(int)statusBarFrame.size.width, (int)statusBarFrame.size.height};
|
112
174
|
}
|
113
175
|
|
114
|
-
- (
|
115
|
-
|
176
|
+
- (Screen)getScreenDimensions {
|
177
|
+
UIViewController *presentedViewController = RCTPresentedViewController();
|
178
|
+
CGRect windowFrame = presentedViewController.view.window.frame;
|
179
|
+
int width = (int)windowFrame.size.width;
|
180
|
+
int height = (int)windowFrame.size.height;
|
181
|
+
float pixelRatio = presentedViewController.view.window.screen.scale;
|
182
|
+
float fontScale = getFontScale();
|
183
|
+
|
184
|
+
return Screen({width, height, pixelRatio, fontScale});
|
116
185
|
}
|
117
186
|
|
118
|
-
- (
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
}
|
150
|
-
|
151
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityLarge]) {
|
152
|
-
return std::string([@"accessibilityLarge" UTF8String]);
|
153
|
-
}
|
154
|
-
|
155
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraLarge]) {
|
156
|
-
return std::string([@"accessibilityExtraLarge" UTF8String]);
|
157
|
-
}
|
158
|
-
|
159
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraLarge]) {
|
160
|
-
return std::string([@"accessibilityExtraExtraLarge" UTF8String]);
|
161
|
-
}
|
162
|
-
|
163
|
-
if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraExtraLarge]) {
|
164
|
-
return std::string([@"accessibilityExtraExtraExtraLarge" UTF8String]);
|
165
|
-
}
|
166
|
-
|
167
|
-
return std::string([@"unspecified" UTF8String]);
|
187
|
+
- (bool)isRtl {
|
188
|
+
// forced by React Native
|
189
|
+
BOOL hasForcedRtl = [[NSUserDefaults standardUserDefaults] boolForKey:@"RCTI18nUtil_forceRTL"];
|
190
|
+
// user preferences
|
191
|
+
BOOL isRtl = [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
|
192
|
+
|
193
|
+
return hasForcedRtl || isRtl;
|
194
|
+
}
|
195
|
+
|
196
|
+
- (void)setStatusBarHidden:(bool)isHidden {
|
197
|
+
// forward it to React Native ViewController
|
198
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
199
|
+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
200
|
+
[RCTSharedApplication() setStatusBarHidden:isHidden animated:true];
|
201
|
+
});
|
202
|
+
}
|
203
|
+
|
204
|
+
- (void)setRootViewBackgroundColor:(std::string)color alpha:(float)alpha {
|
205
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
206
|
+
UIViewController *presentedViewController = RCTPresentedViewController();
|
207
|
+
NSString *colorString = [NSString stringWithUTF8String:color.c_str()];
|
208
|
+
UIColor *backgroundColor = colorFromHexString(colorString, alpha);
|
209
|
+
|
210
|
+
if (backgroundColor == nil) {
|
211
|
+
NSLog(@"🦄 Unistyles: Couldn't set rootView to %@ color", colorString);
|
212
|
+
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
|
216
|
+
presentedViewController.view.backgroundColor = backgroundColor;
|
217
|
+
});
|
168
218
|
}
|
169
219
|
|
170
220
|
@end
|
@@ -4,18 +4,14 @@
|
|
4
4
|
|
5
5
|
@interface Platform : NSObject
|
6
6
|
|
7
|
-
@property (nonatomic, assign) Dimensions initialScreen;
|
8
|
-
@property (nonatomic, assign) std::string initialColorScheme;
|
9
|
-
@property (nonatomic, assign) std::string initialContentSizeCategory;
|
10
|
-
@property (nonatomic, assign) Insets initialInsets;
|
11
|
-
@property (nonatomic, assign) Dimensions initialStatusBar;
|
12
|
-
@property (nonatomic, assign) Dimensions initialNavigationBar;
|
13
7
|
@property (nonatomic, assign) void* unistylesRuntime;
|
14
8
|
|
15
9
|
- (instancetype)init;
|
16
10
|
|
11
|
+
- (void)clean;
|
17
12
|
- (void)setupListeners;
|
18
|
-
- (void)
|
13
|
+
- (void)makeShared:(void*)runtime;
|
14
|
+
- (void)onWindowChange;
|
19
15
|
- (void)onAppearanceChange;
|
20
16
|
|
21
17
|
- (std::string)getColorScheme;
|