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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. package/README.md +5 -2
  2. package/android/src/main/cxx/cpp-adapter.cpp +28 -13
  3. package/android/src/main/cxx/helpers.cpp +21 -56
  4. package/android/src/main/cxx/helpers.h +3 -3
  5. package/android/src/main/java/com/unistyles/Config.kt +116 -0
  6. package/android/src/main/java/com/unistyles/Insets.kt +138 -0
  7. package/android/src/main/java/com/unistyles/Models.kt +85 -0
  8. package/android/src/main/java/com/unistyles/Platform.kt +10 -79
  9. package/android/src/main/java/com/unistyles/UnistylesModule.kt +85 -25
  10. package/cxx/UnistylesRuntime.cpp +57 -42
  11. package/cxx/UnistylesRuntime.h +30 -19
  12. package/ios/UnistylesModule.mm +20 -6
  13. package/ios/platform/Platform_iOS.h +5 -4
  14. package/ios/platform/Platform_iOS.mm +35 -22
  15. package/ios/platform/Platform_macOS.h +5 -4
  16. package/ios/platform/Platform_macOS.mm +18 -25
  17. package/lib/commonjs/common.js +7 -0
  18. package/lib/commonjs/common.js.map +1 -1
  19. package/lib/commonjs/core/UnistylesModule.js +6 -0
  20. package/lib/commonjs/core/UnistylesModule.js.map +1 -1
  21. package/lib/commonjs/core/UnistylesRuntime.js +8 -0
  22. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  23. package/lib/commonjs/hooks/useUnistyles.js +18 -1
  24. package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
  25. package/lib/module/common.js +7 -0
  26. package/lib/module/common.js.map +1 -1
  27. package/lib/module/core/UnistylesModule.js +6 -0
  28. package/lib/module/core/UnistylesModule.js.map +1 -1
  29. package/lib/module/core/UnistylesRuntime.js +8 -0
  30. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  31. package/lib/module/hooks/useUnistyles.js +18 -1
  32. package/lib/module/hooks/useUnistyles.js.map +1 -1
  33. package/lib/typescript/src/common.d.ts +8 -1
  34. package/lib/typescript/src/common.d.ts.map +1 -1
  35. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
  36. package/lib/typescript/src/core/UnistylesRuntime.d.ts +6 -1
  37. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  38. package/lib/typescript/src/hooks/useUnistyles.d.ts +14 -0
  39. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
  40. package/lib/typescript/src/types/unistyles.d.ts +6 -2
  41. package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/src/common.ts +8 -1
  44. package/src/core/UnistylesModule.ts +8 -2
  45. package/src/core/UnistylesRuntime.ts +8 -0
  46. package/src/hooks/useUnistyles.ts +18 -1
  47. package/src/types/unistyles.ts +6 -2
  48. package/windows/ReactNativeUnistyles/ReactNativeUnistyles.h +33 -27
@@ -1 +1 @@
1
- {"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,mBAAmB,gGAE7B;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,MAAM,oCAEhB;IAED;;;OAGG;IACH,IAAW,SAAS,2CAEnB;IAED;;;OAGG;IACH,IAAW,WAAW,6BAQrB;IAED;;;;OAIG;IACI,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAED;;;;;OAKG;IACI,WAAW,SAAU,MAAM,eAAe,mBAAmB,eAAe,CAAC,MAAM,eAAe,CAAC,KAAK,eAAe,CAAC,MAAM,eAAe,CAAC,UAEpJ;IAED;;;OAGG;IACI,iBAAiB,WAAY,OAAO,UAE1C;IAED;;;OAGG;IACI,SAAS,WAAY,eAAe,UAE1C;IAED;;;OAGG;IACI,YAAY,WAAY,eAAe,UAE7C;CACJ"}
1
+ {"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,mBAAmB,gGAE7B;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,MAAM,oCAEhB;IAED;;;OAGG;IACH,IAAW,SAAS,wCAEnB;IAED;;;OAGG;IACH,IAAW,aAAa,wCAEvB;IAED;;;OAGG;IACH,IAAW,WAAW,6BAQrB;IAED;;;;OAIG;IACI,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAED;;;;;OAKG;IACI,WAAW,SAAU,MAAM,eAAe,mBAAmB,eAAe,CAAC,MAAM,eAAe,CAAC,KAAK,eAAe,CAAC,MAAM,eAAe,CAAC,UAEpJ;IAED;;;OAGG;IACI,iBAAiB,WAAY,OAAO,UAE1C;IAED;;;OAGG;IACI,SAAS,WAAY,eAAe,UAE1C;IAED;;;OAGG;IACI,YAAY,WAAY,eAAe,UAE7C;CACJ"}
@@ -8,6 +8,20 @@ export declare const useUnistyles: () => {
8
8
  width: number;
9
9
  height: number;
10
10
  };
11
+ statusBar: {
12
+ width: number;
13
+ height: number;
14
+ };
15
+ navigationBar: {
16
+ width: number;
17
+ height: number;
18
+ };
19
+ insets: {
20
+ top: number;
21
+ bottom: number;
22
+ left: number;
23
+ right: number;
24
+ };
11
25
  };
12
26
  contentSizeCategory: import("../common").IOSContentSizeCategory | import("../common").AndroidContentSizeCategory;
13
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;;;CAuDxB,CAAA"}
1
+ {"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;CAwExB,CAAA"}
@@ -9,7 +9,7 @@ export type ScreenInsets = {
9
9
  bottom: number;
10
10
  left: number;
11
11
  };
12
- export type StatusBarDimensions = {
12
+ export type ScreenDimensions = {
13
13
  height: number;
14
14
  width: number;
15
15
  };
@@ -30,7 +30,8 @@ export type UnistylesBridge = {
30
30
  contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory;
31
31
  sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
32
32
  insets: ScreenInsets;
33
- statusBar: StatusBarDimensions;
33
+ statusBar: ScreenDimensions;
34
+ navigationBar: ScreenDimensions;
34
35
  themes: Array<keyof UnistylesThemes>;
35
36
  useBreakpoints(breakpoints: UnistylesBreakpoints): void;
36
37
  useTheme(name: keyof UnistylesThemes): void;
@@ -49,6 +50,9 @@ export type UnistylesMobileLayoutEvent = {
49
50
  type: UnistylesEventType.Layout;
50
51
  payload: {
51
52
  screen: ScreenSize;
53
+ statusBar: ScreenDimensions;
54
+ navigationBar: ScreenDimensions;
55
+ insets: ScreenInsets;
52
56
  breakpoint: keyof UnistylesBreakpoints;
53
57
  orientation: typeof ScreenOrientation[keyof typeof ScreenOrientation];
54
58
  };
@@ -1 +1 @@
1
- {"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACrH,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAA;AAE9D,MAAM,MAAM,YAAY,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;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CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC;IAC/B,OAAO,EAAE;QACL,SAAS,EAAE,MAAM,eAAe,CAAA;KACnC,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC;QACnB,SAAS,EAAE,gBAAgB,CAAC;QAC5B,aAAa,EAAE,gBAAgB,CAAC;QAChC,MAAM,EAAE,YAAY,CAAC;QACrB,UAAU,EAAE,MAAM,oBAAoB,CAAC;QACvC,WAAW,EAAE,OAAO,iBAAiB,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAA;KACxE,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IACxC,IAAI,EAAE,kBAAkB,CAAC,eAAe,CAAC;IACzC,OAAO,EAAE;QACL,mBAAmB,EAAE,sBAAsB,GAAG,0BAA0B,CAAA;KAC3E,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,oBAAoB,GAAG,6BAA6B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.4.0-rc.1",
3
+ "version": "2.4.0",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
package/src/common.ts CHANGED
@@ -16,6 +16,11 @@ export const ScreenOrientation = {
16
16
  } as const
17
17
 
18
18
  export enum IOSContentSizeCategory {
19
+ AccessibilityExtraExtraExtraLarge = 'accessibilityExtraExtraExtraLarge',
20
+ AccessibilityExtraExtraLarge = 'accessibilityExtraExtraLarge',
21
+ AccessibilityExtraLarge = 'accessibilityExtraLarge',
22
+ AccessibilityLarge = 'accessibilityLarge',
23
+ AccessibilityMedium = 'accessibilityMedium',
19
24
  ExtraExtraExtraLarge = 'xxxLarge',
20
25
  ExtraExtraLarge = 'xxLarge',
21
26
  ExtraLarge = 'xLarge',
@@ -31,7 +36,9 @@ export enum AndroidContentSizeCategory {
31
36
  Default = 'Default',
32
37
  Large = 'Large',
33
38
  ExtraLarge = 'ExtraLarge',
34
- Huge = 'Huge'
39
+ Huge = 'Huge',
40
+ ExtraHuge = 'ExtraHuge',
41
+ ExtraExtraHuge = 'ExtraExtraHuge'
35
42
  }
36
43
 
37
44
  export enum UnistylesEventType {
@@ -1,6 +1,6 @@
1
1
  import { NativeEventEmitter, NativeModules } from 'react-native'
2
2
  import type { UnistylesThemes, UnistylesBreakpoints } from 'react-native-unistyles'
3
- import type { ColorSchemeName, ScreenInsets, StatusBarDimensions } from '../types'
3
+ import type { ColorSchemeName, ScreenInsets, ScreenDimensions } from '../types'
4
4
  import { normalizeWebStylesPlugin } from '../plugins'
5
5
  import { isServer } from '../common'
6
6
 
@@ -25,7 +25,11 @@ export class UnistylesBridgeWeb {
25
25
  bottom: 0,
26
26
  left: 0
27
27
  }
28
- #statusBar: StatusBarDimensions = {
28
+ #statusBar: ScreenDimensions = {
29
+ height: 0,
30
+ width: 0
31
+ }
32
+ #navigationBar: ScreenDimensions = {
29
33
  height: 0,
30
34
  width: 0
31
35
  }
@@ -68,6 +72,8 @@ export class UnistylesBridgeWeb {
68
72
  return this.#insets
69
73
  case 'statusBar':
70
74
  return this.#statusBar
75
+ case 'navigationBar':
76
+ return this.#navigationBar
71
77
  case 'useTheme':
72
78
  return (themeName: keyof UnistylesThemes) => this.useTheme(themeName)
73
79
  case 'updateTheme':
@@ -92,6 +92,14 @@ export class UnistylesRuntime {
92
92
  return this.unistylesBridge.statusBar
93
93
  }
94
94
 
95
+ /**
96
+ * Get the navigation bar info (Android)
97
+ * @returns - The navigation bar size { width, height }
98
+ */
99
+ public get navigationBar() {
100
+ return this.unistylesBridge.navigationBar
101
+ }
102
+
95
103
  /**
96
104
  * Get the screen orientation
97
105
  * @returns - The screen orientation
@@ -16,6 +16,20 @@ export const useUnistyles = () => {
16
16
  screenSize: {
17
17
  width: unistyles.runtime.screen.width,
18
18
  height: unistyles.runtime.screen.height
19
+ },
20
+ statusBar: {
21
+ width: unistyles.runtime.statusBar.width,
22
+ height: unistyles.runtime.statusBar.height
23
+ },
24
+ navigationBar: {
25
+ width: unistyles.runtime.navigationBar.width,
26
+ height: unistyles.runtime.navigationBar.height
27
+ },
28
+ insets: {
29
+ top: unistyles.runtime.insets.top,
30
+ bottom: unistyles.runtime.insets.bottom,
31
+ left: unistyles.runtime.insets.left,
32
+ right: unistyles.runtime.insets.right
19
33
  }
20
34
  })
21
35
 
@@ -35,7 +49,10 @@ export const useUnistyles = () => {
35
49
  return setLayout({
36
50
  breakpoint: layoutEvent.payload.breakpoint,
37
51
  orientation: layoutEvent.payload.orientation,
38
- screenSize: layoutEvent.payload.screen
52
+ screenSize: layoutEvent.payload.screen,
53
+ statusBar: layoutEvent.payload.statusBar,
54
+ insets: layoutEvent.payload.insets,
55
+ navigationBar: layoutEvent.payload.navigationBar
39
56
  })
40
57
  }
41
58
  case UnistylesEventType.Plugin: {
@@ -12,7 +12,7 @@ export type ScreenInsets = {
12
12
  left: number
13
13
  }
14
14
 
15
- export type StatusBarDimensions = {
15
+ export type ScreenDimensions = {
16
16
  height: number,
17
17
  width: number
18
18
  }
@@ -36,7 +36,8 @@ export type UnistylesBridge = {
36
36
  contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory,
37
37
  sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>,
38
38
  insets: ScreenInsets,
39
- statusBar: StatusBarDimensions,
39
+ statusBar: ScreenDimensions,
40
+ navigationBar: ScreenDimensions
40
41
 
41
42
  // setters
42
43
  themes: Array<keyof UnistylesThemes>,
@@ -59,6 +60,9 @@ export type UnistylesMobileLayoutEvent = {
59
60
  type: UnistylesEventType.Layout,
60
61
  payload: {
61
62
  screen: ScreenSize,
63
+ statusBar: ScreenDimensions,
64
+ navigationBar: ScreenDimensions,
65
+ insets: ScreenInsets,
62
66
  breakpoint: keyof UnistylesBreakpoints,
63
67
  orientation: typeof ScreenOrientation[keyof typeof ScreenOrientation]
64
68
  }
@@ -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