@applicaster/zapp-react-native-ui-components 13.0.0-alpha.3755455151 → 13.0.0-alpha.3923423021

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 (128) hide show
  1. package/Components/AppContainer/__tests__/AppContainer.test.js +4 -6
  2. package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
  3. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
  4. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
  5. package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
  6. package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
  7. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
  8. package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
  9. package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
  10. package/Components/AudioPlayer/__tests__/title.test.js +3 -5
  11. package/Components/BaseFocusable/index.ios.ts +1 -1
  12. package/Components/BaseFocusable/index.tsx +2 -3
  13. package/Components/Cell/Cell.tsx +8 -3
  14. package/Components/Cell/CellWithFocusable.ios.tsx +126 -0
  15. package/Components/Cell/CellWithFocusable.tsx +43 -58
  16. package/Components/Cell/TvOSCellComponent.tsx +20 -26
  17. package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
  18. package/Components/Cell/index.js +3 -1
  19. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
  20. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
  21. package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
  22. package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
  23. package/Components/ErrorScreen/index.tsx +6 -6
  24. package/Components/Focusable/Focusable.tsx +1 -0
  25. package/Components/Focusable/FocusableTvOS.tsx +6 -2
  26. package/Components/Focusable/Touchable.tsx +19 -20
  27. package/Components/Focusable/index.android.tsx +10 -3
  28. package/Components/FocusableList/index.tsx +26 -10
  29. package/Components/FocusableScrollView/index.tsx +43 -13
  30. package/Components/Layout/TV/NavBarContainer.tsx +19 -23
  31. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
  32. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
  33. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
  34. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  35. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  36. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -12
  37. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  38. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
  39. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  40. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  41. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
  42. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
  43. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
  44. package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
  45. package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
  46. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  47. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
  48. package/Components/MasterCell/utils/index.ts +1 -1
  49. package/Components/ModalComponent/Button/index.tsx +6 -6
  50. package/Components/ModalComponent/Header/index.tsx +3 -3
  51. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
  52. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
  53. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
  54. package/Components/PlayerContainer/PlayerContainer.tsx +11 -15
  55. package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
  56. package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
  57. package/Components/PlayerImageBackground/index.tsx +23 -3
  58. package/Components/River/ComponentsMap/ComponentsMap.tsx +39 -65
  59. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
  60. package/Components/River/RiverFooter.tsx +39 -9
  61. package/Components/River/RiverItem.tsx +37 -2
  62. package/Components/River/TV/index.tsx +6 -1
  63. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +100 -31
  64. package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
  65. package/Components/River/__tests__/componentsMap.test.js +17 -5
  66. package/Components/River/__tests__/river.test.js +75 -40
  67. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
  68. package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
  69. package/Components/RouteManager/__tests__/testId.test.js +8 -6
  70. package/Components/Screen/hooks.ts +56 -0
  71. package/Components/Screen/index.tsx +16 -42
  72. package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
  73. package/Components/Tabs/Tab.tsx +11 -9
  74. package/Components/TextInputTv/index.tsx +4 -3
  75. package/Components/Transitioner/AnimationManager.js +8 -8
  76. package/Components/Transitioner/Scene.tsx +53 -24
  77. package/Components/Transitioner/Transitioner.tsx +3 -3
  78. package/Components/Transitioner/__tests__/Scene.test.js +25 -14
  79. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +9 -49
  80. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
  81. package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
  82. package/Components/Transitioner/index.js +8 -4
  83. package/Components/VideoLive/LiveImageManager.ts +27 -1
  84. package/Components/VideoLive/PlayerLiveImageComponent.tsx +32 -24
  85. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +51 -1
  86. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
  87. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +16 -12
  88. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +5 -1
  89. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +15 -14
  90. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +2 -3
  91. package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
  92. package/Components/VideoModal/OpaqueLayer.tsx +33 -0
  93. package/Components/VideoModal/PlayerDetails.tsx +9 -6
  94. package/Components/VideoModal/PlayerWrapper.tsx +17 -36
  95. package/Components/VideoModal/VideoModal.tsx +14 -23
  96. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -1
  97. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +0 -90
  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 +1 -1
  104. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
  105. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
  106. package/Components/Viewport/__tests__/utils.test.js +5 -4
  107. package/Components/ZappUIComponent/Placeholder.tsx +3 -1
  108. package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
  109. package/Components/ZappUIComponent/index.tsx +3 -16
  110. package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
  111. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
  112. package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
  113. package/Contexts/ScreenContext/index.tsx +3 -2
  114. package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
  115. package/Decorators/Navigator/index.tsx +1 -1
  116. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
  117. package/Decorators/RiverResolver/index.tsx +1 -1
  118. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  119. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
  120. package/Decorators/ZappPipesDataConnector/index.tsx +31 -1
  121. package/package.json +7 -7
  122. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
  123. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
  124. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
  125. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
  126. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
  127. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
  128. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
@@ -1,25 +1,24 @@
1
1
  import * as React from "react";
2
2
 
3
- type Props =
4
- | {
5
- id: string;
6
- children: React.ReactNode;
7
- onPress?: (ref: FocusManager.TouchableRef) => void;
8
- onPressIn?: (ref: FocusManager.TouchableRef) => void;
9
- onPressOut?: (ref: FocusManager.TouchableRef) => void;
10
- onLongPress?: (ref: FocusManager.TouchableRef) => void;
11
- onFocus?: (
12
- ref: FocusManager.TouchableRef,
13
- options: FocusManager.Android.CallbackOptions
14
- ) => void;
15
- onBlur?: (
16
- ref: FocusManager.TouchableRef,
17
- options: FocusManager.Android.CallbackOptions
18
- ) => void;
19
-
20
- disableFocus?: boolean;
21
- blockFocus?: boolean;
22
- } & Partial<ParentFocus>;
3
+ type Props = {
4
+ id: string;
5
+ children: React.ReactNode;
6
+ onPress?: (ref: FocusManager.TouchableRef) => void;
7
+ onPressIn?: (ref: FocusManager.TouchableRef) => void;
8
+ onPressOut?: (ref: FocusManager.TouchableRef) => void;
9
+ onLongPress?: (ref: FocusManager.TouchableRef) => void;
10
+ onFocus?: (
11
+ ref: FocusManager.TouchableRef,
12
+ options: FocusManager.Android.CallbackOptions
13
+ ) => void;
14
+ onBlur?: (
15
+ ref: FocusManager.TouchableRef,
16
+ options: FocusManager.Android.CallbackOptions
17
+ ) => void;
18
+
19
+ disableFocus?: boolean;
20
+ blockFocus?: boolean;
21
+ } & Partial<ParentFocus>;
23
22
 
24
23
  export class Touchable extends React.Component<Props> {
25
24
  onPress(focusableRef: FocusManager.TouchableRef): void {
@@ -33,6 +33,8 @@ type Props = {
33
33
  onLongPress?: (ref: FocusManager.FocusableRef) => void;
34
34
  onRegister?: () => void;
35
35
  isFocusableCell?: boolean;
36
+ /** only for FocusableScrollView */
37
+ onSetIsFocusable?: (isFocusable: boolean) => void;
36
38
  } & ParentFocus;
37
39
 
38
40
  export const FocusableContext = React.createContext<
@@ -67,6 +69,7 @@ function FocusableComponent(props: Props, forwardedRef) {
67
69
  onLongPress,
68
70
  onRegister = noop,
69
71
  isFocusableCell = true,
72
+ onSetIsFocusable,
70
73
  } = props;
71
74
 
72
75
  const isRTL = useIsRTL();
@@ -137,9 +140,13 @@ function FocusableComponent(props: Props, forwardedRef) {
137
140
  [onBlur]
138
141
  );
139
142
 
140
- const setIsFocusable = React.useCallback((blockFocus) => {
141
- setDisableFocus(!blockFocus);
142
- }, []);
143
+ const setIsFocusable = React.useCallback(
144
+ (blockFocus) => {
145
+ onSetIsFocusable?.(blockFocus);
146
+ setDisableFocus(!blockFocus);
147
+ },
148
+ [onSetIsFocusable]
149
+ );
143
150
 
144
151
  const parentFocus = React.useMemo(
145
152
  () => ({
@@ -15,6 +15,7 @@ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
15
15
 
16
16
  import { useParentFocus, useCheckItemIdsForUnique } from "./hooks";
17
17
  import { FocusableListItemWrapper } from "./FocusableListItemWrapper";
18
+ import { FocusableScrollView } from "../FocusableScrollView";
18
19
 
19
20
  const mapIndexed = R.addIndex(R.map);
20
21
 
@@ -54,6 +55,7 @@ export type Props<ItemT> = FlatListProps<ItemT> & {
54
55
  disableNextFocusUp?: boolean;
55
56
  disableNextFocusLeft?: boolean;
56
57
  disableNextFocusRight?: boolean;
58
+ useScrollView?: boolean;
57
59
  } & ParentFocus;
58
60
 
59
61
  function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
@@ -87,8 +89,8 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
87
89
  initialFocusDirection = "down",
88
90
  data = [],
89
91
  // eslint-disable-next-line unused-imports/no-unused-vars
90
- onAllComponentsLoaded, // TODO: re-implement it
91
92
  omitPropsPropagation = [],
93
+ useScrollView = false,
92
94
  } = props;
93
95
 
94
96
  useCheckItemIdsForUnique({ componentId: props.id, items: data });
@@ -274,6 +276,7 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
274
276
  "initialFocusDirection",
275
277
  "withStateMemory",
276
278
  "useSequentialLoading",
279
+ "useScrollView",
277
280
  ...omitPropsPropagation,
278
281
  ],
279
282
  R.__
@@ -296,15 +299,28 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
296
299
  return (
297
300
  // @ts-ignore
298
301
  <ChildrenFocusDeactivatorView flex={1}>
299
- <FlatList
300
- focusable={false}
301
- scrollEnabled={false}
302
- ref={ref}
303
- {...getFlatListProps(props)}
304
- renderItem={renderItem}
305
- onEndReached={onEndReached}
306
- initialNumToRender={initialNumToRender}
307
- />
302
+ {useScrollView ? (
303
+ <FocusableScrollView
304
+ ref={ref}
305
+ {...getFlatListProps(props)}
306
+ onEndReached={onEndReached}
307
+ initialNumToRender={initialNumToRender}
308
+ renderItem={renderItem}
309
+ focused={focused}
310
+ data={data}
311
+ />
312
+ ) : (
313
+ <FlatList
314
+ testID="focusable-list-flat-list"
315
+ focusable={false}
316
+ scrollEnabled={false}
317
+ ref={ref}
318
+ {...getFlatListProps(props)}
319
+ renderItem={renderItem}
320
+ onEndReached={onEndReached}
321
+ initialNumToRender={initialNumToRender}
322
+ />
323
+ )}
308
324
  </ChildrenFocusDeactivatorView>
309
325
  );
310
326
  }
@@ -11,6 +11,13 @@ import {
11
11
  useInitialFocus,
12
12
  } from "@applicaster/zapp-react-native-utils/focusManager";
13
13
 
14
+ export type FocusableScrollViewRenderItem = (info: {
15
+ item: ZappUIComponent;
16
+ index: number;
17
+ focused: boolean;
18
+ parentFocus: ParentFocus;
19
+ }) => React.ReactElement;
20
+
14
21
  export type Props = ScrollViewProps & {
15
22
  id?: number | string;
16
23
  horizontal?: boolean;
@@ -32,17 +39,27 @@ export type Props = ScrollViewProps & {
32
39
  initialFocusDirection?: FocusManager.Android.FocusNavigationDirections;
33
40
  onAllComponentsLoaded?: () => void;
34
41
  omitPropsPropagation?: Array<keyof FlatListProps<any>>;
35
- renderItem: (info: {
36
- item: ZappUIComponent;
37
- index: number;
38
- focused: boolean;
39
- parentFocus: ParentFocus;
40
- }) => React.ReactElement;
42
+ renderItem: FocusableScrollViewRenderItem;
41
43
  } & ParentFocus;
42
44
 
43
45
  type State = boolean[];
44
46
  type Action = { index?: number; isFocusable: boolean; type?: string };
45
47
 
48
+ const unwrapArray = (maybeArray) =>
49
+ Array.isArray(maybeArray) ? maybeArray[0] : maybeArray;
50
+
51
+ const getEntry = <T extends unknown>(data: T | T[], index: unknown): T => {
52
+ let entry;
53
+
54
+ if (R.isNil(index)) {
55
+ entry = unwrapArray(data);
56
+ } else if (typeof index === "number") {
57
+ entry = unwrapArray(data[index]);
58
+ }
59
+
60
+ return entry;
61
+ };
62
+
46
63
  const focusableStateReducer = (
47
64
  state: State,
48
65
  { index = null, isFocusable, type = null }: Action
@@ -73,7 +90,7 @@ const extendScrollViewRef = (_ref, childCompsMeasurementsMap) => {
73
90
  };
74
91
 
75
92
  _ref.scrollToIndex = (params) => {
76
- const { index, viewOffset } = params;
93
+ const { index, viewOffset = 0 } = params;
77
94
 
78
95
  const itemByIndex = R.find(R.propEq("index", index))(
79
96
  R.values(childCompsMeasurementsMap)
@@ -129,8 +146,11 @@ function FocusableScrollViewComponent(props: Props, ref) {
129
146
  );
130
147
 
131
148
  const getFocusableEntryId = React.useCallback(
132
- (_entry: ZappEntry, index?: number) => {
133
- const entry = R.isNil(index) ? _entry : data[index];
149
+ (_entry: ZappEntry | null, index?: number) => {
150
+ const entry: { id?: string } = getEntry(
151
+ R.isNil(index) ? _entry : data,
152
+ index
153
+ );
134
154
 
135
155
  return entry ? `${props.id}--${entry?.id}` : undefined;
136
156
  },
@@ -273,16 +293,25 @@ function FocusableScrollViewComponent(props: Props, ref) {
273
293
  const renderItem = React.useCallback(
274
294
  (item, index) => {
275
295
  const renderArgs = { item, index };
276
- const id = `${props.id}--${renderArgs?.item?.id}`;
277
- const nextFocus = getNextFocus(renderArgs?.index);
296
+
297
+ const id = getFocusableEntryId(
298
+ Array.isArray(item) ? item[0] : item,
299
+ index
300
+ );
301
+
302
+ const nextFocus = getNextFocus(index);
278
303
 
279
304
  const onItemLayout = (event) => {
280
- childCompsMeasurementsMap.current[item.id] = {
305
+ childCompsMeasurementsMap.current[
306
+ Array.isArray(item) ? index : item.id
307
+ ] = {
281
308
  index,
282
309
  layout: event.nativeEvent.layout,
283
310
  };
284
311
  };
285
312
 
313
+ const onSetIsFocusable = setIsFocusable(renderArgs.index);
314
+
286
315
  return (
287
316
  <View key={id} onLayout={onItemLayout}>
288
317
  <Focusable
@@ -305,6 +334,7 @@ function FocusableScrollViewComponent(props: Props, ref) {
305
334
  id={id}
306
335
  disableFocus={shouldDisableFocus(renderArgs?.index)}
307
336
  blockFocus={!isRendered(renderArgs?.index)}
337
+ onSetIsFocusable={onSetIsFocusable}
308
338
  {...focusableItemProps}
309
339
  >
310
340
  {(focused, parentFocus, parentRef) => (
@@ -319,7 +349,7 @@ function FocusableScrollViewComponent(props: Props, ref) {
319
349
  isReadyToRender={isReadyToRender}
320
350
  onLoadFinished={onLoadFinished(renderArgs.index)}
321
351
  onLoadFailed={onLoadFailed(renderArgs.index)}
322
- setIsFocusable={setIsFocusable(renderArgs.index)}
352
+ setIsFocusable={onSetIsFocusable}
323
353
  />
324
354
  )}
325
355
  </Focusable>
@@ -1,9 +1,5 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet } from "react-native";
3
- import { ScreenLayoutContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenLayoutContext";
4
- import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
5
- import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
6
- import { useScreenConfiguration } from "../../River/useScreenConfiguration";
2
+ import { StyleSheet, View } from "react-native";
7
3
 
8
4
  type Props = {
9
5
  children: React.ReactNode;
@@ -12,33 +8,33 @@ type Props = {
12
8
  };
13
9
 
14
10
  const styles = StyleSheet.create({
15
- container: { position: "absolute", top: 0, zIndex: 10, width: 1920 },
11
+ container: {
12
+ position: "absolute",
13
+ top: 0,
14
+ zIndex: 10,
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,
23
+ },
16
24
  });
17
25
 
18
26
  export const NavBarContainer = ({ children, isVisible, onReady }: Props) => {
19
- const screenLayout = React.useContext(ScreenLayoutContext);
20
- const screenMarginTop = screenLayout?.screenMarginTop || 0;
21
- const screen = useCurrentScreenData();
22
- const screenConfig = useScreenConfiguration(screen?.id);
23
-
24
- const themeStyles = React.useMemo(
25
- () => ({
26
- // limits the height of the focusable container of the TopMenuBarTV component
27
- // to prevent it from being overlapped by the screen content,
28
- // as it makes TopMenuBarTV unfocusable on tvOS
29
- maxHeight: ifEmptyUseFallback(screenConfig?.marginTop, screenMarginTop),
30
- }),
31
- [screenLayout, screenConfig]
32
- );
33
-
34
27
  React.useEffect(() => {
35
28
  setTimeout(() => {
36
29
  onReady?.(true);
37
30
  }, 0);
38
- }, []);
31
+ }, [onReady]);
39
32
 
40
33
  return isVisible ? (
41
- <View testID="nav-bar-container" style={[styles.container, themeStyles]}>
34
+ <View
35
+ testID="nav-bar-container"
36
+ style={[styles.container, styles.themeStyles]}
37
+ >
42
38
  {children}
43
39
  </View>
44
40
  ) : null;
@@ -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;
@@ -38,22 +38,16 @@ 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
52
47
  style={style as ImageStyle}
53
- onError={() => setErrorState(true)}
54
- source={
55
- shouldRenderImg ? withDimensions(source) : defaultPlaceHolderImage
56
- }
48
+ onError={React.useCallback(() => setErrorState(true), [])}
49
+ // as we have defaults as "" for placeholder image, we need to pass undefined to source to not throw warnings
50
+ source={_source?.uri ? _source : undefined}
57
51
  {...R.omit(["source"], otherProps)}
58
52
  />
59
53
  );
@@ -0,0 +1,93 @@
1
+ import { ImageBorderContainer } from "../index";
2
+ import { getImageContainerMarginStyles } from "@applicaster/zapp-react-native-utils/cellUtils";
3
+
4
+ const mockValue = (key) => {
5
+ const values = {
6
+ cell_padding_top: 1,
7
+ cell_padding_left: 2,
8
+ cell_padding_right: 3,
9
+ cell_padding_bottom: 4,
10
+ image_border_size: 5,
11
+ image_focused_border_color: "red",
12
+ image_selected_border_color: "blue",
13
+ image_focused_selected_border_color: "green",
14
+ image_border_color: "black",
15
+ image_corner_radius: 10,
16
+ image_border_position: "outside",
17
+ image_border_padding_top: 6,
18
+ image_border_padding_right: 7,
19
+ image_border_padding_bottom: 8,
20
+ image_border_padding_left: 9,
21
+ image_margin_top: 11,
22
+ image_margin_left: 12,
23
+ image_margin_right: 13,
24
+ image_margin_bottom: 14,
25
+ };
26
+
27
+ return values[key] || 0;
28
+ };
29
+
30
+ describe("ImageBorderContainer", () => {
31
+ it("calculates style properties correctly", () => {
32
+ const marginStyles = getImageContainerMarginStyles({ value: mockValue });
33
+
34
+ expect(marginStyles.marginTop).toBe(11);
35
+ expect(marginStyles.marginLeft).toBe(12);
36
+ expect(marginStyles.marginRight).toBe(13);
37
+ expect(marginStyles.marginBottom).toBe(14);
38
+
39
+ const props = {
40
+ value: mockValue,
41
+ state: "default",
42
+ imageStyles: {},
43
+ };
44
+
45
+ const result = ImageBorderContainer(props);
46
+
47
+ expect(result.style.marginTop).toBe(12); // 11 + 1
48
+ expect(result.style.marginLeft).toBe(14); // 12 + 2
49
+ expect(result.style.marginRight).toBe(16); // 13 + 3
50
+ expect(result.style.marginBottom).toBe(18); // 14 + 4
51
+ expect(result.style.borderWidth).toBe(5);
52
+ expect(result.style.borderColor).toBe("black");
53
+ expect(result.style.borderRadius).toBe(10);
54
+ expect(result.additionalProps.borderPosition).toBe("outside");
55
+ expect(result.additionalProps.borderPaddingTop).toBe(6);
56
+ expect(result.additionalProps.borderPaddingRight).toBe(7);
57
+ expect(result.additionalProps.borderPaddingBottom).toBe(8);
58
+ expect(result.additionalProps.borderPaddingLeft).toBe(9);
59
+ });
60
+
61
+ it("handles focused state correctly", () => {
62
+ const props = {
63
+ value: mockValue,
64
+ state: "focused",
65
+ imageStyles: {},
66
+ };
67
+
68
+ const result = ImageBorderContainer(props);
69
+ expect(result.style.borderColor).toBe("red");
70
+ });
71
+
72
+ it("handles selected state correctly", () => {
73
+ const props = {
74
+ value: mockValue,
75
+ state: "selected",
76
+ imageStyles: {},
77
+ };
78
+
79
+ const result = ImageBorderContainer(props);
80
+ expect(result.style.borderColor).toBe("blue");
81
+ });
82
+
83
+ it("handles focused and selected state correctly", () => {
84
+ const props = {
85
+ value: mockValue,
86
+ state: "focused_selected",
87
+ imageStyles: {},
88
+ };
89
+
90
+ const result = ImageBorderContainer(props);
91
+ expect(result.style.borderColor).toBe("green");
92
+ });
93
+ });
@@ -244,7 +244,7 @@ const LiveImageComponent = (props: LiveImageProps) => {
244
244
  return (
245
245
  <>
246
246
  <Image {...props} applyMaxSize />
247
- {isShouldRender && (
247
+ {isShouldRender ? (
248
248
  <View style={[style, positionAbsolute]}>
249
249
  <PlayerLiveImage
250
250
  uri={props.uri}
@@ -257,7 +257,7 @@ const LiveImageComponent = (props: LiveImageProps) => {
257
257
  audioMutedByDefault={audio_muted_by_default}
258
258
  />
259
259
  </View>
260
- )}
260
+ ) : null}
261
261
  </>
262
262
  );
263
263
  };
@@ -17,7 +17,7 @@ const SECONDARY_IMAGE_PREFIX = "secondary_image";
17
17
 
18
18
  type ImageSizing = typeof IMAGE_SIZING_FIT | typeof IMAGE_SIZING_FILL;
19
19
 
20
- type ImagePosition = typeof IMAGE_POSITION[keyof typeof IMAGE_POSITION];
20
+ type ImagePosition = (typeof IMAGE_POSITION)[keyof typeof IMAGE_POSITION];
21
21
 
22
22
  export type DisplayMode =
23
23
  | typeof DISPLAY_MODE_FIXED
@@ -39,6 +39,6 @@ describe("image with no source", () => {
39
39
  );
40
40
 
41
41
  const testInstance = testRenderer.root;
42
- expect(testInstance.findByType(Image).props.source).toEqual({ uri: "" });
42
+ expect(testInstance.findByType(Image).props.source).toBeUndefined();
43
43
  });
44
44
  });
@@ -34,7 +34,6 @@ export const useFillInPercent = (entry: ZappEntry): number => {
34
34
  React.useState<number>(DEFAULT_FILL);
35
35
 
36
36
  React.useEffect(() => {
37
- // setup progress in UI on mount
38
37
  getProgressValue(action, entry, (progress) => {
39
38
  setFillInPercent(progress);
40
39
  });
@@ -45,17 +44,12 @@ export const useFillInPercent = (entry: ZappEntry): number => {
45
44
  return;
46
45
  }
47
46
 
48
- // refresh progress in UI when it was changed in CW
49
- const unsubscribe = action?.addDataSourceListener?.(() => {
47
+ return action?.addDataSourceListener?.(() => {
50
48
  getProgressValue(action, entry, (progress) => {
51
49
  setFillInPercent(progress);
52
50
  });
53
51
  });
54
-
55
- return () => {
56
- unsubscribe?.();
57
- };
58
- }, [isActive]);
52
+ }, [isActive, action, entry, setFillInPercent]);
59
53
 
60
54
  return fillInPercent;
61
55
  };