react-native-unistyles 2.8.0-rc.5 → 2.8.0-rc.6
Sign up to get free protection for your applications and to get access to all the features.
package/ios/UnistylesModule.h
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
#if TARGET_OS_TV || TARGET_OS_VISION || TARGET_OS_IOS
|
2
|
+
|
1
3
|
#include "Platform_Shared.h"
|
2
4
|
|
3
5
|
std::string getContentSizeCategory() {
|
@@ -154,3 +156,5 @@ UIColor* colorFromHexString(NSString* hexString, float alpha) {
|
|
154
156
|
blue:(rgbValue & 0x0000FF) / 255.0
|
155
157
|
alpha:alpha];
|
156
158
|
}
|
159
|
+
|
160
|
+
#endif
|
@@ -45,8 +45,12 @@
|
|
45
45
|
});
|
46
46
|
|
47
47
|
dispatch_async(dispatch_get_main_queue(), ^{
|
48
|
-
|
48
|
+
Screen screen = [self getScreenDimensions];
|
49
|
+
|
50
|
+
unistylesRuntime->screen = Dimensions({screen.width, screen.height});
|
49
51
|
unistylesRuntime->colorScheme = [self getColorScheme];
|
52
|
+
unistylesRuntime->fontScale = screen.fontScale;
|
53
|
+
unistylesRuntime->pixelRatio = screen.pixelRatio;
|
50
54
|
});
|
51
55
|
}
|
52
56
|
|
@@ -69,7 +73,7 @@
|
|
69
73
|
}
|
70
74
|
|
71
75
|
- (void)onWindowChange {
|
72
|
-
|
76
|
+
Screen screen = [self getScreenDimensions];
|
73
77
|
|
74
78
|
if (self.unistylesRuntime != nullptr) {
|
75
79
|
((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange(
|
@@ -91,11 +95,21 @@
|
|
91
95
|
return UnistylesLightScheme;
|
92
96
|
}
|
93
97
|
|
94
|
-
- (
|
98
|
+
- (Screen)getScreenDimensions {
|
95
99
|
NSWindow *window = RCTSharedApplication().mainWindow;
|
96
|
-
|
100
|
+
int width = (int)window.frame.size.width;
|
101
|
+
int height = (int)window.frame.size.height;
|
102
|
+
float pixelRatio = window.backingScaleFactor;
|
103
|
+
float fontScale = [self getFontScale];
|
97
104
|
|
98
|
-
return
|
105
|
+
return Screen({width, height, pixelRatio, fontScale});
|
106
|
+
}
|
107
|
+
|
108
|
+
- (float)getFontScale {
|
109
|
+
NSFont *systemFont = [NSFont systemFontOfSize:[NSFont systemFontSize]];
|
110
|
+
CGFloat systemFontScale = systemFont.pointSize / 13.0;
|
111
|
+
|
112
|
+
return systemFontScale;
|
99
113
|
}
|
100
114
|
|
101
115
|
@end
|