react-native-unistyles 2.8.0-rc.2 → 2.8.0-rc.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ #import <UIKit/UIKit.h>
1
2
  #import "UnistylesRuntime.h"
2
3
  #include <string>
3
4
 
@@ -112,17 +112,21 @@ float getFontScale() {
112
112
  }
113
113
 
114
114
  std::string getColorScheme() {
115
- UIUserInterfaceStyle colorScheme = [UIScreen mainScreen].traitCollection.userInterfaceStyle;
116
-
117
- switch (colorScheme) {
118
- case UIUserInterfaceStyleLight:
119
- return UnistylesLightScheme;
120
- case UIUserInterfaceStyleDark:
121
- return UnistylesDarkScheme;
122
- case UIUserInterfaceStyleUnspecified:
123
- default:
124
- return UnistylesUnspecifiedScheme;
125
- }
115
+ #if !TARGET_OS_VISION
116
+ UIUserInterfaceStyle colorScheme = [UIScreen mainScreen].traitCollection.userInterfaceStyle;
117
+
118
+ switch (colorScheme) {
119
+ case UIUserInterfaceStyleLight:
120
+ return UnistylesLightScheme;
121
+ case UIUserInterfaceStyleDark:
122
+ return UnistylesDarkScheme;
123
+ case UIUserInterfaceStyleUnspecified:
124
+ default:
125
+ return UnistylesUnspecifiedScheme;
126
+ }
127
+ #endif
128
+
129
+ return UnistylesUnspecifiedScheme;
126
130
  }
127
131
 
128
132
  UIColor* colorFromHexString(NSString* hexString, float alpha) {
@@ -39,9 +39,9 @@
39
39
 
40
40
  - (void)makeShared:(void*)runtime {
41
41
  self.unistylesRuntime = runtime;
42
-
42
+
43
43
  auto unistylesRuntime = ((UnistylesRuntime*)self.unistylesRuntime);
44
-
44
+
45
45
  unistylesRuntime->setScreenDimensionsCallback([self](){
46
46
  return [self getScreenDimensions];
47
47
  });
@@ -49,15 +49,19 @@
49
49
  unistylesRuntime->setColorSchemeCallback([](){
50
50
  return getColorScheme();
51
51
  });
52
-
52
+
53
53
  unistylesRuntime->setContentSizeCategoryCallback([](){
54
54
  return getContentSizeCategory();
55
55
  });
56
-
56
+
57
57
  dispatch_async(dispatch_get_main_queue(), ^{
58
- unistylesRuntime->screen = [self getScreenDimensions];
58
+ Screen screen = [self getScreenDimensions];
59
+
60
+ unistylesRuntime->screen = Dimensions({screen.width, screen.height});
59
61
  unistylesRuntime->contentSizeCategory = getContentSizeCategory();
60
62
  unistylesRuntime->colorScheme = getColorScheme();
63
+ unistylesRuntime->pixelRatio = screen.pixelRatio;
64
+ unistylesRuntime->fontScale = screen.fontScale;
61
65
  });
62
66
  }
63
67
 
@@ -73,11 +77,14 @@
73
77
  }
74
78
  }
75
79
 
76
- - (Dimensions)getScreenDimensions {
80
+ - (Screen)getScreenDimensions {
77
81
  UIScreen *screen = [UIScreen mainScreen];
78
- Dimensions screenDimension = {(int)screen.bounds.size.width, (int)screen.bounds.size.height};
79
-
80
- return screenDimension;
82
+ int width = (int)screen.bounds.size.width;
83
+ int height = (int)screen.bounds.size.height;
84
+ float pixelRatio = screen.scale;
85
+ float fontScale = getFontScale();
86
+
87
+ return Screen({width, height, pixelRatio, fontScale});
81
88
  }
82
89
 
83
90
  @end
@@ -73,13 +73,17 @@
73
73
  });
74
74
 
75
75
  dispatch_async(dispatch_get_main_queue(), ^{
76
- unistylesRuntime->screen = [self getScreenDimensions];
76
+ Screen screen = [self getScreenDimensions];
77
+
78
+ unistylesRuntime->screen = Dimensions({screen.width, screen.height});
77
79
  unistylesRuntime->contentSizeCategory = getContentSizeCategory();
80
+ unistylesRuntime->pixelRatio = screen.pixelRatio;
81
+ unistylesRuntime->fontScale = screen.fontScale;
78
82
  });
79
83
  }
80
84
 
81
85
  - (void)onWindowChange:(NSNotification *)notification {
82
- Dimensions screen = [self getScreenDimensions];
86
+ Screen screen = [self getScreenDimensions];
83
87
 
84
88
  if (self.unistylesRuntime != nullptr) {
85
89
  ((UnistylesRuntime*)self.unistylesRuntime)->handleScreenSizeChange(
@@ -97,11 +101,14 @@
97
101
  }
98
102
  }
99
103
 
100
- - (Dimensions)getScreenDimensions {
104
+ - (Screen)getScreenDimensions {
101
105
  UIWindow* mainWindow = [self getMainWindow];
102
- Dimensions screenDimension = {(int)mainWindow.frame.size.width, (int)mainWindow.frame.size.height};
106
+ int width = (int)mainWindow.frame.size.width;
107
+ int height = (int)mainWindow.frame.size.height;
108
+ float pixelRatio = 1.0;
109
+ float fontScale = getFontScale();
103
110
 
104
- return screenDimension;
111
+ return Screen({width, height, pixelRatio, fontScale});
105
112
  }
106
113
 
107
114
  @end
@@ -1,11 +1,11 @@
1
- import type { MatrixTransform, PerpectiveTransform, RotateTransform, RotateXTransform, RotateYTransform, RotateZTransform, ScaleTransform, ScaleXTransform, ScaleYTransform, SkewXTransform, SkewYTransform, TranslateXTransform, TranslateYTransform } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
1
+ import type { MatrixTransform, PerspectiveTransform, RotateTransform, RotateXTransform, RotateYTransform, RotateZTransform, ScaleTransform, ScaleXTransform, ScaleYTransform, SkewXTransform, SkewYTransform, TranslateXTransform, TranslateYTransform } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
2
2
  import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
3
3
  import type { UnistylesBreakpoints, UnistylesThemes } from '../global';
4
4
  export type ShadowOffset = {
5
5
  width: number;
6
6
  height: number;
7
7
  };
8
- export type TransformStyles = PerpectiveTransform & RotateTransform & RotateXTransform & RotateYTransform & RotateZTransform & ScaleTransform & ScaleXTransform & ScaleYTransform & TranslateXTransform & TranslateYTransform & SkewXTransform & SkewYTransform & MatrixTransform;
8
+ export type TransformStyles = PerspectiveTransform & RotateTransform & RotateXTransform & RotateYTransform & RotateZTransform & ScaleTransform & ScaleXTransform & ScaleYTransform & TranslateXTransform & TranslateYTransform & SkewXTransform & SkewYTransform & MatrixTransform;
9
9
  export type ScreenSize = {
10
10
  width: number;
11
11
  height: number;
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf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.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.8.0-rc.2",
3
+ "version": "2.8.0-rc.4",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
7
7
  "test:coverage": "jest --coverage",
8
8
  "tsc": "node_modules/typescript/bin/tsc --noEmit",
9
9
  "lint": "eslint . --ext .ts,.tsx",
10
- "prepare": "husky install && bob build",
10
+ "prepare": "husky && bob build",
11
11
  "precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
12
12
  "release": "release-it"
13
13
  },
@@ -58,39 +58,39 @@
58
58
  "registry": "https://registry.npmjs.org/"
59
59
  },
60
60
  "devDependencies": {
61
- "@commitlint/config-conventional": "18.4.3",
62
- "@react-native/eslint-config": "0.74.0",
63
- "@react-native/normalize-colors": "0.74.1",
61
+ "@commitlint/config-conventional": "19.2.2",
62
+ "@react-native/eslint-config": "0.74.84",
63
+ "@react-native/normalize-colors": "0.74.84",
64
64
  "@release-it/conventional-changelog": "8.0.1",
65
65
  "@testing-library/react-hooks": "8.0.1",
66
- "@types/jest": "29.5.11",
67
- "@types/react": "18.2.71",
68
- "@typescript-eslint/eslint-plugin": "6.16.0",
69
- "@typescript-eslint/eslint-plugin-tslint": "6.16.0",
70
- "@typescript-eslint/parser": "6.16.0",
71
- "commitlint": "18.4.3",
66
+ "@types/jest": "29.5.12",
67
+ "@types/react": "18.3.3",
68
+ "@typescript-eslint/eslint-plugin": "6.21.0",
69
+ "@typescript-eslint/eslint-plugin-tslint": "6.21.0",
70
+ "@typescript-eslint/parser": "6.21.0",
71
+ "commitlint": "19.3.0",
72
72
  "concurrently": "8.2.2",
73
- "eslint": "8.56.0",
73
+ "eslint": "8.57.0",
74
74
  "eslint-config-codemask": "1.1.7",
75
- "eslint-plugin-functional": "6.0.0",
75
+ "eslint-plugin-functional": "6.6.0",
76
76
  "eslint-plugin-import": "2.29.1",
77
77
  "eslint-plugin-jsdoc": "46.10.1",
78
- "eslint-plugin-jsx-a11y": "6.8.0",
78
+ "eslint-plugin-jsx-a11y": "6.9.0",
79
79
  "eslint-plugin-nested-if": "1.0.0",
80
80
  "eslint-plugin-no-else": "0.2.2",
81
- "eslint-plugin-no-loops": "0.3.0",
81
+ "eslint-plugin-no-loops": "0.4.0",
82
82
  "eslint-plugin-prefer-arrow": "1.2.3",
83
- "eslint-plugin-react": "7.33.2",
84
- "eslint-plugin-react-hooks": "4.6.0",
85
- "husky": "8.0.3",
83
+ "eslint-plugin-react": "7.34.3",
84
+ "eslint-plugin-react-hooks": "4.6.2",
85
+ "husky": "9.0.11",
86
86
  "jest": "29.7.0",
87
87
  "metro-react-native-babel-preset": "0.77.0",
88
- "react": "18.2.0",
89
- "react-native": "0.72.7",
88
+ "react": "18.3.1",
89
+ "react-native": "0.74.2",
90
90
  "react-native-builder-bob": "0.23.2",
91
- "react-native-web": "0.19.9",
92
- "react-test-renderer": "18.2.0",
93
- "release-it": "17.0.1",
91
+ "react-native-web": "0.19.12",
92
+ "react-test-renderer": "18.3.1",
93
+ "release-it": "17.4.0",
94
94
  "typescript": "5.3.3"
95
95
  },
96
96
  "peerDependencies": {
package/src/types/core.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type {
2
2
  MatrixTransform,
3
- PerpectiveTransform,
3
+ PerspectiveTransform,
4
4
  RotateTransform,
5
5
  RotateXTransform,
6
6
  RotateYTransform,
@@ -22,7 +22,7 @@ export type ShadowOffset = {
22
22
  }
23
23
 
24
24
  export type TransformStyles =
25
- & PerpectiveTransform
25
+ & PerspectiveTransform
26
26
  & RotateTransform
27
27
  & RotateXTransform
28
28
  & RotateYTransform