react-native-unistyles 2.8.0-rc.5 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  #import <React/RCTBridgeModule.h>
2
2
  #import <React/RCTEventEmitter.h>
3
- #import <ReactCommon/RCTRuntimeExecutor.h>
3
+
4
4
  #import <string>
5
5
 
6
6
  #if TARGET_OS_OSX
@@ -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
- unistylesRuntime->screen = [self getScreenDimensions];
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
- Dimensions screen = [self getScreenDimensions];
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
- - (Dimensions)getScreenDimensions {
98
+ - (Screen)getScreenDimensions {
95
99
  NSWindow *window = RCTSharedApplication().mainWindow;
96
- Dimensions screenDimension = {(int)window.frame.size.width, (int)window.frame.size.height};
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 screenDimension;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.8.0-rc.5",
3
+ "version": "2.8.0",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",