@applicaster/zapp-react-native-ui-components 12.0.0-alpha.3964644693 → 12.0.0-alpha.4043183114
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.
- package/Components/BaseFocusable/index.tsx +2 -2
- package/Components/Cell/Cell.tsx +9 -8
- package/Components/Cell/CellWithFocusable.tsx +7 -5
- package/Components/Cell/TvOSCellComponent.tsx +6 -11
- package/Components/Layout/TV/ScreenContainer.tsx +79 -5
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
- package/Components/Layout/TV/__tests__/index.test.tsx +2 -1
- package/Components/Layout/TV/index.tsx +11 -65
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +20 -0
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +6 -1
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
- package/Components/NativeFocusables/{index.js → index.ts} +4 -2
- package/Components/Navigator/StackNavigator.tsx +14 -5
- package/Components/PlayerContainer/PlayerContainer.tsx +2 -5
- package/Components/Screen/TV/index.web.tsx +9 -22
- package/Components/Screen/index.tsx +27 -58
- package/Components/Screen/navigationHandler.ts +5 -0
- package/Components/Transitioner/Scene.tsx +12 -11
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +8 -4
- package/Components/VideoLive/LiveImageManager.ts +10 -0
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +2 -14
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +8 -5
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +4 -1
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +6 -5
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +28 -8
- package/Components/VideoModal/ModalAnimation/utils.ts +1 -0
- package/Components/VideoModal/PlayerWrapper.tsx +1 -1
- package/Components/VideoModal/hooks/useModalSize.ts +10 -12
- package/Decorators/Analytics/{index.js → index.tsx} +11 -11
- package/README.md +1 -13
- package/package.json +5 -5
|
@@ -8,6 +8,8 @@ import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/
|
|
|
8
8
|
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
9
9
|
|
|
10
10
|
import { Screen } from "../Screen/TV/index.web";
|
|
11
|
+
import { isLast } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
12
|
+
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
11
13
|
|
|
12
14
|
type Components = {
|
|
13
15
|
NavBar: React.ComponentType<any>;
|
|
@@ -19,25 +21,32 @@ type Props = {
|
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export const StackNavigator = ({ Components }: Props) => {
|
|
22
|
-
const { mainStack
|
|
24
|
+
const { mainStack } = useNavigation();
|
|
23
25
|
|
|
24
|
-
const renderScreen = ({ route, state }) => {
|
|
26
|
+
const renderScreen = ({ route, state }, index) => {
|
|
25
27
|
const pathAttributes = getPathAttributes({ pathname: route });
|
|
26
28
|
|
|
27
29
|
if (isEmpty(pathAttributes)) {
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
// HACK: Adding index to route to avoid conflicts in the navigator.
|
|
34
|
+
// Startup hooks are all using PUSH navigation action to navigate, but their routes are always like root routes.
|
|
35
|
+
// This means some hooks can have the same routes, e.g., ["hooks/context-setter", "/hooks/login-plug", "hooks/context-setter"].
|
|
36
|
+
const routeId = `${route}--${index}`;
|
|
37
|
+
|
|
31
38
|
return (
|
|
32
39
|
<FocusableGroup
|
|
33
40
|
id={route}
|
|
34
|
-
preferredFocus={
|
|
41
|
+
preferredFocus={isLast(index, mainStack.length)}
|
|
35
42
|
excludeFromFocusSearching
|
|
36
|
-
key={
|
|
43
|
+
key={routeId}
|
|
37
44
|
>
|
|
38
45
|
<ScreenDataContext.Provider value={state}>
|
|
39
46
|
<PathnameContext.Provider value={route}>
|
|
40
|
-
<
|
|
47
|
+
<ScreenContextProvider pathname={route}>
|
|
48
|
+
<Screen route={route} Components={Components} />
|
|
49
|
+
</ScreenContextProvider>
|
|
41
50
|
</PathnameContext.Provider>
|
|
42
51
|
</ScreenDataContext.Provider>
|
|
43
52
|
</FocusableGroup>
|
|
@@ -124,6 +124,7 @@ const nativeStyles = {
|
|
|
124
124
|
playerScreen: {
|
|
125
125
|
flex: 1,
|
|
126
126
|
backgroundColor: "black",
|
|
127
|
+
overflow: "hidden",
|
|
127
128
|
},
|
|
128
129
|
playerWrapper: {
|
|
129
130
|
flex: 1,
|
|
@@ -252,11 +253,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
252
253
|
}
|
|
253
254
|
|
|
254
255
|
showNavBar(true);
|
|
255
|
-
|
|
256
|
-
// Hack to close player screen on mobile only (tv handles that in InteractionManager)
|
|
257
|
-
if (!isTV()) {
|
|
258
|
-
navigator.goBack();
|
|
259
|
-
}
|
|
256
|
+
navigator.goBack();
|
|
260
257
|
}, [isModal, navigator.goBack, showNavBar]);
|
|
261
258
|
|
|
262
259
|
const playEntry = (entry) => navigator.replaceTop(entry, { mode });
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { last
|
|
2
|
+
import { last } from "ramda";
|
|
3
3
|
import { View, StyleSheet } from "react-native";
|
|
4
4
|
import {
|
|
5
|
+
findMenuPlugin,
|
|
5
6
|
getNavigationProps,
|
|
6
7
|
getPathAttributes,
|
|
7
|
-
resolveNavigationPlugin,
|
|
8
8
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
9
9
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
10
10
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
11
11
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
useNavbarState,
|
|
14
|
+
useScreenBackgroundColor,
|
|
15
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
13
16
|
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
14
17
|
|
|
15
18
|
import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
|
|
16
19
|
import { ScreenResolver } from "../../ScreenResolver";
|
|
17
20
|
import { useInitialFocus, useRestoreFocus } from "./hooks";
|
|
21
|
+
import { isPlayerPlugin } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
18
22
|
|
|
19
23
|
const styles = StyleSheet.create({
|
|
20
24
|
container: {
|
|
@@ -36,18 +40,6 @@ type Props = {
|
|
|
36
40
|
Components: Components;
|
|
37
41
|
};
|
|
38
42
|
|
|
39
|
-
const getPluginType = pathOr("unknown_plugin_type", [
|
|
40
|
-
"state",
|
|
41
|
-
"screen",
|
|
42
|
-
"plugin_type",
|
|
43
|
-
]);
|
|
44
|
-
|
|
45
|
-
const isPlayerPlugin = (routeState): boolean =>
|
|
46
|
-
getPluginType(routeState) === "player";
|
|
47
|
-
|
|
48
|
-
const isLoginPlugin = (routeState): boolean =>
|
|
49
|
-
getPluginType(routeState) === "login";
|
|
50
|
-
|
|
51
43
|
const getActiveRiver = ({
|
|
52
44
|
screenId,
|
|
53
45
|
screenType,
|
|
@@ -139,19 +131,14 @@ export const Screen = ({ route, Components }: Props) => {
|
|
|
139
131
|
fallbackNavigations: navigator.activeRiver.navigations,
|
|
140
132
|
});
|
|
141
133
|
|
|
142
|
-
const menuPlugin =
|
|
143
|
-
category: "menu",
|
|
144
|
-
navigations,
|
|
145
|
-
plugins,
|
|
146
|
-
}) as QuickBrickPlugin;
|
|
134
|
+
const menuPlugin = findMenuPlugin(navigations, plugins);
|
|
147
135
|
|
|
148
136
|
const NavBar = (Components.NavBar ||
|
|
149
137
|
menuPlugin.module) as React.ComponentType<any>;
|
|
150
138
|
|
|
151
139
|
const isPlayer = isPlayerPlugin(routeState);
|
|
152
|
-
const isLogin = isLoginPlugin(routeState);
|
|
153
140
|
|
|
154
|
-
const isNavBarVisible =
|
|
141
|
+
const { visible: isNavBarVisible } = useNavbarState();
|
|
155
142
|
|
|
156
143
|
const screenData =
|
|
157
144
|
screenType === "hooks" || isPlayer
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
12
12
|
import { getComponentModule } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
shouldNavBarDisplayMenu,
|
|
15
|
+
getNavBarProps,
|
|
16
|
+
getScreenId,
|
|
16
17
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
17
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
18
18
|
import {
|
|
19
19
|
useDimensions,
|
|
20
20
|
useRoute,
|
|
@@ -25,20 +25,16 @@ import {
|
|
|
25
25
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
26
26
|
import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers";
|
|
27
27
|
|
|
28
|
-
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
29
28
|
import { RouteManager } from "../RouteManager";
|
|
30
29
|
import { useScreenConfiguration } from "../River/useScreenConfiguration";
|
|
31
30
|
import { useScreenOrientationHandler } from "./orientationHandler";
|
|
32
31
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
: "screen_id" in screenData
|
|
40
|
-
? screenData.screen_id
|
|
41
|
-
: fallbackRiver.id;
|
|
32
|
+
const screenStyles = {
|
|
33
|
+
flex: 1,
|
|
34
|
+
paddingTop: 0,
|
|
35
|
+
// paddingBottom: insets.bottom, // Should be applied directly by UI plugin
|
|
36
|
+
// paddingLeft: insets.left, // Should be applied directly by UI plugin
|
|
37
|
+
// paddingRight: insets.right, // Should be applied directly by UI plugin
|
|
42
38
|
};
|
|
43
39
|
|
|
44
40
|
function colorIsNotTransparent(color) {
|
|
@@ -49,9 +45,7 @@ function colorIsNotTransparent(color) {
|
|
|
49
45
|
R.replace("rgba(", "")
|
|
50
46
|
)(color);
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return alpha > 0;
|
|
48
|
+
return Number(layers?.[3]) > 0;
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
function isValidColor(string) {
|
|
@@ -71,7 +65,6 @@ export function Screen(_props: Props) {
|
|
|
71
65
|
// Gets the data for the current screen configuration
|
|
72
66
|
const currentScreenData = useCurrentScreenData();
|
|
73
67
|
const { backgroundColor } = useScreenConfiguration(currentScreenData.id);
|
|
74
|
-
const insets = useSafeAreaInsets();
|
|
75
68
|
|
|
76
69
|
const {
|
|
77
70
|
width: screenWidth,
|
|
@@ -96,30 +89,12 @@ export function Screen(_props: Props) {
|
|
|
96
89
|
|
|
97
90
|
const layoutData = { isTablet, isTabletPortrait, width: screenWidth, height };
|
|
98
91
|
|
|
99
|
-
const hasMenu =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(() => {
|
|
107
|
-
const props = getNavigationPropsV2({
|
|
108
|
-
currentRiver,
|
|
109
|
-
title,
|
|
110
|
-
category: "nav_bar",
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
if (props) {
|
|
114
|
-
return {
|
|
115
|
-
...props,
|
|
116
|
-
id: pathname,
|
|
117
|
-
pathname: pathname,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return null;
|
|
122
|
-
}, [currentRiver, pathname]);
|
|
92
|
+
const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
|
|
93
|
+
|
|
94
|
+
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
|
|
95
|
+
getNavBarProps(currentRiver, pathname, title),
|
|
96
|
+
[currentRiver, pathname]
|
|
97
|
+
);
|
|
123
98
|
|
|
124
99
|
const NavBar = React.useMemo(
|
|
125
100
|
() =>
|
|
@@ -141,16 +116,12 @@ export function Screen(_props: Props) {
|
|
|
141
116
|
|
|
142
117
|
const style = React.useMemo(
|
|
143
118
|
() => ({
|
|
144
|
-
|
|
119
|
+
...screenStyles,
|
|
145
120
|
backgroundColor: isValidColor(backgroundColor)
|
|
146
121
|
? backgroundColor
|
|
147
122
|
: theme.app_background_color,
|
|
148
|
-
paddingTop: 0,
|
|
149
|
-
// paddingBottom: insets.bottom, // Should be applied directly by UI plugin
|
|
150
|
-
// paddingLeft: insets.left, // Should be applied directly by UI plugin
|
|
151
|
-
// paddingRight: insets.right, // Should be applied directly by UI plugin
|
|
152
123
|
}),
|
|
153
|
-
[
|
|
124
|
+
[theme.app_background_color, backgroundColor]
|
|
154
125
|
);
|
|
155
126
|
|
|
156
127
|
const targetScreenData =
|
|
@@ -168,19 +139,17 @@ export function Screen(_props: Props) {
|
|
|
168
139
|
layoutData,
|
|
169
140
|
})
|
|
170
141
|
) {
|
|
171
|
-
return
|
|
142
|
+
return <View style={style} />;
|
|
172
143
|
}
|
|
173
144
|
|
|
174
145
|
return (
|
|
175
|
-
<
|
|
176
|
-
<
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
</View>
|
|
184
|
-
</ScreenContextProvider>
|
|
146
|
+
<View style={style}>
|
|
147
|
+
{navBarProps && <NavBar {...navBarProps} hasMenu={hasMenu} />}
|
|
148
|
+
|
|
149
|
+
<OfflineFallbackScreen screenData={targetScreenData}>
|
|
150
|
+
{/* @TODO RouteManager doesn't use props, can they be removed ? */}
|
|
151
|
+
<RouteManager pathname={pathname} screenData={screenData} />
|
|
152
|
+
</OfflineFallbackScreen>
|
|
153
|
+
</View>
|
|
185
154
|
);
|
|
186
155
|
}
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* is similar to the navbar, except that it covers scenarios where only the navbar (and not)
|
|
6
6
|
* the menu, will be hidden
|
|
7
7
|
*
|
|
8
|
+
* - playable screens
|
|
9
|
+
* - qb_search_screen
|
|
10
|
+
* - screen hooks that specify showNavBar or presentFullScreen
|
|
11
|
+
* - screens or nested screens that have allow_screen_plugin_presentation set to true
|
|
12
|
+
*
|
|
8
13
|
* @param {String} route current route of the screen
|
|
9
14
|
* @param {Object} screenData payload associated with the currently presented screen
|
|
10
15
|
* @returns {Boolean}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
Animated,
|
|
4
|
-
useWindowDimensions,
|
|
5
|
-
ViewProps,
|
|
6
|
-
ViewStyle,
|
|
7
|
-
} from "react-native";
|
|
2
|
+
import { Animated, ViewProps, ViewStyle } from "react-native";
|
|
8
3
|
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
9
4
|
import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
10
5
|
import { ScreenDataContext } from "../../Contexts/ScreenDataContext";
|
|
6
|
+
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
11
7
|
|
|
12
8
|
type Props = {
|
|
13
9
|
children: any;
|
|
@@ -53,12 +49,15 @@ export function Scene({
|
|
|
53
49
|
}, [screenData, isActive]);
|
|
54
50
|
|
|
55
51
|
const frame = useSafeAreaFrame();
|
|
56
|
-
const { height, width } = useWindowDimensions();
|
|
57
52
|
|
|
58
|
-
// Safe frame takes too long to update,
|
|
59
|
-
// so we can not rely on it there, and use height and width instead.
|
|
60
53
|
const isAnimating = animating && overlayStyle;
|
|
61
|
-
|
|
54
|
+
|
|
55
|
+
const dimensions = isAnimating
|
|
56
|
+
? {
|
|
57
|
+
height: "100%",
|
|
58
|
+
width: "100%",
|
|
59
|
+
}
|
|
60
|
+
: frame;
|
|
62
61
|
|
|
63
62
|
return (
|
|
64
63
|
<Animated.View
|
|
@@ -67,7 +66,9 @@ export function Scene({
|
|
|
67
66
|
>
|
|
68
67
|
<ScreenDataContext.Provider value={initialScreenData}>
|
|
69
68
|
<PathnameContext.Provider value={pathname}>
|
|
70
|
-
{
|
|
69
|
+
<ScreenContextProvider pathname={pathname}>
|
|
70
|
+
{children}
|
|
71
|
+
</ScreenContextProvider>
|
|
71
72
|
</PathnameContext.Provider>
|
|
72
73
|
</ScreenDataContext.Provider>
|
|
73
74
|
{isAnimating && <Animated.View style={overlayStyle} />}
|
|
@@ -22,7 +22,9 @@ exports[`<Scene /> renders correctly 1`] = `
|
|
|
22
22
|
}
|
|
23
23
|
>
|
|
24
24
|
<ContextProvider>
|
|
25
|
-
<ContextProvider
|
|
25
|
+
<ContextProvider>
|
|
26
|
+
<ScreenContextProvider />
|
|
27
|
+
</ContextProvider>
|
|
26
28
|
</ContextProvider>
|
|
27
29
|
</ForwardRef(AnimatedComponentWrapper)>
|
|
28
30
|
`;
|
|
@@ -39,14 +41,16 @@ exports[`<Scene /> renders the overlay while animating 1`] = `
|
|
|
39
41
|
"paddingBottom": 49,
|
|
40
42
|
},
|
|
41
43
|
Object {
|
|
42
|
-
"height":
|
|
43
|
-
"width":
|
|
44
|
+
"height": "100%",
|
|
45
|
+
"width": "100%",
|
|
44
46
|
},
|
|
45
47
|
]
|
|
46
48
|
}
|
|
47
49
|
>
|
|
48
50
|
<ContextProvider>
|
|
49
|
-
<ContextProvider
|
|
51
|
+
<ContextProvider>
|
|
52
|
+
<ScreenContextProvider />
|
|
53
|
+
</ContextProvider>
|
|
50
54
|
</ContextProvider>
|
|
51
55
|
<ForwardRef(AnimatedComponentWrapper)
|
|
52
56
|
style={
|
|
@@ -525,6 +525,16 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
|
|
|
525
525
|
LiveImageManager.instance.onLiveImageError(this, error);
|
|
526
526
|
};
|
|
527
527
|
|
|
528
|
+
onVideoError = (error: Error) => {
|
|
529
|
+
log_error(
|
|
530
|
+
`onVideoError: live-image, fail to play, switching back to image. error: ${
|
|
531
|
+
error?.message
|
|
532
|
+
}, ${playerInfo(this.player)}`
|
|
533
|
+
);
|
|
534
|
+
|
|
535
|
+
LiveImageManager.instance.onLiveImageError(this, error);
|
|
536
|
+
};
|
|
537
|
+
|
|
528
538
|
onVideoEnd = (_event) => {
|
|
529
539
|
log_info(
|
|
530
540
|
`onVideoEnd: live-image, video completed, switching back to image, ${playerInfo(
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
useModalAnimationContext,
|
|
6
6
|
PlayerAnimationStateEnum,
|
|
7
7
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
8
|
-
import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
9
8
|
|
|
10
9
|
type Props = {
|
|
11
10
|
style: ViewStyle[];
|
|
@@ -18,13 +17,8 @@ export const AnimatedPlayerModalWrapper = (props: Props) => {
|
|
|
18
17
|
animatedValues: { lastScrollY, dragScrollY, translateYOffset },
|
|
19
18
|
modalSnapPoints,
|
|
20
19
|
setStartComponentsAnimation,
|
|
21
|
-
lastScrollYValue,
|
|
22
20
|
} = useModalAnimationContext();
|
|
23
21
|
|
|
24
|
-
const { height: screenHeight } = useDimensions("screen", {
|
|
25
|
-
deviceInfo: true,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
22
|
const interpolateConfig: Animated.InterpolationConfigType = React.useMemo(
|
|
29
23
|
() => ({
|
|
30
24
|
inputRange: modalSnapPoints,
|
|
@@ -51,16 +45,10 @@ export const AnimatedPlayerModalWrapper = (props: Props) => {
|
|
|
51
45
|
}
|
|
52
46
|
|
|
53
47
|
React.useEffect(() => {
|
|
54
|
-
const translateYListener = translateY.addListener((
|
|
55
|
-
const preparedValue = Math.round(
|
|
56
|
-
Math.abs(value) - lastScrollYValue.current
|
|
57
|
-
);
|
|
58
|
-
|
|
48
|
+
const translateYListener = translateY.addListener(() => {
|
|
59
49
|
(playerAnimationState === PlayerAnimationStateEnum.minimize ||
|
|
60
50
|
playerAnimationState === PlayerAnimationStateEnum.maximaze) &&
|
|
61
|
-
setStartComponentsAnimation(
|
|
62
|
-
preparedValue >= Math.round((screenHeight * 10) / 100)
|
|
63
|
-
);
|
|
51
|
+
setStartComponentsAnimation(true);
|
|
64
52
|
});
|
|
65
53
|
|
|
66
54
|
return () => {
|
|
@@ -58,6 +58,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
58
58
|
modalSnapPoints,
|
|
59
59
|
lastSnap,
|
|
60
60
|
setLastSnap,
|
|
61
|
+
setStartComponentsAnimation,
|
|
61
62
|
} = useModalAnimationContext();
|
|
62
63
|
|
|
63
64
|
const { isLanguageOverlayVisible } = React.useContext(PlayerContainerContext);
|
|
@@ -204,7 +205,8 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
204
205
|
|
|
205
206
|
if (
|
|
206
207
|
(videoModalState.mode === "MAXIMIZED" &&
|
|
207
|
-
videoModalState.previousMode === "
|
|
208
|
+
videoModalState.previousMode === "MINIMIZED" &&
|
|
209
|
+
previousItemId === videoModalState.item?.id) ||
|
|
208
210
|
previousItemId !== videoModalState.item?.id
|
|
209
211
|
) {
|
|
210
212
|
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
@@ -281,10 +283,11 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
281
283
|
if (
|
|
282
284
|
preparedValue > 0 &&
|
|
283
285
|
scrollPosition.current === 0 &&
|
|
284
|
-
playerAnimationState !== PlayerAnimationStateEnum.drag_player
|
|
286
|
+
playerAnimationState !== PlayerAnimationStateEnum.drag_player &&
|
|
287
|
+
playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
|
|
285
288
|
) {
|
|
286
|
-
|
|
287
|
-
|
|
289
|
+
isMinimizedModal && setStartComponentsAnimation(true);
|
|
290
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.drag_scroll);
|
|
288
291
|
}
|
|
289
292
|
});
|
|
290
293
|
|
|
@@ -292,7 +295,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
292
295
|
lastScrollY.removeListener(lastScrollYListenerId);
|
|
293
296
|
dragScrollY.removeListener(dragListenerId);
|
|
294
297
|
};
|
|
295
|
-
}, [playerAnimationState, isAudioItem, modalSnapPoints]);
|
|
298
|
+
}, [playerAnimationState, isAudioItem, modalSnapPoints, isMinimizedModal]);
|
|
296
299
|
|
|
297
300
|
const Wrapper = React.useMemo(
|
|
298
301
|
() => (Platform.OS === "android" ? GestureHandlerRootView : View),
|
|
@@ -34,6 +34,7 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
|
|
|
34
34
|
lastSnap,
|
|
35
35
|
setLastSnap,
|
|
36
36
|
resetPlayerAnimationState,
|
|
37
|
+
setStartComponentsAnimation,
|
|
37
38
|
} = useModalAnimationContext();
|
|
38
39
|
|
|
39
40
|
const { videoModalState } = useNavigation();
|
|
@@ -121,8 +122,10 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
|
|
|
121
122
|
preparedValue > 0 &&
|
|
122
123
|
playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
|
|
123
124
|
) {
|
|
124
|
-
playerAnimationState !== PlayerAnimationStateEnum.drag_player
|
|
125
|
+
if (playerAnimationState !== PlayerAnimationStateEnum.drag_player) {
|
|
126
|
+
isMinimizedModal && setStartComponentsAnimation(true);
|
|
125
127
|
setPlayerAnimationState(PlayerAnimationStateEnum.drag_player);
|
|
128
|
+
}
|
|
126
129
|
|
|
127
130
|
translateYOffset.setValue(
|
|
128
131
|
isMaximazedModal
|
|
@@ -51,6 +51,7 @@ export const AnimationView = ({
|
|
|
51
51
|
setTabletLandscapePlayerTopPosition,
|
|
52
52
|
modalSnapPoints,
|
|
53
53
|
startComponentsAnimationDistance,
|
|
54
|
+
progressBarHeight,
|
|
54
55
|
} = useModalAnimationContext();
|
|
55
56
|
|
|
56
57
|
const isRTL = useIsRTL();
|
|
@@ -62,9 +63,9 @@ export const AnimationView = ({
|
|
|
62
63
|
} = useDimensions("window", { deviceInfo: true });
|
|
63
64
|
|
|
64
65
|
const { videoModalState } = useNavigation();
|
|
65
|
-
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
66
|
-
const minimisedWidth = defaultAspectRatioWidth(minimisedHeight);
|
|
67
66
|
const insets = useSafeAreaInsets();
|
|
67
|
+
const bottomTabBarHeight = useGetBottomTabBarHeight() + (insets.bottom || 0);
|
|
68
|
+
const minimisedWidth = defaultAspectRatioWidth(minimisedHeight);
|
|
68
69
|
const animationComponentRef = useRef(null);
|
|
69
70
|
|
|
70
71
|
// retrieving top position of the player for tablet landscape mode
|
|
@@ -92,12 +93,12 @@ export const AnimationView = ({
|
|
|
92
93
|
const inlineAudioPlayer = additionalData.inlineAudioPlayer;
|
|
93
94
|
|
|
94
95
|
const moveUpValue = additionalData.saveArea
|
|
95
|
-
? -insets.top
|
|
96
|
+
? -insets.top + (isAudioItem ? 0 : progressBarHeight)
|
|
96
97
|
: isTablet
|
|
97
98
|
? isTabletLandscape && (!isAudioItem || (isAudioItem && inlineAudioPlayer))
|
|
98
|
-
? -tabletLandscapePlayerTopPosition
|
|
99
|
+
? -tabletLandscapePlayerTopPosition + progressBarHeight
|
|
99
100
|
: -130
|
|
100
|
-
: -50;
|
|
101
|
+
: -50 + progressBarHeight;
|
|
101
102
|
|
|
102
103
|
const moveComponentHorizontalValue = additionalData.moveValue
|
|
103
104
|
? isRTL
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
2
|
import { Animated } from "react-native";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useSafeAreaInsets,
|
|
6
|
+
useSafeAreaFrame,
|
|
7
|
+
} from "react-native-safe-area-context";
|
|
5
8
|
import {
|
|
6
9
|
useGetBottomTabBarHeight,
|
|
7
|
-
|
|
10
|
+
useNavigation,
|
|
8
11
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
|
+
import { isLive } from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
9
13
|
|
|
14
|
+
import { PROGRESS_BAR_HEIGHT } from "./utils";
|
|
10
15
|
import { useConfiguration } from "../utils";
|
|
11
16
|
|
|
12
17
|
export enum PlayerAnimationStateEnum {
|
|
@@ -40,6 +45,7 @@ export type ModalAnimationContextT = {
|
|
|
40
45
|
tabletLandscapePlayerTopPosition: number;
|
|
41
46
|
setTabletLandscapePlayerTopPosition: (value: number) => void;
|
|
42
47
|
startComponentsAnimationDistance: number;
|
|
48
|
+
progressBarHeight: number;
|
|
43
49
|
};
|
|
44
50
|
|
|
45
51
|
const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
@@ -64,6 +70,7 @@ const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
|
64
70
|
tabletLandscapePlayerTopPosition: 0,
|
|
65
71
|
setTabletLandscapePlayerTopPosition: () => null,
|
|
66
72
|
startComponentsAnimationDistance: 0,
|
|
73
|
+
progressBarHeight: 0,
|
|
67
74
|
});
|
|
68
75
|
|
|
69
76
|
export function useModalAnimationContext() {
|
|
@@ -82,6 +89,11 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
|
82
89
|
const [startComponentsAnimation, setStartComponentsAnimation] =
|
|
83
90
|
React.useState<boolean>(false);
|
|
84
91
|
|
|
92
|
+
const {
|
|
93
|
+
videoModalState: { mode, visible, item },
|
|
94
|
+
} = useNavigation();
|
|
95
|
+
|
|
96
|
+
const isLiveItem = isLive(item);
|
|
85
97
|
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
86
98
|
|
|
87
99
|
const resetPlayerAnimationState = React.useCallback(() => {
|
|
@@ -95,21 +107,28 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
|
95
107
|
const translateYOffset = React.useRef(new Animated.Value(0)).current;
|
|
96
108
|
const dragVideoPlayerY = React.useRef(new Animated.Value(0)).current;
|
|
97
109
|
|
|
98
|
-
const { height } =
|
|
110
|
+
const { height: safeAreaFrameHeight } = useSafeAreaFrame();
|
|
111
|
+
const [height, setHeight] = React.useState<number>(safeAreaFrameHeight);
|
|
112
|
+
const progressBarHeight = isLiveItem ? 0 : PROGRESS_BAR_HEIGHT;
|
|
99
113
|
const { bottom: bottomSafeArea } = useSafeAreaInsets();
|
|
100
114
|
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
115
|
+
const startComponentsAnimationDistance = Math.round((height * 60) / 100);
|
|
101
116
|
|
|
102
|
-
|
|
103
|
-
(
|
|
104
|
-
|
|
105
|
-
|
|
117
|
+
React.useEffect(() => {
|
|
118
|
+
if (visible && mode === "MAXIMIZED" && height !== safeAreaFrameHeight) {
|
|
119
|
+
setHeight(safeAreaFrameHeight);
|
|
120
|
+
}
|
|
121
|
+
}, [height, safeAreaFrameHeight, mode, visible]);
|
|
106
122
|
|
|
107
123
|
/*
|
|
108
124
|
If bottomTabBarHeight is equal 0 it means an app does not use bottomTabBar.
|
|
109
125
|
Because of this we need to minus bottom SafeArea offset.
|
|
110
126
|
*/
|
|
111
127
|
const minValue =
|
|
112
|
-
height -
|
|
128
|
+
height -
|
|
129
|
+
minimisedHeight -
|
|
130
|
+
(bottomTabBarHeight || bottomSafeArea) -
|
|
131
|
+
progressBarHeight;
|
|
113
132
|
|
|
114
133
|
const modalSnapPoints = React.useMemo(() => [0, minValue], [minValue]);
|
|
115
134
|
// Last snap state which will helps us to make smooth responder to scrollview animation
|
|
@@ -142,6 +161,7 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
|
142
161
|
tabletLandscapePlayerTopPosition,
|
|
143
162
|
setTabletLandscapePlayerTopPosition,
|
|
144
163
|
startComponentsAnimationDistance,
|
|
164
|
+
progressBarHeight,
|
|
145
165
|
}}
|
|
146
166
|
>
|
|
147
167
|
{children}
|
|
@@ -225,7 +225,7 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
225
225
|
</AnimationComponent>
|
|
226
226
|
</View>
|
|
227
227
|
<AnimatedScrollModal>
|
|
228
|
-
{isInlineModal ? (
|
|
228
|
+
{isInlineModal && !docked ? (
|
|
229
229
|
<AnimationComponent
|
|
230
230
|
animationType={ComponentAnimationType.componentFade}
|
|
231
231
|
style={defaultStyles.flex}
|