@applicaster/zapp-react-native-ui-components 15.0.0-alpha.2882475305 → 15.0.0-alpha.3441591506

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 (23) hide show
  1. package/Components/AnimatedInOut/index.tsx +69 -26
  2. package/Components/HandlePlayable/HandlePlayable.tsx +14 -65
  3. package/Components/HandlePlayable/const.ts +3 -0
  4. package/Components/HandlePlayable/utils.ts +74 -0
  5. package/Components/PlayerContainer/PlayerContainer.tsx +1 -16
  6. package/Components/PlayerImageBackground/index.tsx +3 -22
  7. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +44 -26
  8. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  9. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +3 -153
  10. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  11. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  12. package/Components/VideoModal/PlayerWrapper.tsx +31 -59
  13. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  14. package/Components/VideoModal/hooks/useModalSize.ts +5 -4
  15. package/Components/VideoModal/playerWrapperUtils.ts +104 -0
  16. package/package.json +5 -5
  17. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  18. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -417
  19. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
  20. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  21. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
  22. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  23. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
@@ -6,10 +6,6 @@ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
6
6
 
7
7
  type AnimatedInterpolatedStyle = any;
8
8
 
9
- // type AnimatedInterpolatedStyle =
10
- // | Animated.AnimatedInterpolation
11
- // | [{ [Key: string]: Animated.AnimatedInterpolation }];
12
-
13
9
  type AnimationConfig = {
14
10
  duration: number;
15
11
  easing: EasingFunction;
@@ -45,32 +41,57 @@ export function AnimatedInOut({
45
41
  children,
46
42
  }: Props) {
47
43
  const [animatedValue] = React.useState(new Animated.Value(visible ? 1 : 0));
48
- const [animating, setAnimating] = React.useState(undefined);
44
+ const animationRef = React.useRef<Animated.CompositeAnimation | null>(null);
45
+ const delayTimerRef = React.useRef<NodeJS.Timeout | null>(null);
49
46
 
50
47
  const previousVisible = usePrevious(toBooleanWithDefaultFalse(visible));
51
48
 
52
- function startAnimation(toValue, config) {
53
- if (animating) {
54
- animating.reset();
55
- }
56
-
57
- const { duration, easing, delay = 0, onAnimationEnd = noop } = config;
49
+ const startAnimation = React.useCallback(
50
+ (toValue: number, config: AnimationConfig) => {
51
+ if (delayTimerRef.current) {
52
+ clearTimeout(delayTimerRef.current);
53
+ delayTimerRef.current = null;
54
+ }
55
+
56
+ if (animationRef.current) {
57
+ animationRef.current.stop();
58
+ animationRef.current = null;
59
+ }
60
+
61
+ const { duration, easing, delay = 0, onAnimationEnd = noop } = config;
62
+
63
+ const runAnimation = () => {
64
+ animationRef.current = Animated.timing(animatedValue, {
65
+ duration,
66
+ toValue,
67
+ easing,
68
+ useNativeDriver: true,
69
+ });
70
+
71
+ animationRef.current.start(({ finished }) => {
72
+ if (finished) {
73
+ animationRef.current = null;
74
+ onAnimationEnd();
75
+ }
76
+ });
77
+ };
78
+
79
+ if (delay > 0) {
80
+ delayTimerRef.current = setTimeout(runAnimation, delay);
81
+ } else {
82
+ runAnimation();
83
+ }
84
+ },
85
+ [animatedValue]
86
+ );
58
87
 
59
- const compositeAnimation = Animated.timing(animatedValue, {
60
- duration,
61
- toValue,
62
- easing,
63
- delay,
64
- useNativeDriver: true,
65
- }).start(() => {
66
- setAnimating(undefined);
67
- onAnimationEnd();
68
- });
88
+ React.useEffect(() => {
89
+ if (previousVisible === undefined) {
90
+ animatedValue.setValue(visible ? 1 : 0);
69
91
 
70
- setAnimating(compositeAnimation);
71
- }
92
+ return;
93
+ }
72
94
 
73
- React.useEffect(() => {
74
95
  if (!previousVisible && visible) {
75
96
  startAnimation(1.0, getAnimation(animationConfig, "in"));
76
97
  }
@@ -78,7 +99,29 @@ export function AnimatedInOut({
78
99
  if (previousVisible && !visible) {
79
100
  startAnimation(0.0, getAnimation(animationConfig, "out"));
80
101
  }
81
- }, [visible, previousVisible]);
102
+ }, [
103
+ visible,
104
+ previousVisible,
105
+ animatedValue,
106
+ startAnimation,
107
+ animationConfig,
108
+ ]);
109
+
110
+ React.useEffect(() => {
111
+ return () => {
112
+ if (delayTimerRef.current) {
113
+ clearTimeout(delayTimerRef.current);
114
+ delayTimerRef.current = null;
115
+ }
116
+
117
+ if (animationRef.current) {
118
+ animationRef.current.stop();
119
+ animationRef.current = null;
120
+ }
121
+
122
+ animatedValue.stopAnimation();
123
+ };
124
+ }, [animatedValue]);
82
125
 
83
126
  const styles = visible
84
127
  ? getAnimation(animationConfig, "in").styles
@@ -86,7 +129,7 @@ export function AnimatedInOut({
86
129
 
87
130
  return (
88
131
  <Animated.View
89
- renderToHardwareTextureAndroid={animating}
132
+ renderToHardwareTextureAndroid={!!animationRef.current}
90
133
  style={[styles(animatedValue), staticStyles]}
91
134
  >
92
135
  {children}
@@ -1,9 +1,4 @@
1
1
  import * as React from "react";
2
- import * as R from "ramda";
3
- import {
4
- findPluginByType,
5
- findPluginByIdentifier,
6
- } from "@applicaster/zapp-react-native-utils/pluginUtils";
7
2
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
8
3
  import {
9
4
  useDimensions,
@@ -16,6 +11,7 @@ import { PlayerContainer } from "../PlayerContainer";
16
11
  import { useModalSize } from "../VideoModal/hooks";
17
12
  import { ViewStyle } from "react-native";
18
13
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
14
+ import { findCastPlugin, getPlayer } from "./utils";
19
15
 
20
16
  type Props = {
21
17
  item: ZappEntry;
@@ -26,62 +22,6 @@ type Props = {
26
22
  groupId?: string;
27
23
  };
28
24
 
29
- const YOUTUBE_PLUGIN_ID = "youtube-player-qb";
30
- const CHROMECAST_PLUGIN_ID = "chromecast_qb";
31
-
32
- const getPlayerWithModuleProperties = (
33
- PlayerModule: ZappPlugin
34
- ): [ZappPlugin, PlayerModuleProperties] => {
35
- const getPlayerModuleProperties = R.ifElse(
36
- R.is(Object) && R.has("Component"),
37
- R.omit(["Component"]),
38
- () => ({})
39
- );
40
-
41
- return [
42
- PlayerModule?.Component || PlayerModule,
43
- getPlayerModuleProperties(PlayerModule),
44
- ];
45
- };
46
-
47
- const getPlayer = (
48
- item: ZappEntry,
49
- state
50
- ): [ZappPlugin, PlayerModuleProperties] => {
51
- const {
52
- plugins,
53
- contentTypes,
54
- rivers,
55
- appData: { layoutVersion },
56
- } = state;
57
-
58
- let PlayerModule;
59
-
60
- if (layoutVersion === "v2") {
61
- const { screen_id } = contentTypes?.[item?.type?.value] || {};
62
- const { type } = rivers?.[screen_id] || {};
63
-
64
- if (type) {
65
- PlayerModule = findPluginByIdentifier(type, plugins)?.module;
66
-
67
- return getPlayerWithModuleProperties(PlayerModule);
68
- }
69
- }
70
-
71
- if (item?.content?.type === "youtube-id") {
72
- PlayerModule = findPluginByIdentifier(YOUTUBE_PLUGIN_ID, plugins)?.module;
73
-
74
- return getPlayerWithModuleProperties(PlayerModule);
75
- }
76
-
77
- PlayerModule = findPluginByType(
78
- "playable",
79
- plugins.filter(({ identifier }) => identifier !== YOUTUBE_PLUGIN_ID)
80
- );
81
-
82
- return getPlayerWithModuleProperties(PlayerModule);
83
- };
84
-
85
25
  type PlayableComponent = {
86
26
  Component: React.ComponentType<any>;
87
27
  };
@@ -99,14 +39,23 @@ export function HandlePlayable({
99
39
  mode,
100
40
  groupId,
101
41
  }: Props): React.ReactElement | null {
102
- const state = usePickFromState();
42
+ const { plugins, contentTypes, rivers, appData } = usePickFromState([
43
+ "plugins",
44
+ "contentTypes",
45
+ "rivers",
46
+ "appData",
47
+ ]);
103
48
 
104
49
  const { closeVideoModal } = useNavigation();
105
50
 
106
- const [Player, playerModuleProperties] = getPlayer(item, state);
51
+ const [Player, playerModuleProperties] = getPlayer(item, {
52
+ plugins,
53
+ contentTypes,
54
+ rivers,
55
+ appData,
56
+ });
107
57
 
108
- const { module: CastPlugin } =
109
- findPluginByIdentifier(CHROMECAST_PLUGIN_ID, state.plugins, true) || {};
58
+ const { module: CastPlugin } = findCastPlugin(plugins);
110
59
 
111
60
  const [playable, setPlayable] =
112
61
  React.useState<Nullable<PlayableComponent>>(null);
@@ -0,0 +1,3 @@
1
+ export const YOUTUBE_PLUGIN_ID = "youtube-player-qb";
2
+
3
+ export const CHROMECAST_PLUGIN_ID = "chromecast_qb";
@@ -0,0 +1,74 @@
1
+ import {
2
+ findPluginByIdentifier,
3
+ findPluginByType,
4
+ } from "@applicaster/zapp-react-native-utils/pluginUtils";
5
+
6
+ import { CHROMECAST_PLUGIN_ID, YOUTUBE_PLUGIN_ID } from "./const";
7
+ import { omit } from "@applicaster/zapp-react-native-utils/utils";
8
+
9
+ const getPlayerModuleProperties = (PlayerModule: ZappPlugin) => {
10
+ if (PlayerModule?.Component && typeof PlayerModule.Component === "object") {
11
+ return omit(["Component"], PlayerModule);
12
+ }
13
+
14
+ return {};
15
+ };
16
+
17
+ export const getPlayerWithModuleProperties = (
18
+ PlayerModule: ZappPlugin
19
+ ): [ZappPlugin, PlayerModuleProperties] => {
20
+ return [
21
+ PlayerModule?.Component || PlayerModule,
22
+ getPlayerModuleProperties(PlayerModule),
23
+ ];
24
+ };
25
+
26
+ export const findCastPlugin = (plugins: ZappPlugin[]) =>
27
+ findPluginByIdentifier(CHROMECAST_PLUGIN_ID, plugins, true) || {};
28
+
29
+ export const findYoutubePlugin = (plugins: ZappPlugin[]) =>
30
+ findPluginByIdentifier(YOUTUBE_PLUGIN_ID, plugins, true) || {};
31
+
32
+ export const getPlayer = (
33
+ item: ZappEntry,
34
+ {
35
+ plugins,
36
+ contentTypes,
37
+ rivers,
38
+ appData: { layoutVersion },
39
+ }: {
40
+ plugins: ZappPlugin[];
41
+ contentTypes: Record<string, any>;
42
+ rivers: Record<string, any>;
43
+ appData: { layoutVersion: string };
44
+ }
45
+ ): [ZappPlugin, PlayerModuleProperties] => {
46
+ let PlayerModule;
47
+
48
+ if (layoutVersion === "v2") {
49
+ const screen_id = contentTypes?.[item?.type?.value]?.screen_id;
50
+ const type = rivers?.[screen_id]?.type;
51
+
52
+ if (type) {
53
+ PlayerModule = findPluginByIdentifier(type, plugins)?.module;
54
+
55
+ return getPlayerWithModuleProperties(PlayerModule);
56
+ }
57
+ }
58
+
59
+ if (item?.content?.type === "youtube-id") {
60
+ PlayerModule = findYoutubePlugin(plugins)?.module;
61
+
62
+ return getPlayerWithModuleProperties(PlayerModule);
63
+ }
64
+
65
+ PlayerModule = findPluginByType(
66
+ "playable",
67
+ (plugins as any[]).filter(
68
+ ({ identifier }: { identifier: string }) =>
69
+ identifier !== YOUTUBE_PLUGIN_ID
70
+ )
71
+ );
72
+
73
+ return getPlayerWithModuleProperties(PlayerModule);
74
+ };
@@ -56,11 +56,6 @@ import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
56
56
  import { usePlayNextOverlay } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayNextOverlay";
57
57
  import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
58
58
 
59
- import {
60
- PlayerAnimationStateEnum,
61
- useModalAnimationContext,
62
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
63
-
64
59
  import {
65
60
  PlayerNativeCommandTypes,
66
61
  PlayerNativeSendCommand,
@@ -248,9 +243,6 @@ const PlayerContainerComponent = (props: Props) => {
248
243
  const screenData = useTargetScreenData(item);
249
244
  const { setVisible: showNavBar } = useSetNavbarState();
250
245
 
251
- const { isActiveGesture, startComponentsAnimation, setPlayerAnimationState } =
252
- useModalAnimationContext();
253
-
254
246
  const playerEvent = (event, ...args) => {
255
247
  playerManager.invokeHandler(event, ...args);
256
248
  };
@@ -482,8 +474,6 @@ const PlayerContainerComponent = (props: Props) => {
482
474
  if (isModal && mode === VideoModalMode.MAXIMIZED) {
483
475
  if (disableMiniPlayer) {
484
476
  navigator.closeVideoModal();
485
- } else {
486
- setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
487
477
  }
488
478
  }
489
479
 
@@ -680,11 +670,7 @@ const PlayerContainerComponent = (props: Props) => {
680
670
  autoplay={true}
681
671
  controls={false}
682
672
  disableCastAction={disableCastAction}
683
- docked={
684
- navigator.isVideoModalDocked() &&
685
- !startComponentsAnimation &&
686
- !isActiveGesture
687
- }
673
+ docked={navigator.isVideoModalDocked()}
688
674
  entry={item}
689
675
  fullscreen={mode === VideoModalMode.FULLSCREEN}
690
676
  inline={inline}
@@ -702,7 +688,6 @@ const PlayerContainerComponent = (props: Props) => {
702
688
  setNextVideoPreloadThresholdPercentage={
703
689
  setNextVideoPreloadThresholdPercentage
704
690
  }
705
- startComponentsAnimation={startComponentsAnimation}
706
691
  >
707
692
  {renderApplePlayer(applePlayerProps)}
708
693
  </Player>
@@ -2,12 +2,6 @@ import React, { PropsWithChildren } from "react";
2
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";
11
5
 
12
6
  type Props = PropsWithChildren<{
13
7
  entry: ZappEntry;
@@ -25,30 +19,17 @@ const PlayerImageBackgroundComponent = ({
25
19
  style,
26
20
  imageStyle,
27
21
  imageKey,
28
- defaultImageDimensions,
29
22
  }: Props) => {
30
23
  const source = React.useMemo(
31
24
  () => ({ uri: imageSrcFromMediaItem(entry, [imageKey]) }),
32
25
  [imageKey, entry]
33
26
  );
34
27
 
35
- const { playerAnimationState } = useModalAnimationContext();
36
-
37
28
  if (!source) return <>{children}</>;
38
29
 
39
30
  return (
40
- <View
41
- style={
42
- playerAnimationState === PlayerAnimationStateEnum.maximize
43
- ? defaultImageDimensions
44
- : style
45
- }
46
- >
47
- <AnimationComponent
48
- style={style}
49
- animationType={ComponentAnimationType.player}
50
- additionalData={defaultImageDimensions}
51
- >
31
+ <View style={style}>
32
+ <View style={style}>
52
33
  <ImageBackground
53
34
  resizeMode="cover"
54
35
  style={imageSize}
@@ -57,7 +38,7 @@ const PlayerImageBackgroundComponent = ({
57
38
  >
58
39
  {children}
59
40
  </ImageBackground>
60
- </AnimationComponent>
41
+ </View>
61
42
  </View>
62
43
  );
63
44
  };
@@ -1,8 +1,8 @@
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
8
  import {
@@ -10,16 +10,14 @@ import {
10
10
  emitScreenRevealManagerIsNotReadyToShow,
11
11
  } from "./utils";
12
12
 
13
- const flex = platformSelect({
14
- tvos: 1,
15
- android_tv: 1,
16
- web: undefined,
17
- samsung_tv: undefined,
18
- lg_tv: undefined,
19
- default: undefined,
13
+ const styles = StyleSheet.create({
14
+ container: {
15
+ ...StyleSheet.absoluteFillObject,
16
+ position: "absolute",
17
+ },
20
18
  });
21
19
 
22
- export const TIMEOUT = 500; // 500 ms
20
+ export const TIMEOUT = 300; // 300 ms
23
21
 
24
22
  const HIDDEN = 0; // opacity = 0
25
23
 
@@ -33,37 +31,48 @@ export const withScreenRevealManager = (Component) => {
33
31
  return function WithScreenRevealManager(props: Props) {
34
32
  const { componentsToRender } = props;
35
33
 
36
- const [isReadyToShow, setIsReadyToShow] = React.useState(false);
34
+ const [isContentReadyToBeShown, setIsContentReadyToBeShown] =
35
+ React.useState(false);
37
36
 
38
- const handleSetIsReadyToShow = React.useCallback(() => {
39
- setIsReadyToShow(true);
37
+ const [isShowOverlay, setIsShowOverlay] = React.useState(true);
38
+
39
+ const theme = useTheme<BaseThemePropertiesTV>();
40
+
41
+ const handleSetIsContentReadyToBeShown = React.useCallback(() => {
42
+ setIsContentReadyToBeShown(true);
40
43
  }, []);
41
44
 
42
45
  const managerRef = useRefWithInitialValue<ScreenRevealManager>(
43
- () => new ScreenRevealManager(componentsToRender, handleSetIsReadyToShow)
46
+ () =>
47
+ new ScreenRevealManager(
48
+ componentsToRender,
49
+ handleSetIsContentReadyToBeShown
50
+ )
44
51
  );
45
52
 
46
53
  const opacityRef = useRefWithInitialValue<Animated.Value>(
47
- () => new Animated.Value(HIDDEN)
54
+ () => new Animated.Value(SHOWN)
48
55
  );
49
56
 
50
57
  React.useEffect(() => {
51
- if (!isReadyToShow) {
58
+ if (!isContentReadyToBeShown) {
52
59
  emitScreenRevealManagerIsNotReadyToShow();
53
60
  } else {
54
61
  emitScreenRevealManagerIsReadyToShow();
55
62
  }
56
- }, [isReadyToShow]);
63
+ }, [isContentReadyToBeShown]);
57
64
 
58
65
  React.useEffect(() => {
59
- if (isReadyToShow) {
66
+ if (isContentReadyToBeShown) {
60
67
  Animated.timing(opacityRef.current, {
61
- toValue: SHOWN,
68
+ toValue: HIDDEN,
62
69
  duration: TIMEOUT,
63
70
  useNativeDriver: true,
64
- }).start();
71
+ }).start(() => {
72
+ setIsShowOverlay(false);
73
+ });
65
74
  }
66
- }, [isReadyToShow]);
75
+ }, [isContentReadyToBeShown]);
67
76
 
68
77
  if (isFirstComponentScreenPicker(componentsToRender)) {
69
78
  // for screen-picker with have additional internal ComponentsMap, no need to add this wrapper
@@ -71,10 +80,7 @@ export const withScreenRevealManager = (Component) => {
71
80
  }
72
81
 
73
82
  return (
74
- <Animated.View
75
- style={{ opacity: opacityRef.current, flex }}
76
- testID="animated-component"
77
- >
83
+ <>
78
84
  <Component
79
85
  {...props}
80
86
  initialNumberToLoad={
@@ -85,7 +91,19 @@ export const withScreenRevealManager = (Component) => {
85
91
  }
86
92
  onLoadFailedFromScreenRevealManager={managerRef.current.onLoadFailed}
87
93
  />
88
- </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
+ </>
89
107
  );
90
108
  };
91
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,