@applicaster/zapp-react-native-ui-components 13.0.0-alpha.6714678893 → 13.0.0-alpha.7100577251

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.
Files changed (123) hide show
  1. package/Components/AppContainer/__tests__/__snapshots__/AppContainer.test.js.snap +1 -1
  2. package/Components/AudioPlayer/__tests__/__snapshots__/Runtime.test.js.snap +4 -4
  3. package/Components/AudioPlayer/__tests__/__snapshots__/artWork.test.js.snap +3 -3
  4. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +6 -6
  5. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +7 -7
  6. package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +3 -3
  7. package/Components/AudioPlayer/__tests__/__snapshots__/summary.test.js.snap +2 -2
  8. package/Components/AudioPlayer/__tests__/__snapshots__/title.test.js.snap +2 -2
  9. package/Components/BaseFocusable/index.ios.ts +1 -1
  10. package/Components/BaseFocusable/index.tsx +66 -29
  11. package/Components/Cell/Cell.tsx +7 -3
  12. package/Components/Cell/TvOSCellComponent.tsx +4 -8
  13. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +20 -20
  14. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +5 -3
  15. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +5 -5
  16. package/Components/ComponentResolver/__tests__/componentResolver.test.js +11 -9
  17. package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
  18. package/Components/Focusable/Focusable.tsx +0 -54
  19. package/Components/Focusable/FocusableTvOS.tsx +1 -5
  20. package/Components/Focusable/Touchable.tsx +19 -20
  21. package/Components/FocusableList/index.tsx +0 -1
  22. package/Components/FocusableScrollView/index.tsx +12 -39
  23. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +9 -0
  24. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  25. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +1 -0
  26. package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
  27. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -3
  28. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +9 -9
  29. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  30. package/Components/Layout/TV/__tests__/index.test.tsx +7 -3
  31. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  32. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  33. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -12
  34. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  35. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
  36. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  37. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  38. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  39. package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
  40. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +7 -7
  41. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +34 -34
  42. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  43. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
  44. package/Components/MasterCell/utils/index.ts +1 -1
  45. package/Components/ModalComponent/Header/index.tsx +3 -3
  46. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
  47. package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
  48. package/Components/PlayerContainer/PlayerContainer.tsx +5 -11
  49. package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
  50. package/Components/PlayerImageBackground/index.tsx +23 -3
  51. package/Components/River/ComponentsMap/ComponentsMap.tsx +39 -65
  52. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
  53. package/Components/River/RefreshControl.tsx +1 -1
  54. package/Components/River/RiverFooter.tsx +39 -9
  55. package/Components/River/RiverItem.tsx +37 -2
  56. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +114 -45
  57. package/Components/River/__tests__/__snapshots__/river.test.js.snap +12 -12
  58. package/Components/River/__tests__/componentsMap.test.js +64 -17
  59. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -1
  60. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +1 -1
  61. package/Components/Screen/__tests__/Screen.test.tsx +41 -27
  62. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -4
  63. package/Components/Screen/hooks.ts +56 -0
  64. package/Components/Screen/index.tsx +13 -39
  65. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +2 -2
  66. package/Components/ScreenResolver/__tests__/screenResolver.test.js +31 -27
  67. package/Components/Tabs/Tab.tsx +7 -6
  68. package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
  69. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
  70. package/Components/TextInputTv/index.tsx +4 -4
  71. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
  72. package/Components/Transitioner/AnimationManager.js +8 -8
  73. package/Components/Transitioner/Scene.tsx +52 -23
  74. package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
  75. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +62 -46
  76. package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
  77. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +4 -4
  78. package/Components/Transitioner/index.js +8 -4
  79. package/Components/VideoLive/LiveImageManager.ts +27 -1
  80. package/Components/VideoLive/PlayerLiveImageComponent.tsx +29 -21
  81. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -8
  82. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +5 -10
  83. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +5 -1
  84. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +5 -1
  85. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +8 -7
  86. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -10
  87. package/Components/VideoModal/ModalAnimation/index.ts +2 -1
  88. package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
  89. package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
  90. package/Components/VideoModal/OpaqueLayer.tsx +33 -0
  91. package/Components/VideoModal/PlayerDetails.tsx +4 -1
  92. package/Components/VideoModal/PlayerWrapper.tsx +16 -35
  93. package/Components/VideoModal/VideoModal.tsx +14 -23
  94. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
  95. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -10
  96. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +4 -4
  97. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +66 -156
  98. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
  99. package/Components/VideoModal/hooks/index.ts +7 -0
  100. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
  101. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
  102. package/Components/VideoModal/hooks/utils/index.ts +33 -0
  103. package/Components/VideoModal/utils.ts +3 -5
  104. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +2 -2
  105. package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
  106. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +11 -11
  107. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +30 -30
  108. package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
  109. package/Contexts/ScreenContext/index.tsx +3 -2
  110. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +2 -2
  111. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
  112. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
  113. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
  114. package/Decorators/RiverFeedLoader/index.tsx +1 -1
  115. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
  116. package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
  117. package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
  118. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +5 -5
  119. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +16 -10
  120. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  121. package/Decorators/ZappPipesDataConnector/index.tsx +32 -2
  122. package/package.json +12 -6
  123. package/Decorators/RiverFeedLoader/utils.ts +0 -100
@@ -3,7 +3,7 @@
3
3
  exports[`componentsMap renders renders components map correctly 1`] = `
4
4
  <View
5
5
  style={
6
- Object {
6
+ {
7
7
  "flex": 1,
8
8
  }
9
9
  }
@@ -11,15 +11,98 @@ exports[`componentsMap renders renders components map correctly 1`] = `
11
11
  <View
12
12
  onLayout={[Function]}
13
13
  style={
14
- Object {
14
+ {
15
15
  "flex": 1,
16
16
  }
17
17
  }
18
18
  >
19
19
  <RCTScrollView
20
- ListFooterComponent={[Function]}
20
+ ListFooterComponent={
21
+ <Memo(RiverFooterComponent)
22
+ flatListHeight={null}
23
+ loadingState={
24
+ BehaviorSubject {
25
+ "_value": {
26
+ "done": false,
27
+ "index": -1,
28
+ "waitForAllComponents": false,
29
+ },
30
+ "closed": false,
31
+ "currentObservers": null,
32
+ "hasError": false,
33
+ "isStopped": false,
34
+ "observers": [
35
+ SafeSubscriber {
36
+ "_finalizers": [
37
+ Subscription {
38
+ "_finalizers": null,
39
+ "_parentage": [Circular],
40
+ "closed": false,
41
+ "initialTeardown": [Function],
42
+ },
43
+ ],
44
+ "_parentage": null,
45
+ "closed": false,
46
+ "destination": ConsumerObserver {
47
+ "partialObserver": {
48
+ "complete": undefined,
49
+ "error": undefined,
50
+ "next": [Function],
51
+ },
52
+ },
53
+ "initialTeardown": undefined,
54
+ "isStopped": false,
55
+ },
56
+ SafeSubscriber {
57
+ "_finalizers": [
58
+ Subscription {
59
+ "_finalizers": null,
60
+ "_parentage": [Circular],
61
+ "closed": false,
62
+ "initialTeardown": [Function],
63
+ },
64
+ ],
65
+ "_parentage": null,
66
+ "closed": false,
67
+ "destination": ConsumerObserver {
68
+ "partialObserver": {
69
+ "complete": undefined,
70
+ "error": undefined,
71
+ "next": [Function],
72
+ },
73
+ },
74
+ "initialTeardown": undefined,
75
+ "isStopped": false,
76
+ },
77
+ SafeSubscriber {
78
+ "_finalizers": [
79
+ Subscription {
80
+ "_finalizers": null,
81
+ "_parentage": [Circular],
82
+ "closed": false,
83
+ "initialTeardown": [Function],
84
+ },
85
+ ],
86
+ "_parentage": null,
87
+ "closed": false,
88
+ "destination": ConsumerObserver {
89
+ "partialObserver": {
90
+ "complete": undefined,
91
+ "error": undefined,
92
+ "next": [Function],
93
+ },
94
+ },
95
+ "initialTeardown": undefined,
96
+ "isStopped": false,
97
+ },
98
+ ],
99
+ "thrownError": null,
100
+ }
101
+ }
102
+ />
103
+ }
21
104
  contentContainerStyle={
22
- Object {
105
+ {
23
106
  "paddingBottom": undefined,
24
107
  "paddingLeft": undefined,
25
108
  "paddingRight": undefined,
@@ -27,22 +110,22 @@ exports[`componentsMap renders renders components map correctly 1`] = `
27
110
  }
28
111
  }
29
112
  data={
30
- Array [
31
- Object {
113
+ [
114
+ {
32
115
  "component_type": "hero",
33
116
  "id": "A1",
34
- "styles": Object {
35
- "cell_styles": Array [
117
+ "styles": {
118
+ "cell_styles": [
36
119
  "some",
37
120
  "obsolete",
38
121
  "ids",
39
122
  ],
40
123
  },
41
124
  },
42
- Object {
125
+ {
43
126
  "component_type": "grid",
44
127
  "id": "A2",
45
- "styles": Object {
128
+ "styles": {
46
129
  "master_cell_id": "uuid-5678-B",
47
130
  },
48
131
  },
@@ -66,12 +149,12 @@ exports[`componentsMap renders renders components map correctly 1`] = `
66
149
  renderItem={[Function]}
67
150
  scrollEventThrottle={16}
68
151
  scrollIndicatorInsets={
69
- Object {
152
+ {
70
153
  "right": 1,
71
154
  }
72
155
  }
73
- stickyHeaderIndices={Array []}
74
- viewabilityConfigCallbackPairs={Array []}
156
+ stickyHeaderIndices={[]}
157
+ viewabilityConfigCallbackPairs={[]}
75
158
  windowSize={12}
76
159
  >
77
160
  <View>
@@ -80,22 +163,14 @@ exports[`componentsMap renders renders components map correctly 1`] = `
80
163
  style={null}
81
164
  >
82
165
  <View
166
+ onLayout={[Function]}
83
167
  style={
84
- Object {
85
- "display": "flex",
168
+ {
169
+ "flex": 1,
86
170
  }
87
171
  }
88
172
  >
89
- <View
90
- onLayout={[Function]}
91
- style={
92
- Object {
93
- "flex": 1,
94
- }
95
- }
96
- >
97
- <View />
98
- </View>
173
+ <View />
99
174
  </View>
100
175
  </View>
101
176
  <View
@@ -103,23 +178,13 @@ exports[`componentsMap renders renders components map correctly 1`] = `
103
178
  style={null}
104
179
  >
105
180
  <View
181
+ onLayout={[Function]}
106
182
  style={
107
- Object {
108
- "display": "none",
183
+ {
184
+ "flex": 1,
109
185
  }
110
186
  }
111
- >
112
- <View
113
- onLayout={[Function]}
114
- style={
115
- Object {
116
- "flex": 1,
117
- }
118
- }
119
- >
120
- <View />
121
- </View>
122
- </View>
187
+ />
123
188
  </View>
124
189
  <View
125
190
  onLayout={[Function]}
@@ -127,12 +192,16 @@ exports[`componentsMap renders renders components map correctly 1`] = `
127
192
  <View
128
193
  renderToHardwareTextureAndroid={true}
129
194
  style={
130
- Object {
131
- "alignItems": "center",
132
- "height": null,
133
- "justifyContent": "center",
134
- "width": "100%",
135
- }
195
+ [
196
+ {
197
+ "alignItems": "center",
198
+ "justifyContent": "center",
199
+ "width": "100%",
200
+ },
201
+ {
202
+ "height": null,
203
+ },
204
+ ]
136
205
  }
137
206
  >
138
207
  <ActivityIndicator
@@ -6,42 +6,42 @@ exports[`When River has a general_content type <River /> renders correctly 1`] =
6
6
  >
7
7
  <RiverWithData
8
8
  appData={
9
- Object {
9
+ {
10
10
  "layoutVersion": "v1",
11
11
  }
12
12
  }
13
13
  dispatch={[Function]}
14
14
  rivers={
15
- Object {
16
- "A1234": Object {
15
+ {
16
+ "A1234": {
17
17
  "home": true,
18
18
  "id": "A1234",
19
19
  "name": "foo",
20
20
  "type": "general_content",
21
- "ui_components": Array [
22
- Object {
21
+ "ui_components": [
22
+ {
23
23
  "component_type": "hero",
24
24
  },
25
- Object {
25
+ {
26
26
  "component_type": "grid",
27
27
  },
28
28
  ],
29
29
  },
30
- "B4567": Object {
30
+ "B4567": {
31
31
  "id": "B4567",
32
32
  },
33
- "C0987": Object {
33
+ "C0987": {
34
34
  "home": false,
35
35
  "id": "C0987",
36
36
  "name": "Some-Screen-Plugin",
37
37
  "type": "some-screen-plugin",
38
- "ui_components": Array [],
38
+ "ui_components": [],
39
39
  },
40
40
  }
41
41
  }
42
42
  screenId="A1234"
43
43
  store={
44
- Object {
44
+ {
45
45
  "clearActions": [Function],
46
46
  "dispatch": [Function],
47
47
  "getActions": [Function],
@@ -64,13 +64,13 @@ exports[`When River has a general_content type <RiverComponent /> renders correc
64
64
  exports[`When River has any other type other than general_content <RiverComponent /> renders correctly 1`] = `
65
65
  <WithProvider
66
66
  screenData={
67
- Object {
67
+ {
68
68
  "groupId": undefined,
69
69
  "home": false,
70
70
  "id": "C0987",
71
71
  "name": "Some-Screen-Plugin",
72
72
  "type": "some-screen-plugin",
73
- "ui_components": Array [],
73
+ "ui_components": [],
74
74
  }
75
75
  }
76
76
  screenId="C0987"
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import TestRenderer from "react-test-renderer";
3
- import { cleanup } from "@testing-library/react-native";
2
+ import { cleanup, render } from "@testing-library/react-native";
4
3
  import { Provider } from "react-redux";
5
4
  import configureStore from "redux-mock-store";
6
5
 
@@ -75,28 +74,70 @@ const riverComponents = [
75
74
  },
76
75
  ];
77
76
 
78
- const screenData = {
77
+ const mockScreenData = {
79
78
  ui_components: riverComponents,
80
79
  rules: { pull_to_refresh_enabled: false },
81
80
  id: "A1234",
82
81
  };
83
82
 
83
+ jest.mock("@applicaster/zapp-react-native-redux/AppStore", () => ({
84
+ appStore: {
85
+ get: jest.fn((prop) => mockStore[prop]),
86
+ getState: jest.fn(),
87
+ },
88
+ }));
89
+
84
90
  jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
85
91
  useIsRTL: jest.fn(() => mock_rtl_flag),
86
92
  }));
87
93
 
88
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
89
- useNavigation: jest.fn(() => ({ currentRoute: "/river/A1234" })),
90
- useRoute: jest.fn(() => ({ pathname: "/river/A1234", screenData })),
91
- useProfilerLogging: jest.fn(),
92
- useIsScreenActive: jest.fn().mockReturnValue(true),
93
- }));
94
+ jest.mock(
95
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
96
+ () => ({
97
+ useNavigation: jest.fn(() => ({ currentRoute: "/river/A1234" })),
98
+ })
99
+ );
94
100
 
95
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
96
- useCurrentScreenData: jest.fn(() => screenData),
97
- useScreenData: jest.fn(() => screenData),
98
- useScreenContext: jest.fn(() => screenData),
99
- }));
101
+ jest.mock(
102
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
103
+ () => ({
104
+ useRoute: jest.fn(() => ({
105
+ pathname: "/river/A1234",
106
+ screenData: mockScreenData,
107
+ })),
108
+ })
109
+ );
110
+
111
+ jest.mock(
112
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
113
+ () => ({
114
+ useIsScreenActive: jest.fn().mockReturnValue(true),
115
+ })
116
+ );
117
+
118
+ jest.mock(
119
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useCurrentScreenData",
120
+ () => ({
121
+ useCurrentScreenData: jest.fn(() => mockScreenData),
122
+ })
123
+ );
124
+
125
+ jest.mock(
126
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData",
127
+ () => ({
128
+ useScreenData: jest.fn(() => mockScreenData),
129
+ })
130
+ );
131
+
132
+ jest.mock(
133
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
134
+ () => ({
135
+ ...jest.requireActual(
136
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext"
137
+ ),
138
+ useScreenContext: jest.fn(() => mockScreenData),
139
+ })
140
+ );
100
141
 
101
142
  const { View } = require("react-native");
102
143
  const { ComponentsMap } = require("../ComponentsMap/ComponentsMap");
@@ -118,7 +159,13 @@ const plugins = [];
118
159
  const navigation = {};
119
160
 
120
161
  const props = { components, cellStyles, riverComponents, navigation };
121
- const store = mockStore({ components, cellStyles, plugins });
162
+
163
+ const store = mockStore({
164
+ components,
165
+ cellStyles,
166
+ plugins,
167
+ getState: jest.fn(),
168
+ });
122
169
 
123
170
  jest.useFakeTimers();
124
171
 
@@ -135,12 +182,12 @@ describe("componentsMap", () => {
135
182
  .spyOn(themeUtils, "useTheme")
136
183
  .mockImplementation(() => () => theme);
137
184
 
138
- const wrapper = TestRenderer.create(
185
+ const { toJSON } = render(
139
186
  <Provider store={store}>
140
187
  <ComponentsMap {...props} />
141
188
  </Provider>
142
189
  );
143
190
 
144
- expect(wrapper.toJSON()).toMatchSnapshot();
191
+ expect(toJSON()).toMatchSnapshot();
145
192
  });
146
193
  });
@@ -7,7 +7,7 @@ exports[`<RouteManager /> renders correctly 1`] = `
7
7
  <WithProvider
8
8
  pathname="/river/A1234"
9
9
  screenData={
10
- Object {
10
+ {
11
11
  "id": "A1234",
12
12
  }
13
13
  }
@@ -4,7 +4,7 @@ exports[`TestId renders correctly and assigns the testID to a wrapping view 1`]
4
4
  <View
5
5
  accessibilityLabel="A1234"
6
6
  style={
7
- Object {
7
+ {
8
8
  "flex": 1,
9
9
  }
10
10
  }
@@ -46,27 +46,37 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
46
46
  })),
47
47
  }));
48
48
 
49
- const NavBar = jest.fn((props) => <View testID="navBar" {...props} />);
49
+ const mockNavBar = jest.fn((props) => {
50
+ const View = jest.requireActual("react-native").View;
51
+
52
+ return <View testID="navBar" {...props} />;
53
+ });
50
54
 
51
55
  jest.mock(
52
56
  "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers",
53
57
  () => ({
54
- getNavigationPluginModule: () => NavBar,
58
+ getNavigationPluginModule: () => mockNavBar,
55
59
  })
56
60
  );
57
61
 
58
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
59
- ...(jest.requireActual(
60
- "@applicaster/zapp-react-native-utils/reactHooks/screen"
61
- ) as any),
62
- useScreenData: jest.fn(() => ({
63
- id: "testId",
64
- navigations: [{ id: "testId", category: "nav_bar" }],
65
- })),
66
- useCurrentScreenData: jest.fn(() => ({
67
- id: "testId",
68
- })),
69
- }));
62
+ jest.mock(
63
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useCurrentScreenData",
64
+ () => ({
65
+ useCurrentScreenData: jest.fn(() => ({
66
+ id: "testId",
67
+ })),
68
+ })
69
+ );
70
+
71
+ jest.mock(
72
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData",
73
+ () => ({
74
+ useScreenData: jest.fn(() => ({
75
+ id: "testId",
76
+ navigations: [{ id: "testId", category: "nav_bar" }],
77
+ })),
78
+ })
79
+ );
70
80
 
71
81
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
72
82
  isNavBarVisible: mockIsNavBarVisible,
@@ -84,20 +94,24 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
84
94
  useIsScreenActive: jest.fn().mockReturnValue(true),
85
95
  }));
86
96
 
87
- jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
88
- usePickFromState: () => ({
89
- plugins: [
90
- {
91
- name: "Offline Plugin",
92
- identifier: "offline-experience",
93
- type: "general",
94
- module: {
95
- OfflineFallbackScreen: ({ children }) => <View>{children}</View>, // eslint-disable-line
97
+ jest.mock("@applicaster/zapp-react-native-redux/hooks/usePickFromState", () => {
98
+ const View = jest.requireActual("react-native").View;
99
+
100
+ return {
101
+ usePickFromState: () => ({
102
+ plugins: [
103
+ {
104
+ name: "Offline Plugin",
105
+ identifier: "offline-experience",
106
+ type: "general",
107
+ module: {
108
+ OfflineFallbackScreen: ({ children }) => <View>{children}</View>, // eslint-disable-line
109
+ },
96
110
  },
97
- },
98
- ],
99
- }),
100
- }));
111
+ ],
112
+ }),
113
+ };
114
+ });
101
115
 
102
116
  const {
103
117
  allowedOrientationsForScreen,
@@ -3,7 +3,7 @@
3
3
  exports[`<Screen Component /> when the navbar should be hidden renders correctly 1`] = `
4
4
  <View
5
5
  style={
6
- Object {
6
+ {
7
7
  "backgroundColor": "blue",
8
8
  "flex": 1,
9
9
  "paddingTop": 0,
@@ -22,7 +22,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
22
22
  <View
23
23
  pathname="/river/testId"
24
24
  screenData={
25
- Object {
25
+ {
26
26
  "id": "testId",
27
27
  }
28
28
  }
@@ -35,7 +35,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
35
35
  exports[`<Screen Component /> when the navbar should show renders correctly 1`] = `
36
36
  <View
37
37
  style={
38
- Object {
38
+ {
39
39
  "backgroundColor": "blue",
40
40
  "flex": 1,
41
41
  "paddingTop": 0,
@@ -54,7 +54,7 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
54
54
  <View
55
55
  pathname="/river/testId"
56
56
  screenData={
57
- Object {
57
+ {
58
58
  "id": "testId",
59
59
  }
60
60
  }
@@ -0,0 +1,56 @@
1
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
2
+ import {
3
+ useGetScreenOrientation,
4
+ isOrientationCompatible,
5
+ } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
6
+ import {
7
+ useCurrentScreenData,
8
+ useDimensions,
9
+ useRoute,
10
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
11
+ import { useMemo, useEffect, useState } from "react";
12
+
13
+ export const useWaitForValidOrientation = () => {
14
+ const {
15
+ width: screenWidth,
16
+ height,
17
+ deviceInfo,
18
+ } = useDimensions("screen", {
19
+ fullDimensions: true,
20
+ updateForInactiveScreens: false,
21
+ });
22
+
23
+ const currentScreenData = useCurrentScreenData();
24
+
25
+ const { screenData } = useRoute();
26
+
27
+ const [readyState, setReadyState] = useState(false);
28
+
29
+ const isTablet = deviceInfo?.isTablet;
30
+
31
+ const { appData } = usePickFromState(["appData"]);
32
+ const isTabletPortrait = appData?.isTabletPortrait;
33
+
34
+ const layoutData = useMemo(
35
+ () => ({ isTablet, isTabletPortrait, width: screenWidth, height }),
36
+ [isTablet, isTabletPortrait, screenWidth, height]
37
+ );
38
+
39
+ const targetScreenData =
40
+ currentScreenData || (screenData as any)?.targetScreen || screenData;
41
+
42
+ const orientation = useGetScreenOrientation(targetScreenData);
43
+
44
+ const isReadyForDisplay = isOrientationCompatible({
45
+ orientation,
46
+ layoutData,
47
+ });
48
+
49
+ useEffect(() => {
50
+ if (isReadyForDisplay && !readyState) {
51
+ setReadyState(true);
52
+ }
53
+ }, [readyState, orientation, layoutData]);
54
+
55
+ return readyState;
56
+ };