react-native-unistyles 2.8.0-beta.1 → 2.8.0-beta.3

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.
Files changed (33) hide show
  1. package/android/CMakeLists.txt +8 -1
  2. package/android/build.gradle +4 -1
  3. package/android/src/main/cxx/cpp-adapter.cpp +10 -100
  4. package/android/src/main/cxx/helpers.h +2 -0
  5. package/android/src/main/cxx/platform.cpp +126 -0
  6. package/android/src/main/cxx/platform.h +15 -0
  7. package/android/src/main/java/com/unistyles/Models.kt +14 -35
  8. package/android/src/main/java/com/unistyles/Platform.kt +91 -10
  9. package/android/src/main/java/com/unistyles/UnistylesModule.kt +84 -139
  10. package/cxx/Macros.h +11 -0
  11. package/cxx/UnistylesImpl.cpp +241 -0
  12. package/cxx/UnistylesModel.cpp +234 -0
  13. package/cxx/UnistylesModel.h +112 -0
  14. package/cxx/UnistylesRuntime.cpp +17 -388
  15. package/cxx/UnistylesRuntime.h +56 -95
  16. package/ios/UnistylesModule.h +8 -0
  17. package/ios/UnistylesModule.mm +12 -89
  18. package/ios/platform/Platform_Shared.h +5 -0
  19. package/ios/platform/Platform_Shared.mm +69 -0
  20. package/ios/platform/Platform_iOS.h +2 -9
  21. package/ios/platform/Platform_iOS.mm +47 -94
  22. package/ios/platform/Platform_macOS.h +1 -6
  23. package/ios/platform/Platform_macOS.mm +29 -29
  24. package/ios/platform/Platform_tvOS.h +2 -9
  25. package/ios/platform/Platform_tvOS.mm +30 -92
  26. package/ios/platform/Platform_visionOS.h +2 -8
  27. package/ios/platform/Platform_visionOS.mm +28 -83
  28. package/package.json +1 -1
  29. package/react-native-unistyles.podspec +3 -0
  30. package/android/src/main/java/com/unistyles/Config.kt +0 -116
  31. package/android/src/main/java/com/unistyles/Insets.kt +0 -141
  32. package/ios/UnistylesHelpers.h +0 -3
  33. package/ios/UnistylesHelpers.mm +0 -5
@@ -1,5 +1,4 @@
1
1
  #import "UnistylesModule.h"
2
- #import "UnistylesHelpers.h"
3
2
  #import "UnistylesRuntime.h"
4
3
 
5
4
  #import <React/RCTBridge+Private.h>
@@ -47,106 +46,30 @@ RCT_EXPORT_MODULE(Unistyles)
47
46
  #pragma mark - Core
48
47
 
49
48
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
50
- RCTBridge* bridge = [RCTBridge currentBridge];
51
- RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
52
-
53
- if (cxxBridge == nil) {
54
- return @false;
55
- }
56
-
57
- auto jsiRuntime = (jsi::Runtime*)cxxBridge.runtime;
58
-
59
- if (jsiRuntime == nil) {
49
+ UnistylesModule *__weak weakSelf = self;
50
+ RCTBridge *bridge = self.bridge;
51
+
52
+ if (bridge == nullptr) {
60
53
  return @false;
61
54
  }
62
55
 
63
- auto& runtime = *jsiRuntime;
64
- UnistylesModule *__weak weakSelf = self;
65
-
66
- registerUnistylesHostObject(runtime, weakSelf);
56
+ registerUnistylesHostObject(bridge, weakSelf);
67
57
 
68
58
  NSLog(@"Installed Unistyles 🦄!");
69
59
 
70
60
  return @true;
71
61
  }
72
62
 
73
- void registerUnistylesHostObject(jsi::Runtime &runtime, UnistylesModule* weakSelf) {
74
- auto unistylesRuntime = std::make_shared<UnistylesRuntime>(
75
- weakSelf.platform.initialScreen,
76
- weakSelf.platform.initialColorScheme,
77
- weakSelf.platform.initialContentSizeCategory,
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
- });
123
-
124
- unistylesRuntime.get()->onPluginChange([=]() {
125
- NSDictionary *body = @{
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
- });
63
+ void registerUnistylesHostObject(RCTBridge* bridge, UnistylesModule* weakSelf) {
64
+ std::shared_ptr<react::CallInvoker> callInvoker = bridge.jsCallInvoker;
65
+ jsi::Runtime* runtime = reinterpret_cast<jsi::Runtime*>(bridge.runtime);
66
+ auto unistylesRuntime = std::make_shared<UnistylesRuntime>(*runtime, callInvoker);
144
67
 
145
- weakSelf.platform.unistylesRuntime = unistylesRuntime.get();
68
+ [weakSelf.platform makeShared:unistylesRuntime.get()];
146
69
 
147
- auto hostObject = jsi::Object::createFromHostObject(runtime, unistylesRuntime);
70
+ auto hostObject = jsi::Object::createFromHostObject(*runtime, unistylesRuntime);
148
71
 
149
- runtime.global().setProperty(runtime, "__UNISTYLES__", std::move(hostObject));
72
+ runtime->global().setProperty(*runtime, "__UNISTYLES__", std::move(hostObject));
150
73
  }
151
74
 
152
75
  @end
@@ -0,0 +1,5 @@
1
+ #import "UnistylesRuntime.h"
2
+ #include <string>
3
+
4
+ std::string getContentSizeCategory();
5
+ std::string getColorScheme();
@@ -0,0 +1,69 @@
1
+ #include "Platform_Shared.h"
2
+
3
+ std::string getContentSizeCategory() {
4
+ UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
5
+
6
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraExtraLarge]) {
7
+ return std::string([@"xxxLarge" UTF8String]);
8
+ }
9
+
10
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraLarge]) {
11
+ return std::string([@"xxLarge" UTF8String]);
12
+ }
13
+
14
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraLarge]) {
15
+ return std::string([@"xLarge" UTF8String]);
16
+ }
17
+
18
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryLarge]) {
19
+ return std::string([@"Large" UTF8String]);
20
+ }
21
+
22
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryMedium]) {
23
+ return std::string([@"Medium" UTF8String]);
24
+ }
25
+
26
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategorySmall]) {
27
+ return std::string([@"Small" UTF8String]);
28
+ }
29
+
30
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraSmall]) {
31
+ return std::string([@"xSmall" UTF8String]);
32
+ }
33
+
34
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityMedium]) {
35
+ return std::string([@"accessibilityMedium" UTF8String]);
36
+ }
37
+
38
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityLarge]) {
39
+ return std::string([@"accessibilityLarge" UTF8String]);
40
+ }
41
+
42
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraLarge]) {
43
+ return std::string([@"accessibilityExtraLarge" UTF8String]);
44
+ }
45
+
46
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraLarge]) {
47
+ return std::string([@"accessibilityExtraExtraLarge" UTF8String]);
48
+ }
49
+
50
+ if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraExtraLarge]) {
51
+ return std::string([@"accessibilityExtraExtraExtraLarge" UTF8String]);
52
+ }
53
+
54
+ return std::string([@"unspecified" UTF8String]);
55
+ }
56
+
57
+ std::string getColorScheme() {
58
+ UIUserInterfaceStyle colorScheme = [UIScreen mainScreen].traitCollection.userInterfaceStyle;
59
+
60
+ switch (colorScheme) {
61
+ case UIUserInterfaceStyleLight:
62
+ return UnistylesLightScheme;
63
+ case UIUserInterfaceStyleDark:
64
+ return UnistylesDarkScheme;
65
+ case UIUserInterfaceStyleUnspecified:
66
+ default:
67
+ return UnistylesUnspecifiedScheme;
68
+ }
69
+ }
@@ -1,25 +1,18 @@
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
 
17
12
  - (void)setupListeners;
13
+ - (void)makeShared:(void*)runtime;
18
14
  - (void)onWindowChange:(NSNotification *)notification;
19
15
  - (void)onAppearanceChange:(NSNotification *)notification;
20
16
  - (void)onContentSizeCategoryChange:(NSNotification *)notification;
21
17
 
22
- - (std::string)getColorScheme;
23
- - (std::string)getContentSizeCategory:(UIContentSizeCategory)contentSizeCategory;
24
-
25
18
  @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,17 +8,6 @@
9
8
  - (instancetype)init {
10
9
  self = [super init];
11
10
  if (self) {
12
- UIViewController *presentedViewController = RCTPresentedViewController();
13
- CGRect windowFrame = presentedViewController.view.window.frame;
14
-
15
- UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
16
-
17
- self.initialScreen = {(int)windowFrame.size.width, (int)windowFrame.size.height};
18
- self.initialColorScheme = [self getColorScheme];
19
- self.initialContentSizeCategory = [self getContentSizeCategory:contentSizeCategory];
20
- self.initialStatusBar = [self getStatusBarDimensions];
21
- self.initialInsets = [self getInsets];
22
-
23
11
  [self setupListeners];
24
12
  }
25
13
  return self;
@@ -56,52 +44,64 @@
56
44
  object:nil];
57
45
  }
58
46
 
59
- - (void)onAppearanceChange:(NSNotification *)notification {
60
- std::string colorScheme = [self getColorScheme];
47
+ - (void)makeShared:(void*)runtime {
48
+ self.unistylesRuntime = runtime;
49
+
50
+ auto unistylesRuntime = ((UnistylesRuntime*)self.unistylesRuntime);
51
+
52
+ unistylesRuntime->setScreenDimensionsCallback([self](){
53
+ return [self getScreenDimensions];
54
+ });
55
+
56
+ unistylesRuntime->setContentSizeCategoryCallback([](){
57
+ return getContentSizeCategory();
58
+ });
59
+
60
+ unistylesRuntime->setColorSchemeCallback([self](){
61
+ return getColorScheme();
62
+ });
63
+
64
+ unistylesRuntime->setStatusBarDimensionsCallback([self](){
65
+ return [self getStatusBarDimensions];
66
+ });
67
+
68
+ unistylesRuntime->setInsetsCallback([self](){
69
+ return [self getInsets];
70
+ });
71
+
72
+ dispatch_async(dispatch_get_main_queue(), ^{
73
+ unistylesRuntime->screen = [self getScreenDimensions];
74
+ unistylesRuntime->contentSizeCategory = getContentSizeCategory();
75
+ unistylesRuntime->colorScheme = getColorScheme();
76
+ unistylesRuntime->statusBar = [self getStatusBarDimensions];
77
+ unistylesRuntime->insets = [self getInsets];
78
+ });
79
+ }
61
80
 
81
+ - (void)onAppearanceChange:(NSNotification *)notification {
62
82
  if (self.unistylesRuntime != nullptr) {
63
- ((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(colorScheme);
83
+ ((UnistylesRuntime*)self.unistylesRuntime)->handleAppearanceChange(getColorScheme());
64
84
  }
65
85
  }
66
86
 
67
87
  - (void)onContentSizeCategoryChange:(NSNotification *)notification {
68
- UIContentSizeCategory contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory];
69
-
70
88
  if (self.unistylesRuntime != nullptr) {
71
- ((UnistylesRuntime*)self.unistylesRuntime)->handleContentSizeCategoryChange([self getContentSizeCategory:contentSizeCategory]);
89
+ ((UnistylesRuntime*)self.unistylesRuntime)->handleContentSizeCategoryChange(getContentSizeCategory());
72
90
  }
73
91
  }
74
92
 
75
93
  - (void)onWindowChange:(NSNotification *)notification {
76
94
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
77
- UIViewController *presentedViewController = RCTPresentedViewController();
78
-
79
- CGRect windowFrame = presentedViewController.view.frame;
80
- Dimensions screen = {(int)windowFrame.size.width, (int)windowFrame.size.height};
95
+ Dimensions screen = [self getScreenDimensions];
81
96
  Insets insets = [self getInsets];
82
97
  Dimensions statusBar = [self getStatusBarDimensions];
83
- Dimensions navigationBar = [self getNavigationBarDimensions];
84
98
 
85
99
  if (self.unistylesRuntime != nullptr) {
86
- ((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange(screen, insets, statusBar, navigationBar);
100
+ ((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange(screen, insets, statusBar, std::nullopt);
87
101
  }
88
102
  });
89
103
  }
90
104
 
91
- - (std::string)getColorScheme {
92
- UIUserInterfaceStyle colorScheme = [UIScreen mainScreen].traitCollection.userInterfaceStyle;
93
-
94
- switch (colorScheme) {
95
- case UIUserInterfaceStyleLight:
96
- return UnistylesLightScheme;
97
- case UIUserInterfaceStyleDark:
98
- return UnistylesDarkScheme;
99
- case UIUserInterfaceStyleUnspecified:
100
- default:
101
- return UnistylesUnspecifiedScheme;
102
- }
103
- }
104
-
105
105
  - (Insets)getInsets {
106
106
  UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
107
107
  UIEdgeInsets safeArea = window.safeAreaInsets;
@@ -110,65 +110,18 @@
110
110
  }
111
111
 
112
112
  - (Dimensions)getStatusBarDimensions {
113
- CGRect statusBarFrame = UIApplication.sharedApplication.statusBarFrame;
114
-
113
+ UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
114
+ CGRect statusBarFrame = window.windowScene.statusBarManager.statusBarFrame;
115
+
115
116
  return {(int)statusBarFrame.size.width, (int)statusBarFrame.size.height};
116
117
  }
117
118
 
118
- - (Dimensions)getNavigationBarDimensions {
119
- return {0, 0};
120
- }
121
-
122
- - (std::string)getContentSizeCategory:(UIContentSizeCategory)contentSizeCategory {
123
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraExtraLarge]) {
124
- return std::string([@"xxxLarge" UTF8String]);
125
- }
126
-
127
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraExtraLarge]) {
128
- return std::string([@"xxLarge" UTF8String]);
129
- }
130
-
131
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraLarge]) {
132
- return std::string([@"xLarge" UTF8String]);
133
- }
134
-
135
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryLarge]) {
136
- return std::string([@"Large" UTF8String]);
137
- }
138
-
139
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryMedium]) {
140
- return std::string([@"Medium" UTF8String]);
141
- }
142
-
143
- if ([contentSizeCategory isEqualToString:UIContentSizeCategorySmall]) {
144
- return std::string([@"Small" UTF8String]);
145
- }
146
-
147
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryExtraSmall]) {
148
- return std::string([@"xSmall" UTF8String]);
149
- }
150
-
151
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityMedium]) {
152
- return std::string([@"accessibilityMedium" UTF8String]);
153
- }
154
-
155
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityLarge]) {
156
- return std::string([@"accessibilityLarge" UTF8String]);
157
- }
158
-
159
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraLarge]) {
160
- return std::string([@"accessibilityExtraLarge" UTF8String]);
161
- }
162
-
163
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraLarge]) {
164
- return std::string([@"accessibilityExtraExtraLarge" UTF8String]);
165
- }
166
-
167
- if ([contentSizeCategory isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraExtraLarge]) {
168
- return std::string([@"accessibilityExtraExtraExtraLarge" UTF8String]);
169
- }
170
-
171
- return std::string([@"unspecified" UTF8String]);
119
+ - (Dimensions)getScreenDimensions {
120
+ UIViewController *presentedViewController = RCTPresentedViewController();
121
+ CGRect windowFrame = presentedViewController.view.window.frame;
122
+ Dimensions screenDimension = {(int)windowFrame.size.width, (int)windowFrame.size.height};
123
+
124
+ return screenDimension;
172
125
  }
173
126
 
174
127
  @end
@@ -4,17 +4,12 @@
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
 
17
11
  - (void)setupListeners;
12
+ - (void)makeShared:(void*)runtime;
18
13
  - (void)onWindowChange;
19
14
  - (void)onAppearanceChange;
20
15
 
@@ -1,7 +1,6 @@
1
1
  #if TARGET_OS_OSX
2
2
 
3
3
  #import "Platform_macOS.h"
4
- #import "UnistylesRuntime.h"
5
4
  #import <React/RCTUtils.h>
6
5
 
7
6
  @implementation Platform
@@ -9,15 +8,6 @@
9
8
  - (instancetype)init {
10
9
  self = [super init];
11
10
  if (self) {
12
- NSWindow *window = RCTSharedApplication().mainWindow;
13
-
14
- self.initialScreen = {(int)window.frame.size.width, (int)window.frame.size.height};
15
- self.initialContentSizeCategory = std::string([@"unspecified" UTF8String]);
16
- self.initialColorScheme = [self getColorScheme];
17
- self.initialStatusBar = [self getStatusBarDimensions];
18
- self.initialNavigationBar = [self getNavigationBarDimensions];
19
- self.initialInsets = [self getInsets];
20
-
21
11
  [self setupListeners];
22
12
  }
23
13
  return self;
@@ -41,6 +31,25 @@
41
31
  [window addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];
42
32
  }
43
33
 
34
+ - (void)makeShared:(void*)runtime {
35
+ self.unistylesRuntime = runtime;
36
+
37
+ auto unistylesRuntime = ((UnistylesRuntime*)self.unistylesRuntime);
38
+
39
+ unistylesRuntime->setScreenDimensionsCallback([self](){
40
+ return [self getScreenDimensions];
41
+ });
42
+
43
+ unistylesRuntime->setColorSchemeCallback([self](){
44
+ return [self getColorScheme];
45
+ });
46
+
47
+ dispatch_async(dispatch_get_main_queue(), ^{
48
+ unistylesRuntime->screen = [self getScreenDimensions];
49
+ unistylesRuntime->colorScheme = [self getColorScheme];
50
+ });
51
+ }
52
+
44
53
  - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
45
54
  if ([keyPath isEqualToString:@"effectiveAppearance"]) {
46
55
  return [self onAppearanceChange];
@@ -60,18 +69,14 @@
60
69
  }
61
70
 
62
71
  - (void)onWindowChange {
63
- NSWindow *window = RCTSharedApplication().mainWindow;
64
- Dimensions screen = {(int)window.frame.size.width, (int)window.frame.size.height};
65
- Insets insets = [self getInsets];
66
- Dimensions statusBar = [self getStatusBarDimensions];
67
- Dimensions navigationBar = [self getNavigationBarDimensions];
68
-
72
+ Dimensions screen = [self getScreenDimensions];
73
+
69
74
  if (self.unistylesRuntime != nullptr) {
70
75
  ((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange(
71
76
  screen,
72
- insets,
73
- statusBar,
74
- navigationBar
77
+ std::nullopt,
78
+ std::nullopt,
79
+ std::nullopt
75
80
  );
76
81
  }
77
82
  }
@@ -86,16 +91,11 @@
86
91
  return UnistylesLightScheme;
87
92
  }
88
93
 
89
- - (Insets)getInsets {
90
- return {0, 0, 0, 0};
91
- }
92
-
93
- - (Dimensions)getStatusBarDimensions {
94
- return {0, 0};
95
- }
96
-
97
- - (Dimensions)getNavigationBarDimensions {
98
- return {0, 0};
94
+ - (Dimensions)getScreenDimensions {
95
+ NSWindow *window = RCTSharedApplication().mainWindow;
96
+ Dimensions screenDimension = {(int)window.frame.size.width, (int)window.frame.size.height};
97
+
98
+ return screenDimension;
99
99
  }
100
100
 
101
101
  @end
@@ -1,23 +1,16 @@
1
1
  #include <string>
2
2
  #include <map>
3
- #include <UnistylesRuntime.h>
3
+ #include "Platform_Shared.h"
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)makeShared:(void*)runtime;
17
12
  - (void)onAppearanceChange:(NSNotification *)notification;
18
13
  - (void)onContentSizeCategoryChange:(NSNotification *)notification;
19
14
 
20
- - (std::string)getColorScheme;
21
-
22
15
  @end
23
16