@applicaster/zapp-react-native-ui-components 14.0.0-rc.9 → 14.0.0-rc.90

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 (178) hide show
  1. package/Components/AnimatedInOut/index.tsx +68 -23
  2. package/Components/AudioPlayer/index.tsx +15 -0
  3. package/Components/AudioPlayer/mobile/Layout.tsx +66 -0
  4. package/Components/AudioPlayer/{__tests__/__snapshots__/audioPlayer.test.js.snap → mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap} +2 -2
  5. package/Components/AudioPlayer/mobile/__tests__/audioPlayerMobileLayout.test.js +18 -0
  6. package/Components/AudioPlayer/mobile/index.tsx +18 -0
  7. package/Components/AudioPlayer/{Artwork.tsx → tv/Artwork.tsx} +3 -2
  8. package/Components/AudioPlayer/{Channel.tsx → tv/Channel.tsx} +7 -7
  9. package/Components/AudioPlayer/tv/Layout.tsx +168 -0
  10. package/Components/AudioPlayer/{Runtime.tsx → tv/Runtime.tsx} +7 -1
  11. package/Components/AudioPlayer/{Summary.tsx → tv/Summary.tsx} +6 -2
  12. package/Components/AudioPlayer/{Title.tsx → tv/Title.tsx} +6 -2
  13. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/Runtime.test.js.snap +2 -2
  14. package/Components/AudioPlayer/tv/__tests__/__snapshots__/audioPlayer.test.js.snap +164 -0
  15. package/Components/AudioPlayer/tv/__tests__/__snapshots__/channel.test.js.snap +19 -0
  16. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/summary.test.js.snap +1 -2
  17. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/title.test.js.snap +1 -2
  18. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/audioPlayer.test.js +7 -3
  19. package/Components/AudioPlayer/{helpers.tsx → tv/helpers.tsx} +11 -5
  20. package/Components/AudioPlayer/{AudioPlayer.tsx → tv/index.tsx} +17 -58
  21. package/Components/AudioPlayer/types.ts +40 -0
  22. package/Components/BaseFocusable/index.tsx +23 -12
  23. package/Components/Cell/Cell.tsx +91 -64
  24. package/Components/Cell/CellWithFocusable.tsx +3 -0
  25. package/Components/Cell/FocusableWrapper.tsx +44 -0
  26. package/Components/Cell/TvOSCellComponent.tsx +92 -17
  27. package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
  28. package/Components/Cell/index.js +7 -3
  29. package/Components/ComponentResolver/index.ts +1 -1
  30. package/Components/FeedLoader/FeedLoader.tsx +7 -16
  31. package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
  32. package/Components/FeedLoader/index.js +2 -8
  33. package/Components/Focusable/Focusable.tsx +12 -3
  34. package/Components/Focusable/FocusableTvOS.tsx +5 -5
  35. package/Components/Focusable/FocusableiOS.tsx +2 -2
  36. package/Components/Focusable/Touchable.tsx +5 -3
  37. package/Components/Focusable/__tests__/index.android.test.tsx +3 -0
  38. package/Components/Focusable/index.android.tsx +19 -11
  39. package/Components/Focusable/index.tsx +1 -1
  40. package/Components/FocusableGroup/FocusableTvOS.tsx +1 -1
  41. package/Components/FocusableList/FocusableItem.tsx +4 -3
  42. package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
  43. package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
  44. package/Components/FocusableList/index.tsx +20 -9
  45. package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
  46. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
  47. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +22 -21
  48. package/Components/HandlePlayable/HandlePlayable.tsx +39 -74
  49. package/Components/HandlePlayable/const.ts +3 -0
  50. package/Components/HandlePlayable/utils.ts +74 -0
  51. package/Components/Layout/TV/LayoutBackground.tsx +1 -1
  52. package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
  53. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +6 -2
  54. package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
  55. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -39
  56. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
  57. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
  58. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
  59. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
  60. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
  61. package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
  62. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
  63. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
  64. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
  65. package/Components/MasterCell/elementMapper.tsx +1 -2
  66. package/Components/MasterCell/index.tsx +1 -1
  67. package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
  68. package/Components/MasterCell/utils/index.ts +11 -5
  69. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
  70. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
  71. package/Components/OfflineHandler/__tests__/index.test.tsx +26 -35
  72. package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
  73. package/Components/PlayerContainer/PlayerContainer.tsx +45 -47
  74. package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
  75. package/Components/PlayerContainer/index.ts +1 -1
  76. package/Components/PlayerImageBackground/index.tsx +4 -23
  77. package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -43
  78. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
  79. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
  80. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +378 -0
  81. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +2 -2
  82. package/Components/River/RefreshControl.tsx +11 -17
  83. package/Components/River/TV/River.tsx +2 -17
  84. package/Components/River/TV/index.tsx +3 -1
  85. package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
  86. package/Components/River/TV/withRiverDataLoader.tsx +17 -0
  87. package/Components/River/TV/withTVEventHandler.tsx +1 -1
  88. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  89. package/Components/River/__tests__/river.test.js +12 -26
  90. package/Components/River/index.tsx +1 -1
  91. package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
  92. package/Components/Screen/__tests__/Screen.test.tsx +28 -29
  93. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
  94. package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
  95. package/Components/Screen/index.tsx +22 -5
  96. package/Components/Screen/navigationHandler.ts +20 -2
  97. package/Components/ScreenRevealManager/ScreenRevealManager.ts +76 -0
  98. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +107 -0
  99. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +96 -0
  100. package/Components/ScreenRevealManager/index.ts +1 -0
  101. package/Components/ScreenRevealManager/utils/index.ts +23 -0
  102. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +109 -0
  103. package/Components/Tabs/TV/Tabs.android.tsx +1 -3
  104. package/Components/Tabs/Tabs.tsx +2 -3
  105. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
  106. package/Components/TextInputTv/index.tsx +11 -0
  107. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
  108. package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
  109. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
  110. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  111. package/Components/VideoLive/animationUtils.ts +3 -3
  112. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +120 -133
  113. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  114. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  115. package/Components/VideoModal/PlayerDetails.tsx +29 -7
  116. package/Components/VideoModal/PlayerWrapper.tsx +25 -215
  117. package/Components/VideoModal/VideoModal.tsx +4 -22
  118. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
  119. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +2 -7
  120. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -240
  121. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
  122. package/Components/VideoModal/hooks/index.ts +0 -2
  123. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
  124. package/Components/VideoModal/hooks/useModalSize.ts +23 -2
  125. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
  126. package/Components/VideoModal/hooks/utils/index.ts +4 -0
  127. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  128. package/Components/VideoModal/playerWrapperUtils.ts +91 -0
  129. package/Components/VideoModal/utils.ts +13 -0
  130. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
  131. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
  132. package/Components/Viewport/VisibilitySensor/VisibilitySensor.tsx +3 -3
  133. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/index.ts +3 -3
  134. package/Contexts/CellFocusedStateContext/index.tsx +27 -0
  135. package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
  136. package/Contexts/ScreenContext/index.tsx +46 -6
  137. package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
  138. package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
  139. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
  140. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
  141. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
  142. package/Decorators/RiverFeedLoader/index.tsx +22 -4
  143. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
  144. package/Decorators/RiverFeedLoader/utils/index.ts +0 -18
  145. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
  146. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
  147. package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
  148. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
  149. package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
  150. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
  151. package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
  152. package/Decorators/ZappPipesDataConnector/index.tsx +26 -293
  153. package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
  154. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
  155. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +266 -0
  156. package/Decorators/ZappPipesDataConnector/types.ts +29 -0
  157. package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +738 -0
  158. package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +157 -0
  159. package/events/index.ts +3 -0
  160. package/package.json +5 -10
  161. package/Components/AudioPlayer/AudioPlayerLayout.tsx +0 -202
  162. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +0 -66
  163. package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +0 -28
  164. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +0 -26
  165. package/Components/AudioPlayer/index.ts +0 -1
  166. package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
  167. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  168. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -421
  169. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  170. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  171. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
  172. package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
  173. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/Runtime.test.js +0 -0
  174. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/artWork.test.js.snap +0 -0
  175. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/artWork.test.js +0 -0
  176. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/channel.test.js +0 -0
  177. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/summary.test.js +0 -0
  178. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/title.test.js +0 -0
@@ -21,87 +21,27 @@ exports[`PlayerWrapper renders inline 1`] = `
21
21
  "top": "additive",
22
22
  }
23
23
  }
24
- style={
25
- [
26
- {
27
- "backgroundColor": "transparent",
28
- },
29
- {
30
- "height": 800,
31
- "width": 300,
32
- },
33
- {},
34
- ]
35
- }
24
+ style={{}}
36
25
  >
37
26
  <View
38
- additionalData={
39
- {
40
- "saveArea": true,
41
- }
42
- }
43
- animationType="moveUpComponent"
44
27
  style={
45
28
  [
46
29
  {
47
- "flexDirection": "column",
30
+ "alignSelf": "center",
31
+ "position": "relative",
32
+ "zIndex": 200,
48
33
  },
34
+ {},
49
35
  {
50
- "flex": 1,
36
+ "aspectRatio": 1.7777777777777777,
37
+ "height": undefined,
38
+ "width": "100%",
51
39
  },
40
+ {},
52
41
  ]
53
42
  }
54
- >
55
- <View
56
- style={
57
- [
58
- {
59
- "alignSelf": "center",
60
- "position": "relative",
61
- "zIndex": 200,
62
- },
63
- {
64
- "aspectRatio": 1.7777777777777777,
65
- "height": undefined,
66
- "width": "100%",
67
- },
68
- {},
69
- {},
70
- ]
71
- }
72
- testID="test-player-container"
73
- />
74
- <View
75
- animationType="componentFade"
76
- style={
77
- {
78
- "flex": 1,
79
- }
80
- }
81
- >
82
- <View
83
- configuration={
84
- {
85
- "tablet_landscape_player_container_background_color": "red",
86
- "tablet_landscape_sidebar_width": "35%",
87
- }
88
- }
89
- entry={
90
- {
91
- "id": "test",
92
- }
93
- }
94
- isTablet={false}
95
- isTabletLandscape={false}
96
- style={
97
- {
98
- "flex": 1,
99
- "paddingTop": 20,
100
- }
101
- }
102
- />
103
- </View>
104
- </View>
43
+ testID="test-player-container"
44
+ />
105
45
  </RNCSafeAreaView>
106
46
  </RNCSafeAreaProvider>
107
47
  `;
@@ -127,57 +67,27 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
127
67
  "top": "additive",
128
68
  }
129
69
  }
130
- style={
131
- [
132
- {
133
- "backgroundColor": "transparent",
134
- },
135
- {
136
- "height": undefined,
137
- "width": 300,
138
- },
139
- {},
140
- ]
141
- }
70
+ style={{}}
142
71
  >
143
72
  <View
144
- additionalData={
145
- {
146
- "saveArea": true,
147
- }
148
- }
149
- animationType="moveUpComponent"
150
73
  style={
151
74
  [
152
75
  {
153
- "flexDirection": "column",
76
+ "alignSelf": "center",
77
+ "position": "relative",
78
+ "zIndex": 200,
154
79
  },
80
+ {},
155
81
  {
156
- "flex": 1,
82
+ "aspectRatio": 1.7777777777777777,
83
+ "height": undefined,
84
+ "width": "100%",
157
85
  },
86
+ {},
158
87
  ]
159
88
  }
160
- >
161
- <View
162
- style={
163
- [
164
- {
165
- "alignSelf": "center",
166
- "position": "relative",
167
- "zIndex": 200,
168
- },
169
- {
170
- "aspectRatio": undefined,
171
- "height": undefined,
172
- "width": "100%",
173
- },
174
- {},
175
- {},
176
- ]
177
- }
178
- testID="test-player-container"
179
- />
180
- </View>
89
+ testID="test-player-container"
90
+ />
181
91
  </RNCSafeAreaView>
182
92
  </RNCSafeAreaProvider>
183
93
  `;
@@ -203,103 +113,27 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
203
113
  "top": "additive",
204
114
  }
205
115
  }
206
- style={
207
- [
208
- {
209
- "backgroundColor": "red",
210
- },
211
- {
212
- "height": 800,
213
- "width": 300,
214
- },
215
- {},
216
- ]
217
- }
116
+ style={{}}
218
117
  >
219
118
  <View
220
- additionalData={
221
- {
222
- "saveArea": true,
223
- }
224
- }
225
- animationType="moveUpComponent"
226
119
  style={
227
120
  [
228
121
  {
229
- "flexDirection": "row",
122
+ "alignSelf": "center",
123
+ "position": "relative",
124
+ "zIndex": 200,
230
125
  },
126
+ {},
231
127
  {
232
- "flex": 1,
128
+ "aspectRatio": 1.7777777777777777,
129
+ "height": undefined,
130
+ "width": 195,
233
131
  },
132
+ {},
234
133
  ]
235
134
  }
236
- >
237
- <View
238
- style={
239
- [
240
- {
241
- "alignSelf": "center",
242
- "position": "relative",
243
- "zIndex": 200,
244
- },
245
- {
246
- "aspectRatio": 1.7777777777777777,
247
- "height": undefined,
248
- "width": 195,
249
- },
250
- {},
251
- {},
252
- ]
253
- }
254
- testID="test-player-container"
255
- >
256
- <View
257
- additionalData={
258
- {
259
- "disableAnimatedComponent": false,
260
- "resetAnimationValue": undefined,
261
- "useLayoutMeasure": true,
262
- }
263
- }
264
- animationType="moveUpComponent"
265
- style={
266
- {
267
- "flex": 1,
268
- }
269
- }
270
- />
271
- </View>
272
- <View
273
- animationType="componentFade"
274
- style={
275
- {
276
- "flex": 1,
277
- }
278
- }
279
- >
280
- <View
281
- configuration={
282
- {
283
- "tablet_landscape_player_container_background_color": "red",
284
- "tablet_landscape_sidebar_width": "35%",
285
- }
286
- }
287
- entry={
288
- {
289
- "id": "test",
290
- }
291
- }
292
- isTablet={true}
293
- isTabletLandscape={true}
294
- style={
295
- {
296
- "flex": 1,
297
- "paddingTop": 20,
298
- }
299
- }
300
- />
301
- </View>
302
- </View>
135
+ testID="test-player-container"
136
+ />
303
137
  </RNCSafeAreaView>
304
138
  </RNCSafeAreaProvider>
305
139
  `;
@@ -325,57 +159,27 @@ exports[`PlayerWrapper renders properly 1`] = `
325
159
  "top": "additive",
326
160
  }
327
161
  }
328
- style={
329
- [
330
- {
331
- "backgroundColor": "transparent",
332
- },
333
- {
334
- "height": 800,
335
- "width": 300,
336
- },
337
- {},
338
- ]
339
- }
162
+ style={{}}
340
163
  >
341
164
  <View
342
- additionalData={
343
- {
344
- "saveArea": true,
345
- }
346
- }
347
- animationType="moveUpComponent"
348
165
  style={
349
166
  [
350
167
  {
351
- "flexDirection": "column",
168
+ "alignSelf": "center",
169
+ "position": "relative",
170
+ "zIndex": 200,
352
171
  },
172
+ {},
353
173
  {
354
- "flex": 1,
174
+ "aspectRatio": 1.7786666666666666,
175
+ "height": undefined,
176
+ "width": "100%",
355
177
  },
178
+ {},
356
179
  ]
357
180
  }
358
- >
359
- <View
360
- style={
361
- [
362
- {
363
- "alignSelf": "center",
364
- "position": "relative",
365
- "zIndex": 200,
366
- },
367
- {
368
- "aspectRatio": 1.7786666666666666,
369
- "height": undefined,
370
- "width": "100%",
371
- },
372
- {},
373
- {},
374
- ]
375
- }
376
- testID="test-player-container"
377
- />
378
- </View>
181
+ testID="test-player-container"
182
+ />
379
183
  </RNCSafeAreaView>
380
184
  </RNCSafeAreaProvider>
381
185
  `;
@@ -2,6 +2,8 @@ import { renderHook } from "@testing-library/react-hooks";
2
2
  import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
3
3
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
4
4
 
5
+ jest.useFakeTimers();
6
+
5
7
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
6
8
  useIsTablet: jest.fn().mockReturnValue(false),
7
9
  }));
@@ -11,11 +13,15 @@ describe("useDelayedPlayerDetails", () => {
11
13
  jest.clearAllMocks();
12
14
  });
13
15
 
14
- it("should return true initially", () => {
16
+ it("should return false initially, that changes after 1 second", () => {
15
17
  const { result } = renderHook(() =>
16
18
  useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
17
19
  );
18
20
 
21
+ expect(result.current).toBe(false);
22
+
23
+ jest.advanceTimersByTime(1000);
24
+
19
25
  expect(result.current).toBe(true);
20
26
  });
21
27
 
@@ -46,6 +52,8 @@ describe("useDelayedPlayerDetails", () => {
46
52
  })
47
53
  );
48
54
 
55
+ jest.advanceTimersByTime(1000);
56
+
49
57
  expect(result.current).toBe(true);
50
58
  });
51
59
  });
@@ -1,5 +1,3 @@
1
- export { useBackgroundColor } from "./useBackgroundColor";
2
-
3
1
  export { useDelayedPlayerDetails } from "./useDelayedPlayerDetails";
4
2
 
5
3
  export { useInitialPlayerState } from "./useInitialPlayerState";
@@ -1,22 +1,26 @@
1
+ // const showPlayerDetails = (
2
+ // isInline: boolean,
3
+ // isDocked: boolean,
4
+ // isPip: boolean,
5
+ // isTablet: boolean
6
+ // ) => {
7
+ // return showDetails({
8
+ // isMobile: !isTablet,
9
+ // isInline,
10
+ // isDocked,
11
+ // isPip,
12
+ // });
13
+ // };
14
+
15
+ import * as React from "react";
1
16
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
17
+ import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
2
18
 
3
19
  import { showDetails } from "./utils";
4
20
 
5
- type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
21
+ const TIMEOUT = 1000; // ms
6
22
 
7
- const showPlayerDetails = (
8
- isInline: boolean,
9
- isDocked: boolean,
10
- isPip: boolean,
11
- isTablet: boolean
12
- ) => {
13
- return showDetails({
14
- isMobile: !isTablet,
15
- isInline,
16
- isDocked,
17
- isPip,
18
- });
19
- };
23
+ type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
20
24
 
21
25
  /**
22
26
  * Custom hook to determine whether to show player details with a delay.
@@ -32,7 +36,28 @@ export const useDelayedPlayerDetails = ({
32
36
  isDocked,
33
37
  isPip,
34
38
  }: Props): boolean => {
39
+ const [shouldShowDetails, setShouldShowDetails] = React.useState(false);
40
+
35
41
  const isTablet = useIsTablet();
36
42
 
37
- return showPlayerDetails(isInline, isDocked, isPip, isTablet);
43
+ React.useEffect(() => {
44
+ const subscription = withTimeout$(TIMEOUT).subscribe({
45
+ next: () => {
46
+ setShouldShowDetails(() => {
47
+ return showDetails({
48
+ isMobile: !isTablet,
49
+ isInline,
50
+ isDocked,
51
+ isPip,
52
+ });
53
+ });
54
+ },
55
+ });
56
+
57
+ return () => {
58
+ subscription.unsubscribe();
59
+ };
60
+ }, [isDocked, isTablet, isInline, isPip]);
61
+
62
+ return shouldShowDetails;
38
63
  };
@@ -9,6 +9,12 @@ import {
9
9
 
10
10
  import { getXray } from "@applicaster/zapp-react-native-utils/logger";
11
11
  import { useSafeAreaFrame } from "react-native-safe-area-context";
12
+ import {
13
+ isAndroidPlatform,
14
+ isAndroidVersionAtLeast,
15
+ } from "@applicaster/zapp-react-native-utils/reactUtils";
16
+ import { StatusBar } from "react-native";
17
+ import { isAndroidTablet } from "@applicaster/zapp-react-native-utils/reactHooks/layout/isTablet";
12
18
 
13
19
  const { Logger } = getXray();
14
20
 
@@ -27,12 +33,21 @@ const MODAL_SIZE_FOR_LANDSCAPE: Size = {
27
33
  height: "100%",
28
34
  };
29
35
 
36
+ const SAFE_AREA_BREAKING_API_VERSION = 35;
37
+
38
+ const isOldAndroidDevice =
39
+ isAndroidPlatform() &&
40
+ !isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION) &&
41
+ !isAndroidTablet();
42
+
30
43
  export const useModalSize = (): Size => {
31
44
  const frame = useSafeAreaFrame();
32
45
 
33
46
  const [modalSize, setModalSize] = React.useState<Size>({
34
47
  width: frame.width,
35
- height: frame.height,
48
+ height: isOldAndroidDevice
49
+ ? frame.height + (StatusBar.currentHeight ?? 0)
50
+ : frame.height,
36
51
  });
37
52
 
38
53
  const setNewModalSize = React.useCallback((newSize, log) => {
@@ -44,7 +59,13 @@ export const useModalSize = (): Size => {
44
59
  return oldSize;
45
60
  }
46
61
 
47
- return newSize;
62
+ return {
63
+ width: newSize.width,
64
+ height:
65
+ isOldAndroidDevice && newSize.height !== "100%"
66
+ ? newSize.height + (StatusBar.currentHeight ?? 0)
67
+ : newSize.height,
68
+ };
48
69
  });
49
70
 
50
71
  logger.debug({
@@ -12,7 +12,7 @@ describe("showDetails", () => {
12
12
  expect(result).toBe(false);
13
13
  });
14
14
 
15
- it("should return false if isDocked is true", () => {
15
+ it("should return true if isDocked & mobile", () => {
16
16
  const result = showDetails({
17
17
  isMobile: true,
18
18
  isInline: true,
@@ -20,7 +20,7 @@ describe("showDetails", () => {
20
20
  isPip: false,
21
21
  });
22
22
 
23
- expect(result).toBe(false);
23
+ expect(result).toBe(true);
24
24
  });
25
25
 
26
26
  it("should return true if isMobile is true and isInline is true", () => {
@@ -52,6 +52,10 @@ export const showDetails = ({
52
52
  }
53
53
 
54
54
  if (isDocked) {
55
+ if (isMobile) {
56
+ return true;
57
+ }
58
+
55
59
  return false;
56
60
  }
57
61
 
@@ -0,0 +1,70 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, ViewStyle } from "react-native";
3
+ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
4
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
5
+ import { playerDimensionsHack } from "./utils";
6
+ import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
7
+ import {
8
+ getBaseDimensions,
9
+ calculateAspectRatio,
10
+ getPlayerDimensions,
11
+ getContainerDimensions,
12
+ } from "./playerWrapperUtils";
13
+
14
+ export const defaultStyles = StyleSheet.create({
15
+ playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
16
+ });
17
+
18
+ export const useStyle = ({
19
+ style,
20
+ inline,
21
+ isModal,
22
+ isTabletPortrait,
23
+ configuration,
24
+ pip,
25
+ }) => {
26
+ const isTablet = useIsTablet();
27
+
28
+ const isInlineModal = inline && isModal;
29
+
30
+ const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
31
+
32
+ const tabletWidth = getTabletWidth(
33
+ configuration.tablet_landscape_sidebar_width,
34
+ style
35
+ );
36
+
37
+ const baseDimensions: ViewStyle = React.useMemo(
38
+ () => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
39
+ [isInlineModal, isTabletLandscape, tabletWidth]
40
+ );
41
+
42
+ const aspectRatio = React.useMemo(
43
+ () => calculateAspectRatio(isInlineModal, pip),
44
+ // ignoring insets - only initial needed
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
+ [isInlineModal, pip]
47
+ );
48
+
49
+ return React.useMemo(() => {
50
+ const playerDimensions: ViewStyle = getPlayerDimensions(
51
+ baseDimensions,
52
+ aspectRatio
53
+ );
54
+
55
+ const containerDimensions: ViewStyle = getContainerDimensions(
56
+ baseDimensions,
57
+ aspectRatio
58
+ );
59
+
60
+ const childrenStyles = {
61
+ ...playerDimensions,
62
+ ...playerDimensionsHack,
63
+ };
64
+
65
+ return StyleSheet.create({
66
+ containerDimensions,
67
+ childrenStyles,
68
+ });
69
+ }, [baseDimensions, aspectRatio]);
70
+ };
@@ -0,0 +1,91 @@
1
+ import { Dimensions, DimensionValue, Platform, ViewStyle } from "react-native";
2
+ import { Edge } from "react-native-safe-area-context";
3
+
4
+ export type DimensionsT = {
5
+ width: number | string;
6
+ height: number | string | undefined;
7
+ aspectRatio?: number;
8
+ };
9
+
10
+ export type Configuration = {
11
+ [key: string]: any;
12
+ tablet_landscape_sidebar_width?: string;
13
+ tablet_landscape_player_container_background_color?: string;
14
+ };
15
+
16
+ // This is safe, remembering screen dimensions once as they do not change during runtime
17
+ // TODO: consider sharing screen orientation as a shared function for the app
18
+ const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
19
+
20
+ export const getWindowDimensions = () => {
21
+ const { width, height } = Dimensions.get("window");
22
+
23
+ return { width, height };
24
+ };
25
+
26
+ export const getMaxWindowDimension = () => {
27
+ const { width, height } = getWindowDimensions();
28
+
29
+ return Math.max(width, height);
30
+ };
31
+
32
+ export const getMinWindowDimension = () => {
33
+ const { width, height } = getWindowDimensions();
34
+
35
+ return Math.min(width, height);
36
+ };
37
+
38
+ export const getScreenAspectRatio = () => {
39
+ const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
40
+ const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
41
+
42
+ return longEdge / shortEdge;
43
+ };
44
+
45
+ export const getEdges = (
46
+ isTablet: boolean,
47
+ isInlineModal: boolean
48
+ ): readonly Edge[] => {
49
+ if (isTablet) {
50
+ return ["top"];
51
+ }
52
+
53
+ if (!isInlineModal && Platform.OS === "android") {
54
+ return [];
55
+ }
56
+
57
+ return ["top"];
58
+ };
59
+
60
+ export const getBaseDimensions = (
61
+ isInlineModal: boolean,
62
+ isTabletLandscape: boolean,
63
+ tabletWidth: DimensionValue
64
+ ): ViewStyle => ({
65
+ width: isInlineModal && isTabletLandscape ? tabletWidth : "100%",
66
+ height: undefined,
67
+ });
68
+
69
+ export const calculateAspectRatio = (
70
+ isInlineModal: boolean,
71
+ pip?: boolean
72
+ ): number => {
73
+ return !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9;
74
+ };
75
+
76
+ export const getPlayerDimensions = (
77
+ baseDimensions: ViewStyle,
78
+ aspectRatio: number
79
+ ): ViewStyle => ({
80
+ ...(baseDimensions as any),
81
+ width: baseDimensions.width,
82
+ aspectRatio,
83
+ });
84
+
85
+ export const getContainerDimensions = (
86
+ baseDimensions: ViewStyle,
87
+ aspectRatio?: string | number
88
+ ): ViewStyle => ({
89
+ ...baseDimensions,
90
+ aspectRatio,
91
+ });