@applicaster/zapp-react-native-ui-components 14.0.0-alpha.6931095759 → 14.0.0-alpha.7104619551

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 (32) hide show
  1. package/Components/AudioPlayer/AudioPlayer.tsx +2 -2
  2. package/Components/AudioPlayer/AudioPlayerLayout.tsx +10 -11
  3. package/Components/AudioPlayer/Runtime.tsx +2 -1
  4. package/Components/AudioPlayer/Summary.tsx +12 -9
  5. package/Components/AudioPlayer/Title.tsx +12 -9
  6. package/Components/AudioPlayer/__tests__/__snapshots__/Runtime.test.js.snap +2 -2
  7. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +6 -0
  8. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +6 -0
  9. package/Components/AudioPlayer/__tests__/__snapshots__/summary.test.js.snap +1 -1
  10. package/Components/AudioPlayer/__tests__/__snapshots__/title.test.js.snap +1 -1
  11. package/Components/AudioPlayer/helpers.tsx +2 -2
  12. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +0 -2
  13. package/Components/MasterCell/DefaultComponents/Text/index.tsx +1 -0
  14. package/Components/PlayerContainer/PlayerContainer.tsx +19 -7
  15. package/Components/River/ComponentsMap/ComponentsMap.tsx +1 -5
  16. package/Components/River/RiverItem.tsx +8 -8
  17. package/Components/River/TV/River.tsx +0 -3
  18. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +0 -6
  19. package/Components/TopMarginApplicator/TopMarginApplicator.tsx +16 -15
  20. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +9 -1
  21. package/Components/VideoModal/PlayerDetails.tsx +24 -2
  22. package/Components/VideoModal/PlayerWrapper.tsx +26 -142
  23. package/Components/VideoModal/VideoModal.tsx +3 -17
  24. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -7
  25. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -180
  26. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +17 -55
  27. package/Components/VideoModal/hooks/index.ts +0 -2
  28. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +15 -26
  29. package/Components/VideoModal/utils.ts +6 -0
  30. package/index.d.ts +0 -1
  31. package/package.json +5 -5
  32. package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
@@ -52,7 +52,7 @@ type Props = {
52
52
  };
53
53
 
54
54
  export function AudioPlayer(props: Props) {
55
- const { audio_item, plugin_configuration, style } = props;
55
+ const { audio_item, plugin_configuration } = props;
56
56
  const { extensions, title, summary } = audio_item;
57
57
 
58
58
  const getProp = useCallback(
@@ -164,7 +164,7 @@ export function AudioPlayer(props: Props) {
164
164
  ]);
165
165
 
166
166
  return (
167
- <AudioPlayerLayout artwork={artwork} config={config} style={style || {}}>
167
+ <AudioPlayerLayout artwork={artwork} config={config}>
168
168
  <Channel srcImage={config?.channelIcon} config={config} />
169
169
  <Title title={title} config={config} />
170
170
  <Summary summary={summary} config={config} />
@@ -1,5 +1,5 @@
1
1
  import React, { useRef } from "react";
2
- import { View, ImageBackground, Animated, ViewStyle } from "react-native";
2
+ import { View, ImageBackground, Animated } from "react-native";
3
3
 
4
4
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
5
 
@@ -17,10 +17,9 @@ type Props = {
17
17
  artworkBorderRadius: Option<number>;
18
18
  };
19
19
  children: React.ReactNode;
20
- style: ViewStyle;
21
20
  };
22
21
 
23
- export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
22
+ export function AudioPlayerLayout({ artwork, config, children }: Props) {
24
23
  const fadeAnimation = useRef(new Animated.Value(0)).current;
25
24
 
26
25
  const fadeAudioPlayerIn = () => {
@@ -33,25 +32,24 @@ export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
33
32
 
34
33
  const { isRTL, backgroundColor, backgroundImage } = config;
35
34
 
36
- const backgroundImageSource = { uri: backgroundImage };
35
+ const backgroundImageSource = { uri: backgroundImage || artwork };
37
36
 
38
- const backgroundColorStyle = backgroundImage
37
+ const backgroundColorStyle = backgroundImageSource.uri
39
38
  ? "transparent"
40
39
  : backgroundColor;
41
40
 
42
41
  const mainContainerStyles = platformSelect({
43
42
  tvos: {
44
- width: 1920,
45
- height: 1080,
43
+ width: "100%",
44
+ height: "100%",
46
45
  alignItems: "center",
47
46
  justifyContent: "center",
48
47
  flexDirection: directionStyles(isRTL).flexDirection,
49
48
  backgroundColor: backgroundColorStyle,
50
49
  },
51
50
  android_tv: {
52
- position: "absolute",
53
- width: 1920,
54
- height: 1080,
51
+ width: "100%",
52
+ height: "100%",
55
53
  alignItems: "center",
56
54
  justifyContent: "center",
57
55
  flexDirection: directionStyles(isRTL).flexDirection,
@@ -68,7 +66,8 @@ export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
68
66
  native: {
69
67
  backgroundColor: backgroundColorStyle,
70
68
  overflow: "hidden",
71
- ...style,
69
+ width: "100%",
70
+ height: "100%",
72
71
  },
73
72
  samsung_tv: {
74
73
  position: "absolute",
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { View, Text, ViewStyle, TextStyle } from "react-native";
3
+ import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
3
4
  import { directionStyles } from "./helpers";
4
5
 
5
6
  type Props = {
@@ -31,7 +32,7 @@ const textStyles = ({
31
32
  }) => ({
32
33
  color: summaryColor,
33
34
  opacity: 0.8,
34
- fontSize: runTimeFontSize ? Number(runTimeFontSize) : 20,
35
+ fontSize: toNumberWithDefault(20, runTimeFontSize),
35
36
  fontFamily: runTimeFontFamily || null,
36
37
  ...directionStyles(isRTL),
37
38
  });
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { View, Text, TextStyle } from "react-native";
2
+ import { View, Text, TextStyle, StyleSheet } from "react-native";
3
+ import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
3
4
 
4
5
  type Props = {
5
6
  config: {
@@ -14,11 +15,13 @@ type Props = {
14
15
  summary: string | number;
15
16
  };
16
17
 
17
- const containerStyles = {
18
- width: 600,
19
- height: 80,
20
- marginBottom: 30,
21
- };
18
+ const styles = StyleSheet.create({
19
+ container: {
20
+ width: 600,
21
+ height: 80,
22
+ marginBottom: 30,
23
+ },
24
+ });
22
25
 
23
26
  const textStyles = ({
24
27
  summaryColor,
@@ -26,8 +29,8 @@ const textStyles = ({
26
29
  summaryFontFamily,
27
30
  summaryFontSize,
28
31
  }) => ({
29
- textAlign: (isRTL ? "left" : "right") as TextStyle["textAlign"],
30
- fontSize: summaryFontSize ? Number(summaryFontSize) : 20,
32
+ textAlign: (isRTL ? "right" : "left") as TextStyle["textAlign"],
33
+ fontSize: toNumberWithDefault(20, summaryFontSize),
31
34
  color: summaryColor,
32
35
  fontWeight: "600" as TextStyle["fontWeight"],
33
36
  opacity: 0.8,
@@ -36,7 +39,7 @@ const textStyles = ({
36
39
 
37
40
  export function Summary({ summary, config }: Props) {
38
41
  return (
39
- <View style={containerStyles}>
42
+ <View style={styles.container}>
40
43
  <Text style={textStyles(config)} numberOfLines={2}>
41
44
  {summary}
42
45
  </Text>
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { View, Text, TextStyle } from "react-native";
2
+ import { View, Text, TextStyle, StyleSheet } from "react-native";
3
+ import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
3
4
 
4
5
  type Props = {
5
6
  config: {
@@ -14,15 +15,17 @@ type Props = {
14
15
  title: string | number;
15
16
  };
16
17
 
17
- const containerStyles = {
18
- width: 600,
19
- height: 100,
20
- marginBottom: 12,
21
- };
18
+ const styles = StyleSheet.create({
19
+ container: {
20
+ width: 600,
21
+ height: 100,
22
+ marginBottom: 12,
23
+ },
24
+ });
22
25
 
23
26
  const textStyles = ({ titleColor, isRTL, titleFontFamily, titleFontSize }) => ({
24
- textAlign: (isRTL ? "left" : "right") as TextStyle["textAlign"],
25
- fontSize: titleFontSize ? Number(titleFontSize) : 38,
27
+ textAlign: (isRTL ? "right" : "left") as TextStyle["textAlign"],
28
+ fontSize: toNumberWithDefault(38, titleFontSize),
26
29
  fontWeight: "600" as TextStyle["fontWeight"],
27
30
  color: titleColor,
28
31
  fontFamily: titleFontFamily || null,
@@ -30,7 +33,7 @@ const textStyles = ({ titleColor, isRTL, titleFontFamily, titleFontSize }) => ({
30
33
 
31
34
  export function Title({ title, config }: Props) {
32
35
  return (
33
- <View style={containerStyles}>
36
+ <View style={styles.container}>
34
37
  <Text style={textStyles(config)} numberOfLines={2}>
35
38
  {title}
36
39
  </Text>
@@ -20,7 +20,7 @@ exports[`<Runtime /> LTR renders correctly 1`] = `
20
20
  "fontSize": 20,
21
21
  "justifyContent": "flex-start",
22
22
  "opacity": 0.8,
23
- "textAlign": "right",
23
+ "textAlign": "left",
24
24
  }
25
25
  }
26
26
  >
@@ -49,7 +49,7 @@ exports[`<Runtime /> RTL renders correctly 1`] = `
49
49
  "fontSize": 20,
50
50
  "justifyContent": "flex-end",
51
51
  "opacity": 0.8,
52
- "textAlign": "left",
52
+ "textAlign": "right",
53
53
  }
54
54
  }
55
55
  >
@@ -6,7 +6,9 @@ exports[`<AudioPlayer /> renders correctly 1`] = `
6
6
  style={
7
7
  {
8
8
  "backgroundColor": "transparent",
9
+ "height": "100%",
9
10
  "overflow": "hidden",
11
+ "width": "100%",
10
12
  }
11
13
  }
12
14
  >
@@ -15,8 +17,10 @@ exports[`<AudioPlayer /> renders correctly 1`] = `
15
17
  style={
16
18
  {
17
19
  "backgroundColor": "transparent",
20
+ "height": "100%",
18
21
  "opacity": 0,
19
22
  "overflow": "hidden",
23
+ "width": "100%",
20
24
  }
21
25
  }
22
26
  >
@@ -56,7 +60,9 @@ exports[`<AudioPlayer /> renders correctly 1`] = `
56
60
  style={
57
61
  {
58
62
  "backgroundColor": "transparent",
63
+ "height": "100%",
59
64
  "overflow": "hidden",
65
+ "width": "100%",
60
66
  }
61
67
  }
62
68
  />
@@ -6,7 +6,9 @@ exports[`<AudioPlayerLayout /> renders correctly 1`] = `
6
6
  style={
7
7
  {
8
8
  "backgroundColor": "transparent",
9
+ "height": "100%",
9
10
  "overflow": "hidden",
11
+ "width": "100%",
10
12
  }
11
13
  }
12
14
  >
@@ -15,8 +17,10 @@ exports[`<AudioPlayerLayout /> renders correctly 1`] = `
15
17
  style={
16
18
  {
17
19
  "backgroundColor": "transparent",
20
+ "height": "100%",
18
21
  "opacity": 0,
19
22
  "overflow": "hidden",
23
+ "width": "100%",
20
24
  }
21
25
  }
22
26
  >
@@ -56,7 +60,9 @@ exports[`<AudioPlayerLayout /> renders correctly 1`] = `
56
60
  style={
57
61
  {
58
62
  "backgroundColor": "transparent",
63
+ "height": "100%",
59
64
  "overflow": "hidden",
65
+ "width": "100%",
60
66
  }
61
67
  }
62
68
  />
@@ -19,7 +19,7 @@ exports[`<Summary /> renders correctly 1`] = `
19
19
  "fontSize": 20,
20
20
  "fontWeight": "600",
21
21
  "opacity": 0.8,
22
- "textAlign": "left",
22
+ "textAlign": "right",
23
23
  }
24
24
  }
25
25
  >
@@ -18,7 +18,7 @@ exports[`<Title /> renders correctly 1`] = `
18
18
  "fontFamily": null,
19
19
  "fontSize": 38,
20
20
  "fontWeight": "600",
21
- "textAlign": "left",
21
+ "textAlign": "right",
22
22
  }
23
23
  }
24
24
  >
@@ -26,14 +26,14 @@ export function getPropertyFromEntryOrConfig({ entry, plugin_configuration }) {
26
26
  const LTR = {
27
27
  flexDirection: "row",
28
28
  justifyContent: "flex-start",
29
- textAlign: "right",
29
+ textAlign: "left",
30
30
  alignItems: "flex-end",
31
31
  };
32
32
 
33
33
  const RTL = {
34
34
  flexDirection: "row-reverse",
35
35
  justifyContent: "flex-end",
36
- textAlign: "left",
36
+ textAlign: "right",
37
37
  alignItems: "flex-start",
38
38
  };
39
39
 
@@ -30,7 +30,6 @@ export const GeneralContentScreen = ({
30
30
  isScreenWrappedInContainer,
31
31
  componentsMapExtraProps = {},
32
32
  focused,
33
- extraOffset,
34
33
  parentFocus,
35
34
  containerHeight,
36
35
  preferredFocus = false,
@@ -122,7 +121,6 @@ export const GeneralContentScreen = ({
122
121
  isScreenWrappedInContainer={isScreenWrappedInContainer}
123
122
  parentFocus={parentFocus}
124
123
  focused={focused}
125
- extraOffset={extraOffset}
126
124
  containerHeight={containerHeight}
127
125
  preferredFocus={preferredFocus}
128
126
  {...componentsMapExtraProps}
@@ -52,6 +52,7 @@ const _Text = ({
52
52
  withScaledLineHeight(withFocusedStyles({ style, otherProps })),
53
53
  { height },
54
54
  ]}
55
+ allowFontScaling={false}
55
56
  {...withoutLabel(otherProps)}
56
57
  >
57
58
  {dateTransformEnabled
@@ -88,7 +88,7 @@ export const VideoModalMode = {
88
88
  MAXIMIZED: "MAXIMIZED",
89
89
  MINIMIZED: "MINIMIZED",
90
90
  FULLSCREEN: "FULLSCREEN",
91
- };
91
+ } as const;
92
92
 
93
93
  export type PlayNextData = {
94
94
  state: PlayNextState;
@@ -127,7 +127,7 @@ const webStyles = {
127
127
  playerScreen: {
128
128
  flex: 1,
129
129
  height: "100vh",
130
- background: "black",
130
+ backgroundColor: "black",
131
131
  },
132
132
  playerWrapper: {
133
133
  height: "100%",
@@ -135,6 +135,9 @@ const webStyles = {
135
135
  },
136
136
  inlineRiver: {
137
137
  height: INLINE_CONTAINER_CONTENT_HEIGHT,
138
+
139
+ borderWidth: 4,
140
+ borderColor: "yellow",
138
141
  },
139
142
  };
140
143
 
@@ -145,7 +148,6 @@ const nativeStyles = {
145
148
  },
146
149
  playerScreen: {
147
150
  flex: 1,
148
- backgroundColor: "black",
149
151
  overflow: "hidden",
150
152
  },
151
153
  playerWrapper: {
@@ -565,8 +567,9 @@ const PlayerContainerComponent = (props: Props) => {
565
567
  const isInlineTV = isInlineTVUtil(screenData);
566
568
 
567
569
  const inline =
568
- [VideoModalMode.MAXIMIZED, VideoModalMode.MINIMIZED].includes(mode) ||
569
- isInlineTV;
570
+ [VideoModalMode.MAXIMIZED, VideoModalMode.MINIMIZED].includes(
571
+ mode as any
572
+ ) || isInlineTV;
570
573
 
571
574
  const value = React.useMemo(
572
575
  () => ({ playerId: state.playerId }),
@@ -587,7 +590,11 @@ const PlayerContainerComponent = (props: Props) => {
587
590
  );
588
591
  }
589
592
 
590
- if (screen_background_color && mode !== VideoModalMode.FULLSCREEN) {
593
+ if (
594
+ screen_background_color &&
595
+ mode !== VideoModalMode.FULLSCREEN &&
596
+ isTV()
597
+ ) {
591
598
  updatedStyles.playerScreen.backgroundColor = screen_background_color;
592
599
  }
593
600
 
@@ -617,6 +624,8 @@ const PlayerContainerComponent = (props: Props) => {
617
624
  playNextData,
618
625
  };
619
626
 
627
+ const pointerEventsProp = mode === "MINIMIZED" ? "box-none" : "auto";
628
+
620
629
  return (
621
630
  <PlayerStateContext.Provider value={value}>
622
631
  <PlayerContainerContextProvider
@@ -637,14 +646,17 @@ const PlayerContainerComponent = (props: Props) => {
637
646
  preferredFocus
638
647
  shouldUsePreferredFocus
639
648
  groupId={groupId}
649
+ pointerEvents={pointerEventsProp}
640
650
  >
641
651
  {/* Video player and components */}
642
652
  <View
643
653
  style={styles.playerScreen}
644
654
  testID={"player-screen-container"}
655
+ pointerEvents={pointerEventsProp}
645
656
  >
646
657
  {/* Player container */}
647
658
  <View
659
+ pointerEvents={pointerEventsProp}
648
660
  style={[
649
661
  styles.playerWrapper,
650
662
  // eslint-disable-next-line react-native/no-inline-styles, react-native/no-color-literals
@@ -720,7 +732,7 @@ const PlayerContainerComponent = (props: Props) => {
720
732
  isScreenWrappedInContainer={true}
721
733
  containerHeight={styles.inlineRiver.height}
722
734
  componentsMapExtraProps={{
723
- isNestedComponentsMap: R.T,
735
+ isNestedComponentsMap: true,
724
736
  }}
725
737
  />
726
738
  )}
@@ -281,8 +281,8 @@ function ComponentsMapComponent(props: Props) {
281
281
  scrollIndicatorInsets={scrollIndicatorInsets}
282
282
  extraData={feed}
283
283
  stickyHeaderIndices={stickyHeaderIndices}
284
- onLayout={handleOnLayout}
285
284
  removeClippedSubviews={isAndroid}
285
+ onLayout={handleOnLayout}
286
286
  initialNumToRender={3}
287
287
  maxToRenderPerBatch={10}
288
288
  windowSize={12}
@@ -303,10 +303,6 @@ function ComponentsMapComponent(props: Props) {
303
303
  onMomentumScrollEnd={_onMomentumScrollEnd}
304
304
  onScrollEndDrag={_onScrollEndDrag}
305
305
  scrollEventThrottle={16}
306
- maintainVisibleContentPosition={{
307
- minIndexForVisible: 0,
308
- autoscrollToTopThreshold: 10,
309
- }}
310
306
  {...scrollViewExtraProps}
311
307
  />
312
308
  </ViewportTracker>
@@ -39,6 +39,10 @@ function getFeedUrl(feed: ZappFeed, index: number) {
39
39
  }
40
40
  }
41
41
 
42
+ const isNextIndex = (index, readyIndex) => {
43
+ return readyIndex + 1 >= index;
44
+ };
45
+
42
46
  /**
43
47
  * useLoadingState for RiverItemComponent
44
48
  * takes currentIndex and loadingState as arguments
@@ -48,24 +52,20 @@ const useLoadingState = (
48
52
  loadingState: RiverItemType["loadingState"]
49
53
  ) => {
50
54
  const [readyToBeDisplayed, setReadyToBeDisplayed] = React.useState(
51
- loadingState.getValue().index + 1 >= currentIndex
55
+ isNextIndex(currentIndex, loadingState.getValue().index)
52
56
  );
53
57
 
54
58
  useEffect(() => {
55
59
  const subscription = loadingState.subscribe(({ index }) => {
56
- if (index + 1 >= currentIndex) {
60
+ if (isNextIndex(currentIndex, index)) {
57
61
  setReadyToBeDisplayed(true);
58
62
  }
59
63
  });
60
64
 
61
- if (loadingState.getValue().index + 1 >= currentIndex) {
62
- setReadyToBeDisplayed(true);
63
- }
64
-
65
65
  return () => {
66
66
  subscription.unsubscribe();
67
67
  };
68
- }, [loadingState, currentIndex]);
68
+ }, [currentIndex]);
69
69
 
70
70
  return readyToBeDisplayed;
71
71
  };
@@ -151,7 +151,7 @@ function RiverItemComponent(props: RiverItemType) {
151
151
  component={item}
152
152
  componentIndex={index}
153
153
  onLoadFailed={onLoadFailed}
154
- onLoadFinished={() => onLoadFinished(index)} // Keeping it here to don't break the plugins.
154
+ onLoadFinished={() => onLoadFinished(index)}
155
155
  groupId={groupId}
156
156
  feedUrl={feedUrl}
157
157
  isLast={isLast}
@@ -26,7 +26,6 @@ type Props = {
26
26
  componentsMapExtraProps?: any;
27
27
  isInsideContainer?: boolean;
28
28
  extraAnchorPointYOffset: number;
29
- extraOffset: number;
30
29
  river?: ZappRiver | ZappEntry;
31
30
  };
32
31
 
@@ -39,7 +38,6 @@ export const River = (props: Props) => {
39
38
  componentsMapExtraProps,
40
39
  isInsideContainer,
41
40
  extraAnchorPointYOffset,
42
- extraOffset,
43
41
  } = props;
44
42
 
45
43
  const { title: screenTitle, summary: screenSummary } = useNavbarState();
@@ -120,7 +118,6 @@ export const River = (props: Props) => {
120
118
  <GeneralContentScreen
121
119
  feed={feedData}
122
120
  screenId={screenId}
123
- extraOffset={extraOffset}
124
121
  isScreenWrappedInContainer={isInsideContainer}
125
122
  extraAnchorPointYOffset={extraAnchorPointYOffset}
126
123
  componentsMapExtraProps={componentsMapExtraProps}
@@ -135,12 +135,6 @@ exports[`componentsMap renders renders components map correctly 1`] = `
135
135
  getItemCount={[Function]}
136
136
  initialNumToRender={3}
137
137
  keyExtractor={[Function]}
138
- maintainVisibleContentPosition={
139
- {
140
- "autoscrollToTopThreshold": 10,
141
- "minIndexForVisible": 0,
142
- }
143
- }
144
138
  maxToRenderPerBatch={10}
145
139
  onContentSizeChange={[Function]}
146
140
  onLayout={[Function]}
@@ -1,17 +1,17 @@
1
1
  import React from "react";
2
- import { View, ViewProps, ViewStyle } from "react-native";
2
+ import { View, ViewStyle } from "react-native";
3
3
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
4
4
  import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks";
5
5
  import { isFirstComponentScreenPicker } from "@applicaster/zapp-react-native-utils/componentsUtils";
6
+ import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
6
7
 
7
8
  interface IProps {
8
9
  targetScreenId?: string;
9
10
  children?: React.ReactNode;
10
11
  style?: ViewStyle;
11
- extraOffset?: number;
12
+ extraVerticalOffset: Option<number>;
12
13
  }
13
14
 
14
- type CombinedProps = IProps & ViewProps;
15
15
  /**
16
16
  * The MarginTop is essentially a feature used for managing the visibility of components on your screen.
17
17
  * A more accurate term for this might be something like a 'component visibility threshold' or 'cut-off point'.
@@ -47,7 +47,7 @@ export const useMarginTop = (targetScreenId: string): number => {
47
47
 
48
48
  // Empty string means that value is blank in the CMS. Fallback to theme
49
49
  if (String(screenData?.styles?.screen_margin_top) === "") {
50
- return Number(theme.screen_margin_top);
50
+ return toNumberWithDefault(0, theme.screen_margin_top);
51
51
  }
52
52
 
53
53
  /**
@@ -58,28 +58,29 @@ export const useMarginTop = (targetScreenId: string): number => {
58
58
  */
59
59
  if (screenData?.styles?.screen_margin_top === undefined) {
60
60
  if (isGeneralContentScreen || supportsUiComponents) {
61
- return Number(theme.screen_margin_top);
61
+ return toNumberWithDefault(0, theme.screen_margin_top);
62
62
  }
63
63
 
64
64
  return 0;
65
65
  }
66
66
 
67
- return Number(screenData?.styles?.screen_margin_top);
67
+ return toNumberWithDefault(0, screenData?.styles?.screen_margin_top);
68
68
  };
69
69
 
70
- export const TopMarginApplicator: React.FC<CombinedProps> = (
71
- props: CombinedProps
72
- ) => {
73
- const extraOffset = props?.extraOffset ?? 0;
70
+ export const TopMarginApplicator: React.FC<IProps> = ({
71
+ targetScreenId,
72
+ style,
73
+ children,
74
+ extraVerticalOffset,
75
+ }: IProps) => {
76
+ const extraOffset = toNumberWithDefault(0, extraVerticalOffset);
74
77
 
75
78
  // HACK: Remove extraOffset when focusIssue with absolute elements is fixed on tvos
76
- const marginTop = useMarginTop(props.targetScreenId) + extraOffset;
77
- const style = { ...((props.style as {}) || {}), marginTop };
79
+ const marginTop = useMarginTop(targetScreenId);
78
80
 
79
- // Then, spread the rest of the props on your returned JSX.
80
81
  return (
81
- <View {...props} style={style}>
82
- {props.children}
82
+ <View style={[style, { marginTop: marginTop + extraOffset }]}>
83
+ {children}
83
84
  </View>
84
85
  );
85
86
  };
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect } from "react";
2
- import { Animated } from "react-native";
2
+ import { Animated, Dimensions } from "react-native";
3
3
 
4
4
  import {
5
5
  useSafeAreaInsets,
@@ -23,6 +23,7 @@ export enum PlayerAnimationStateEnum {
23
23
  export type PlayerAnimationStateT = number | PlayerAnimationStateEnum | null;
24
24
 
25
25
  export type ModalAnimationContextT = {
26
+ yTranslate: React.MutableRefObject<Animated.Value | null>;
26
27
  isActiveGesture: boolean;
27
28
  playerAnimationState: PlayerAnimationStateT;
28
29
  setPlayerAnimationState: (value: PlayerAnimationStateT) => void;
@@ -48,6 +49,7 @@ export type ModalAnimationContextT = {
48
49
  };
49
50
 
50
51
  export const ReactContext = React.createContext<ModalAnimationContextT>({
52
+ yTranslate: React.createRef<Animated.Value | null>(),
51
53
  isActiveGesture: false,
52
54
  playerAnimationState: null,
53
55
  setPlayerAnimationState: () => null,
@@ -73,6 +75,10 @@ export const ReactContext = React.createContext<ModalAnimationContextT>({
73
75
  });
74
76
 
75
77
  const Provider = ({ children }: { children: React.ReactNode }) => {
78
+ const yTranslate = React.useRef(
79
+ new Animated.Value(Dimensions.get("window").height)
80
+ );
81
+
76
82
  const [playerAnimationState, setPlayerAnimationState] =
77
83
  React.useState<PlayerAnimationStateT>(null);
78
84
 
@@ -100,6 +106,7 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
100
106
  // Reset player animation state when video modal is closed
101
107
  if (!visible) {
102
108
  resetPlayerAnimationState();
109
+ yTranslate.current?.setValue(Dimensions.get("window").height);
103
110
  }
104
111
  }, [visible, resetPlayerAnimationState]);
105
112
 
@@ -141,6 +148,7 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
141
148
  return (
142
149
  <ReactContext.Provider
143
150
  value={{
151
+ yTranslate,
144
152
  startComponentsAnimation,
145
153
  setStartComponentsAnimation,
146
154
  isActiveGesture: playerAnimationState !== null,