@applicaster/zapp-react-native-ui-components 14.0.0-alpha.2308642114 → 14.0.0-alpha.2332850672

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.
@@ -1,10 +1,16 @@
1
1
  import React, { useCallback, useMemo } from "react";
2
2
 
3
- import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
3
+ import {
4
+ platformSelect,
5
+ isTV,
6
+ } from "@applicaster/zapp-react-native-utils/reactUtils";
4
7
 
5
8
  import { imageSrcFromMediaItem } from "@applicaster/zapp-react-native-utils/configurationUtils";
9
+ import { getBackgroundImage } from "@applicaster/zapp-react-native-utils/audioPlayerUtils";
10
+
11
+ import { AudioPlayerMobileLayout } from "./AudioPlayerMobileLayout";
12
+ import { AudioPlayerTVLayout } from "./AudioPlayerTVLayout";
6
13
 
7
- import { AudioPlayerLayout } from "./AudioPlayerLayout";
8
14
  import { Channel } from "./Channel";
9
15
  import { Title } from "./Title";
10
16
  import { Summary } from "./Summary";
@@ -52,9 +58,20 @@ type Props = {
52
58
  };
53
59
 
54
60
  export function AudioPlayer(props: Props) {
55
- const { audio_item, plugin_configuration, style } = props;
61
+ const { audio_item, plugin_configuration, style = {} } = props;
56
62
  const { extensions, title, summary } = audio_item;
57
63
 
64
+ const mobileConfig = useMemo(() => {
65
+ const backgroundImage = getBackgroundImage({
66
+ entry: audio_item,
67
+ plugin_configuration,
68
+ });
69
+
70
+ return {
71
+ backgroundImage,
72
+ };
73
+ }, [audio_item, plugin_configuration]);
74
+
58
75
  const getProp = useCallback(
59
76
  getPropertyFromEntryOrConfig({
60
77
  entry: audio_item,
@@ -63,12 +80,13 @@ export function AudioPlayer(props: Props) {
63
80
  [audio_item, plugin_configuration]
64
81
  );
65
82
 
66
- const config = useMemo(() => {
83
+ const tvConfig = useMemo(() => {
67
84
  // Checking if we are recieving items from the DSP
68
85
  const titleColor = getProp("audio_player_title_color");
69
86
  const summaryColor = getProp("audio_player_summary_color");
70
87
  const backgroundColor = getProp("audio_player_background_color");
71
88
  const backgroundImage = getProp("audio_player_background_image");
89
+ const backgroundImageKey = getProp("audio_player_background_image_key");
72
90
  const artworkAspectRatio = getProp("audio_player_artwork_aspect_ratio");
73
91
  const channelIcon = getProp("audio_player_channel_icon");
74
92
  const rtlFlag = getProp("audio_player_rtl");
@@ -145,6 +163,7 @@ export function AudioPlayer(props: Props) {
145
163
  summaryColor,
146
164
  backgroundColor,
147
165
  backgroundImage,
166
+ backgroundImageKey,
148
167
  isRTL,
149
168
  titleFontFamily,
150
169
  titleFontSize,
@@ -160,15 +179,31 @@ export function AudioPlayer(props: Props) {
160
179
  }, [getProp]);
161
180
 
162
181
  const artwork = imageSrcFromMediaItem(audio_item, [
163
- config?.artworkAspectRatio,
182
+ tvConfig?.artworkAspectRatio,
164
183
  ]);
165
184
 
185
+ console.log("debug_2", "AudioPlayer", {
186
+ tvConfig,
187
+ mobileConfig,
188
+ audio_item,
189
+ plugin_configuration,
190
+ });
191
+
192
+ if (isTV()) {
193
+ return (
194
+ <AudioPlayerTVLayout artwork={artwork} config={tvConfig} style={style}>
195
+ <Channel srcImage={tvConfig?.channelIcon} config={tvConfig} />
196
+ <Title title={title} config={tvConfig} />
197
+ <Summary summary={summary} config={tvConfig} />
198
+ <Runtime {...extensions} config={tvConfig} />
199
+ </AudioPlayerTVLayout>
200
+ );
201
+ }
202
+
166
203
  return (
167
- <AudioPlayerLayout artwork={artwork} config={config} style={style || {}}>
168
- <Channel srcImage={config?.channelIcon} config={config} />
169
- <Title title={title} config={config} />
170
- <Summary summary={summary} config={config} />
171
- <Runtime {...extensions} config={config} />
172
- </AudioPlayerLayout>
204
+ <AudioPlayerMobileLayout
205
+ backgroundImage={mobileConfig.backgroundImage}
206
+ style={style}
207
+ />
173
208
  );
174
209
  }
@@ -0,0 +1,61 @@
1
+ import React, { useRef } from "react";
2
+ import {
3
+ View,
4
+ ImageBackground,
5
+ Animated,
6
+ ViewStyle,
7
+ StyleSheet,
8
+ } from "react-native";
9
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
10
+
11
+ const styles = StyleSheet.create({
12
+ flex: {
13
+ flex: 1,
14
+ },
15
+ });
16
+
17
+ type Props = {
18
+ backgroundImage: string;
19
+ style: ViewStyle;
20
+ };
21
+
22
+ export function AudioPlayerMobileLayout({ backgroundImage, style }: Props) {
23
+ const fadeAnimation = useRef(new Animated.Value(0)).current;
24
+
25
+ const mainContainerStyles = platformSelect({
26
+ native: {
27
+ backgroundColor: "transparent",
28
+ overflow: "hidden",
29
+ ...style,
30
+ },
31
+ });
32
+
33
+ React.useEffect(() => {
34
+ Animated.timing(fadeAnimation, {
35
+ toValue: 1,
36
+ duration: 3000,
37
+ useNativeDriver: true,
38
+ }).start();
39
+ }, []);
40
+
41
+ return (
42
+ <View style={mainContainerStyles} pointerEvents="none">
43
+ <Animated.View
44
+ style={[
45
+ mainContainerStyles,
46
+ {
47
+ opacity: fadeAnimation,
48
+ },
49
+ ]}
50
+ >
51
+ <ImageBackground
52
+ source={{ uri: backgroundImage }}
53
+ style={styles.flex}
54
+ resizeMode="cover"
55
+ >
56
+ <View style={mainContainerStyles} />
57
+ </ImageBackground>
58
+ </Animated.View>
59
+ </View>
60
+ );
61
+ }
@@ -1,5 +1,5 @@
1
- import React, { useRef } from "react";
2
- import { View, ImageBackground, Animated, ViewStyle } from "react-native";
1
+ import * as React from "react";
2
+ import { View, ImageBackground, ViewStyle } from "react-native";
3
3
 
4
4
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
5
 
@@ -20,17 +20,12 @@ type Props = {
20
20
  style: ViewStyle;
21
21
  };
22
22
 
23
- export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
24
- const fadeAnimation = useRef(new Animated.Value(0)).current;
25
-
26
- const fadeAudioPlayerIn = () => {
27
- Animated.timing(fadeAnimation, {
28
- toValue: 1,
29
- duration: 3000,
30
- useNativeDriver: true,
31
- }).start();
32
- };
33
-
23
+ export function AudioPlayerTVLayout({
24
+ artwork,
25
+ config,
26
+ children,
27
+ style,
28
+ }: Props) {
34
29
  const { isRTL, backgroundColor, backgroundImage } = config;
35
30
 
36
31
  const backgroundImageSource = { uri: backgroundImage };
@@ -119,9 +114,6 @@ export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
119
114
  alignItems: "center",
120
115
  justifyContent: "center",
121
116
  },
122
- native: {
123
- flex: 1,
124
- },
125
117
  });
126
118
 
127
119
  const textContainerStyles = platformSelect({
@@ -145,58 +137,25 @@ export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
145
137
  },
146
138
  });
147
139
 
148
- const audioPlayerLayoutTV = backgroundImageSource?.uri ? (
149
- <ImageBackground
150
- source={backgroundImageSource}
151
- style={backgroundImgStyles}
152
- resizeMode="cover"
153
- >
154
- <View style={mainContainerStyles}>
155
- {!!artwork && <Artwork srcImage={artwork} config={config} />}
156
- <View style={textContainerStyles}>{children}</View>
157
- </View>
158
- </ImageBackground>
159
- ) : (
140
+ if (backgroundImageSource?.uri) {
141
+ return (
142
+ <ImageBackground
143
+ source={backgroundImageSource}
144
+ style={backgroundImgStyles}
145
+ resizeMode="cover"
146
+ >
147
+ <View style={mainContainerStyles}>
148
+ {!!artwork && <Artwork srcImage={artwork} config={config} />}
149
+ <View style={textContainerStyles}>{children}</View>
150
+ </View>
151
+ </ImageBackground>
152
+ );
153
+ }
154
+
155
+ return (
160
156
  <View style={mainContainerStyles}>
161
157
  {!!artwork && <Artwork srcImage={artwork} config={config} />}
162
158
  <View style={textContainerStyles}>{children}</View>
163
159
  </View>
164
160
  );
165
-
166
- const audioPlayerLayoutMobile = () => {
167
- fadeAudioPlayerIn();
168
-
169
- return (
170
- <View style={mainContainerStyles} pointerEvents="none">
171
- <Animated.View
172
- style={[
173
- mainContainerStyles,
174
- {
175
- opacity: fadeAnimation,
176
- },
177
- ]}
178
- >
179
- <ImageBackground
180
- source={backgroundImageSource}
181
- style={backgroundImgStyles}
182
- resizeMode="cover"
183
- >
184
- <View style={mainContainerStyles} />
185
- </ImageBackground>
186
- </Animated.View>
187
- </View>
188
- );
189
- };
190
-
191
- const audioPlayerLayout = platformSelect({
192
- tvos: audioPlayerLayoutTV,
193
- android_tv: audioPlayerLayoutTV,
194
- web: audioPlayerLayoutTV,
195
- samsung_tv: audioPlayerLayoutTV,
196
- lg_tv: audioPlayerLayoutTV,
197
- ios: audioPlayerLayoutMobile(),
198
- android: audioPlayerLayoutMobile(),
199
- });
200
-
201
- return audioPlayerLayout;
202
161
  }
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`<AudioPlayerLayout /> renders correctly 1`] = `
3
+ exports[`<AudioPlayerMobileLayout /> renders correctly 1`] = `
4
4
  <View
5
5
  pointerEvents="none"
6
6
  style={
@@ -32,7 +32,7 @@ exports[`<AudioPlayerLayout /> renders correctly 1`] = `
32
32
  resizeMode="cover"
33
33
  source={
34
34
  {
35
- "uri": "https://example.com",
35
+ "uri": undefined,
36
36
  }
37
37
  }
38
38
  style={
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { render } from "@testing-library/react-native";
3
+
4
+ import { AudioPlayerMobileLayout } from "../AudioPlayerMobileLayout";
5
+
6
+ const audioPlayerLayoutProps = {
7
+ backgroundColor: "black",
8
+ };
9
+
10
+ describe("<AudioPlayerMobileLayout />", () => {
11
+ it("renders correctly", () => {
12
+ const { toJSON } = render(
13
+ <AudioPlayerMobileLayout {...audioPlayerLayoutProps} />
14
+ );
15
+
16
+ expect(toJSON()).toMatchSnapshot();
17
+ });
18
+ });
@@ -1,5 +1,4 @@
1
1
  import React, { useEffect } from "react";
2
- import { View, StyleSheet } from "react-native";
3
2
  import { ComponentsMap } from "../River/ComponentsMap";
4
3
  import { CellTapContext } from "@applicaster/zapp-react-native-ui-components/Contexts/CellTapContext";
5
4
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
@@ -13,23 +12,12 @@ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
13
12
  import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
14
13
  import { ScreenTrackedViewPositionsContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenTrackedViewPositionsContext";
15
14
  import { useEventAlerts } from "./utils/useEventAlerts";
16
- import { useScreenBackgroundColor } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
17
15
 
18
16
  const { log_info } = createLogger({
19
17
  category: "ScreenContainer",
20
18
  subsystem: "General",
21
19
  });
22
20
 
23
- const styles = StyleSheet.create({
24
- background: {
25
- position: "absolute",
26
- left: 0,
27
- bottom: 0,
28
- right: 0,
29
- top: 0,
30
- },
31
- });
32
-
33
21
  export const GeneralContentScreen = ({
34
22
  feed,
35
23
  screenId,
@@ -42,7 +30,6 @@ export const GeneralContentScreen = ({
42
30
  isScreenWrappedInContainer,
43
31
  componentsMapExtraProps = {},
44
32
  focused,
45
- extraOffset,
46
33
  parentFocus,
47
34
  containerHeight,
48
35
  preferredFocus = false,
@@ -50,12 +37,6 @@ export const GeneralContentScreen = ({
50
37
  const screenData = useScreenData(screenId);
51
38
 
52
39
  const uiComponents = useCurationAPI(screenData?.ui_components);
53
- const backgroundColor = useScreenBackgroundColor(screenId);
54
-
55
- const shouldShowBackground = React.useMemo(
56
- () => backgroundColor && backgroundColor !== "transparent",
57
- [backgroundColor]
58
- );
59
40
 
60
41
  const onCellTapAction = useActions(
61
42
  whenMatchingType(String, cellTapAction) ||
@@ -127,30 +108,24 @@ export const GeneralContentScreen = ({
127
108
  if (!isReady || isNilOrEmpty(components || uiComponents)) return null;
128
109
 
129
110
  return (
130
- <>
131
- {shouldShowBackground ? (
132
- <View style={[styles.background, { backgroundColor }]} />
133
- ) : null}
134
- <ScreenTrackedViewPositionsContext.Provider>
135
- <CellTapContext.Provider value={contextValue}>
136
- <ComponentsMap
137
- feed={feed}
138
- riverId={screenId}
139
- groupId={groupId || `general-content-screen-${screenId}`}
140
- riverComponents={components || uiComponents}
141
- scrollViewExtraProps={scrollViewExtraProps}
142
- getStaticComponentFeed={getStaticComponentFeed}
143
- extraAnchorPointYOffset={extraAnchorPointYOffset}
144
- isScreenWrappedInContainer={isScreenWrappedInContainer}
145
- parentFocus={parentFocus}
146
- focused={focused}
147
- extraOffset={extraOffset}
148
- containerHeight={containerHeight}
149
- preferredFocus={preferredFocus}
150
- {...componentsMapExtraProps}
151
- />
152
- </CellTapContext.Provider>
153
- </ScreenTrackedViewPositionsContext.Provider>
154
- </>
111
+ <ScreenTrackedViewPositionsContext.Provider>
112
+ <CellTapContext.Provider value={contextValue}>
113
+ <ComponentsMap
114
+ feed={feed}
115
+ riverId={screenId}
116
+ groupId={groupId || `general-content-screen-${screenId}`}
117
+ riverComponents={components || uiComponents}
118
+ scrollViewExtraProps={scrollViewExtraProps}
119
+ getStaticComponentFeed={getStaticComponentFeed}
120
+ extraAnchorPointYOffset={extraAnchorPointYOffset}
121
+ isScreenWrappedInContainer={isScreenWrappedInContainer}
122
+ parentFocus={parentFocus}
123
+ focused={focused}
124
+ containerHeight={containerHeight}
125
+ preferredFocus={preferredFocus}
126
+ {...componentsMapExtraProps}
127
+ />
128
+ </CellTapContext.Provider>
129
+ </ScreenTrackedViewPositionsContext.Provider>
155
130
  );
156
131
  };
@@ -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
@@ -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
 
@@ -720,7 +723,7 @@ const PlayerContainerComponent = (props: Props) => {
720
723
  isScreenWrappedInContainer={true}
721
724
  containerHeight={styles.inlineRiver.height}
722
725
  componentsMapExtraProps={{
723
- isNestedComponentsMap: R.T,
726
+ isNestedComponentsMap: true,
724
727
  }}
725
728
  />
726
729
  )}
@@ -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
  };
@@ -71,6 +71,36 @@ exports[`PlayerWrapper renders inline 1`] = `
71
71
  }
72
72
  testID="test-player-container"
73
73
  />
74
+ <View
75
+ animationType="componentFade"
76
+ style={
77
+ {
78
+ "flex": 1,
79
+ }
80
+ }
81
+ >
82
+ <View
83
+ configuration={
84
+ {
85
+ "tablet_landscape_player_container_background_color": "red",
86
+ "tablet_landscape_sidebar_width": "35%",
87
+ }
88
+ }
89
+ entry={
90
+ {
91
+ "id": "test",
92
+ }
93
+ }
94
+ isTablet={false}
95
+ isTabletLandscape={false}
96
+ style={
97
+ {
98
+ "flex": 1,
99
+ "paddingTop": 20,
100
+ }
101
+ }
102
+ />
103
+ </View>
74
104
  </View>
75
105
  </RNCSafeAreaView>
76
106
  </RNCSafeAreaProvider>
@@ -239,6 +269,36 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
239
269
  }
240
270
  />
241
271
  </View>
272
+ <View
273
+ animationType="componentFade"
274
+ style={
275
+ {
276
+ "flex": 1,
277
+ }
278
+ }
279
+ >
280
+ <View
281
+ configuration={
282
+ {
283
+ "tablet_landscape_player_container_background_color": "red",
284
+ "tablet_landscape_sidebar_width": "35%",
285
+ }
286
+ }
287
+ entry={
288
+ {
289
+ "id": "test",
290
+ }
291
+ }
292
+ isTablet={true}
293
+ isTabletLandscape={true}
294
+ style={
295
+ {
296
+ "flex": 1,
297
+ "paddingTop": 20,
298
+ }
299
+ }
300
+ />
301
+ </View>
242
302
  </View>
243
303
  </RNCSafeAreaView>
244
304
  </RNCSafeAreaProvider>
@@ -1,19 +1,9 @@
1
1
  import { renderHook } from "@testing-library/react-hooks";
2
2
  import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
3
- import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
4
- import { showDetails } from "../utils";
5
3
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
6
4
 
7
- jest.mock("@applicaster/zapp-react-native-utils/idleUtils", () => ({
8
- withTimeout$: jest.fn(),
9
- }));
10
-
11
- jest.mock("../utils", () => ({
12
- showDetails: jest.fn(),
13
- }));
14
-
15
5
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
16
- useIsTablet: jest.fn(),
6
+ useIsTablet: jest.fn().mockReturnValue(false),
17
7
  }));
18
8
 
19
9
  describe("useDelayedPlayerDetails", () => {
@@ -21,69 +11,41 @@ describe("useDelayedPlayerDetails", () => {
21
11
  jest.clearAllMocks();
22
12
  });
23
13
 
24
- it("should return false initially", () => {
25
- (withTimeout$ as jest.Mock).mockReturnValue({
26
- subscribe: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }),
27
- });
28
-
14
+ it("should return true initially", () => {
29
15
  const { result } = renderHook(() =>
30
16
  useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
31
17
  );
32
18
 
33
- expect(result.current).toBe(false);
19
+ expect(result.current).toBe(true);
34
20
  });
35
21
 
36
- it("should return true if showDetails returns true", () => {
37
- (withTimeout$ as jest.Mock).mockReturnValue({
38
- subscribe: (callback) => {
39
- callback.next();
40
-
41
- return { unsubscribe: jest.fn() };
42
- },
43
- });
44
-
45
- (showDetails as jest.Mock).mockReturnValue(true);
46
- (useIsTablet as jest.Mock).mockReturnValue(false);
47
-
22
+ it("should return false when isPip is true", () => {
48
23
  const { result } = renderHook(() =>
49
- useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
24
+ useDelayedPlayerDetails({ isInline: true, isDocked: true, isPip: true })
50
25
  );
51
26
 
52
- expect(result.current).toBe(true);
27
+ expect(result.current).toBe(false);
53
28
  });
54
29
 
55
- it("should return false if showDetails returns false", () => {
56
- (withTimeout$ as jest.Mock).mockReturnValue({
57
- subscribe: (callback) => {
58
- callback.next();
59
-
60
- return { unsubscribe: jest.fn() };
61
- },
62
- });
63
-
64
- (showDetails as jest.Mock).mockReturnValue(false);
65
- (useIsTablet as jest.Mock).mockReturnValue(false);
66
-
30
+ it("should return false when isDocked is true", () => {
67
31
  const { result } = renderHook(() =>
68
- useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
32
+ useDelayedPlayerDetails({ isInline: true, isDocked: true, isPip: false })
69
33
  );
70
34
 
71
35
  expect(result.current).toBe(false);
72
36
  });
73
37
 
74
- it("should unsubscribe on unmount", () => {
75
- const unsubscribeMock = jest.fn();
38
+ it("should return true for tablet regardless of other flags", () => {
39
+ (useIsTablet as jest.Mock).mockReturnValue(true);
76
40
 
77
- (withTimeout$ as jest.Mock).mockReturnValue({
78
- subscribe: jest.fn().mockReturnValue({ unsubscribe: unsubscribeMock }),
79
- });
80
-
81
- const { unmount } = renderHook(() =>
82
- useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
41
+ const { result } = renderHook(() =>
42
+ useDelayedPlayerDetails({
43
+ isInline: false,
44
+ isDocked: false,
45
+ isPip: false,
46
+ })
83
47
  );
84
48
 
85
- unmount();
86
-
87
- expect(unsubscribeMock).toHaveBeenCalled();
49
+ expect(result.current).toBe(true);
88
50
  });
89
51
  });
@@ -1,13 +1,23 @@
1
- import * as React from "react";
2
1
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
3
- import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
4
2
 
5
3
  import { showDetails } from "./utils";
6
4
 
7
- const TIMEOUT = 100; // ms
8
-
9
5
  type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
10
6
 
7
+ const showPlayerDetails = (
8
+ isInline: boolean,
9
+ isDocked: boolean,
10
+ isPip: boolean,
11
+ isTablet: boolean
12
+ ) => {
13
+ return showDetails({
14
+ isMobile: !isTablet,
15
+ isInline,
16
+ isDocked,
17
+ isPip,
18
+ });
19
+ };
20
+
11
21
  /**
12
22
  * Custom hook to determine whether to show player details with a delay.
13
23
  *
@@ -22,28 +32,7 @@ export const useDelayedPlayerDetails = ({
22
32
  isDocked,
23
33
  isPip,
24
34
  }: Props): boolean => {
25
- const [shouldShowDetails, setShouldShowDetails] = React.useState(false);
26
-
27
35
  const isTablet = useIsTablet();
28
36
 
29
- React.useEffect(() => {
30
- const subscription = withTimeout$(TIMEOUT).subscribe({
31
- next: () => {
32
- setShouldShowDetails(() => {
33
- return showDetails({
34
- isMobile: !isTablet,
35
- isInline,
36
- isDocked,
37
- isPip,
38
- });
39
- });
40
- },
41
- });
42
-
43
- return () => {
44
- subscription.unsubscribe();
45
- };
46
- }, [isDocked, isTablet, isInline, isPip]);
47
-
48
- return shouldShowDetails;
37
+ return showPlayerDetails(isInline, isDocked, isPip, isTablet);
49
38
  };
package/index.d.ts CHANGED
@@ -24,7 +24,6 @@ type GeneralContentScreenProps = {
24
24
  } & Record<string, any>;
25
25
  focused?: boolean;
26
26
  parentFocus?: ParentFocus;
27
- extraOffset?: number;
28
27
  containerHeight?: number;
29
28
  };
30
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "14.0.0-alpha.2308642114",
3
+ "version": "14.0.0-alpha.2332850672",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -31,10 +31,10 @@
31
31
  "redux-mock-store": "^1.5.3"
32
32
  },
33
33
  "dependencies": {
34
- "@applicaster/applicaster-types": "14.0.0-alpha.2308642114",
35
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.2308642114",
36
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.2308642114",
37
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.2308642114",
34
+ "@applicaster/applicaster-types": "14.0.0-alpha.2332850672",
35
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.2332850672",
36
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.2332850672",
37
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.2332850672",
38
38
  "promise": "^8.3.0",
39
39
  "url": "^0.11.0",
40
40
  "uuid": "^3.3.2"
@@ -1,26 +0,0 @@
1
- import React from "react";
2
- import { render } from "@testing-library/react-native";
3
-
4
- import { AudioPlayerLayout } from "../AudioPlayerLayout";
5
-
6
- const audioPlayerLayoutProps = {
7
- artwork: "string",
8
- config: {
9
- titleColor: "white",
10
- summaryColor: "white",
11
- backgroundColor: "black",
12
- backgroundImage: "https://example.com",
13
- isRTL: true,
14
- },
15
- children: [],
16
- };
17
-
18
- describe("<AudioPlayerLayout />", () => {
19
- it("renders correctly", () => {
20
- const { toJSON } = render(
21
- <AudioPlayerLayout {...audioPlayerLayoutProps} />
22
- );
23
-
24
- expect(toJSON()).toMatchSnapshot();
25
- });
26
- });