@applicaster/zapp-react-native-ui-components 11.0.0-rc.99 → 12.0.0-alpha.5643066061

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 (54) hide show
  1. package/Components/BaseFocusable/index.ios.ts +1 -1
  2. package/Components/Cell/Cell.tsx +5 -13
  3. package/Components/Cell/{CellWithFocusable.js → CellWithFocusable.tsx} +13 -11
  4. package/Components/Cell/TvOSCellComponent.tsx +12 -10
  5. package/Components/FastImage/index.ios.js +3 -0
  6. package/Components/Focusable/FocusableTvOS.tsx +4 -1
  7. package/Components/FocusableCell/{index.js → index.tsx} +8 -5
  8. package/Components/FocusableGroup/FocusableTvOS.tsx +2 -2
  9. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +13 -8
  10. package/Components/HandlePlayable/HandlePlayable.tsx +2 -2
  11. package/Components/HookRenderer/HookRenderer.tsx +9 -6
  12. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  13. package/Components/Layout/TV/index.tsx +9 -13
  14. package/Components/Layout/index.tsx +9 -1
  15. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +3 -1
  16. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +22 -19
  17. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +1 -0
  18. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +4 -1
  19. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +2 -0
  20. package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -3
  21. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/CollapsibleTextContainer.tsx +9 -3
  22. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +7 -1
  23. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +12 -4
  24. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +23 -9
  25. package/Components/MasterCell/hoc/withAsyncRender.tsx +8 -4
  26. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +12 -6
  27. package/Components/MasterCell/hooks/useAsyncRendering/__tests__/MasterCellAsyncRenderManager.test.ts +21 -0
  28. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +15 -13
  29. package/Components/MasterCell/utils/index.ts +143 -19
  30. package/Components/PlayerContainer/PlayerContainer.tsx +10 -6
  31. package/Components/River/ComponentsMap/ComponentsMap.tsx +4 -1
  32. package/Components/River/River.tsx +3 -4
  33. package/Components/River/TV/River.tsx +9 -4
  34. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -0
  35. package/Components/River/index.tsx +3 -1
  36. package/Components/Screen/__tests__/Screen.test.tsx +6 -3
  37. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -0
  38. package/Components/Screen/index.tsx +12 -44
  39. package/Components/Screen/navigationHandler.ts +1 -1
  40. package/Components/Spinner/SpinnerComponent.tsx +6 -2
  41. package/Components/VideoLive/LiveImageManager.ts +24 -9
  42. package/Components/VideoLive/PlayerLiveImageComponent.tsx +23 -1
  43. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +74 -0
  44. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +47 -0
  45. package/Components/VideoLive/__tests__/utils.test.ts +109 -0
  46. package/Components/VideoLive/utils.ts +40 -0
  47. package/Components/VideoModal/PlayerDetails.tsx +42 -6
  48. package/Components/VideoModal/PlayerWrapper.tsx +32 -29
  49. package/Components/VideoModal/VideoModal.tsx +20 -17
  50. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +21 -9
  51. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +14 -24
  52. package/Contexts/InteractionManagerContext/index.ts +0 -2
  53. package/Contexts/ScreenContext/index.tsx +118 -0
  54. package/package.json +5 -5
@@ -9,7 +9,7 @@ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
9
9
  type Props = {
10
10
  initialFocus?: boolean;
11
11
  id: string;
12
- groupId?: string;
12
+ groupId: string;
13
13
  preferredFocus?: boolean;
14
14
  onRegister?: (focusable: FocusManager.TouchableRef) => void;
15
15
  onUnregister?: (focusable: FocusManager.TouchableRef) => void;
@@ -11,7 +11,6 @@ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
11
11
 
12
12
  import { CellWithFocusable } from "./CellWithFocusable";
13
13
  import { BaseFocusable } from "../BaseFocusable";
14
- import { getCellState } from "./utils";
15
14
 
16
15
  type Props = {
17
16
  item: {
@@ -32,7 +31,7 @@ type Props = {
32
31
  component: {
33
32
  id: string;
34
33
  };
35
- selected: boolean;
34
+ selected?: boolean;
36
35
  CellRenderer: React.ComponentType<{
37
36
  item: any;
38
37
  state: string;
@@ -64,6 +63,7 @@ type Props = {
64
63
  isFocusable: boolean;
65
64
  skipFocusManagerRegistration?: boolean;
66
65
  shouldUpdate: boolean;
66
+ behavior: Behavior;
67
67
  };
68
68
 
69
69
  const baseCellStyles = {
@@ -80,7 +80,6 @@ const touchableStyles = {
80
80
  export class CellComponent extends React.Component<Props> {
81
81
  constructor(props) {
82
82
  super(props);
83
-
84
83
  this.onPress = this.onPress.bind(this);
85
84
  this.onFocus = this.onFocus.bind(this);
86
85
  this.onBlur = this.onBlur.bind(this);
@@ -182,14 +181,6 @@ export class CellComponent extends React.Component<Props> {
182
181
  };
183
182
  }
184
183
 
185
- getCellState(_focused) {
186
- const { selected } = this.props;
187
-
188
- const focused = this.props.focused || _focused;
189
-
190
- return getCellState({ focused, selected });
191
- }
192
-
193
184
  isCellFocused(focusableFocused) {
194
185
  const { focused, isFocusable = true } = this.props;
195
186
 
@@ -211,6 +202,7 @@ export class CellComponent extends React.Component<Props> {
211
202
  groupId,
212
203
  isFocusable = true,
213
204
  skipFocusManagerRegistration,
205
+ behavior
214
206
  } = this.props;
215
207
 
216
208
  const { id } = item;
@@ -220,7 +212,6 @@ export class CellComponent extends React.Component<Props> {
220
212
  const handleFocus = (focusable, mouse) => {
221
213
  const focusFn = onFocus || noop;
222
214
  focusFn(focusable, mouse);
223
-
224
215
  this.onFocus(focusable, mouse);
225
216
  };
226
217
 
@@ -238,6 +229,7 @@ export class CellComponent extends React.Component<Props> {
238
229
  scrollTo={this.scrollToIndex()}
239
230
  isFocusable={isFocusable}
240
231
  skipFocusManagerRegistration={skipFocusManagerRegistration}
232
+ behavior={behavior}
241
233
  />
242
234
  );
243
235
  }
@@ -271,7 +263,7 @@ export class CellComponent extends React.Component<Props> {
271
263
  item,
272
264
  focused: this.isCellFocused(focused),
273
265
  scrollTo: this.scrollToIndex(event),
274
- cellState: this.getCellState(focused),
266
+ behavior
275
267
  }}
276
268
  />
277
269
  );
@@ -3,10 +3,10 @@ import * as React from "react";
3
3
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
4
4
  import * as FOCUS_EVENTS from "@applicaster/zapp-react-native-utils/appUtils/focusManager/events";
5
5
  import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
6
- import { getCellState } from "./utils";
7
6
  import { isAppleTV } from "../../Helpers/Platform";
7
+ import { useCellState } from "../MasterCell/utils";
8
8
 
9
- const useCellState = (groupId: string, id: string) => {
9
+ const useCellFocusedState = (groupId: string, id: string) => {
10
10
  const [currentCellFocused, setCurrentCellFocused] = React.useState(false);
11
11
 
12
12
  React.useEffect(() => {
@@ -26,15 +26,17 @@ const useCellState = (groupId: string, id: string) => {
26
26
 
27
27
  focusManager.on(FOCUS_EVENTS.FOCUS, handler);
28
28
 
29
- return () => focusManager.removeHandler(FOCUS_EVENTS.FOCUS, handler);
29
+ return () => {
30
+ focusManager.removeHandler(FOCUS_EVENTS.FOCUS, handler);
31
+ };
30
32
  }, [groupId]);
31
33
 
32
34
  return currentCellFocused;
33
35
  };
34
36
 
35
37
  type Props = {
36
- item: {},
37
- CellRenderer: React.componentType<{ item: Object, state: string }>,
38
+ item: ZappEntry,
39
+ CellRenderer: React.ComponentType<{ item: Object, state: string }>,
38
40
  id: string,
39
41
  groupId: string,
40
42
  onFocus: Function,
@@ -43,7 +45,8 @@ type Props = {
43
45
  preferredFocus?: boolean,
44
46
  skipFocusManagerRegistration?: boolean,
45
47
  isFocusable?: boolean,
46
- selected: boolean,
48
+ behavior: Behavior,
49
+ selected?: boolean,
47
50
  };
48
51
 
49
52
  export function CellWithFocusable(props: Props) {
@@ -58,9 +61,12 @@ export function CellWithFocusable(props: Props) {
58
61
  preferredFocus,
59
62
  skipFocusManagerRegistration,
60
63
  isFocusable,
61
- selected,
64
+ behavior,
65
+ selected
62
66
  } = props;
63
67
 
68
+ const isFocused = useCellFocusedState(groupId, id);
69
+ const state = useCellState({ id: item.id, behavior, focused: isFocused, selected });
64
70
  const [focusedButtonId, setFocusedButtonId] = React.useState(undefined);
65
71
 
66
72
  // for horizontal scrolling
@@ -78,10 +84,6 @@ export function CellWithFocusable(props: Props) {
78
84
  }
79
85
  };
80
86
 
81
- const isFocused = useCellState(groupId, id);
82
-
83
- const state = getCellState({ focused: isFocused, selected });
84
-
85
87
  return (
86
88
  <CellRenderer
87
89
  item={item}
@@ -16,10 +16,7 @@ const _getCellState = (focused, selected) =>
16
16
  getCellState({ focused, selected });
17
17
 
18
18
  type Props = {
19
- item: {
20
- id: string;
21
- title: string;
22
- };
19
+ item: ZappEntry;
23
20
  index: number;
24
21
  shouldScrollHorizontally: (
25
22
  focusable: any,
@@ -36,6 +33,7 @@ type Props = {
36
33
  componentId: string;
37
34
  component: {
38
35
  id: number | string;
36
+ component_type: string;
39
37
  };
40
38
  selected: boolean;
41
39
  CellRenderer: React.ComponentType<{
@@ -71,6 +69,7 @@ type Props = {
71
69
  mainOffsetUpdater: (...args: any[]) => void | null | undefined;
72
70
  isFocusable: boolean;
73
71
  shouldUpdate: boolean;
72
+ behavior: Behavior;
74
73
  };
75
74
 
76
75
  type State = {
@@ -192,7 +191,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
192
191
 
193
192
  if (
194
193
  this.props.shouldUpdate &&
195
- shouldScrollVertically?.(focusable, id, title)
194
+ shouldScrollVertically?.(focusable, String(id), String(title))
196
195
  ) {
197
196
  const { headerOffset } = getHeaderOffset();
198
197
 
@@ -228,7 +227,11 @@ export class TvOSCellComponent extends React.Component<Props, State> {
228
227
  hasReceivedFocus() {}
229
228
 
230
229
  scrollTo(index) {
231
- this.props?.scrollToIndex?.(index);
230
+ // Workaround for HL autoscroll/autoloop feature, we scroll manually on tvOS.
231
+ // Should be removed after refactoring autoscroll/autoloop feature
232
+ if (this.props.component?.component_type !== "horizontal_list_qb") {
233
+ this.props?.scrollToIndex?.(index);
234
+ }
232
235
  }
233
236
 
234
237
  render() {
@@ -246,6 +249,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
246
249
  hasReceivedFocus,
247
250
  groupId,
248
251
  isFocusable,
252
+ behavior
249
253
  } = this.props;
250
254
 
251
255
  const { id } = item;
@@ -275,6 +279,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
275
279
  index={index}
276
280
  scrollTo={this.scrollTo}
277
281
  preferredFocus={preferredFocus}
282
+ behavior={behavior}
278
283
  />
279
284
  </View>
280
285
  );
@@ -305,10 +310,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
305
310
  item,
306
311
  focused: this.props.focused || selectedCell || focused,
307
312
  scrollTo: this.scrollTo,
308
- cellState: getCellState({
309
- focused: this.props.focused || focused,
310
- selected,
311
- }),
313
+ behavior
312
314
  }}
313
315
  />
314
316
  );
@@ -0,0 +1,3 @@
1
+ import { Image } from "react-native";
2
+
3
+ export default Image;
@@ -19,7 +19,7 @@ type Props = {
19
19
  onPress?: (nativeEvent: React.SyntheticEvent) => void;
20
20
  onFocus?: (nativeEvent: React.SyntheticEvent) => void;
21
21
  onBlur?: (nativeEvent: React.SyntheticEvent) => void;
22
- children: (focused: boolean) => React.ReactNode;
22
+ children: (focused?: boolean) => React.ReactNode;
23
23
  isParallaxDisabled: boolean;
24
24
  preferredFocus?: boolean;
25
25
  selected?: boolean;
@@ -32,6 +32,9 @@ type Props = {
32
32
  nextTvosFocusRight?: import("react").RefObject<any>;
33
33
  nextTvosFocusUp?: import("react").RefObject<any>;
34
34
  nextTvosFocusDown?: import("react").RefObject<any>;
35
+ forceFocus?: boolean;
36
+ initialFocus?: boolean;
37
+ onLayout?: (e: any) => void;
35
38
  };
36
39
 
37
40
  export class Focusable extends BaseFocusable<Props> {
@@ -1,13 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { Platform } from "react-native";
3
+ import { useCellState } from "../MasterCell/utils";
3
4
 
4
5
  type Props = {
5
6
  index: number,
6
- item: {},
7
+ item: ZappEntry,
7
8
  focused: boolean,
8
9
  scrollTo?: (index: number) => void,
9
- cellState: string,
10
- CellRenderer: React.componentType<{ item: Object, state: string }>,
10
+ CellRenderer: React.ComponentType<{ item: Object, state: string }>,
11
+ behavior: Behavior
11
12
  };
12
13
 
13
14
  const isAndroid = Platform.OS === "android";
@@ -19,14 +20,16 @@ export function FocusableCell(props: Props) {
19
20
  CellRenderer,
20
21
  focused,
21
22
  scrollTo = null,
22
- cellState,
23
+ behavior
23
24
  } = props;
24
25
 
26
+ const state = useCellState({ id: item.id, behavior, focused });
27
+
25
28
  React.useEffect(() => {
26
29
  if (focused && scrollTo && !isAndroid) {
27
30
  scrollTo(index);
28
31
  }
29
32
  }, [focused]);
30
33
 
31
- return <CellRenderer item={item} state={cellState} />;
34
+ return <CellRenderer item={item} state={state} />;
32
35
  }
@@ -76,8 +76,8 @@ export class FocusableGroup extends BaseFocusable<Props> {
76
76
  }
77
77
 
78
78
  onDidUpdateFocus({ nativeEvent }) {
79
- const { onWillUpdateFocus = noop } = this.props;
80
- onWillUpdateFocus(nativeEvent);
79
+ const { onDidUpdateFocus = noop } = this.props;
80
+ onDidUpdateFocus(nativeEvent);
81
81
  }
82
82
 
83
83
  setFocusDisabled(isFocusDisabled) {
@@ -9,6 +9,7 @@ import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
9
9
  import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
10
10
  import { Categories } from "./logger";
11
11
  import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
12
+ import { produce } from "immer";
12
13
  // types reference
13
14
 
14
15
  declare type CurationEntry = { preset_name: string; feed_url: string };
@@ -39,14 +40,18 @@ export const getTransformedPreset = (
39
40
  return;
40
41
  }
41
42
 
42
- return {
43
- ...presetComponent,
44
- id: `${componentId}${index}`,
45
- data: {
46
- ...presetComponent.data,
47
- source: preset?.feed_url,
48
- },
49
- };
43
+ const updatedPresetComponent = produce(presetComponent, (draft) => {
44
+ draft.id = `${componentId}${index}`;
45
+ draft.data.source = preset?.feed_url;
46
+
47
+ if (draft.ui_components) {
48
+ draft.ui_components.forEach((comp, uiIndex) => {
49
+ comp.id = `${draft.id}-${uiIndex}`;
50
+ });
51
+ }
52
+ });
53
+
54
+ return updatedPresetComponent;
50
55
  };
51
56
 
52
57
  export const enrichComponent = (
@@ -93,7 +93,7 @@ export function HandlePlayable({
93
93
  modalHeight,
94
94
  modalWidth,
95
95
  mode,
96
- }: Props) {
96
+ }: Props): React.ReactElement | null {
97
97
  const state = usePickFromState();
98
98
 
99
99
  const { width: screenWidth, height: screenHeight } =
@@ -171,5 +171,5 @@ export function HandlePlayable({
171
171
  );
172
172
  }
173
173
 
174
- return !isModal && <BufferAnimation videoStyle={style as ViewStyle} />;
174
+ return !isModal ? <BufferAnimation videoStyle={style as ViewStyle} /> : null;
175
175
  }
@@ -2,9 +2,10 @@ import * as React from "react";
2
2
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
3
3
  import {
4
4
  useBackHandler,
5
- useNavigation,
5
+ useIsNavBarVisible,
6
6
  } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
7
7
  import { useHookAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks";
8
+ import { useSetNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks";
8
9
 
9
10
  type Props = {
10
11
  focused?: boolean;
@@ -18,6 +19,8 @@ export const HookRenderer = (props: Props) => {
18
19
  screenData: { callback, payload, hookPlugin },
19
20
  } = props;
20
21
 
22
+ const { setVisible: showNavBar } = useSetNavbarState();
23
+
21
24
  const {
22
25
  module: { Component: HookComponent, presentFullScreen },
23
26
  configuration,
@@ -25,7 +28,7 @@ export const HookRenderer = (props: Props) => {
25
28
 
26
29
  useHookAnalytics(props);
27
30
 
28
- const navigator = useNavigation();
31
+ const isNavBarVisible = useIsNavBarVisible();
29
32
 
30
33
  useBackHandler(() => {
31
34
  callback({ success: false, payload, cancelled: true });
@@ -35,18 +38,18 @@ export const HookRenderer = (props: Props) => {
35
38
 
36
39
  React.useEffect(() => {
37
40
  if (presentFullScreen && isTV()) {
38
- navigator.hideNavBar();
41
+ showNavBar(false);
39
42
  }
40
43
 
41
44
  return () => {
42
45
  if (isTV()) {
43
- navigator.showNavBar();
46
+ showNavBar(true);
44
47
  }
45
48
  };
46
- }, []);
49
+ }, [showNavBar]);
47
50
 
48
51
  // Passing empty parentFocus if navbar is not visible (fullScreen hook)
49
- const parentFocus = navigator.isNavBarVisible ? props.parentFocus : {};
52
+ const parentFocus = isNavBarVisible ? props.parentFocus : {};
50
53
 
51
54
  return (
52
55
  <HookComponent
@@ -48,7 +48,7 @@ exports[`Layout TV renders 1`] = `
48
48
  "rules": undefined,
49
49
  "selected": undefined,
50
50
  "styles": undefined,
51
- "title": undefined,
51
+ "title": "",
52
52
  }
53
53
  }
54
54
  testID="nav-bar-component"
@@ -1,9 +1,11 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
3
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
4
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
+ import {
5
+ useIsNavBarVisible,
6
+ useNavigation,
7
+ } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
5
8
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
6
- import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
7
9
 
8
10
  import {
9
11
  getNavigationProps,
@@ -18,9 +20,9 @@ import { ScreenContainer } from "./ScreenContainer";
18
20
  import { TransitionOverlay } from "./TransitionOverlay";
19
21
 
20
22
  import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
21
- import { isNavBarVisible as shouldShowNavBar } from "../../Screen/navigationHandler";
22
23
  import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
23
24
  import { PathnameContext } from "../../../Contexts/PathnameContext";
25
+ import { useNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
24
26
 
25
27
  type Components = {
26
28
  NavBar: React.ComponentType<any>;
@@ -41,8 +43,8 @@ type Props = {
41
43
  const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
42
44
  const navigator = useNavigation();
43
45
  const theme = useTheme();
44
- const { isNavBarVisible, activeRiver, currentRoute } = navigator;
45
- const screenData = useCurrentScreenData();
46
+ const { title } = useNavbarState();
47
+ const { activeRiver, currentRoute } = navigator;
46
48
 
47
49
  const {
48
50
  appState: { appReady = false } = {},
@@ -52,6 +54,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
52
54
 
53
55
  const navigationProps = getNavigationProps({
54
56
  navigator,
57
+ title,
55
58
  category: "menu",
56
59
  });
57
60
 
@@ -77,14 +80,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
77
80
  []
78
81
  );
79
82
 
80
- const navBarVisible = React.useMemo(() => {
81
- return shouldShowNavBar(
82
- currentRoute,
83
- screenData,
84
- isNavBarVisible && !routeIsPlayerScreen(currentRoute),
85
- navigator.canGoBack()
86
- );
87
- }, [isNavBarVisible, currentRoute, screenData?.id, navigator.key]);
83
+ const navBarVisible = useIsNavBarVisible();
88
84
 
89
85
  const [navBarReady, setNavBarReady] = React.useState(false);
90
86
 
@@ -1,12 +1,20 @@
1
1
  import * as React from "react";
2
2
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
3
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
+ import { ScreenContextProvider } from "../../Contexts/ScreenContext";
3
5
 
4
6
  import Mobile from "./Mobile";
5
7
  import TV from "./TV";
6
8
 
7
9
  export default function Layout(props) {
10
+ const { currentRoute: pathname } = useNavigation();
11
+
8
12
  if (isTV()) {
9
- return <TV {...props} />;
13
+ return (
14
+ <ScreenContextProvider pathname={pathname}>
15
+ <TV {...props} />
16
+ </ScreenContextProvider>
17
+ );
10
18
  } else {
11
19
  return <Mobile {...props} />;
12
20
  }
@@ -103,7 +103,9 @@ const InsideBorder = ({
103
103
  };
104
104
 
105
105
  export const BorderContainerView = (props: Props) => {
106
- const { borderPosition = "outside", style, children } = props;
106
+ const { style, children } = props;
107
+ // Return border position prop after re-implementing
108
+ const borderPosition = "outside";
107
109
 
108
110
  const borderWidth = toNumberWithDefaultZero(style.borderWidth);
109
111
  const spacing = getContainerPadding(borderPosition, borderWidth);
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
- import { Platform, View } from "react-native";
3
+ import { Platform, View, ViewStyle } from "react-native";
4
4
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
5
5
  import { isTV, isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
6
6
  import { PlayerLiveImage } from "../../../VideoLive/PlayerLiveImageComponent";
@@ -173,6 +173,8 @@ const getPlayerConfig = (player_screen_id, actionIdentifier) => {
173
173
  return { playerPluginId: actionIdentifier };
174
174
  };
175
175
 
176
+ const positionAbsolute: ViewStyle = { position: "absolute" };
177
+
176
178
  const LiveImageComponent = (props: LiveImageProps) => {
177
179
  const { item, style, cellUUID, imageKey, actionIdentifier, state } = props;
178
180
 
@@ -185,7 +187,7 @@ const LiveImageComponent = (props: LiveImageProps) => {
185
187
 
186
188
  const {
187
189
  id: componentId,
188
- rules: { player_screen_id, audio_muted_by_default },
190
+ rules: { player_screen_id, audio_muted_by_default = false },
189
191
  } = component;
190
192
 
191
193
  const isCurrentlyFocused = useTrackCurrentAutoScrollingElement(componentId);
@@ -205,23 +207,24 @@ const LiveImageComponent = (props: LiveImageProps) => {
205
207
  cellUUID &&
206
208
  isSupportedTVForLiveImage();
207
209
 
208
- if (isShouldRender) {
209
- return (
210
- <View style={style}>
211
- <PlayerLiveImage
212
- playerId={cellUUID}
213
- playerPluginId={playerPluginId}
214
- screenConfig={screenConfig}
215
- style={style}
216
- imageKey={imageKey}
217
- item={playableEntry}
218
- audioMutedByDefault={audio_muted_by_default}
219
- />
220
- </View>
221
- );
222
- }
223
-
224
- return <Image {...props} />;
210
+ return (
211
+ <>
212
+ <Image {...props} />
213
+ {isShouldRender && (
214
+ <View style={[style, positionAbsolute]}>
215
+ <PlayerLiveImage
216
+ playerId={cellUUID}
217
+ playerPluginId={playerPluginId}
218
+ screenConfig={screenConfig}
219
+ style={style}
220
+ imageKey={imageKey}
221
+ item={playableEntry}
222
+ audioMutedByDefault={audio_muted_by_default}
223
+ />
224
+ </View>
225
+ )}
226
+ </>
227
+ );
225
228
  };
226
229
 
227
230
  export const LiveImage = React.memo<LiveImageProps>(LiveImageComponent);
@@ -71,6 +71,7 @@ const SecondaryImageComponent = (props: Props) => {
71
71
  containerHeight,
72
72
  containerWidth,
73
73
  }),
74
+ borderRadius: style.borderRadius,
74
75
  aspectRatio: imageDimension.aspectRatio,
75
76
  }}
76
77
  />
@@ -15,7 +15,10 @@ describe("SecondaryImage - Image", () => {
15
15
 
16
16
  it("SecondaryImage should render if known dimensions", async () => {
17
17
  const wrapper = await render(
18
- <SecondaryImage uri="" style={{ width: 100, height: 100 }} />
18
+ <SecondaryImage
19
+ uri=""
20
+ style={{ width: 100, height: 100, borderRadius: 10 }}
21
+ />
19
22
  );
20
23
 
21
24
  expect(wrapper.toJSON()).not.toEqual(null);
@@ -7,6 +7,7 @@ exports[`SecondaryImage - Image SecondaryImage should render if known dimensions
7
7
  onLayout={[Function]}
8
8
  style={
9
9
  Object {
10
+ "borderRadius": 10,
10
11
  "height": 100,
11
12
  "width": 100,
12
13
  }
@@ -22,6 +23,7 @@ exports[`SecondaryImage - Image SecondaryImage should render if known dimensions
22
23
  style={
23
24
  Object {
24
25
  "aspectRatio": 1,
26
+ "borderRadius": 10,
25
27
  "height": 100,
26
28
  "width": 100,
27
29
  }
@@ -9,10 +9,11 @@ type Props = {
9
9
  type?: string;
10
10
  };
11
11
  style: Styles;
12
+ cellState: CellState;
12
13
  };
13
14
 
14
15
  export const Toggle = (props: Props) => {
15
- const { style, item, action } = props;
16
+ const { style, item, action, cellState } = props;
16
17
 
17
18
  const {
18
19
  trackColor,
@@ -22,6 +23,7 @@ export const Toggle = (props: Props) => {
22
23
  iosBackgroundColor,
23
24
  } = style;
24
25
 
26
+ const isSelected = React.useMemo(() => (cellState === "selected"), [item?.id, cellState]);
25
27
  const actionContext = useActions(action?.identifier);
26
28
 
27
29
  const [actionState, setActionState] = useState(
@@ -37,10 +39,10 @@ export const Toggle = (props: Props) => {
37
39
  return (
38
40
  <Switch
39
41
  trackColor={{ false: trackColor, true: trackColorActive }}
40
- thumbColor={actionState?.state ? thumbColorActive : thumbColor}
42
+ thumbColor={isSelected ? thumbColorActive : thumbColor}
41
43
  ios_backgroundColor={iosBackgroundColor}
42
44
  onValueChange={onPress}
43
- value={!!actionState?.state}
45
+ value={isSelected}
44
46
  />
45
47
  );
46
48
  };