@applicaster/zapp-react-native-ui-components 12.0.0-alpha.9611121395 → 12.0.0-alpha.9739074790

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/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  2. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  3. package/Components/Layout/TV/index.tsx +12 -9
  4. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  5. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +80 -109
  6. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  7. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  8. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  9. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +14 -1
  10. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  11. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  12. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  13. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
  14. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  15. package/Components/MasterCell/utils/index.ts +16 -5
  16. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  17. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  18. package/Components/PlayerContainer/PlayerContainer.tsx +15 -2
  19. package/Components/PlayerImageBackground/index.tsx +34 -8
  20. package/Components/River/ComponentsMap/ComponentsMap.tsx +92 -41
  21. package/Components/River/RefreshControl.tsx +55 -1
  22. package/Components/River/__tests__/componentsMap.test.js +6 -0
  23. package/Components/RouteManager/index.tsx +2 -2
  24. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -0
  25. package/Components/Transitioner/Scene.tsx +24 -19
  26. package/Components/Transitioner/Transitioner.tsx +9 -2
  27. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
  28. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  29. package/Components/VideoLive/LiveImageManager.ts +3 -0
  30. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +20 -5
  31. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
  32. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
  33. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +342 -0
  34. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +151 -0
  35. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +438 -0
  36. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +154 -0
  37. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  38. package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
  39. package/Components/VideoModal/PlayerDetails.tsx +3 -3
  40. package/Components/VideoModal/PlayerWrapper.tsx +78 -48
  41. package/Components/VideoModal/VideoModal.tsx +25 -42
  42. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -1
  43. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +151 -119
  44. package/Components/VideoModal/utils.ts +3 -3
  45. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  46. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  47. package/Components/Viewport/utils.js +1 -1
  48. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  49. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  50. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  51. package/Contexts/ScreenContext/index.tsx +94 -25
  52. package/Contexts/ScreenDataContext/index.ts +3 -0
  53. package/events/index.ts +1 -0
  54. package/package.json +5 -5
  55. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  56. /package/Contexts/{index.js → index.ts} +0 -0
@@ -35,7 +35,16 @@ const MeasurementsPortal = ({ Component, onLayout, componentProps }: Props) => {
35
35
  );
36
36
  };
37
37
 
38
- const MeasurementPortalContext = React.createContext(null);
38
+ type MeasurementPortalContextType = {
39
+ measureComponent?: (
40
+ comp: React.ElementType,
41
+ props: Record<any, any>
42
+ ) => Promise<any>;
43
+ measuringInProgress?: boolean;
44
+ };
45
+
46
+ const MeasurementPortalContext =
47
+ React.createContext<null | MeasurementPortalContextType>(null);
39
48
 
40
49
  const MeasurementsPortalContextProvider = ({ children }) => {
41
50
  const Component = React.useRef(View);
@@ -54,6 +54,11 @@ import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
54
54
  import { usePlayNextOverlay } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayNextOverlay";
55
55
  import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
56
56
 
57
+ import {
58
+ useModalAnimationContext,
59
+ PlayerAnimationStateEnum,
60
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
61
+
57
62
  type Props = {
58
63
  Player: React.ComponentType<any>;
59
64
  PlayerLoadingView?: React.ComponentType<any>; // 👀 we are not receiving this prop
@@ -229,6 +234,9 @@ const PlayerContainerComponent = (props: Props) => {
229
234
  const screenData = useTargetScreenData(item);
230
235
  const { setVisible: showNavBar } = useSetNavbarState();
231
236
 
237
+ const { isActiveGesture, startComponentsAnimation, setPlayerAnimationState } =
238
+ useModalAnimationContext();
239
+
232
240
  const playerEvent = (event, ...args) => {
233
241
  playerManager.invokeHandler(event, ...args);
234
242
  };
@@ -446,7 +454,7 @@ const PlayerContainerComponent = (props: Props) => {
446
454
  if (disableMiniPlayer) {
447
455
  navigator.closeVideoModal();
448
456
  } else {
449
- navigator.minimiseVideoModal();
457
+ setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
450
458
  }
451
459
  }
452
460
 
@@ -641,7 +649,11 @@ const PlayerContainerComponent = (props: Props) => {
641
649
  autoplay={true}
642
650
  controls={false}
643
651
  disableCastAction={disableCastAction}
644
- docked={navigator.isVideoModalDocked()}
652
+ docked={
653
+ navigator.isVideoModalDocked() &&
654
+ !startComponentsAnimation &&
655
+ !isActiveGesture
656
+ }
645
657
  entry={item}
646
658
  fullscreen={mode === VideoModalMode.FULLSCREEN}
647
659
  inline={inline}
@@ -659,6 +671,7 @@ const PlayerContainerComponent = (props: Props) => {
659
671
  setNextVideoPreloadThresholdPercentage={
660
672
  setNextVideoPreloadThresholdPercentage
661
673
  }
674
+ startComponentsAnimation={startComponentsAnimation}
662
675
  >
663
676
  {renderApplePlayer(applePlayerProps)}
664
677
  </Player>
@@ -1,38 +1,64 @@
1
1
  import React, { PropsWithChildren } from "react";
2
- import { ImageBackground } from "react-native";
2
+ import { ImageBackground, View } from "react-native";
3
3
 
4
4
  import { imageSrcFromMediaItem } from "@applicaster/zapp-react-native-utils/configurationUtils";
5
+ import {
6
+ AnimationComponent,
7
+ ComponentAnimationType,
8
+ useModalAnimationContext,
9
+ PlayerAnimationStateEnum,
10
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
5
11
 
6
12
  type Props = PropsWithChildren<{
7
13
  entry: ZappEntry;
8
14
  style?: { [K: string]: any };
9
15
  imageStyle?: { [K: string]: any };
10
16
  imageKey?: string;
17
+ defaultImageDimensions?: { [K: string]: any };
11
18
  }>;
12
19
 
20
+ const imageSize = { width: "100%", height: "100%" };
21
+
13
22
  const PlayerImageBackgroundComponent = ({
14
23
  entry,
15
24
  children,
16
25
  style,
17
26
  imageStyle,
18
27
  imageKey,
28
+ defaultImageDimensions,
19
29
  }: Props) => {
20
30
  const source = React.useMemo(
21
31
  () => ({ uri: imageSrcFromMediaItem(entry, imageKey) }),
22
32
  [imageKey, entry]
23
33
  );
24
34
 
35
+ const { playerAnimationState } = useModalAnimationContext();
36
+
25
37
  if (!source) return <>{children}</>;
26
38
 
27
39
  return (
28
- <ImageBackground
29
- resizeMode="cover"
30
- style={style}
31
- imageStyle={imageStyle}
32
- source={source}
40
+ <View
41
+ style={
42
+ playerAnimationState === PlayerAnimationStateEnum.maximaze
43
+ ? defaultImageDimensions
44
+ : style
45
+ }
33
46
  >
34
- {children}
35
- </ImageBackground>
47
+ <AnimationComponent
48
+ style={style}
49
+ animationType={ComponentAnimationType.player}
50
+ additionalData={defaultImageDimensions}
51
+ >
52
+ <ImageBackground
53
+ resizeMode="cover"
54
+ style={imageSize}
55
+ imageStyle={imageStyle}
56
+ source={source}
57
+ >
58
+ {children}
59
+ </ImageBackground>
60
+ </AnimationComponent>
61
+ </View>
36
62
  );
37
63
  };
38
64
 
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
- import { View, FlatList, StyleSheet, Platform } from "react-native";
3
+ import { View, StyleSheet, Platform, FlatList } from "react-native";
4
4
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
5
5
  import { RiverItem } from "../RiverItem";
6
6
  import { RiverFooter } from "../RiverFooter";
@@ -21,7 +21,8 @@ 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
+ import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
25
+ import { useShallow } from "zustand/react/shallow";
25
26
 
26
27
  type Props = {
27
28
  feed: ZappFeed;
@@ -41,8 +42,10 @@ const styles = StyleSheet.create({
41
42
  },
42
43
  });
43
44
 
44
- const scrollIndicatorInsets = { right: 1 };
45
+ const getNearestValue = (value, optionA, optionB) =>
46
+ Math.abs(value - optionA) < Math.abs(value - optionB) ? optionA : optionB;
45
47
 
48
+ const scrollIndicatorInsets = { right: 1 };
46
49
  const keyExtractor = R.compose(String, R.prop("id"));
47
50
 
48
51
  function ComponentsMapComponent(props: Props) {
@@ -60,6 +63,7 @@ function ComponentsMapComponent(props: Props) {
60
63
  refreshingPipesV1,
61
64
  } = props;
62
65
 
66
+ const flatListRef = React.useRef<FlatList | null>(null);
63
67
  const screenConfig = useScreenConfiguration(riverId);
64
68
  const screenData = useScreenData(riverId);
65
69
  const pullToRefreshEnabled = screenData?.rules?.pull_to_refresh_enabled;
@@ -194,44 +198,87 @@ function ComponentsMapComponent(props: Props) {
194
198
  []
195
199
  );
196
200
 
197
- const onScrollFlatList = React.useCallback(
198
- ({ nativeEvent }, isScrollingDone = false) => {
199
- const {
200
- contentOffset: { y },
201
- } = nativeEvent;
202
-
203
- const oldState = useScreenScrollStore.getState();
204
- const scrollingVelocity = isScrollingDone ? 0 : 1;
205
- const scrollPosition = y;
206
-
207
- if (
208
- scrollingVelocity !== oldState.scrollingVelocity ||
209
- scrollPosition !== oldState.scrollPosition
210
- ) {
211
- useScreenScrollStore.setState({
212
- scrollingVelocity,
213
- scrollPosition,
214
- });
215
- }
216
- },
217
- []
218
- );
201
+ const navBarStore = useScreenContextV2()._navBarStore;
219
202
 
220
- const onMomentumScrollEnd = React.useCallback(
221
- ({ nativeEvent }) => {
222
- onScrollFlatList({ nativeEvent }, true);
223
- },
224
- [onScrollFlatList]
203
+ const scrollY = navBarStore(
204
+ useShallow(({ scrollYAnimated }) => scrollYAnimated)
225
205
  );
226
206
 
227
- const onScrollEndDrag = React.useCallback(
228
- ({ nativeEvent }) => {
229
- if (nativeEvent.velocity.y === 0) {
230
- onScrollFlatList({ nativeEvent }, true);
207
+ const canMomentum = React.useRef(false);
208
+
209
+ const onScrollBeginDrag = React.useCallback(() => {
210
+ canMomentum.current = true;
211
+ }, []);
212
+
213
+ /* onMomentumScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
214
+ const _onMomentumScrollEnd = React.useCallback(({ nativeEvent }) => {
215
+ if (!canMomentum.current) return;
216
+ canMomentum.current = false;
217
+
218
+ const { height: headerHeight, scrollState } = navBarStore.getState();
219
+
220
+ const offsetY = Math.max(0, nativeEvent.contentOffset.y);
221
+
222
+ if (
223
+ !(scrollState === 0 || scrollState === -headerHeight) &&
224
+ flatListRef.current
225
+ ) {
226
+ const offset =
227
+ getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
228
+ -headerHeight
229
+ ? Math.round(offsetY + scrollState + headerHeight)
230
+ : Math.round(offsetY + scrollState);
231
+
232
+ flatListRef.current.scrollToOffset({
233
+ animated: true,
234
+ offset,
235
+ });
236
+ }
237
+ }, []);
238
+
239
+ /* onScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
240
+ const _onScrollEndDrag = React.useCallback(({ nativeEvent }) => {
241
+ const { height: headerHeight, scrollState } = navBarStore.getState();
242
+
243
+ const offsetY = Math.max(0, nativeEvent.contentOffset.y);
244
+
245
+ if (
246
+ !(scrollState === 0 || scrollState === -headerHeight) &&
247
+ flatListRef.current &&
248
+ nativeEvent.velocity.y === 0
249
+ ) {
250
+ const offset =
251
+ getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
252
+ -headerHeight
253
+ ? Math.round(offsetY + scrollState + headerHeight)
254
+ : Math.round(offsetY + scrollState);
255
+
256
+ flatListRef.current.scrollToOffset({
257
+ animated: true,
258
+ offset,
259
+ });
260
+ }
261
+ }, []);
262
+
263
+ const onScroll = React.useCallback((event) => {
264
+ const {
265
+ nativeEvent: {
266
+ contentOffset: { y },
267
+ layoutMeasurement: { height },
268
+ contentSize: { height: contentHeight },
269
+ },
270
+ } = event;
271
+
272
+ if (y >= 0 && y + height <= contentHeight) {
273
+ scrollY.setValue(y);
274
+ } else {
275
+ if (y <= 0) {
276
+ scrollY.setValue(0);
277
+ } else if (y + height > contentHeight) {
278
+ scrollY.setValue(contentHeight - height);
231
279
  }
232
- },
233
- [onScrollFlatList]
234
- );
280
+ }
281
+ }, []);
235
282
 
236
283
  if (shouldShowLoadingError) {
237
284
  return <RiverError />;
@@ -248,6 +295,9 @@ function ComponentsMapComponent(props: Props) {
248
295
  >
249
296
  <ViewportTracker>
250
297
  <FlatList
298
+ ref={(ref) => {
299
+ flatListRef.current = ref;
300
+ }}
251
301
  // Fix for WebView rerender crashes on Android API 28+
252
302
  // https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
253
303
  overScrollMode={Platform.OS === "android" ? "never" : "auto"}
@@ -267,10 +317,11 @@ function ComponentsMapComponent(props: Props) {
267
317
  }
268
318
  ListFooterComponent={renderFooter}
269
319
  refreshControl={refreshControl}
270
- onScroll={onScrollFlatList}
271
- onScrollEndDrag={Platform.OS === "ios" && onScrollEndDrag}
272
- onMomentumScrollEnd={onMomentumScrollEnd}
273
- scrollEventThrottle={50}
320
+ onScrollBeginDrag={onScrollBeginDrag}
321
+ onScroll={onScroll}
322
+ onMomentumScrollEnd={_onMomentumScrollEnd}
323
+ onScrollEndDrag={_onScrollEndDrag}
324
+ scrollEventThrottle={16}
274
325
  {...scrollViewExtraProps}
275
326
  />
276
327
  </ViewportTracker>
@@ -1,5 +1,9 @@
1
1
  import * as React from "react";
2
- import { RefreshControl as RNRefreshControl } from "react-native";
2
+ import {
3
+ Platform,
4
+ RefreshControl as RNRefreshControl,
5
+ StyleSheet,
6
+ } from "react-native";
3
7
  import * as R from "ramda";
4
8
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
5
9
  import { useLocalizedStrings } from "@applicaster/zapp-react-native-utils/localizationUtils";
@@ -8,10 +12,30 @@ import { useSendAnalyticsEventWithFunction } from "@applicaster/zapp-react-nativ
8
12
  import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
9
13
  import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
10
14
  import { useDispatch } from "react-redux";
15
+ import { useShallow } from "zustand/react/shallow";
16
+ import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
17
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
11
18
 
12
19
  const BRIGHTNESS_THRESHOLD = 160;
13
20
  const ABOVE_DEFAULT_COLOR = "gray";
14
21
  const BELOW_DEFAULT_COLOR = "white";
22
+ const BASE_INDICATOR_HEIGHT = 40;
23
+ const BASE_INDICATOR_OFFSET = 16;
24
+
25
+ /** Return spacing required to position indicator below the navbar bottom line (Android only) */
26
+ const getRefreshControlOffset = () => {
27
+ return Platform.OS === "ios"
28
+ ? 0
29
+ : BASE_INDICATOR_HEIGHT + BASE_INDICATOR_OFFSET;
30
+ };
31
+
32
+ const styles = StyleSheet.create({
33
+ // eslint-disable-next-line react-native/no-color-literals
34
+ control: {
35
+ zIndex: 1,
36
+ backgroundColor: "transparent",
37
+ },
38
+ });
15
39
 
16
40
  const getBrightness = (RGBcolor) => {
17
41
  const RGBvalues = RGBcolor.substring(
@@ -91,6 +115,34 @@ export const usePullToRefresh = (
91
115
  };
92
116
  };
93
117
 
118
+ /** Returns the offset for the progress view of the RefreshControl component
119
+ * based on navbar content position */
120
+ export const useGetProgressViewOffset = () => {
121
+ const { _navBarStore } = useScreenContextV2();
122
+ const { top } = useSafeAreaInsets();
123
+
124
+ const offset = getRefreshControlOffset();
125
+
126
+ const { height, contentPosition } = _navBarStore(
127
+ useShallow(({ contentPosition, height }) => ({ contentPosition, height }))
128
+ );
129
+
130
+ if (height === 0) {
131
+ return offset;
132
+ }
133
+
134
+ switch (contentPosition) {
135
+ case "on_bottom_status_bar":
136
+ // navbar height
137
+ return offset + height;
138
+ case "on_top_screen":
139
+ // navbar height + status bar height
140
+ return offset + height + top;
141
+ default:
142
+ return offset;
143
+ }
144
+ };
145
+
94
146
  export function RefreshControl(props: {
95
147
  pullToRefreshPipesV1RefreshingStateUpdater?: (refreshing: boolean) => void;
96
148
  refreshingPipesV1?: boolean;
@@ -211,6 +263,7 @@ export function RefreshControl(props: {
211
263
  refreshing={refreshing}
212
264
  onRefresh={onRefreshHandler}
213
265
  colors={[preparedIndicatorColor]}
266
+ progressViewOffset={useGetProgressViewOffset()}
214
267
  progressBackgroundColor={preparedIndicatorBackgroundColor}
215
268
  // @ts-ignore in RN68 this `size` became string
216
269
  size={indicatorSize}
@@ -222,6 +275,7 @@ export function RefreshControl(props: {
222
275
  : null
223
276
  }
224
277
  titleColor={preparedTitleUnderIndicatorColor}
278
+ style={styles.control}
225
279
  />
226
280
  );
227
281
  }
@@ -6,6 +6,12 @@ import configureStore from "redux-mock-store";
6
6
 
7
7
  import * as themeUtils from "@applicaster/zapp-react-native-utils/theme";
8
8
 
9
+ // silences the errors related to React-native-gesture-handler in tests
10
+ jest.mock(
11
+ "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation",
12
+ () => () => null
13
+ );
14
+
9
15
  jest.mock("react-native-safe-area-context", () => ({
10
16
  useSafeAreaInsets: () => ({ top: 50 }),
11
17
  }));
@@ -14,7 +14,7 @@ type Props = { pathname: string; screenData: Record<string, any> };
14
14
  * @param {Props}: see props above
15
15
  */
16
16
  export function RouteManager(props: Props) {
17
- const { pathname, screenData: _screenData } = useRoute();
17
+ const { pathname, screenData } = useRoute();
18
18
  const pathAttributes = getPathAttributes({ pathname });
19
19
 
20
20
  const { screenType, screenId } = R.last(pathAttributes);
@@ -25,7 +25,7 @@ export function RouteManager(props: Props) {
25
25
  screenType={screenType}
26
26
  screenId={screenId}
27
27
  {...props}
28
- screenData={props.screenData}
28
+ screenData={screenData}
29
29
  />
30
30
  </TestId>
31
31
  );
@@ -11,7 +11,9 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
11
11
  }
12
12
  >
13
13
  <View
14
+ hasMenu={false}
14
15
  id="/river/testId"
16
+ pathname="/river/testId"
15
17
  selected="testId"
16
18
  testID="navBar"
17
19
  title=""
@@ -41,7 +43,9 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
41
43
  }
42
44
  >
43
45
  <View
46
+ hasMenu={false}
44
47
  id="/river/testId"
48
+ pathname="/river/testId"
45
49
  selected="testId"
46
50
  testID="navBar"
47
51
  title=""
@@ -7,6 +7,7 @@ import {
7
7
  } from "react-native";
8
8
  import { useSafeAreaFrame } from "react-native-safe-area-context";
9
9
  import { PathnameContext } from "../../Contexts/PathnameContext";
10
+ import { ScreenDataContext } from "../../Contexts/ScreenDataContext";
10
11
 
11
12
  type Props = {
12
13
  children: any;
@@ -16,6 +17,8 @@ type Props = {
16
17
  animating: boolean;
17
18
  contentStyle: ViewStyle;
18
19
  pathname: string;
20
+ isActive: boolean;
21
+ screenData: NavigationScreenData;
19
22
  };
20
23
 
21
24
  /**
@@ -38,34 +41,36 @@ export function Scene({
38
41
  animating,
39
42
  contentStyle,
40
43
  pathname,
44
+ isActive = false,
45
+ screenData,
41
46
  }: Props) {
47
+ const [initialScreenData, setInitialScreenData] = React.useState(screenData);
48
+
49
+ React.useLayoutEffect(() => {
50
+ if (isActive) {
51
+ setInitialScreenData(screenData);
52
+ }
53
+ }, [screenData, isActive]);
54
+
42
55
  const frame = useSafeAreaFrame();
43
56
  const { height, width } = useWindowDimensions();
44
57
 
45
- if (overlayStyle && animating) {
46
- // Safe frame takes too long to update,
47
- // so we can not rely on it there, and use height and width instead.
48
- return (
49
- <Animated.View
50
- pointerEvents={pointerEvents}
51
- style={[style, contentStyle, { height, width }]}
52
- >
53
- <PathnameContext.Provider value={pathname}>
54
- {children}
55
- </PathnameContext.Provider>
56
- <Animated.View style={overlayStyle} />
57
- </Animated.View>
58
- );
59
- }
58
+ // Safe frame takes too long to update,
59
+ // so we can not rely on it there, and use height and width instead.
60
+ const isAnimating = animating && overlayStyle;
61
+ const dimensions = isAnimating ? { height, width } : frame;
60
62
 
61
63
  return (
62
64
  <Animated.View
63
65
  pointerEvents={pointerEvents}
64
- style={[style, contentStyle, frame]}
66
+ style={[style, contentStyle, dimensions]}
65
67
  >
66
- <PathnameContext.Provider value={pathname}>
67
- {children}
68
- </PathnameContext.Provider>
68
+ <ScreenDataContext.Provider value={initialScreenData}>
69
+ <PathnameContext.Provider value={pathname}>
70
+ {children}
71
+ </PathnameContext.Provider>
72
+ </ScreenDataContext.Provider>
73
+ {isAnimating && <Animated.View style={overlayStyle} />}
69
74
  </Animated.View>
70
75
  );
71
76
  }
@@ -278,7 +278,8 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
278
278
  // instead of dangerous nulls or duplicates.
279
279
  renderSingleScene({ scenes, to }) {
280
280
  const { contentStyle, layoutData } = this.props;
281
- const screenData = scenes[to.index]?.children?.props?.screenData;
281
+ const screenData = this.props.children.props.screenData;
282
+ const pathname = scenes[to.index].key;
282
283
 
283
284
  const orientation = getScreenOrientation({
284
285
  screenData,
@@ -296,10 +297,12 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
296
297
  }) && (
297
298
  <Scene
298
299
  {...{ style: to.style }}
299
- pathname={scenes[to.index].key}
300
+ pathname={pathname}
301
+ isActive={pathname === this.props.navigator.currentRoute}
300
302
  contentStyle={contentStyle}
301
303
  key={scenes[to.index].key}
302
304
  screenUniqueId={scenes[to.index].screenUniqueId}
305
+ screenData={screenData}
303
306
  >
304
307
  {scenes[to.index].children}
305
308
  </Scene>
@@ -319,12 +322,14 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
319
322
  <Scene
320
323
  key={scenes[from.index].key}
321
324
  pathname={scenes[from.index].key}
325
+ isActive={scenes[from.index].key === this.props.navigator.currentRoute}
322
326
  style={from.style}
323
327
  pointerEvents="none"
324
328
  overlayStyle={from.overlayStyle}
325
329
  animating={this.state.animating}
326
330
  contentStyle={contentStyle}
327
331
  screenUniqueId={scenes[from.index].screenUniqueId}
332
+ screenData={scenes[from.index].children.props.screenData}
328
333
  >
329
334
  {scenes[from.index].children}
330
335
  </Scene>
@@ -333,12 +338,14 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
333
338
  const toScene = scenes[to.index] && (
334
339
  <Scene
335
340
  pathname={scenes[to.index].key}
341
+ isActive={scenes[to.index].key === this.props.navigator.currentRoute}
336
342
  key={scenes[to.index].key}
337
343
  style={to.style}
338
344
  overlayStyle={to.overlayStyle}
339
345
  animating={this.state.animating}
340
346
  contentStyle={contentStyle}
341
347
  screenUniqueId={scenes[to.index].screenUniqueId}
348
+ screenData={this.props.children.props.screenData}
342
349
  >
343
350
  {scenes[to.index].children}
344
351
  </Scene>
@@ -21,7 +21,9 @@ exports[`<Scene /> renders correctly 1`] = `
21
21
  ]
22
22
  }
23
23
  >
24
- <ContextProvider />
24
+ <ContextProvider>
25
+ <ContextProvider />
26
+ </ContextProvider>
25
27
  </ForwardRef(AnimatedComponentWrapper)>
26
28
  `;
27
29
 
@@ -43,7 +45,9 @@ exports[`<Scene /> renders the overlay while animating 1`] = `
43
45
  ]
44
46
  }
45
47
  >
46
- <ContextProvider />
48
+ <ContextProvider>
49
+ <ContextProvider />
50
+ </ContextProvider>
47
51
  <ForwardRef(AnimatedComponentWrapper)
48
52
  style={
49
53
  Object {
@@ -10,6 +10,7 @@ exports[`<TransitionerComponent /> renders correctly 1`] = `
10
10
  }
11
11
  >
12
12
  <Scene
13
+ isActive={true}
13
14
  screenUniqueId="mocked-uuid"
14
15
  >
15
16
  <View
@@ -351,6 +351,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
351
351
  item,
352
352
  playerId: this.currentlyPlaying?.playerId,
353
353
  primaryPlayerId: this.primaryPlayer?.playerId,
354
+ entry: item.getPlayer().getEntry(),
354
355
  },
355
356
  });
356
357
  };
@@ -385,6 +386,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
385
386
  item,
386
387
  playerId: this.currentlyPlaying?.playerId,
387
388
  primaryPlayerId: this.primaryPlayer?.playerId,
389
+ entry: item.getPlayer().getEntry(),
388
390
  },
389
391
  });
390
392
  };
@@ -419,6 +421,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
419
421
  error,
420
422
  playerId: currentItem?.playerId,
421
423
  primaryPlayerId: currentItem?.playerId,
424
+ entry: item.getPlayer().getEntry(),
422
425
  },
423
426
  });
424
427
  };