@applicaster/zapp-react-native-ui-components 12.0.0-alpha.8433353116 → 12.0.0-alpha.8939308044

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 (65) hide show
  1. package/Components/BaseFocusable/index.tsx +1 -1
  2. package/Components/Cell/Cell.tsx +5 -5
  3. package/Components/Cell/CellWithFocusable.tsx +17 -5
  4. package/Components/FocusableGroup/index.tsx +1 -0
  5. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  6. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  7. package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
  8. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  9. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  10. package/Components/Layout/TV/__tests__/index.test.tsx +18 -74
  11. package/Components/Layout/TV/index.tsx +43 -102
  12. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  13. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  14. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  15. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +14 -1
  16. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  17. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  18. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  19. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  20. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +4 -1
  21. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
  22. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  23. package/Components/MasterCell/utils/index.ts +16 -5
  24. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  25. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  26. package/Components/PlayerContainer/PlayerContainer.tsx +19 -10
  27. package/Components/PlayerImageBackground/index.tsx +34 -8
  28. package/Components/River/ComponentsMap/ComponentsMap.tsx +86 -22
  29. package/Components/River/RefreshControl.tsx +55 -1
  30. package/Components/River/TV/River.tsx +0 -23
  31. package/Components/River/__tests__/componentsMap.test.js +6 -0
  32. package/Components/Screen/TV/hooks/index.ts +3 -0
  33. package/Components/Screen/TV/hooks/useInitialFocus.ts +67 -0
  34. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  35. package/Components/Screen/TV/index.web.tsx +176 -0
  36. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -0
  37. package/Components/Screen/index.tsx +36 -25
  38. package/Components/ScreenResolver/index.tsx +3 -1
  39. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +20 -5
  40. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
  41. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
  42. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +342 -0
  43. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +151 -0
  44. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +438 -0
  45. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +154 -0
  46. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  47. package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
  48. package/Components/VideoModal/PlayerWrapper.tsx +66 -43
  49. package/Components/VideoModal/VideoModal.tsx +25 -42
  50. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +6 -1
  51. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +151 -119
  52. package/Components/VideoModal/utils.ts +3 -3
  53. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +1 -1
  54. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  55. package/Components/Viewport/utils.js +1 -1
  56. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  57. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  58. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  59. package/Contexts/ScreenContext/index.tsx +94 -25
  60. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  61. package/events/index.ts +1 -0
  62. package/package.json +5 -5
  63. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  64. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  65. /package/Contexts/{index.js → index.ts} +0 -0
@@ -7,14 +7,10 @@ import * as R from "ramda";
7
7
  import {
8
8
  useFeedLoader,
9
9
  useLayoutVersion,
10
- useNavigationPluginData,
11
10
  } from "@applicaster/zapp-react-native-utils/reactHooks";
12
11
  import { GeneralContentScreen } from "../../GeneralContentScreen";
13
12
  import { ScreenResolver } from "@applicaster/zapp-react-native-ui-components/Components/ScreenResolver";
14
13
  import { utilsLogger } from "@applicaster/zapp-react-native-utils/logger";
15
- import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
16
- import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
17
- import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
18
14
  import {
19
15
  useNavbarState,
20
16
  useSetNavbarState,
@@ -51,8 +47,6 @@ export const River = (props: Props) => {
51
47
  const { setTitle: setScreenTitle, setSummary: setScreenSummary } =
52
48
  useSetNavbarState();
53
49
 
54
- const navigationPluginData = useNavigationPluginData();
55
-
56
50
  const rivers = useRivers();
57
51
  const isV2 = useLayoutVersion({ isV2: true });
58
52
 
@@ -99,23 +93,6 @@ export const River = (props: Props) => {
99
93
  }
100
94
  }, [feedData, screenData, screenTitle, screenSummary]);
101
95
 
102
- React.useEffect(() => {
103
- if (
104
- isWeb() &&
105
- toBooleanWithDefaultFalse(
106
- navigationPluginData?.rules?.focus_on_content
107
- ) &&
108
- river &&
109
- river.type !== "general_content"
110
- ) {
111
- const groupId = R.pathOr("river", ["groupId"], componentsMapExtraProps);
112
-
113
- focusManager.setupInitialFocus(groupId, true);
114
- focusManager.setInitialFocus();
115
- focusManager.enableAutomaticFocus();
116
- }
117
- }, [river, componentsMapExtraProps]);
118
-
119
96
  if (!river) {
120
97
  utilsLogger.error({
121
98
  message: `River ${screenData.id} not found!`,
@@ -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
  }));
@@ -0,0 +1,3 @@
1
+ export { useInitialFocus } from "./useInitialFocus";
2
+
3
+ export { useRestoreFocus } from "./useRestoreFocus";
@@ -0,0 +1,67 @@
1
+ import * as React from "react";
2
+ import {
3
+ useNavigationPluginData,
4
+ useIsNavBarVisible,
5
+ useRoute,
6
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
7
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
8
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
9
+
10
+ type Return =
11
+ | {
12
+ onContent: true;
13
+ onMenu: false;
14
+ }
15
+ | {
16
+ onContent: false;
17
+ onMenu: true;
18
+ };
19
+
20
+ const getInitialFocus = (focusOnContent, isNavBarVisible): Return => {
21
+ if (focusOnContent) {
22
+ return {
23
+ onContent: true,
24
+ onMenu: false,
25
+ };
26
+ }
27
+
28
+ if (!focusOnContent && isNavBarVisible) {
29
+ // put focus on navbar
30
+ return {
31
+ onContent: false,
32
+ onMenu: true,
33
+ };
34
+ }
35
+
36
+ // we don't have navbar, put focus on content anyway
37
+ return {
38
+ onContent: true,
39
+ onMenu: false,
40
+ };
41
+ };
42
+
43
+ export const useInitialFocus = (): void => {
44
+ const navigationPluginData = useNavigationPluginData();
45
+
46
+ const focusOnContent = toBooleanWithDefaultFalse(
47
+ navigationPluginData?.rules?.focus_on_content
48
+ );
49
+
50
+ const isNavBarVisible = useIsNavBarVisible();
51
+
52
+ const { pathname: currentRoute } = useRoute();
53
+
54
+ React.useEffect(() => {
55
+ const initialFocus = getInitialFocus(focusOnContent, isNavBarVisible);
56
+
57
+ if (initialFocus.onContent) {
58
+ focusManager.setFocusOnContent(currentRoute);
59
+
60
+ return;
61
+ }
62
+
63
+ if (initialFocus.onMenu) {
64
+ focusManager.setFocusOnMenu(currentRoute);
65
+ }
66
+ }, []);
67
+ };
@@ -0,0 +1,22 @@
1
+ import * as React from "react";
2
+ import { isNil } from "ramda";
3
+ import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
+ import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
5
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
6
+
7
+ export const useRestoreFocus = (): void => {
8
+ const isScreenActive = useIsScreenActive();
9
+ const previousIsScreenActive = usePrevious(isScreenActive);
10
+
11
+ React.useEffect(() => {
12
+ if (isNil(previousIsScreenActive)) {
13
+ // it's initial mounting of the screen, do nothing here
14
+ return;
15
+ }
16
+
17
+ if (!previousIsScreenActive && isScreenActive) {
18
+ // restore focus when we go back from next screen
19
+ focusManager.setInitialFocus();
20
+ }
21
+ }, [previousIsScreenActive, isScreenActive]);
22
+ };
@@ -0,0 +1,176 @@
1
+ import * as React from "react";
2
+ import { last, pathOr } from "ramda";
3
+ import { View, StyleSheet } from "react-native";
4
+ import {
5
+ getNavigationProps,
6
+ getPathAttributes,
7
+ resolveNavigationPlugin,
8
+ } from "@applicaster/zapp-react-native-utils/navigationUtils";
9
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
10
+ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
11
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
12
+ import { useScreenBackgroundColor } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
13
+ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
14
+
15
+ import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
16
+ import { ScreenResolver } from "../../ScreenResolver";
17
+ import { useInitialFocus, useRestoreFocus } from "./hooks";
18
+
19
+ const styles = StyleSheet.create({
20
+ container: {
21
+ position: "absolute",
22
+ top: 0,
23
+ left: 0,
24
+ right: 0,
25
+ bottom: 0,
26
+ },
27
+ });
28
+
29
+ type Components = {
30
+ NavBar: React.ComponentType<any>;
31
+ Background: React.ComponentType<any>;
32
+ };
33
+
34
+ type Props = {
35
+ route: string;
36
+ Components: Components;
37
+ };
38
+
39
+ const isPlayerPlugin = (routeState): boolean => {
40
+ const pluginType = pathOr(
41
+ "unknown_plugin_type",
42
+ ["state", "screen", "plugin_type"],
43
+ routeState
44
+ );
45
+
46
+ return pluginType === "player";
47
+ };
48
+
49
+ const getActiveRiver = ({
50
+ screenId,
51
+ screenType,
52
+ routeState,
53
+ rivers,
54
+ fallbackActiveRiver,
55
+ }) => {
56
+ if (rivers[screenId]) {
57
+ if (screenType === "hooks") {
58
+ const navigations = routeState?.state?.entry?.payload?.navigations;
59
+
60
+ if (navigations) {
61
+ return routeState.state.entry.payload;
62
+ }
63
+ }
64
+
65
+ return routeState?.state?.screen;
66
+ }
67
+
68
+ // screenId is not presented into rivers, use fallback instead
69
+ return fallbackActiveRiver;
70
+ };
71
+
72
+ const getNavigations = ({
73
+ screenId,
74
+ screenType,
75
+ routeState,
76
+ rivers,
77
+ fallbackNavigations,
78
+ }) => {
79
+ if (rivers[screenId]) {
80
+ // river presents
81
+ if (screenType === "hooks") {
82
+ const navigations = routeState?.state?.entry?.payload?.navigations;
83
+
84
+ if (navigations) {
85
+ return navigations;
86
+ }
87
+ }
88
+
89
+ return routeState?.state?.screen?.navigations;
90
+ }
91
+
92
+ // screenId is not presented into rivers, use fallback instead
93
+ return fallbackNavigations;
94
+ };
95
+
96
+ export const Screen = ({ route, Components }: Props) => {
97
+ if (isNilOrEmpty(route)) {
98
+ throw Error("Required props: route is missing");
99
+ }
100
+
101
+ const navigator = useNavigation();
102
+ const { plugins = [], rivers = [] } = usePickFromState(["plugins", "rivers"]);
103
+
104
+ const pathAttributes = getPathAttributes({ pathname: route });
105
+ const routeState = navigator.getStackForPathname(route);
106
+
107
+ const { screenType, screenId } = last(pathAttributes);
108
+
109
+ const backgroundColor = useScreenBackgroundColor(screenId);
110
+
111
+ useInitialFocus();
112
+ useRestoreFocus();
113
+
114
+ const activeRiver = getActiveRiver({
115
+ screenId,
116
+ screenType,
117
+ routeState,
118
+ rivers,
119
+ fallbackActiveRiver: navigator.activeRiver,
120
+ });
121
+
122
+ const navigationProps = getNavigationProps({
123
+ navigator: {
124
+ // @ts-ignore
125
+ activeRiver,
126
+ // @ts-ignore
127
+ screenTitle: routeState.state.entry?.title || routeState.screen?.name,
128
+ },
129
+ category: "menu",
130
+ });
131
+
132
+ const navigations = getNavigations({
133
+ screenId,
134
+ screenType,
135
+ routeState,
136
+ rivers,
137
+ fallbackNavigations: navigator.activeRiver.navigations,
138
+ });
139
+
140
+ const menuPlugin = resolveNavigationPlugin({
141
+ category: "menu",
142
+ navigations,
143
+ plugins,
144
+ }) as QuickBrickPlugin;
145
+
146
+ const NavBar = (Components.NavBar ||
147
+ menuPlugin.module) as React.ComponentType<any>;
148
+
149
+ const isPlayer = isPlayerPlugin(routeState);
150
+
151
+ const isNavBarVisible = !isPlayer;
152
+
153
+ const screenData =
154
+ screenType === "hooks" || isPlayer
155
+ ? routeState?.state?.entry
156
+ : routeState?.state?.screen;
157
+
158
+ return (
159
+ <View style={[styles.container, { backgroundColor }]}>
160
+ <NavBarContainer isVisible={isNavBarVisible} onReady={noop}>
161
+ <NavBar
162
+ groupId={route}
163
+ isVisible={isNavBarVisible}
164
+ menuPlugin={menuPlugin}
165
+ navigationProps={navigationProps}
166
+ />
167
+ </NavBarContainer>
168
+ <ScreenResolver
169
+ screenType={screenType}
170
+ screenId={screenId}
171
+ screenData={screenData}
172
+ groupId={route}
173
+ />
174
+ </View>
175
+ );
176
+ };
@@ -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=""
@@ -6,7 +6,10 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
6
6
 
7
7
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
8
8
  import { getComponentModule } from "@applicaster/zapp-react-native-utils/pluginUtils";
9
- import { getNavigationPropsV2 } from "@applicaster/zapp-react-native-utils/navigationUtils";
9
+ import {
10
+ getNavigationPropsV2,
11
+ resolveNavigationPlugin,
12
+ } from "@applicaster/zapp-react-native-utils/navigationUtils";
10
13
  import { useSafeAreaInsets } from "react-native-safe-area-context";
11
14
  import {
12
15
  useDimensions,
@@ -52,11 +55,11 @@ function isValidColor(string) {
52
55
  }
53
56
 
54
57
  type Props = {
55
- setToggleMenu: () => void;
56
- setCloseMenu: () => void;
58
+ pathname: unknown;
59
+ screenData: unknown;
57
60
  };
58
61
 
59
- export function Screen({ setToggleMenu, setCloseMenu }: Props) {
62
+ export function Screen(_props: Props) {
60
63
  const theme = useTheme<BaseThemePropertiesMobile>();
61
64
  const navigation = useNavigation();
62
65
  const { plugins } = usePickFromState(["plugins"]);
@@ -70,26 +73,38 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
70
73
  fullDimensions: true,
71
74
  });
72
75
 
73
- const routeData = useRoute();
76
+ const { screenData, pathname } = useRoute();
74
77
 
75
78
  const currentRiver = useScreenData(
76
- getScreenId(routeData.screenData, navigation.activeRiver)
79
+ getScreenId(screenData, navigation.activeRiver)
77
80
  );
78
81
 
79
82
  const { title } = useNavbarState();
80
83
 
81
- const navBarProps = React.useMemo(
82
- () => ({
83
- ...getNavigationPropsV2({
84
- currentRiver,
85
- title,
86
- category: "nav_bar",
87
- }),
88
- setToggleMenu,
89
- setCloseMenu,
90
- }),
91
- [currentRiver, setCloseMenu, setToggleMenu]
92
- );
84
+ const hasMenu =
85
+ resolveNavigationPlugin({
86
+ category: "menu",
87
+ navigations: currentRiver.navigations,
88
+ plugins,
89
+ })?.identifier === "quick_brick_side_menu";
90
+
91
+ const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(() => {
92
+ const props = getNavigationPropsV2({
93
+ currentRiver,
94
+ title,
95
+ category: "nav_bar",
96
+ });
97
+
98
+ if (props) {
99
+ return {
100
+ ...props,
101
+ id: pathname,
102
+ pathname: pathname,
103
+ };
104
+ }
105
+
106
+ return null;
107
+ }, [currentRiver, pathname]);
93
108
 
94
109
  const NavBar = React.useMemo(
95
110
  () =>
@@ -97,12 +112,10 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
97
112
  "nav_bar",
98
113
  currentRiver,
99
114
  plugins
100
- ) as React.ComponentType<MobileNavBarPluginProps>,
115
+ ) as React.ComponentType<MobileNavBarPluginProps & { hasMenu: boolean }>,
101
116
  []
102
117
  );
103
118
 
104
- const { screenData, pathname } = routeData;
105
-
106
119
  const offlinePlugin = getComponentModule({
107
120
  plugins,
108
121
  components: {},
@@ -133,11 +146,9 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
133
146
  return (
134
147
  <ScreenContextProvider pathname={pathname}>
135
148
  <View style={style}>
136
- <NavBar
137
- {...{ ...(navBarProps as MobileNavBarPluginProps), id: pathname }}
138
- />
149
+ {navBarProps && <NavBar {...navBarProps} hasMenu={hasMenu} />}
139
150
 
140
- <OfflineFallbackScreen screenData={screenData}>
151
+ <OfflineFallbackScreen screenData={targetScreenData}>
141
152
  {/* @TODO RouteManager doesn't use props, can they be removed ? */}
142
153
  <RouteManager pathname={pathname} screenData={screenData} />
143
154
  </OfflineFallbackScreen>
@@ -32,12 +32,13 @@ type Props = {
32
32
  nextFocusLeft?: React.Ref<any>;
33
33
  nextFocusUp?: React.Ref<any>;
34
34
  };
35
+ groupId?: string;
35
36
  };
36
37
 
37
38
  export function ScreenResolverComponent(props: Props) {
38
39
  useScreenAnalytics(props);
39
40
 
40
- const { screenType, screenId, screenData } = props;
41
+ const { screenType, screenId, screenData, groupId } = props;
41
42
 
42
43
  const { hookPlugin } = screenData || {};
43
44
 
@@ -81,6 +82,7 @@ export function ScreenResolverComponent(props: Props) {
81
82
  item={screenData}
82
83
  mode={mode === "PIP" ? "PIP" : "FULLSCREEN"}
83
84
  isModal={false}
85
+ groupId={groupId}
84
86
  />
85
87
  );
86
88
  }
@@ -7,6 +7,10 @@ import { ThemeContext } from "@applicaster/zapp-react-native-utils/theme";
7
7
  import * as navigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
8
8
 
9
9
  import { PlayerLiveImage } from "../PlayerLiveImageComponent";
10
+ import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
11
+
12
+ import { Provider } from "react-redux";
13
+ import configureStore from "redux-mock-store";
10
14
 
11
15
  const seekTo = jest.fn();
12
16
 
@@ -19,14 +23,25 @@ jest.mock(
19
23
  })
20
24
  );
21
25
 
26
+ jest
27
+ .spyOn(useNavigationHooks, "useNavigation")
28
+ .mockImplementation(() => ({ videoModalState: { visible: false } }));
29
+
22
30
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
23
31
 
32
+ const mockStore = configureStore();
33
+
34
+ const store = mockStore({ appData: {} });
35
+
24
36
  const Wrapper = ({ children }: { children: React.ReactChildren }) => (
25
- <ThemeContext.Provider
26
- value={{ themes: { myTheme: {} }, selectedThemeId: "myTheme" }}
27
- >
28
- {children}
29
- </ThemeContext.Provider>
37
+ /* @ts-ignore */
38
+ <Provider store={store}>
39
+ <ThemeContext.Provider
40
+ value={{ themes: { myTheme: {} }, selectedThemeId: "myTheme" }}
41
+ >
42
+ {children}
43
+ </ThemeContext.Provider>
44
+ </Provider>
30
45
  );
31
46
 
32
47
  describe("PlayerLiveImageComponent", () => {
@@ -30,11 +30,6 @@ exports[`PlayerLiveImageComponent should render correctly with default props 1`]
30
30
  playerId="player1"
31
31
  resizeMode="cover"
32
32
  screenConfig={Object {}}
33
- source={
34
- Object {
35
- "uri": "",
36
- }
37
- }
38
33
  style={Object {}}
39
34
  />
40
35
  </View>
@@ -0,0 +1,78 @@
1
+ import React from "react";
2
+ import { Animated, ViewStyle } from "react-native";
3
+
4
+ import {
5
+ useModalAnimationContext,
6
+ PlayerAnimationStateEnum,
7
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
8
+ import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks";
9
+
10
+ type Props = {
11
+ style: ViewStyle[];
12
+ children: React.ReactNode;
13
+ };
14
+
15
+ export const AnimatedPlayerModalWrapper = (props: Props) => {
16
+ const {
17
+ playerAnimationState,
18
+ animatedValues: { lastScrollY, dragScrollY, translateYOffset },
19
+ modalSnapPoints,
20
+ setStartComponentsAnimation,
21
+ lastScrollYValue,
22
+ } = useModalAnimationContext();
23
+
24
+ const { height: screenHeight } = useDimensions("screen", {
25
+ deviceInfo: true,
26
+ });
27
+
28
+ const interpolateConfig: Animated.InterpolationConfigType = React.useMemo(
29
+ () => ({
30
+ inputRange: modalSnapPoints,
31
+ outputRange: modalSnapPoints,
32
+ extrapolate: "clamp",
33
+ }),
34
+ [modalSnapPoints]
35
+ );
36
+
37
+ let translateY;
38
+
39
+ if (playerAnimationState === PlayerAnimationStateEnum.drag_player) {
40
+ translateY = translateYOffset.interpolate(interpolateConfig);
41
+ } else {
42
+ const reverseLastScrollY = Animated.multiply(
43
+ new Animated.Value(-1),
44
+ lastScrollY
45
+ );
46
+
47
+ translateY = Animated.add(
48
+ translateYOffset,
49
+ Animated.add(dragScrollY, reverseLastScrollY)
50
+ ).interpolate(interpolateConfig);
51
+ }
52
+
53
+ React.useEffect(() => {
54
+ const translateYListener = translateY.addListener(({ value }) => {
55
+ const preparedValue = Math.round(
56
+ Math.abs(value) - lastScrollYValue.current
57
+ );
58
+
59
+ (playerAnimationState === PlayerAnimationStateEnum.minimize ||
60
+ playerAnimationState === PlayerAnimationStateEnum.maximaze) &&
61
+ setStartComponentsAnimation(
62
+ preparedValue >= Math.round((screenHeight * 10) / 100)
63
+ );
64
+ });
65
+
66
+ return () => {
67
+ translateYListener && translateY.removeListener(translateYListener);
68
+ };
69
+ }, [playerAnimationState]);
70
+
71
+ return (
72
+ <Animated.View
73
+ style={[props.style, { transform: [{ translateY: translateY }] }]}
74
+ >
75
+ {props.children}
76
+ </Animated.View>
77
+ );
78
+ };