@applicaster/zapp-react-native-ui-components 14.0.0-alpha.5810348423 → 14.0.0-alpha.6000342231

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 (41) hide show
  1. package/Components/AnimatedInOut/index.tsx +69 -26
  2. package/Components/Cell/FocusableWrapper.tsx +44 -0
  3. package/Components/Cell/TvOSCellComponent.tsx +80 -14
  4. package/Components/FocusableGroup/FocusableTvOS.tsx +0 -5
  5. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +9 -11
  6. package/Components/HandlePlayable/HandlePlayable.tsx +14 -65
  7. package/Components/HandlePlayable/const.ts +3 -0
  8. package/Components/HandlePlayable/utils.ts +74 -0
  9. package/Components/PlayerContainer/PlayerContainer.tsx +1 -16
  10. package/Components/PlayerImageBackground/index.tsx +3 -22
  11. package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -42
  12. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
  13. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
  14. package/Components/River/TV/River.tsx +1 -10
  15. package/Components/River/TV/index.tsx +3 -3
  16. package/Components/River/TV/withTVEventHandler.tsx +27 -0
  17. package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
  18. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
  19. package/Components/Screen/index.tsx +22 -5
  20. package/Components/ScreenRevealManager/utils/index.ts +23 -0
  21. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +54 -24
  22. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  23. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +111 -171
  24. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  25. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  26. package/Components/VideoModal/PlayerDetails.tsx +5 -5
  27. package/Components/VideoModal/PlayerWrapper.tsx +14 -88
  28. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  29. package/Components/VideoModal/hooks/useModalSize.ts +10 -5
  30. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  31. package/Components/VideoModal/playerWrapperUtils.ts +91 -0
  32. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
  33. package/package.json +5 -5
  34. package/Components/River/TV/withTVFocus.tsx +0 -43
  35. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  36. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -415
  37. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
  38. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  39. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
  40. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  41. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
- import { View, StyleSheet, FlatList } from "react-native";
3
+ import { FlatList, StyleSheet, View } 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";
@@ -9,8 +9,8 @@ import { useScreenConfiguration } from "../useScreenConfiguration";
9
9
  import { RefreshControl } from "../RefreshControl";
10
10
  import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
11
11
  import {
12
- useProfilerLogging,
13
12
  usePipesCacheReset,
13
+ useProfilerLogging,
14
14
  } from "@applicaster/zapp-react-native-utils/reactHooks";
15
15
  import { useLoadingState } from "./hooks/useLoadingState";
16
16
  import { ViewportTracker } from "../../Viewport";
@@ -25,6 +25,8 @@ import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHo
25
25
  import { useShallow } from "zustand/react/shallow";
26
26
 
27
27
  import { isAndroidPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
28
+ import { ComponentsMapHeightContext } from "./ContextProviders/ComponentsMapHeightContext";
29
+ import { ComponentsMapRefContext } from "./ContextProviders/ComponentsMapRefContext";
28
30
 
29
31
  const isAndroid = isAndroidPlatform();
30
32
 
@@ -70,6 +72,7 @@ function ComponentsMapComponent(props: Props) {
70
72
  } = props;
71
73
 
72
74
  const flatListRef = React.useRef<FlatList | null>(null);
75
+ const flatListWrapperRef = React.useRef<View | null>(null);
73
76
  const screenConfig = useScreenConfiguration(riverId);
74
77
  const screenData = useScreenData(riverId);
75
78
  const pullToRefreshEnabled = screenData?.rules?.pull_to_refresh_enabled;
@@ -265,47 +268,51 @@ function ComponentsMapComponent(props: Props) {
265
268
  // The Screen Picker in Mobile is completly different than the TV
266
269
  // so the various offsets / margins in TV do not apply here.
267
270
  return (
268
- <View style={styles.container}>
269
- <ScreenLoadingMeasurements
270
- riverId={riverId}
271
- numberOfComponents={riverComponents.length}
272
- >
273
- <ViewportTracker>
274
- <FlatList
275
- ref={(ref) => {
276
- flatListRef.current = ref;
277
- }}
278
- // Fix for WebView rerender crashes on Android API 28+
279
- // https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
280
- overScrollMode={isAndroid ? "never" : "auto"}
281
- scrollIndicatorInsets={scrollIndicatorInsets}
282
- extraData={feed}
283
- stickyHeaderIndices={stickyHeaderIndices}
284
- removeClippedSubviews={isAndroid}
285
- onLayout={handleOnLayout}
286
- initialNumToRender={3}
287
- maxToRenderPerBatch={10}
288
- windowSize={12}
289
- keyExtractor={keyExtractor}
290
- renderItem={renderRiverItem}
291
- data={riverComponents}
292
- contentContainerStyle={contentContainerStyle}
293
- ListFooterComponent={
294
- <RiverFooter
295
- flatListHeight={flatListHeight}
296
- loadingState={loadingState}
271
+ <View style={styles.container} ref={flatListWrapperRef}>
272
+ <ComponentsMapHeightContext.Provider value={flatListHeight}>
273
+ <ComponentsMapRefContext.Provider value={flatListWrapperRef}>
274
+ <ScreenLoadingMeasurements
275
+ riverId={riverId}
276
+ numberOfComponents={riverComponents.length}
277
+ >
278
+ <ViewportTracker>
279
+ <FlatList
280
+ ref={(ref) => {
281
+ flatListRef.current = ref;
282
+ }}
283
+ // Fix for WebView rerender crashes on Android API 28+
284
+ // https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
285
+ overScrollMode={isAndroid ? "never" : "auto"}
286
+ scrollIndicatorInsets={scrollIndicatorInsets}
287
+ extraData={feed}
288
+ stickyHeaderIndices={stickyHeaderIndices}
289
+ removeClippedSubviews={isAndroid}
290
+ onLayout={handleOnLayout}
291
+ initialNumToRender={3}
292
+ maxToRenderPerBatch={10}
293
+ windowSize={12}
294
+ keyExtractor={keyExtractor}
295
+ renderItem={renderRiverItem}
296
+ data={riverComponents}
297
+ contentContainerStyle={contentContainerStyle}
298
+ ListFooterComponent={
299
+ <RiverFooter
300
+ flatListHeight={flatListHeight}
301
+ loadingState={loadingState}
302
+ />
303
+ }
304
+ refreshControl={refreshControl}
305
+ onScrollBeginDrag={onScrollBeginDrag}
306
+ onScroll={onScroll}
307
+ onMomentumScrollEnd={_onMomentumScrollEnd}
308
+ onScrollEndDrag={_onScrollEndDrag}
309
+ scrollEventThrottle={16}
310
+ {...scrollViewExtraProps}
297
311
  />
298
- }
299
- refreshControl={refreshControl}
300
- onScrollBeginDrag={onScrollBeginDrag}
301
- onScroll={onScroll}
302
- onMomentumScrollEnd={_onMomentumScrollEnd}
303
- onScrollEndDrag={_onScrollEndDrag}
304
- scrollEventThrottle={16}
305
- {...scrollViewExtraProps}
306
- />
307
- </ViewportTracker>
308
- </ScreenLoadingMeasurements>
312
+ </ViewportTracker>
313
+ </ScreenLoadingMeasurements>
314
+ </ComponentsMapRefContext.Provider>
315
+ </ComponentsMapHeightContext.Provider>
309
316
  </View>
310
317
  );
311
318
  }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+
3
+ export const ComponentsMapHeightContext = React.createContext<number | null>(
4
+ null
5
+ );
6
+
7
+ export const useComponentsMapHeight = () =>
8
+ React.useContext(ComponentsMapHeightContext);
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import { View } from "react-native";
3
+
4
+ export const ComponentsMapRefContext =
5
+ React.createContext<React.RefObject<View | null> | null>(null);
6
+
7
+ export const useComponentsMapRef = () =>
8
+ React.useContext(ComponentsMapRefContext);
@@ -24,7 +24,6 @@ type Props = {
24
24
  isInsideContainer?: boolean;
25
25
  extraAnchorPointYOffset: number;
26
26
  river?: ZappRiver | ZappEntry;
27
- groupId: string;
28
27
  };
29
28
 
30
29
  export const River = (props: Props) => {
@@ -36,15 +35,8 @@ export const River = (props: Props) => {
36
35
  componentsMapExtraProps,
37
36
  isInsideContainer,
38
37
  extraAnchorPointYOffset,
39
- groupId,
40
38
  } = props;
41
39
 
42
- // console.log("debug_2", "River", {
43
- // groupId,
44
- // extraProps,
45
- // componentsMapExtraProps,
46
- // });
47
-
48
40
  const { title: screenTitle, summary: screenSummary } = useNavbarState();
49
41
 
50
42
  const { setTitle: setScreenTitle, setSummary: setScreenSummary } =
@@ -101,7 +93,7 @@ export const River = (props: Props) => {
101
93
  screenType={river.type}
102
94
  screenId={screenId}
103
95
  screenData={R.merge(river, { groupId: extraData?.groupId })}
104
- componentsMapExtraProps={R.merge(componentsMapExtraProps, { groupId })}
96
+ componentsMapExtraProps={componentsMapExtraProps}
105
97
  {...extraData}
106
98
  />
107
99
  );
@@ -114,7 +106,6 @@ export const River = (props: Props) => {
114
106
  isScreenWrappedInContainer={isInsideContainer}
115
107
  extraAnchorPointYOffset={extraAnchorPointYOffset}
116
108
  componentsMapExtraProps={componentsMapExtraProps}
117
- groupId={groupId}
118
109
  />
119
110
  );
120
111
  };
@@ -1,11 +1,11 @@
1
1
  import { compose } from "ramda";
2
2
  import { River as RiverComponent } from "./River";
3
+ import { withTvEventHandler } from "./withTVEventHandler";
3
4
  import { withComponentsMapOffsetContext } from "../../../Contexts/ComponentsMapOffsetContext";
4
5
  import { withRiverDataLoader } from "./withRiverDataLoader";
5
- import { withTVFocus } from "./withTVFocus";
6
6
 
7
7
  export const River = compose(
8
+ withTvEventHandler,
8
9
  withComponentsMapOffsetContext,
9
- withRiverDataLoader,
10
- withTVFocus
10
+ withRiverDataLoader
11
11
  )(RiverComponent);
@@ -0,0 +1,27 @@
1
+ /* eslint max-len: off */
2
+
3
+ import React from "react";
4
+ import { TVEventHandlerComponent } from "@applicaster/zapp-react-native-tvos-ui-components/Components/TVEventHandlerComponent";
5
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
6
+
7
+ export const withTvEventHandler = (Component) => {
8
+ return function WithTVEventHandler(props) {
9
+ const navigator = useNavigation();
10
+
11
+ const remoteHandler = (event) => {
12
+ const { eventType } = event;
13
+
14
+ const canGoBack = navigator.canGoBack();
15
+
16
+ if (eventType === "menu" && canGoBack) {
17
+ navigator.goBack();
18
+ }
19
+ };
20
+
21
+ return (
22
+ <TVEventHandlerComponent tvEventHandler={remoteHandler}>
23
+ <Component {...props} />
24
+ </TVEventHandlerComponent>
25
+ );
26
+ };
27
+ };
@@ -10,6 +10,8 @@ import {
10
10
  setFocusOnMenu,
11
11
  } from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux";
12
12
 
13
+ import { waitUntilScreenRevealManagerIsReady } from "@applicaster/zapp-react-native-ui-components/Components/ScreenRevealManager/utils";
14
+
13
15
  type Return =
14
16
  | {
15
17
  onContent: true;
@@ -57,14 +59,22 @@ export const useInitialFocus = (): void => {
57
59
  React.useEffect(() => {
58
60
  const initialFocus = getInitialFocus(focusOnContent, isNavBarVisible);
59
61
 
60
- if (initialFocus.onContent) {
61
- setFocusOnContent(currentRoute);
62
+ if (initialFocus.onMenu) {
63
+ setFocusOnMenu(currentRoute);
62
64
 
63
65
  return;
64
66
  }
65
67
 
66
- if (initialFocus.onMenu) {
67
- setFocusOnMenu(currentRoute);
68
+ if (initialFocus.onContent) {
69
+ const subscription = waitUntilScreenRevealManagerIsReady().subscribe(
70
+ () => {
71
+ setFocusOnContent(currentRoute);
72
+ }
73
+ );
74
+
75
+ return () => {
76
+ subscription.unsubscribe();
77
+ };
68
78
  }
69
79
  }, []);
70
80
  };
@@ -2,6 +2,7 @@
2
2
 
3
3
  exports[`<Screen Component /> when the navbar should be hidden renders correctly 1`] = `
4
4
  <View
5
+ importantForAccessibility="yes"
5
6
  style={
6
7
  {
7
8
  "backgroundColor": "blue",
@@ -34,6 +35,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
34
35
 
35
36
  exports[`<Screen Component /> when the navbar should show renders correctly 1`] = `
36
37
  <View
38
+ importantForAccessibility="yes"
37
39
  style={
38
40
  {
39
41
  "backgroundColor": "blue",
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@applicaster/applicaster-types" />
2
2
  import React from "react";
3
- import { View } from "react-native";
3
+ import { AccessibilityInfo, findNodeHandle, View } from "react-native";
4
4
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
5
 
6
6
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
@@ -12,6 +12,7 @@ import {
12
12
  } from "@applicaster/zapp-react-native-utils/navigationUtils";
13
13
  import {
14
14
  useCurrentScreenData,
15
+ useIsScreenActive,
15
16
  useNavbarState,
16
17
  useNavigation,
17
18
  useRoute,
@@ -57,8 +58,8 @@ export function Screen(_props: Props) {
57
58
  const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
58
59
 
59
60
  const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
60
- getNavBarProps(currentRiver, pathname, title),
61
- [currentRiver, pathname]
61
+ () => getNavBarProps(currentRiver, pathname, title),
62
+ [currentRiver, pathname, title]
62
63
  );
63
64
 
64
65
  const NavBar = React.useMemo(
@@ -89,13 +90,29 @@ export function Screen(_props: Props) {
89
90
  [theme.app_background_color, backgroundColor]
90
91
  );
91
92
 
92
- // Set ready state when screen is rotated to desired orientation
93
+ const isActive = useIsScreenActive();
94
+
95
+ const ref = React.useRef(null);
93
96
  const isReady = useWaitForValidOrientation();
94
97
 
98
+ React.useEffect(() => {
99
+ if (ref.current && isActive && isReady) {
100
+ const nodeHandle = findNodeHandle(ref.current);
101
+
102
+ if (nodeHandle != null) {
103
+ AccessibilityInfo.setAccessibilityFocus(nodeHandle);
104
+ }
105
+ }
106
+ }, [isActive, isReady]);
107
+
95
108
  // We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
96
109
  // This saves unnecessary re-renders and user will not see distorted aspect screen.
97
110
  return (
98
- <View style={style}>
111
+ <View
112
+ ref={ref}
113
+ style={style}
114
+ importantForAccessibility={!isActive ? "no-hide-descendants" : "yes"}
115
+ >
99
116
  {isReady ? (
100
117
  <>
101
118
  {navBarProps ? <NavBar {...navBarProps} hasMenu={hasMenu} /> : null}
@@ -0,0 +1,23 @@
1
+ import { ReplaySubject } from "rxjs";
2
+ import { pairwise, filter, first } from "rxjs/operators";
3
+
4
+ // we are interested in last 2 events, because we wait transition from <false> to <true>
5
+ const screenRevealManagerSubject$ = new ReplaySubject<boolean>(2);
6
+
7
+ export const emitScreenRevealManagerIsReadyToShow = () => {
8
+ screenRevealManagerSubject$.next(true);
9
+ };
10
+
11
+ export const emitScreenRevealManagerIsNotReadyToShow = () => {
12
+ screenRevealManagerSubject$.next(false);
13
+ };
14
+
15
+ export const waitUntilScreenRevealManagerIsReady = () => {
16
+ return screenRevealManagerSubject$.pipe(
17
+ pairwise(), // emit consecutive pairs: [prev, curr]
18
+ filter(
19
+ ([previousIsReady, currentIsReady]) => !previousIsReady && currentIsReady
20
+ ), // detect transition from not_ready to ready
21
+ first()
22
+ );
23
+ };
@@ -1,21 +1,23 @@
1
1
  import * as React from "react";
2
- import { Animated } from "react-native";
2
+ import { Animated, StyleSheet } from "react-native";
3
3
  import { isFirstComponentScreenPicker } from "@applicaster/zapp-react-native-utils/componentsUtils";
4
- import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
4
  import { useRefWithInitialValue } from "@applicaster/zapp-react-native-utils/reactHooks/state/useRefWithInitialValue";
5
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
6
6
 
7
7
  import { ScreenRevealManager } from "./ScreenRevealManager";
8
+ import {
9
+ emitScreenRevealManagerIsReadyToShow,
10
+ emitScreenRevealManagerIsNotReadyToShow,
11
+ } from "./utils";
8
12
 
9
- const flex = platformSelect({
10
- tvos: 1,
11
- android_tv: 1,
12
- web: undefined,
13
- samsung_tv: undefined,
14
- lg_tv: undefined,
15
- default: undefined,
13
+ const styles = StyleSheet.create({
14
+ container: {
15
+ ...StyleSheet.absoluteFillObject,
16
+ position: "absolute",
17
+ },
16
18
  });
17
19
 
18
- export const TIMEOUT = 500; // 500 ms
20
+ export const TIMEOUT = 300; // 300 ms
19
21
 
20
22
  const HIDDEN = 0; // opacity = 0
21
23
 
@@ -29,29 +31,48 @@ export const withScreenRevealManager = (Component) => {
29
31
  return function WithScreenRevealManager(props: Props) {
30
32
  const { componentsToRender } = props;
31
33
 
32
- const [isReadyToShow, setIsReadyToShow] = React.useState(false);
34
+ const [isContentReadyToBeShown, setIsContentReadyToBeShown] =
35
+ React.useState(false);
33
36
 
34
- const handleSetIsReadyToShow = React.useCallback(() => {
35
- setIsReadyToShow(true);
37
+ const [isShowOverlay, setIsShowOverlay] = React.useState(true);
38
+
39
+ const theme = useTheme<BaseThemePropertiesTV>();
40
+
41
+ const handleSetIsContentReadyToBeShown = React.useCallback(() => {
42
+ setIsContentReadyToBeShown(true);
36
43
  }, []);
37
44
 
38
45
  const managerRef = useRefWithInitialValue<ScreenRevealManager>(
39
- () => new ScreenRevealManager(componentsToRender, handleSetIsReadyToShow)
46
+ () =>
47
+ new ScreenRevealManager(
48
+ componentsToRender,
49
+ handleSetIsContentReadyToBeShown
50
+ )
40
51
  );
41
52
 
42
53
  const opacityRef = useRefWithInitialValue<Animated.Value>(
43
- () => new Animated.Value(HIDDEN)
54
+ () => new Animated.Value(SHOWN)
44
55
  );
45
56
 
46
57
  React.useEffect(() => {
47
- if (isReadyToShow) {
58
+ if (!isContentReadyToBeShown) {
59
+ emitScreenRevealManagerIsNotReadyToShow();
60
+ } else {
61
+ emitScreenRevealManagerIsReadyToShow();
62
+ }
63
+ }, [isContentReadyToBeShown]);
64
+
65
+ React.useEffect(() => {
66
+ if (isContentReadyToBeShown) {
48
67
  Animated.timing(opacityRef.current, {
49
- toValue: SHOWN,
68
+ toValue: HIDDEN,
50
69
  duration: TIMEOUT,
51
70
  useNativeDriver: true,
52
- }).start();
71
+ }).start(() => {
72
+ setIsShowOverlay(false);
73
+ });
53
74
  }
54
- }, [isReadyToShow]);
75
+ }, [isContentReadyToBeShown]);
55
76
 
56
77
  if (isFirstComponentScreenPicker(componentsToRender)) {
57
78
  // for screen-picker with have additional internal ComponentsMap, no need to add this wrapper
@@ -59,10 +80,7 @@ export const withScreenRevealManager = (Component) => {
59
80
  }
60
81
 
61
82
  return (
62
- <Animated.View
63
- style={{ opacity: opacityRef.current, flex }}
64
- testID="animated-component"
65
- >
83
+ <>
66
84
  <Component
67
85
  {...props}
68
86
  initialNumberToLoad={
@@ -73,7 +91,19 @@ export const withScreenRevealManager = (Component) => {
73
91
  }
74
92
  onLoadFailedFromScreenRevealManager={managerRef.current.onLoadFailed}
75
93
  />
76
- </Animated.View>
94
+ {isShowOverlay ? (
95
+ <Animated.View
96
+ style={[
97
+ styles.container,
98
+ {
99
+ opacity: opacityRef.current,
100
+ backgroundColor: theme.app_background_color,
101
+ },
102
+ ]}
103
+ testID="animated-component"
104
+ />
105
+ ) : null}
106
+ </>
77
107
  );
78
108
  };
79
109
  };
@@ -9,6 +9,7 @@ exports[`PlayerLiveImageComponent should render correctly with default props 1`]
9
9
  <View>
10
10
  <View
11
11
  collapsable={false}
12
+ renderToHardwareTextureAndroid={false}
12
13
  style={
13
14
  {
14
15
  "opacity": 1,