@applicaster/zapp-react-native-ui-components 12.0.0-alpha.7101461483 → 12.0.0-alpha.7254207052

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 (56) hide show
  1. package/Components/AudioPlayer/AudioPlayer.tsx +9 -1
  2. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +5 -0
  3. package/Components/AudioPlayer/helpers.tsx +1 -0
  4. package/Components/Cell/Cell.tsx +2 -2
  5. package/Components/Cell/CellWithFocusable.tsx +21 -14
  6. package/Components/Cell/TvOSCellComponent.tsx +2 -2
  7. package/Components/ErrorScreen/index.tsx +1 -1
  8. package/Components/FocusableCell/index.tsx +7 -7
  9. package/Components/FocusableList/FocusableChild.ts +24 -14
  10. package/Components/FocusableList/FocusableItem.tsx +1 -1
  11. package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
  12. package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
  13. package/Components/FocusableList/index.tsx +26 -25
  14. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +6 -3
  15. package/Components/HookRenderer/index.tsx +1 -6
  16. package/Components/Image/Image.android.tsx +3 -25
  17. package/Components/Image/Image.tsx +18 -2
  18. package/Components/Image/utils/index.ts +39 -0
  19. package/Components/Layout/TV/__tests__/index.test.tsx +1 -34
  20. package/Components/Layout/TV/index.tsx +20 -36
  21. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
  22. package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
  23. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +3 -1
  24. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
  25. package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
  26. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +8 -14
  27. package/Components/MasterCell/utils/index.ts +2 -2
  28. package/Components/PlayerContainer/PlayerContainer.tsx +46 -28
  29. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
  30. package/Components/River/ComponentsMap/ComponentsMap.tsx +25 -0
  31. package/Components/River/TV/River.tsx +2 -2
  32. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
  33. package/Components/River/__tests__/componentsMap.test.js +1 -0
  34. package/Components/River/useScreenConfiguration.ts +2 -2
  35. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
  36. package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
  37. package/Components/RouteManager/index.tsx +5 -3
  38. package/Components/Screen/__tests__/Screen.test.tsx +88 -70
  39. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +20 -6
  40. package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
  41. package/Components/Screen/index.tsx +91 -42
  42. package/Components/Screen/navigationHandler.ts +0 -82
  43. package/Components/ScreenResolver/index.tsx +1 -1
  44. package/Components/Tabs/TV/styles.ts +1 -1
  45. package/Components/VideoLive/PlayerLiveImageComponent.tsx +31 -28
  46. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +30 -3
  47. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +22 -27
  48. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +0 -2
  49. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -2
  50. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +211 -163
  51. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
  52. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
  53. package/Components/ZappUIComponent/index.tsx +22 -12
  54. package/Contexts/ScreenContext/index.tsx +1 -4
  55. package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
  56. package/package.json +5 -5
@@ -1,10 +1,7 @@
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 {
5
- useIsNavBarVisible,
6
- useNavigation,
7
- } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
8
5
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
9
6
 
10
7
  import {
@@ -43,7 +40,7 @@ type Props = {
43
40
  const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
44
41
  const navigator = useNavigation();
45
42
  const theme = useTheme();
46
- const { title } = useNavbarState();
43
+ const { title, visible } = useNavbarState();
47
44
  const { activeRiver, currentRoute } = navigator;
48
45
 
49
46
  const {
@@ -80,10 +77,22 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
80
77
  []
81
78
  );
82
79
 
83
- const navBarVisible = useIsNavBarVisible();
84
-
85
80
  const [navBarReady, setNavBarReady] = React.useState(false);
86
81
 
82
+ const navBarContainer = (
83
+ <NavBarContainer isVisible={visible} onReady={setNavBarReady}>
84
+ <NavBar
85
+ ref={ComponentsExtraProps?.NavBar?.ref}
86
+ isVisible={visible && !routeIsPlayerScreen(currentRoute)}
87
+ menuPlugin={menuPlugin}
88
+ navigationProps={navigationProps}
89
+ {...R.omit(["ref"])(ComponentsExtraProps?.NavBar)}
90
+ />
91
+ </NavBarContainer>
92
+ );
93
+
94
+ const isTVOS = isApplePlatform();
95
+
87
96
  if (!appReady) {
88
97
  return null;
89
98
  }
@@ -96,18 +105,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
96
105
  backgroundImageUrl={backgroundImageUrl}
97
106
  {...R.omit(["ref"])(ComponentsExtraProps?.Background)}
98
107
  >
99
- {!isApplePlatform() ? (
100
- <NavBarContainer isVisible={navBarVisible} onReady={setNavBarReady}>
101
- <NavBar
102
- ref={ComponentsExtraProps?.NavBar?.ref}
103
- isVisible={navBarVisible && !routeIsPlayerScreen(currentRoute)}
104
- menuPlugin={menuPlugin}
105
- navigationProps={navigationProps}
106
- {...R.omit(["ref"])(ComponentsExtraProps?.NavBar)}
107
- />
108
- </NavBarContainer>
109
- ) : null}
110
-
108
+ {!isTVOS ? navBarContainer : null}
111
109
  {navBarReady ? (
112
110
  /**
113
111
  Need to re-mount this component on each navigation event
@@ -118,23 +116,9 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
118
116
  <ScreenContainer>{children}</ScreenContainer>
119
117
  </PathnameContext.Provider>
120
118
  ) : null}
121
-
122
- {isApplePlatform() ? (
123
- /**
124
- Render NavBarContainer over ScreenContainer to let tvOS native
125
- focus manager works correctly to focus nav bar items first
126
- **/
127
- <NavBarContainer isVisible={navBarVisible} onReady={setNavBarReady}>
128
- <NavBar
129
- ref={ComponentsExtraProps?.NavBar?.ref}
130
- isVisible={navBarVisible && !routeIsPlayerScreen(currentRoute)}
131
- menuPlugin={menuPlugin}
132
- navigationProps={navigationProps}
133
- {...R.omit(["ref"])(ComponentsExtraProps?.NavBar)}
134
- />
135
- </NavBarContainer>
136
- ) : null}
137
-
119
+ {/** Render NavBarContainer over ScreenContainer to let tvOS native
120
+ focus manager works correctly to focus nav bar items first **/}
121
+ {isTVOS ? navBarContainer : null}
138
122
  <TransitionOverlay />
139
123
  </Components.Background>
140
124
  </ScreenLayoutContextProvider>
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
2
  import { ImageStyle, View } from "react-native";
3
3
  import * as R from "ramda";
4
- import ImageComponent from "@applicaster/zapp-react-native-ui-components/Components/FastImage";
4
+ import { QBImage } from "@applicaster/zapp-react-native-ui-components/Components/Image";
5
5
  import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
6
- import { toFiniteNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
7
6
 
8
7
  import { useImageSourceWithDefault, useCheckFailedUri } from "./hooks";
8
+ import useImageSize from "./hooks/useImageSize";
9
9
 
10
10
  type Source = {
11
11
  uri: string;
@@ -19,32 +19,13 @@ type Props = Record<string, any> & {
19
19
  withDimensions: (source: Source) => Source;
20
20
  };
21
21
 
22
- const MemoizedImage = React.memo(ImageComponent, R.equals);
23
-
24
- const normalize = Math.ceil;
22
+ const MemoizedImage = React.memo(QBImage, R.equals);
25
23
 
26
24
  const isValidExternalSource = (source): boolean =>
27
25
  source?.uri?.startsWith("http") ||
28
26
  source?.uri?.startsWith("data:image") ||
29
27
  source?.uri?.startsWith("file://");
30
28
 
31
- const isValidSize = (size: unknown): boolean =>
32
- toFiniteNumberWithDefault(0, size) > 0;
33
-
34
- const getSourceWithMaxSizes = (applyMaxSize, style, source) => {
35
- const { width, height } = style;
36
-
37
- if (!applyMaxSize || !isValidSize(width) || !isValidSize(height)) {
38
- return source;
39
- }
40
-
41
- return {
42
- ...source,
43
- maxWidth: normalize(width),
44
- maxHeight: normalize(height),
45
- };
46
- };
47
-
48
29
  export default function Image({
49
30
  style,
50
31
  uri,
@@ -82,10 +63,12 @@ export default function Image({
82
63
 
83
64
  const applyMaxSize = toBooleanWithDefaultFalse(otherProps?.applyMaxSize);
84
65
 
85
- const sourceWithMaxSizes = React.useMemo(
86
- () => withDimensions(getSourceWithMaxSizes(applyMaxSize, style, source)),
87
- [applyMaxSize, style?.height, style?.width, source?.uri, withDimensions]
88
- );
66
+ const sourceWithMaxSizes = useImageSize({
67
+ style,
68
+ applyMaxSize,
69
+ source,
70
+ withDimensions,
71
+ });
89
72
 
90
73
  if (isFailedToLoadUri(uri) || !isValidExternalSource(source)) {
91
74
  return <View style={style} />;
@@ -0,0 +1,65 @@
1
+ import * as React from "react";
2
+ import { ImageStyle } from "react-native";
3
+ import { toFiniteNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
4
+
5
+ type Source = {
6
+ uri: string;
7
+ };
8
+
9
+ type Props = Record<string, any> & {
10
+ style: ImageStyle;
11
+ uri?: string;
12
+ placeholderImage?: string;
13
+ entry?: ZappEntry | ZappFeed;
14
+ withDimensions: (source: Source) => Source;
15
+ };
16
+
17
+ const normalize = Math.ceil;
18
+
19
+ const isValidSize = (size: unknown): boolean =>
20
+ toFiniteNumberWithDefault(0, size) > 0;
21
+
22
+ type WidthDimensions = { aspectRatio?: number; width: number; height?: number };
23
+ type HeightDimensions = {
24
+ aspectRatio?: number;
25
+ width?: number;
26
+ height: number;
27
+ };
28
+ type FullDimensions = { aspectRatio?: number; width: number; height: number };
29
+ type Dimensions = WidthDimensions | HeightDimensions | FullDimensions;
30
+
31
+ const calculateDimensions = ({ aspectRatio, width, height }: Dimensions) => {
32
+ if (aspectRatio) {
33
+ return {
34
+ width: width || height * aspectRatio,
35
+ height: height || width / aspectRatio,
36
+ };
37
+ }
38
+
39
+ return { width, height };
40
+ };
41
+
42
+ const getSourceWithMaxSizes = (applyMaxSize, style, source) => {
43
+ const { width, height } = calculateDimensions(style);
44
+
45
+ if (!applyMaxSize || !isValidSize(width) || !isValidSize(height)) {
46
+ return source;
47
+ }
48
+
49
+ return {
50
+ ...source,
51
+ maxWidth: normalize(width),
52
+ maxHeight: normalize(height),
53
+ };
54
+ };
55
+
56
+ export default function useImageSize(props: Props) {
57
+ const { style, applyMaxSize, source, withDimensions } = props;
58
+
59
+ const sourceWithMaxSizes = React.useMemo(
60
+ () => withDimensions(getSourceWithMaxSizes(applyMaxSize, style, source)),
61
+ [applyMaxSize, style?.height, style?.width, source?.uri, withDimensions]
62
+ );
63
+
64
+ return sourceWithMaxSizes;
65
+ }
@@ -18,6 +18,7 @@ type LiveImageProps = {
18
18
  imageKey?: string;
19
19
  state: "focused" | "unfocused" | "selected";
20
20
  audio_muted_by_default?: boolean;
21
+ uri: string; // cover image url
21
22
  };
22
23
 
23
24
  const DEFAULT_PLAYER_IDENTIFIER = "QuickBrickPlayerPlugin";
@@ -209,10 +210,11 @@ const LiveImageComponent = (props: LiveImageProps) => {
209
210
 
210
211
  return (
211
212
  <>
212
- <Image {...props} />
213
+ <Image {...props} applyMaxSize />
213
214
  {isShouldRender && (
214
215
  <View style={[style, positionAbsolute]}>
215
216
  <PlayerLiveImage
217
+ uri={props.uri}
216
218
  playerId={cellUUID}
217
219
  playerPluginId={playerPluginId}
218
220
  screenConfig={screenConfig}
@@ -1,11 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { isNil } from "ramda";
3
- import { Image as RNImage, ImageStyle, View } from "react-native";
3
+ import { ImageStyle, View } from "react-native";
4
4
  import {
5
5
  FIT_POSITION,
6
6
  IMAGE_SIZING_FIT,
7
7
  IMAGE_SIZING_FILL,
8
8
  } from "@applicaster/zapp-react-native-utils/manifestUtils/secondaryImage";
9
+ import { QBImage as Image } from "@applicaster/zapp-react-native-ui-components/Components/Image";
9
10
 
10
11
  import { useGetImageDimensions } from "./hooks";
11
12
  import {
@@ -59,7 +60,7 @@ const SecondaryImageComponent = (props: Props) => {
59
60
 
60
61
  return (
61
62
  <View style={style} onLayout={onAsyncRender}>
62
- <RNImage
63
+ <Image
63
64
  {...props}
64
65
  source={{ uri }}
65
66
  style={{
@@ -23,7 +23,11 @@ export const Toggle = (props: Props) => {
23
23
  iosBackgroundColor,
24
24
  } = style;
25
25
 
26
- const isSelected = React.useMemo(() => (cellState === "selected"), [item?.id, cellState]);
26
+ const isSelected = React.useMemo(
27
+ () => cellState === "selected",
28
+ [item?.id, cellState]
29
+ );
30
+
27
31
  const actionContext = useActions(action?.identifier);
28
32
 
29
33
  const [actionState, setActionState] = useState(
@@ -1,6 +1,7 @@
1
- import { path, pathOr } from "ramda";
1
+ import { path } from "ramda";
2
2
  import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
3
3
  import {
4
+ getColorFromData,
4
5
  getKeyForLabel,
5
6
  mapSelfAlignment,
6
7
  } from "@applicaster/zapp-react-native-utils/cellUtils";
@@ -48,19 +49,12 @@ export const CollapsibleTextContainer = ({
48
49
  ]),
49
50
  {
50
51
  func: (data) => {
51
- const value = getValue("background_color");
52
-
53
- const valueFromData = pathOr(value, value.split("."), data);
54
-
55
- if (
56
- valueFromData &&
57
- (valueFromData.startsWith("#") || valueFromData.startsWith("rgba("))
58
- ) {
59
- return valueFromData;
60
- }
61
-
62
- // return default value
63
- return additionalStyles.backgroundColor;
52
+ return getColorFromData({
53
+ data,
54
+ getValue,
55
+ key: "background_color",
56
+ defaultColor: additionalStyles.backgroundColor,
57
+ });
64
58
  },
65
59
  propName: "backgroundColor",
66
60
  },
@@ -285,8 +285,8 @@ export const useBehaviorUpdate = (behavior: Behavior) => {
285
285
  }
286
286
  }
287
287
  }, [behavior]);
288
-
289
- useEffect(() => {
288
+
289
+ useEffect(() => {
290
290
  if (!behavior) {
291
291
  return;
292
292
  }
@@ -145,34 +145,30 @@ const renderApplePlayer = ({
145
145
  }) => {
146
146
  const { title, summary } = item || {};
147
147
 
148
- if (!isApplePlatform()) {
148
+ if (!isAppleTV() || !player) {
149
+ return null;
150
+ }
151
+
152
+ if (isAudioContent) {
153
+ return (
154
+ <AudioPlayer
155
+ audio_item={item}
156
+ plugin_configuration={pluginConfiguration}
157
+ />
158
+ );
159
+ }
160
+
161
+ if (!playNextData && player.isPaused() && player.isAd() === false) {
149
162
  return null;
150
163
  }
151
164
 
152
165
  return (
153
- <>
154
- {!playNextData && (
155
- <>
156
- {!isAudioContent &&
157
- !!player?.isPaused() &&
158
- !!player?.isAd() === false && (
159
- <ProgramInfo
160
- title={title}
161
- subtitle={summary}
162
- plugin_configuration={pluginConfiguration}
163
- videoStyle={videoStyle}
164
- />
165
- )}
166
- </>
167
- )}
168
-
169
- {isAudioContent && (
170
- <AudioPlayer
171
- audio_item={item}
172
- plugin_configuration={pluginConfiguration}
173
- />
174
- )}
175
- </>
166
+ <ProgramInfo
167
+ title={title}
168
+ subtitle={summary}
169
+ plugin_configuration={pluginConfiguration}
170
+ videoStyle={videoStyle}
171
+ />
176
172
  );
177
173
  };
178
174
 
@@ -339,6 +335,18 @@ const PlayerContainerComponent = (props: Props) => {
339
335
  }
340
336
  }, [item?.id, item?.extensions?.resumeTime, player]);
341
337
 
338
+ const onVideoFullscreenPlayerWillPresent = React.useCallback(() => {
339
+ playerManager.invokeHandler("toggleFullscreen", {
340
+ fullscreen: true,
341
+ });
342
+ }, []);
343
+
344
+ const onVideoFullscreenPlayerWillDismiss = React.useCallback(() => {
345
+ playerManager.invokeHandler("toggleFullscreen", {
346
+ fullscreen: false,
347
+ });
348
+ }, []);
349
+
342
350
  // Util methods
343
351
  const toggleFullscreen = (event) => {
344
352
  const { fullscreen = false } = event || {};
@@ -381,17 +389,27 @@ const PlayerContainerComponent = (props: Props) => {
381
389
  id: playerContainerId,
382
390
  listener: {
383
391
  onVideoEnd,
384
- onError: onError,
385
- onLoad: onLoad,
392
+ onError,
393
+ onLoad,
386
394
  onPlayerClose: close,
387
395
  onPlayerDetached: close,
396
+ onVideoFullscreenPlayerWillDismiss,
397
+ onVideoFullscreenPlayerWillPresent,
388
398
  },
389
399
  });
390
400
 
391
401
  return () => {
392
402
  player.removeListener(playerContainerId);
393
403
  };
394
- }, [player, onVideoEnd]);
404
+ }, [
405
+ player,
406
+ onVideoEnd,
407
+ onError,
408
+ onLoad,
409
+ close,
410
+ onVideoFullscreenPlayerWillDismiss,
411
+ onVideoFullscreenPlayerWillPresent,
412
+ ]);
395
413
 
396
414
  useEffect(() => {
397
415
  // TODO: We should not use playerManager here to connect buttons to player container
@@ -621,7 +639,7 @@ const PlayerContainerComponent = (props: Props) => {
621
639
  }}
622
640
  focused={isInlineTV ? true : undefined}
623
641
  autoplay={true}
624
- controls={isAppleTV() && !isInlineTV}
642
+ controls={false}
625
643
  disableCastAction={disableCastAction}
626
644
  docked={navigator.isVideoModalDocked()}
627
645
  entry={item}
@@ -4,7 +4,9 @@ import { styleKeys } from "@applicaster/zapp-react-native-utils/styleKeysUtils";
4
4
  import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform";
5
5
  import * as R from "ramda";
6
6
  import * as React from "react";
7
- import { Image, Text, TextStyle, View, ViewStyle } from "react-native";
7
+ import { Text, TextStyle, View, ViewStyle } from "react-native";
8
+ import { QBImage as Image } from "@applicaster/zapp-react-native-ui-components/Components/Image";
9
+
8
10
  import * as programStyles from "./styles";
9
11
 
10
12
  type Props = {
@@ -21,6 +21,7 @@ import {
21
21
  import { useScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData";
22
22
  import { isLast } from "@applicaster/zapp-react-native-utils/arrayUtils";
23
23
  import { withComponentsMapProvider } from "@applicaster/zapp-react-native-ui-components/Decorators/ComponentsMapWrapper";
24
+ import { useScreenScrollStore } from "@applicaster/zapp-react-native-utils/screenState";
24
25
 
25
26
  type Props = {
26
27
  feed: ZappFeed;
@@ -193,6 +194,27 @@ function ComponentsMapComponent(props: Props) {
193
194
  []
194
195
  );
195
196
 
197
+ const onScrollFlatList = React.useCallback(
198
+ ({ nativeEvent }, isScrollingDone = false) => {
199
+ const {
200
+ contentOffset: { y },
201
+ } = nativeEvent;
202
+
203
+ useScreenScrollStore.setState({
204
+ scrollingVelocity: isScrollingDone ? 0 : 1,
205
+ scrollPosition: y,
206
+ });
207
+ },
208
+ []
209
+ );
210
+
211
+ const onMomentumScrollEnd = React.useCallback(
212
+ ({ nativeEvent }) => {
213
+ onScrollFlatList({ nativeEvent }, true);
214
+ },
215
+ [onScrollFlatList]
216
+ );
217
+
196
218
  if (shouldShowLoadingError) {
197
219
  return <RiverError />;
198
220
  }
@@ -227,6 +249,9 @@ function ComponentsMapComponent(props: Props) {
227
249
  }
228
250
  ListFooterComponent={renderFooter}
229
251
  refreshControl={refreshControl}
252
+ onScroll={onScrollFlatList}
253
+ onMomentumScrollEnd={onMomentumScrollEnd}
254
+ scrollEventThrottle={16}
230
255
  {...scrollViewExtraProps}
231
256
  />
232
257
  </ViewportTracker>
@@ -4,7 +4,6 @@ import * as React from "react";
4
4
  import { Text } from "react-native";
5
5
  import * as R from "ramda";
6
6
 
7
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
8
7
  import {
9
8
  useFeedLoader,
10
9
  useLayoutVersion,
@@ -20,6 +19,7 @@ import {
20
19
  useNavbarState,
21
20
  useSetNavbarState,
22
21
  } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
22
+ import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks/state";
23
23
 
24
24
  type Props = {
25
25
  screenId: string;
@@ -53,7 +53,7 @@ export const River = (props: Props) => {
53
53
 
54
54
  const navigationPluginData = useNavigationPluginData();
55
55
 
56
- const { rivers } = usePickFromState(["rivers"]);
56
+ const rivers = useRivers();
57
57
  const isV2 = useLayoutVersion({ isV2: true });
58
58
 
59
59
  const river = React.useMemo(() => rivers?.[screenId], [screenId]);
@@ -64,7 +64,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
64
64
  refreshControl={null}
65
65
  removeClippedSubviews={true}
66
66
  renderItem={[Function]}
67
- scrollEventThrottle={50}
67
+ scrollEventThrottle={16}
68
68
  scrollIndicatorInsets={
69
69
  Object {
70
70
  "right": 1,
@@ -83,6 +83,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
83
83
  useNavigation: jest.fn(() => ({ currentRoute: "/river/A1234" })),
84
84
  useRoute: jest.fn(() => ({ pathname: "/river/A1234", screenData })),
85
85
  useProfilerLogging: jest.fn(),
86
+ useIsScreenActive: jest.fn().mockReturnValue(true),
86
87
  }));
87
88
 
88
89
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
@@ -1,10 +1,10 @@
1
1
  import * as R from "ramda";
2
2
 
3
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
4
3
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
5
4
  import { toCamelCase } from "@applicaster/zapp-react-native-utils/stringUtils";
6
5
  import { useMemo } from "react";
7
6
  import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
7
+ import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks/state";
8
8
 
9
9
  type GeneralContentScreen = ZappRiver & {
10
10
  styles: {
@@ -46,7 +46,7 @@ const stylingKeys = [
46
46
  ];
47
47
 
48
48
  export function useScreenConfiguration(screenId: string): ScreenConfiguration {
49
- const { rivers } = usePickFromState(["rivers"]);
49
+ const rivers = useRivers();
50
50
  const isTablet = useIsTablet();
51
51
 
52
52
  return useMemo(() => {
@@ -5,6 +5,7 @@ exports[`<RouteManager /> renders correctly 1`] = `
5
5
  screenId="A1234"
6
6
  >
7
7
  <WithProvider
8
+ pathname="/river/A1234"
8
9
  screenData={
9
10
  Object {
10
11
  "id": "A1234",
@@ -2,11 +2,17 @@ import React from "react";
2
2
  import { shallow } from "enzyme";
3
3
  import { shallowToJson } from "enzyme-to-json";
4
4
 
5
- import { ScreenResolver } from "@applicaster/zapp-react-native-ui-components/Components/ScreenResolver";
6
-
7
5
  const pathname = "/river/A1234";
8
6
  const screenData = { id: "A1234" };
9
7
 
8
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
9
+ useRoute: jest.fn(() => ({ pathname: pathname, screenData: screenData })),
10
+ }));
11
+
12
+ const {
13
+ ScreenResolver,
14
+ } = require("@applicaster/zapp-react-native-ui-components/Components/ScreenResolver");
15
+
10
16
  const { RouteManager } = require("../index");
11
17
 
12
18
  describe("<RouteManager />", () => {
@@ -20,6 +26,7 @@ describe("<RouteManager />", () => {
20
26
 
21
27
  it("passes the correct props to ScreenResolver", () => {
22
28
  expect(wrapper.find(ScreenResolver).props()).toEqual({
29
+ pathname: "/river/A1234",
23
30
  screenType: "river",
24
31
  screenId: "A1234",
25
32
  screenData: { id: "A1234" },
@@ -2,6 +2,7 @@ import * as React from "react";
2
2
  import * as R from "ramda";
3
3
 
4
4
  import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
5
+ import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
5
6
  import { ScreenResolver } from "../ScreenResolver";
6
7
  import { TestId } from "./TestId";
7
8
 
@@ -12,7 +13,8 @@ type Props = { pathname: string; screenData: Record<string, any> };
12
13
  * and reconciles data returned from hook plugins if needed
13
14
  * @param {Props}: see props above
14
15
  */
15
- export function RouteManager({ pathname, screenData, ...otherProps }: Props) {
16
+ export function RouteManager(props: Props) {
17
+ const { pathname, screenData: _screenData } = useRoute();
16
18
  const pathAttributes = getPathAttributes({ pathname });
17
19
 
18
20
  const { screenType, screenId } = R.last(pathAttributes);
@@ -22,8 +24,8 @@ export function RouteManager({ pathname, screenData, ...otherProps }: Props) {
22
24
  <ScreenResolver
23
25
  screenType={screenType}
24
26
  screenId={screenId}
25
- screenData={screenData}
26
- {...otherProps}
27
+ {...props}
28
+ screenData={props.screenData}
27
29
  />
28
30
  </TestId>
29
31
  );