react-native-unistyles 2.4.0-rc.2 → 2.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.4.0-rc.2",
3
+ "version": "2.4.0",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -18,8 +18,7 @@ using namespace winrt::Windows::UI::Core;
18
18
  using namespace facebook;
19
19
 
20
20
  struct UIInitialInfo {
21
- int screenWidth;
22
- int screenHeight;
21
+ Dimensions screen;
23
22
  std::string colorScheme;
24
23
  std::string contentSizeCategory;
25
24
  };
@@ -39,7 +38,9 @@ struct Unistyles {
39
38
  auto bounds = Window::Current().Bounds();
40
39
 
41
40
  if (this->unistylesRuntime != nullptr) {
42
- ((UnistylesRuntime*)this->unistylesRuntime)->handleScreenSizeChange((int)bounds.Width, (int)bounds.Height, this->getInsets(), this->getStatusBarDimensions());
41
+ Dimensions screenDimensions = Dimensions{(int)bounds.Width, (int)bounds.Height};
42
+
43
+ ((UnistylesRuntime*)this->unistylesRuntime)->handleScreenSizeChange(screenDimensions, this->getInsets(), this->getStatusBarDimensions(), this->getNavigationBarDimensions());
43
44
  }
44
45
  }));
45
46
 
@@ -80,8 +81,7 @@ struct Unistyles {
80
81
  UIInitialInfo uiMetadata;
81
82
  auto bounds = Window::Current().Bounds();
82
83
 
83
- uiMetadata.screenWidth = bounds.Width;
84
- uiMetadata.screenHeight = bounds.Height;
84
+ uiMetadata.screen = Dimensions{(int)bounds.Width, (int)bounds.Height};
85
85
  uiMetadata.colorScheme = this->getColorScheme();
86
86
  uiMetadata.contentSizeCategory = UnistylesUnspecifiedScheme;
87
87
 
@@ -91,12 +91,12 @@ struct Unistyles {
91
91
  UIInitialInfo uiInfo = uiInfoFuture.get();
92
92
 
93
93
  auto unistylesRuntime = std::make_shared<UnistylesRuntime>(
94
- uiInfo.screenWidth,
95
- uiInfo.screenHeight,
94
+ uiInfo.screen,
96
95
  uiInfo.colorScheme,
97
96
  uiInfo.contentSizeCategory,
98
97
  this->getInsets(),
99
- this->getStatusBarDimensions()
98
+ this->getStatusBarDimensions(),
99
+ this->getNavigationBarDimensions()
100
100
  );
101
101
 
102
102
  unistylesRuntime->onThemeChange([this](std::string theme) {
@@ -110,16 +110,30 @@ struct Unistyles {
110
110
  this->OnThemeChange(payload);
111
111
  });
112
112
 
113
- unistylesRuntime.get()->onLayoutChange([this](std::string breakpoint, std::string orientation, int width, int height) {
113
+ unistylesRuntime.get()->onLayoutChange([this](std::string breakpoint, std::string orientation, Dimensions& screen, Dimensions& statusBar, Insets& insets, Dimensions& navigationBar) {
114
114
  auto payload = winrt::Microsoft::ReactNative::JSValueObject{
115
115
  {"type", "layout"},
116
116
  {"payload", winrt::Microsoft::ReactNative::JSValueObject{
117
117
  {"breakpoint", breakpoint},
118
118
  {"orientation", orientation},
119
119
  {"screen", winrt::Microsoft::ReactNative::JSValueObject{
120
- {"width", width},
121
- {"height", height}
122
- }}
120
+ {"width", screen.width},
121
+ {"height", screen.height}
122
+ }},
123
+ {"statusBar", winrt::Microsoft::ReactNative::JSValueObject{
124
+ {"width", statusBar.width},
125
+ {"height", statusBar.height}
126
+ }},
127
+ {"navigationBar", winrt::Microsoft::ReactNative::JSValueObject{
128
+ {"width", navigationBar.width},
129
+ {"height", navigationBar.height}
130
+ }},
131
+ {"insets", winrt::Microsoft::ReactNative::JSValueObject{
132
+ {"top", insets.top},
133
+ {"bottom", insets.bottom},
134
+ {"left", insets.left},
135
+ {"right", insets.right}
136
+ }},
123
137
  }}
124
138
  };
125
139
 
@@ -195,24 +209,16 @@ struct Unistyles {
195
209
  return UnistylesUnspecifiedScheme;
196
210
  }
197
211
 
198
- std::map<std::string, int>getInsets() {
199
- std::map<std::string, int> insets;
200
-
201
- insets.insert({ "top", 0 });
202
- insets.insert({ "bottom", 0 });
203
- insets.insert({ "left", 0 });
204
- insets.insert({ "right", 0 });
205
-
206
- return insets;
212
+ Insets getInsets() {
213
+ return Insets{ 0, 0, 0, 0 };
207
214
  }
208
215
 
209
- std::map<std::string, int>getStatusBarDimensions() {
210
- std::map<std::string, int> statusBar;
211
-
212
- statusBar.insert({ "height", 0 });
213
- statusBar.insert({ "width", 0 });
216
+ Dimensions getStatusBarDimensions() {
217
+ return {0, 0};
218
+ }
214
219
 
215
- return statusBar;
220
+ Dimensions getNavigationBarDimensions() {
221
+ return { 0, 0 };
216
222
  }
217
223
  };
218
224