@applicaster/zapp-react-native-ui-components 13.0.0-alpha.3592913150 → 13.0.0-alpha.3637360334

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 (153) hide show
  1. package/Components/AppContainer/__tests__/AppContainer.test.js +4 -6
  2. package/Components/AudioPlayer/AudioPlayer.tsx +7 -0
  3. package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
  4. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
  5. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
  6. package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
  7. package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
  8. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
  9. package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
  10. package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
  11. package/Components/AudioPlayer/__tests__/title.test.js +3 -5
  12. package/Components/AudioPlayer/helpers.tsx +1 -0
  13. package/Components/BaseFocusable/index.ios.ts +1 -1
  14. package/Components/BaseFocusable/index.tsx +2 -3
  15. package/Components/Cell/Cell.tsx +10 -16
  16. package/Components/Cell/CellWithFocusable.tsx +48 -59
  17. package/Components/Cell/CellWrapper.ts +5 -0
  18. package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
  19. package/Components/Cell/styles.ts +17 -0
  20. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
  21. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
  22. package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
  23. package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
  24. package/Components/ErrorScreen/index.tsx +14 -6
  25. package/Components/Focusable/Focusable.tsx +1 -0
  26. package/Components/Focusable/Touchable.tsx +19 -20
  27. package/Components/Focusable/index.android.tsx +10 -3
  28. package/Components/FocusableCell/index.tsx +1 -1
  29. package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
  30. package/Components/FocusableGroup/index.tsx +0 -3
  31. package/Components/FocusableList/index.tsx +1 -0
  32. package/Components/FocusableScrollView/index.tsx +6 -3
  33. package/Components/HandlePlayable/HandlePlayable.tsx +14 -27
  34. package/Components/Layout/TV/NavBarContainer.tsx +14 -19
  35. package/Components/Layout/TV/ScreenContainer.tsx +8 -1
  36. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
  37. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +2 -1
  38. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
  39. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
  40. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
  41. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  42. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  43. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +9 -14
  44. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
  45. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  46. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
  47. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  48. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  49. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
  50. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
  51. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
  52. package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
  53. package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
  54. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  55. package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
  56. package/Components/MasterCell/utils/index.ts +9 -135
  57. package/Components/ModalComponent/Button/assets.ts +1 -1
  58. package/Components/ModalComponent/Button/index.tsx +6 -6
  59. package/Components/ModalComponent/Header/index.tsx +3 -3
  60. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
  61. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
  62. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
  63. package/Components/OfflineHandler/utils/index.ts +1 -1
  64. package/Components/PlayerContainer/PlayerContainer.tsx +17 -13
  65. package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
  66. package/Components/PlayerImageBackground/index.tsx +1 -1
  67. package/Components/River/ComponentsMap/ComponentsMap.tsx +42 -65
  68. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
  69. package/Components/River/RiverFooter.tsx +39 -9
  70. package/Components/River/RiverItem.tsx +37 -2
  71. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +100 -31
  72. package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
  73. package/Components/River/__tests__/componentsMap.test.js +17 -5
  74. package/Components/River/__tests__/river.test.js +75 -40
  75. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
  76. package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
  77. package/Components/RouteManager/__tests__/testId.test.js +8 -6
  78. package/Components/Screen/TV/index.web.tsx +5 -6
  79. package/Components/Screen/hooks.ts +53 -0
  80. package/Components/Screen/index.tsx +16 -42
  81. package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
  82. package/Components/Tabs/Tab.tsx +11 -9
  83. package/Components/TextInputTv/index.tsx +4 -3
  84. package/Components/TrackedView/index.tsx +1 -0
  85. package/Components/Transitioner/AnimationManager.js +15 -15
  86. package/Components/Transitioner/Scene.tsx +53 -24
  87. package/Components/Transitioner/Transitioner.tsx +3 -3
  88. package/Components/Transitioner/__tests__/Scene.test.js +25 -14
  89. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +9 -49
  90. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
  91. package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
  92. package/Components/Transitioner/index.js +8 -4
  93. package/Components/VideoLive/LiveImageManager.ts +27 -1
  94. package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
  95. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +51 -1
  96. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -5
  97. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
  98. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +47 -31
  99. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +3 -3
  100. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +43 -21
  101. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -5
  102. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
  103. package/Components/VideoModal/ModalAnimation/const.ts +5 -0
  104. package/Components/VideoModal/ModalAnimation/index.ts +2 -0
  105. package/Components/VideoModal/ModalAnimation/utils.ts +38 -2
  106. package/Components/VideoModal/OpaqueLayer.tsx +33 -0
  107. package/Components/VideoModal/PlayerDetails.tsx +9 -6
  108. package/Components/VideoModal/PlayerWrapper.tsx +17 -36
  109. package/Components/VideoModal/VideoModal.tsx +16 -25
  110. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -1
  111. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +0 -90
  112. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
  113. package/Components/VideoModal/hooks/index.ts +7 -0
  114. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
  115. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
  116. package/Components/VideoModal/hooks/utils/index.ts +33 -0
  117. package/Components/VideoModal/utils.ts +1 -1
  118. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
  119. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
  120. package/Components/Viewport/__tests__/utils.test.js +5 -4
  121. package/Components/ZappUIComponent/Placeholder.tsx +3 -1
  122. package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
  123. package/Components/ZappUIComponent/index.tsx +3 -16
  124. package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
  125. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
  126. package/Contexts/ComponentsMapOffsetContext/index.tsx +8 -5
  127. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
  128. package/Contexts/HeaderOffsetContext/index.tsx +4 -6
  129. package/Contexts/ScreenContext/index.tsx +6 -12
  130. package/Contexts/ScreenLayoutContext/index.tsx +5 -3
  131. package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
  132. package/Decorators/Navigator/index.tsx +1 -1
  133. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
  134. package/Decorators/RiverResolver/index.tsx +6 -8
  135. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  136. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
  137. package/Decorators/ZappPipesDataConnector/index.tsx +6 -2
  138. package/package.json +7 -11
  139. package/tsconfig.json +2 -3
  140. package/.babelrc +0 -8
  141. package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
  142. package/Components/Cell/CellStyles/Hero/index.js +0 -111
  143. package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
  144. package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
  145. package/Components/Cell/CellStyles/colors.js +0 -40
  146. package/Components/Cell/CellStyles/index.js +0 -15
  147. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
  148. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
  149. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
  150. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
  151. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
  152. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
  153. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
@@ -1,17 +1,30 @@
1
1
  import * as React from "react";
2
2
  import { FocusableGroupNative } from "@applicaster/zapp-react-native-ui-components/Components/NativeFocusables";
3
3
  import { BaseFocusable } from "@applicaster/zapp-react-native-ui-components/Components/BaseFocusable";
4
-
5
- function noop() {}
4
+ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
5
+
6
+ const { log_verbose } = createLogger({
7
+ subsystem: "General",
8
+ category: "FocusableGroup",
9
+ });
10
+
11
+ type FocusableGroupNativeEvent = {
12
+ nativeEvent: {
13
+ focusHeading: FocusManager.Direction;
14
+ groupId: string;
15
+ isActive: boolean;
16
+ isFocusDisabled: boolean;
17
+ isFocusingByUser: boolean;
18
+ itemId: string;
19
+ target: number;
20
+ };
21
+ };
6
22
 
7
23
  type Props = {
8
24
  id: string;
9
25
  children: (arg1: boolean) => React.ComponentType<any>;
10
- onWillUpdateFocus: (nativeEvent: any) => void;
11
- onDidUpdateFocus: (nativeEvent: any) => void;
12
26
  isFocusDisabled: boolean;
13
- initialItemId: string;
14
- resetFocusToInitialValue: boolean;
27
+ isWithMemory: boolean;
15
28
  focusGroupRef: React.Component;
16
29
  shouldUsePreferredFocus: boolean;
17
30
  groupId: string;
@@ -21,86 +34,26 @@ type Props = {
21
34
  };
22
35
 
23
36
  export class FocusableGroup extends BaseFocusable<Props> {
24
- focusableGroupNativeRef: React.Component | null;
25
- constructor(props) {
26
- super(props);
27
- this.focusableGroupNativeRef = null;
28
-
29
- this.state = {
30
- isActive: false,
31
- };
32
-
33
- this.onWillUpdateFocus = this.onWillUpdateFocus.bind(this);
34
- this.onDidUpdateFocus = this.onDidUpdateFocus.bind(this);
35
- this.isGroup = true;
36
-
37
- this.shouldUsePreferredFocus = this.shouldUsePreferredFocus.bind(this);
38
- this.measureView = this.measureView.bind(this);
39
- }
40
-
41
- connectedScreenId() {
42
- const {
43
- screenData: { screenId, parentScreenId },
44
- } = this.props;
45
-
46
- if (screenId) {
47
- return null;
48
- }
49
-
50
- return parentScreenId ? `${parentScreenId}-${screenId}` : screenId;
51
- }
52
-
53
- /**
54
- * tells whether the group should give focus to a preferred item when it gains focus from another
55
- * group
56
- * @returns {boolean}
57
- */
58
- shouldUsePreferredFocus() {
59
- return this.props.shouldUsePreferredFocus || false;
60
- }
61
-
62
- /**
63
- * indicates whether the underlying component should claim preferred focus
64
- * when navigating into the group of this item
65
- * @returns {boolean}
66
- */
67
- isPreferredFocus() {
68
- return this.props.preferredFocus || false;
69
- }
70
-
71
- onWillUpdateFocus({ nativeEvent }) {
72
- const { isActive } = nativeEvent;
73
- this.setState({ isActive });
74
- const { onWillUpdateFocus = noop } = this.props;
75
- onWillUpdateFocus(nativeEvent);
76
- }
77
-
78
- onDidUpdateFocus({ nativeEvent }) {
79
- const { onDidUpdateFocus = noop } = this.props;
80
- onDidUpdateFocus(nativeEvent);
81
- }
82
-
83
- setFocusDisabled(isFocusDisabled) {
84
- if (this.ref) {
85
- this.ref.current.setNativeProps({
86
- isFocusDisabled,
87
- });
88
- }
89
- }
90
-
91
37
  render() {
92
38
  const {
93
39
  children,
94
40
  id,
95
41
  isFocusDisabled,
96
- initialItemId,
97
- resetFocusToInitialValue,
98
- style,
42
+ isWithMemory,
43
+ style = {},
99
44
  groupId,
100
45
  ...otherProps
101
46
  } = this.props;
102
47
 
103
- const focusableStyles = style || {};
48
+ const onGroupFocus = ({ nativeEvent }: FocusableGroupNativeEvent) => {
49
+ log_verbose("FOCUSABLE_GROUP: onGroupFocus", { nativeEvent });
50
+ this.onFocus(this.ref, nativeEvent.focusHeading);
51
+ };
52
+
53
+ const onGroupBlur = ({ nativeEvent }: FocusableGroupNativeEvent) => {
54
+ log_verbose("FOCUSABLE_GROUP: onGroupBlur", { nativeEvent });
55
+ this.onBlur(this.ref, nativeEvent.focusHeading);
56
+ };
104
57
 
105
58
  return (
106
59
  <FocusableGroupNative
@@ -108,16 +61,11 @@ export class FocusableGroup extends BaseFocusable<Props> {
108
61
  itemId={id}
109
62
  ref={this.ref}
110
63
  isFocusDisabled={isFocusDisabled}
111
- initialItemId={initialItemId}
112
- resetFocusToInitialValue={resetFocusToInitialValue}
113
- onLayout={this.measureView}
114
- onViewFocus={this.onFocus}
115
- onViewPress={this.onPress}
116
- onViewBlur={this.onBlur}
117
- style={focusableStyles}
64
+ isWithMemory={isWithMemory}
65
+ onGroupFocus={onGroupFocus}
66
+ onGroupBlur={onGroupBlur}
67
+ style={style}
118
68
  {...otherProps}
119
- onWillUpdateFocus={this.onWillUpdateFocus}
120
- onDidUpdateFocus={this.onDidUpdateFocus}
121
69
  >
122
70
  {children}
123
71
  </FocusableGroupNative>
@@ -16,12 +16,9 @@ type Props = {
16
16
  prioritiseFocusOn?: number;
17
17
  groupId?: string;
18
18
  hasTVPreferredFocus?: boolean;
19
- resetFocusToInitialValue?: boolean;
20
19
  onFocus?: () => void;
21
20
  onBlur?: () => void;
22
- onWillUpdateFocus?: (event?: any) => void;
23
21
  willReceiveFocus?: (event?: any) => void;
24
- onDidUpdateFocus?: (event?: any) => void;
25
22
  hasLostFocus?: any;
26
23
  nextFocusUp?: any;
27
24
  nextFocusDown?: any;
@@ -311,6 +311,7 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
311
311
  />
312
312
  ) : (
313
313
  <FlatList
314
+ testID="focusable-list-flat-list"
314
315
  focusable={false}
315
316
  scrollEnabled={false}
316
317
  ref={ref}
@@ -48,7 +48,7 @@ type Action = { index?: number; isFocusable: boolean; type?: string };
48
48
  const unwrapArray = (maybeArray) =>
49
49
  Array.isArray(maybeArray) ? maybeArray[0] : maybeArray;
50
50
 
51
- function getEntry<T>(data: T | T[], index: unknown): T {
51
+ const getEntry = <T extends unknown>(data: T | T[], index: unknown): T => {
52
52
  let entry;
53
53
 
54
54
  if (R.isNil(index)) {
@@ -58,7 +58,7 @@ function getEntry<T>(data: T | T[], index: unknown): T {
58
58
  }
59
59
 
60
60
  return entry;
61
- }
61
+ };
62
62
 
63
63
  const focusableStateReducer = (
64
64
  state: State,
@@ -310,6 +310,8 @@ function FocusableScrollViewComponent(props: Props, ref) {
310
310
  };
311
311
  };
312
312
 
313
+ const onSetIsFocusable = setIsFocusable(renderArgs.index);
314
+
313
315
  return (
314
316
  <View key={id} onLayout={onItemLayout}>
315
317
  <Focusable
@@ -332,6 +334,7 @@ function FocusableScrollViewComponent(props: Props, ref) {
332
334
  id={id}
333
335
  disableFocus={shouldDisableFocus(renderArgs?.index)}
334
336
  blockFocus={!isRendered(renderArgs?.index)}
337
+ onSetIsFocusable={onSetIsFocusable}
335
338
  {...focusableItemProps}
336
339
  >
337
340
  {(focused, parentFocus, parentRef) => (
@@ -346,7 +349,7 @@ function FocusableScrollViewComponent(props: Props, ref) {
346
349
  isReadyToRender={isReadyToRender}
347
350
  onLoadFinished={onLoadFinished(renderArgs.index)}
348
351
  onLoadFailed={onLoadFailed(renderArgs.index)}
349
- setIsFocusable={setIsFocusable(renderArgs.index)}
352
+ setIsFocusable={onSetIsFocusable}
350
353
  />
351
354
  )}
352
355
  </Focusable>
@@ -1,14 +1,14 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
- import { ViewStyle } from "react-native";
4
3
  import {
5
4
  findPluginByType,
6
5
  findPluginByIdentifier,
7
6
  } from "@applicaster/zapp-react-native-utils/pluginUtils";
8
- import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/layout";
9
7
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
10
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
11
- import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
8
+ import {
9
+ useDimensions,
10
+ useNavigation,
11
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
12
12
 
13
13
  import { BufferAnimation } from "../PlayerContainer/BufferAnimation";
14
14
  import { PlayerContainer } from "../PlayerContainer";
@@ -78,12 +78,6 @@ const getPlayer = (
78
78
  return getPlayerWithModuleProperties(PlayerModule);
79
79
  };
80
80
 
81
- const dimensionsContext: "window" | "screen" = platformSelect({
82
- android_tv: "window",
83
- amazon: "window",
84
- default: "screen",
85
- });
86
-
87
81
  type PlayableComponent = {
88
82
  Component: React.ComponentType<any>;
89
83
  };
@@ -91,16 +85,11 @@ type PlayableComponent = {
91
85
  export function HandlePlayable({
92
86
  item,
93
87
  isModal,
94
- modalHeight,
95
- modalWidth,
96
88
  mode,
97
89
  groupId,
98
90
  }: Props): React.ReactElement | null {
99
91
  const state = usePickFromState();
100
92
 
101
- const { width: screenWidth, height: screenHeight } =
102
- useDimensions(dimensionsContext);
103
-
104
93
  const { closeVideoModal } = useNavigation();
105
94
 
106
95
  const [Player, playerModuleProperties] = getPlayer(item, state);
@@ -118,9 +107,7 @@ export function HandlePlayable({
118
107
  if (!isModal) {
119
108
  closeVideoModal();
120
109
  }
121
- }, []);
122
110
 
123
- React.useEffect(() => {
124
111
  const castStateHandler = async () => {
125
112
  const castState = await CastPlugin?.getCastState();
126
113
  setCasting(castState === "Connected");
@@ -142,23 +129,23 @@ export function HandlePlayable({
142
129
  }, []);
143
130
 
144
131
  React.useEffect(() => {
145
- if (casting) {
146
- setPlayable({ Component: CastPlugin?.CastHandler });
147
- } else {
148
- setPlayable({ Component: PlayerContainer });
149
- }
132
+ setPlayable({
133
+ Component: casting ? CastPlugin?.CastHandler : PlayerContainer,
134
+ });
150
135
  }, [casting]);
151
136
 
152
- const Component = playable?.Component;
137
+ const { width: screenWidth, height: screenHeight } = useDimensions("window");
153
138
 
154
139
  const style = React.useMemo(
155
140
  () => ({
156
- width: isModal ? modalWidth : mode === "PIP" ? "100%" : screenWidth,
157
- height: isModal ? modalHeight : mode === "PIP" ? "100%" : screenHeight,
141
+ width: isModal ? "100%" : mode === "PIP" ? "100%" : screenWidth,
142
+ height: isModal ? "100%" : mode === "PIP" ? "100%" : screenHeight,
158
143
  }),
159
- [screenWidth, screenHeight, modalHeight, modalWidth, isModal, mode]
144
+ [screenWidth, screenHeight, isModal, mode]
160
145
  );
161
146
 
147
+ const Component = playable?.Component;
148
+
162
149
  if (Component) {
163
150
  return (
164
151
  <Component
@@ -174,5 +161,5 @@ export function HandlePlayable({
174
161
  );
175
162
  }
176
163
 
177
- return !isModal ? <BufferAnimation videoStyle={style as ViewStyle} /> : null;
164
+ return !isModal ? <BufferAnimation videoStyle={style} /> : null;
178
165
  }
@@ -1,7 +1,5 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet } from "react-native";
3
- import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
4
- import { useScreenConfiguration } from "../../River/useScreenConfiguration";
2
+ import { StyleSheet, View } from "react-native";
5
3
 
6
4
  type Props = {
7
5
  children: React.ReactNode;
@@ -14,32 +12,29 @@ const styles = StyleSheet.create({
14
12
  position: "absolute",
15
13
  top: 0,
16
14
  zIndex: 10,
17
- width: 1920,
15
+ flex: 1,
16
+ width: "100%",
17
+ },
18
+ themeStyles: {
19
+ // limits the height of the focusable container of the TopMenuBarTV component
20
+ // to prevent it from being overlapped by the screen content,
21
+ // as it makes TopMenuBarTV unfocusable on tvOS
22
+ maxHeight: 1,
18
23
  },
19
24
  });
20
25
 
21
26
  export const NavBarContainer = ({ children, isVisible, onReady }: Props) => {
22
- const screen = useCurrentScreenData();
23
- const screenConfig = useScreenConfiguration(screen?.id);
24
-
25
- const themeStyles = React.useMemo(
26
- () => ({
27
- // limits the height of the focusable container of the TopMenuBarTV component
28
- // to prevent it from being overlapped by the screen content,
29
- // as it makes TopMenuBarTV unfocusable on tvOS
30
- maxHeight: 1,
31
- }),
32
- [screenConfig]
33
- );
34
-
35
27
  React.useEffect(() => {
36
28
  setTimeout(() => {
37
29
  onReady?.(true);
38
30
  }, 0);
39
- }, []);
31
+ }, [onReady]);
40
32
 
41
33
  return isVisible ? (
42
- <View testID="nav-bar-container" style={[styles.container, themeStyles]}>
34
+ <View
35
+ testID="nav-bar-container"
36
+ style={[styles.container, styles.themeStyles]}
37
+ >
43
38
  {children}
44
39
  </View>
45
40
  ) : null;
@@ -55,8 +55,11 @@ export const ScreenContainer = React.memo(function ScreenContainer({
55
55
  ComponentsExtraProps,
56
56
  NavBar,
57
57
  }: Props) {
58
- const { screenMarginBottom } = React.useContext(ScreenLayoutContext);
58
+ const { screenMarginBottom, resetScreenLayout } =
59
+ React.useContext(ScreenLayoutContext);
60
+
59
61
  const { currentRoute, screenData } = useNavigation();
62
+
60
63
  const screen = useCurrentScreenData();
61
64
 
62
65
  const { marginBottom, backgroundColor, paddingTop, paddingBottom } =
@@ -65,6 +68,10 @@ export const ScreenContainer = React.memo(function ScreenContainer({
65
68
  const theme = useTheme();
66
69
  const getThemeValue = React.useCallback(R.propOr(0, R.__, theme), [theme]);
67
70
 
71
+ React.useEffect(() => {
72
+ resetScreenLayout();
73
+ }, [currentRoute]);
74
+
68
75
  const fullscreen = React.useCallback(
69
76
  displayFullScreen({ currentRoute, screenData }),
70
77
  [currentRoute, screenData]
@@ -60,10 +60,15 @@ export function ScreenLayoutContextProvider(props: {
60
60
  initialState
61
61
  );
62
62
 
63
+ const resetScreenLayout = React.useCallback(() => {
64
+ setScreenLayout(initialState);
65
+ }, [initialState]);
66
+
63
67
  const screenLayoutValue = React.useMemo(
64
68
  () => ({
65
69
  ...screenLayout,
66
70
  setScreenLayout,
71
+ resetScreenLayout,
67
72
  }),
68
73
  [screenLayout]
69
74
  );
@@ -56,11 +56,12 @@ describe("ScreenContainer", () => {
56
56
  };
57
57
 
58
58
  const setScreenLayout = () => {};
59
+ const resetScreenLayout = () => {};
59
60
 
60
61
  const wrapper = ({ children }) => (
61
62
  <WrappedWithProviders>
62
63
  <ScreenLayoutContext.Provider
63
- value={{ ...screenLayout, setScreenLayout }}
64
+ value={{ ...screenLayout, setScreenLayout, resetScreenLayout }}
64
65
  >
65
66
  <ScreenContainer NavBar={View}>{children}</ScreenContainer>
66
67
  </ScreenLayoutContext.Provider>
@@ -5,13 +5,14 @@ exports[`NavBarContainer renders 1`] = `
5
5
  style={
6
6
  [
7
7
  {
8
+ "flex": 1,
8
9
  "position": "absolute",
9
10
  "top": 0,
10
- "width": 1920,
11
+ "width": "100%",
11
12
  "zIndex": 10,
12
13
  },
13
14
  {
14
- "maxHeight": 10,
15
+ "maxHeight": 1,
15
16
  },
16
17
  ]
17
18
  }
@@ -16,13 +16,14 @@ exports[`ScreenContainer renders 1`] = `
16
16
  style={
17
17
  [
18
18
  {
19
+ "flex": 1,
19
20
  "position": "absolute",
20
21
  "top": 0,
21
- "width": 1920,
22
+ "width": "100%",
22
23
  "zIndex": 10,
23
24
  },
24
25
  {
25
- "maxHeight": 10,
26
+ "maxHeight": 1,
26
27
  },
27
28
  ]
28
29
  }
@@ -4,7 +4,6 @@ import { TouchableOpacity, ViewStyle } from "react-native";
4
4
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
5
5
 
6
6
  import Image from "./Image";
7
-
8
7
  type Props = {
9
8
  item: ZappEntry | ZappFeed;
10
9
  flavour?: "flavour_1" | "flavour_2";
@@ -69,7 +68,7 @@ export function ActionButton(props: Props) {
69
68
  if (!((actionDisabled || !actionContext) && actionState !== null)) {
70
69
  setActionState(actionContext.initialEntryState(item));
71
70
  }
72
- }, [actionDisabled, item?.id, actionContext, action]);
71
+ }, [actionDisabled, item?.id, actionContext, action, setActionState]);
73
72
 
74
73
  const onPress = useCallback(() => {
75
74
  actionContext.invokeAction(item, {
@@ -85,7 +84,7 @@ export function ActionButton(props: Props) {
85
84
  setActionState(state);
86
85
  });
87
86
  }
88
- }, [item?.id]);
87
+ }, [item?.id, setActionState, actionContext]);
89
88
 
90
89
  if (actionDisabled || !actionContext) return null;
91
90
  const AssetComponent = actionState?.asset;
@@ -0,0 +1,66 @@
1
+ import {
2
+ BorderContainerView,
3
+ getBorderPadding, // Export for testing (using a double underscore prefix is a common convention)
4
+ } from "../index";
5
+ import * as React from "react";
6
+ import { render } from "@testing-library/react-native";
7
+ import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
8
+ import { View } from "react-native";
9
+
10
+ jest.mock("@applicaster/zapp-react-native-utils/numberUtils", () => ({
11
+ toNumberWithDefaultZero: jest.fn((value) => Number(value) || 0),
12
+ }));
13
+
14
+ describe("BorderContainerView", () => {
15
+ describe("getBorderPadding", () => {
16
+ it("returns 0 for inside", () => {
17
+ expect(getBorderPadding("inside", 10)).toBe(0);
18
+ });
19
+
20
+ it("returns borderWidth / 2 for center", () => {
21
+ expect(getBorderPadding("center", 10)).toBe(5);
22
+ });
23
+
24
+ it("returns borderWidth for outside", () => {
25
+ expect(getBorderPadding("outside", 10)).toBe(10);
26
+ });
27
+
28
+ it("returns borderWidth for invalid position", () => {
29
+ // @ts-ignore
30
+ expect(getBorderPadding("other_value", 10)).toBe(10);
31
+ });
32
+ });
33
+
34
+ it("Border component renders null if no borderPosition", () => {
35
+ const style = { borderWidth: 5, borderRadius: 10, borderColor: "red" };
36
+
37
+ const padding = {
38
+ paddingTop: 2,
39
+ paddingRight: 3,
40
+ paddingBottom: 4,
41
+ paddingLeft: 5,
42
+ };
43
+
44
+ const borderPosition = null;
45
+
46
+ const { queryByTestId } = render(
47
+ <BorderContainerView
48
+ style={style}
49
+ testID="border-container"
50
+ borderPosition={borderPosition}
51
+ borderPaddingTop={toNumberWithDefaultZero(padding.paddingTop)}
52
+ borderPaddingRight={toNumberWithDefaultZero(padding.paddingRight)}
53
+ borderPaddingBottom={toNumberWithDefaultZero(padding.paddingBottom)}
54
+ borderPaddingLeft={toNumberWithDefaultZero(padding.paddingLeft)}
55
+ >
56
+ <View testID="child" />
57
+ </BorderContainerView>
58
+ );
59
+
60
+ const children = queryByTestId("border-container").children;
61
+
62
+ expect(children[1].props.testID).toBe("child");
63
+
64
+ expect(children[0].children.length).toBe(0);
65
+ });
66
+ });
@@ -28,7 +28,10 @@ const styles = StyleSheet.create({
28
28
  },
29
29
  });
30
30
 
31
- const getBorderPadding = (borderPosition: BorderPosition, borderWidth) => {
31
+ export const getBorderPadding = (
32
+ borderPosition: BorderPosition,
33
+ borderWidth: number
34
+ ) => {
32
35
  switch (borderPosition) {
33
36
  case "inside":
34
37
  return 0;
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Image as RnImage, ImageStyle } from "react-native";
3
- import * as R from "ramda";
3
+ import { equals, omit } from "ramda";
4
4
 
5
5
  import { useImageSource } from "./hooks";
6
6
 
@@ -17,7 +17,7 @@ type Props = Record<string, any> & {
17
17
  withDimensions: (source: Source) => Source;
18
18
  };
19
19
 
20
- const MemoizedImage = React.memo(RnImage, R.equals);
20
+ const MemoizedImage = React.memo(RnImage, equals);
21
21
 
22
22
  function Image({
23
23
  style,
@@ -38,23 +38,18 @@ function Image({
38
38
 
39
39
  const shouldRenderImg = source && !error;
40
40
 
41
- // Default placeholder image fallback is empty string because it won't rerender
42
- // in case of undefined or {uri: undefined} source
43
- // https://github.com/facebook/react-native/issues/9195
44
- const defaultPlaceHolderImage = React.useMemo(
45
- () => ({ uri: placeholderImage || "" }),
46
- [source, error]
47
- );
41
+ const _source = shouldRenderImg
42
+ ? withDimensions(source)
43
+ : { uri: placeholderImage };
48
44
 
49
45
  return (
50
- // @ts-ignore
51
46
  <MemoizedImage
47
+ key={_source?.uri || "no-image"}
52
48
  style={style as ImageStyle}
53
49
  onError={React.useCallback(() => setErrorState(true), [])}
54
- source={
55
- shouldRenderImg ? withDimensions(source) : defaultPlaceHolderImage
56
- }
57
- {...R.omit(["source"], otherProps)}
50
+ // as we have defaults as "" for placeholder image, we need to pass undefined to source to not throw warnings
51
+ source={_source?.uri ? _source : undefined}
52
+ {...omit(["source"], otherProps)}
58
53
  />
59
54
  );
60
55
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import * as R from "ramda";
2
+ import { path } from "ramda";
3
3
 
4
4
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
5
5
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
@@ -7,9 +7,13 @@ import { extractAsset } from "./utils";
7
7
 
8
8
  type Return = { uri: string } | null;
9
9
 
10
+ const getSourceContext = path(["source", "context"]);
11
+ const getSourceUri = path(["source", "uri"]);
12
+ const getState = path(["state"]);
13
+
10
14
  export const useImageSource = ({ uri, entry, otherProps }): Return => {
11
- const uriContext = R.path(["source", "context"], otherProps);
12
- const uriState = R.path(["state"], otherProps);
15
+ const uriContext = getSourceContext(otherProps);
16
+ const uriState = getState(otherProps);
13
17
 
14
18
  const action = useActions(uriContext);
15
19
 
@@ -34,7 +38,7 @@ export const useImageSource = ({ uri, entry, otherProps }): Return => {
34
38
  return { uri };
35
39
  }
36
40
 
37
- const uriFromSource = R.path(["source", "uri"], otherProps);
41
+ const uriFromSource = getSourceUri(otherProps);
38
42
 
39
43
  if (uriFromSource) {
40
44
  return { uri: uriFromSource };
@@ -56,7 +60,7 @@ const getSource = (uri, showDefault, placeholderImage, otherProps) => {
56
60
  return { uri };
57
61
  }
58
62
 
59
- const uriFromSource = R.path(["source", "uri"], otherProps);
63
+ const uriFromSource = getSourceUri(otherProps);
60
64
 
61
65
  if (uriFromSource) {
62
66
  return { uri: uriFromSource };
@@ -72,8 +76,8 @@ export const useImageSourceWithDefault = ({
72
76
  placeholderImage,
73
77
  otherProps,
74
78
  }): Return => {
75
- const uriContext = R.path(["source", "context"], otherProps);
76
- const uriState = R.path(["state"], otherProps);
79
+ const uriContext = getSourceContext(otherProps);
80
+ const uriState = getState(otherProps);
77
81
 
78
82
  const action = useActions(uriContext);
79
83