@applicaster/zapp-react-native-ui-components 15.0.0-alpha.2239032089 → 15.0.0-alpha.2413435535
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/AnimatedInOut/index.tsx +69 -26
- package/Components/Cell/Cell.tsx +8 -3
- package/Components/Cell/FocusableWrapper.tsx +44 -0
- package/Components/Cell/TvOSCellComponent.tsx +92 -17
- package/Components/Focusable/Focusable.tsx +2 -4
- package/Components/Focusable/FocusableTvOS.tsx +1 -5
- package/Components/FocusableGroup/FocusableTvOS.tsx +0 -5
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +9 -11
- package/Components/HandlePlayable/HandlePlayable.tsx +14 -65
- package/Components/HandlePlayable/const.ts +3 -0
- package/Components/HandlePlayable/utils.ts +74 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +12 -6
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +8 -8
- package/Components/MasterCell/index.tsx +2 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +1 -16
- package/Components/PlayerImageBackground/index.tsx +3 -22
- package/Components/River/TV/River.tsx +3 -9
- package/Components/River/TV/index.tsx +3 -3
- package/Components/River/TV/withTVEventHandler.tsx +27 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
- package/Components/Screen/index.tsx +22 -5
- package/Components/ScreenResolver/index.tsx +8 -2
- package/Components/ScreenRevealManager/utils/index.ts +23 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +54 -24
- package/Components/Tabs/TV/Tabs.tsx +20 -3
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +114 -171
- package/Components/VideoModal/ModalAnimation/index.ts +2 -13
- package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
- package/Components/VideoModal/PlayerWrapper.tsx +14 -88
- package/Components/VideoModal/VideoModal.tsx +1 -5
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/hooks/useModalSize.ts +10 -5
- package/Components/VideoModal/playerWrapperStyle.ts +70 -0
- package/Components/VideoModal/playerWrapperUtils.ts +91 -0
- package/Components/VideoModal/utils.ts +7 -0
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -6
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
- package/events/index.ts +0 -2
- package/index.d.ts +7 -0
- package/package.json +5 -5
- package/Components/River/TV/withFocusableGroupForContent.tsx +0 -60
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -417
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
- package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
|
@@ -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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 =
|
|
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 [
|
|
34
|
+
const [isContentReadyToBeShown, setIsContentReadyToBeShown] =
|
|
35
|
+
React.useState(false);
|
|
33
36
|
|
|
34
|
-
const
|
|
35
|
-
|
|
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
|
-
() =>
|
|
46
|
+
() =>
|
|
47
|
+
new ScreenRevealManager(
|
|
48
|
+
componentsToRender,
|
|
49
|
+
handleSetIsContentReadyToBeShown
|
|
50
|
+
)
|
|
40
51
|
);
|
|
41
52
|
|
|
42
53
|
const opacityRef = useRefWithInitialValue<Animated.Value>(
|
|
43
|
-
() => new Animated.Value(
|
|
54
|
+
() => new Animated.Value(SHOWN)
|
|
44
55
|
);
|
|
45
56
|
|
|
46
57
|
React.useEffect(() => {
|
|
47
|
-
if (
|
|
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:
|
|
68
|
+
toValue: HIDDEN,
|
|
50
69
|
duration: TIMEOUT,
|
|
51
70
|
useNativeDriver: true,
|
|
52
|
-
}).start()
|
|
71
|
+
}).start(() => {
|
|
72
|
+
setIsShowOverlay(false);
|
|
73
|
+
});
|
|
53
74
|
}
|
|
54
|
-
}, [
|
|
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
|
-
|
|
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
|
-
|
|
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
|
};
|
|
@@ -8,6 +8,7 @@ import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
|
8
8
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
9
9
|
import { FocusableGroup } from "@applicaster/zapp-react-native-ui-components/Components/FocusableGroup";
|
|
10
10
|
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable";
|
|
11
|
+
import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
|
|
11
12
|
import { Gutter } from "../Gutter";
|
|
12
13
|
import Tab from "./Tab";
|
|
13
14
|
import { getStyles } from "./styles";
|
|
@@ -28,11 +29,14 @@ const TabsComponent = ({
|
|
|
28
29
|
style,
|
|
29
30
|
selectedEntryIndex,
|
|
30
31
|
setSelectedEntry,
|
|
32
|
+
accessibility,
|
|
31
33
|
}: TabsProps & Partial<TabsSelectionContextType>) => {
|
|
32
34
|
const configuration = useConfiguration();
|
|
33
35
|
const config = applyFontConfig(configuration);
|
|
34
36
|
const styles = useMemo(() => getStyles(config), [config]);
|
|
35
37
|
|
|
38
|
+
const accessibilityManager = useAccessibilityManager({});
|
|
39
|
+
|
|
36
40
|
const {
|
|
37
41
|
tab_bar_gutter: horizontalGutter,
|
|
38
42
|
tab_bar_background_image: bgImage,
|
|
@@ -60,10 +64,20 @@ const TabsComponent = ({
|
|
|
60
64
|
);
|
|
61
65
|
|
|
62
66
|
const onListElementFocus = useCallback(
|
|
63
|
-
(index) => {
|
|
67
|
+
(index, isSelected: boolean, item: ZappEntry) => {
|
|
68
|
+
if (isSelected) {
|
|
69
|
+
accessibilityManager.readText({
|
|
70
|
+
text: `${accessibility?.selectedHint} ${item.title}`,
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
accessibilityManager.readText({
|
|
74
|
+
text: `${accessibility?.hint} ${item.title}`,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
64
78
|
scrollToSelectedIndex(index, VIEW_POSITION);
|
|
65
79
|
},
|
|
66
|
-
[scrollToSelectedIndex]
|
|
80
|
+
[scrollToSelectedIndex, accessibility]
|
|
67
81
|
);
|
|
68
82
|
|
|
69
83
|
const renderItem = useCallback(
|
|
@@ -94,7 +108,7 @@ const TabsComponent = ({
|
|
|
94
108
|
id={itemId}
|
|
95
109
|
testID={itemId}
|
|
96
110
|
preferredFocus={isSelected}
|
|
97
|
-
onFocus={() => onListElementFocus(index)}
|
|
111
|
+
onFocus={() => onListElementFocus(index, isSelected, item)}
|
|
98
112
|
onPress={() => setSelectedEntry && setSelectedEntry(item)}
|
|
99
113
|
style={style}
|
|
100
114
|
>
|
|
@@ -149,6 +163,9 @@ const TabsComponent = ({
|
|
|
149
163
|
shouldUsePreferredFocus
|
|
150
164
|
isWithMemory={false}
|
|
151
165
|
nextFocusDown={parentFocus?.nextFocusDown}
|
|
166
|
+
onFocus={() => {
|
|
167
|
+
accessibilityManager.addHeading(accessibility?.announcement);
|
|
168
|
+
}}
|
|
152
169
|
>
|
|
153
170
|
<View style={tabs}>
|
|
154
171
|
<ImageBackground
|
|
@@ -1,212 +1,155 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
2
|
import { Animated, Dimensions } from "react-native";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
useSafeAreaInsets,
|
|
6
|
-
useSafeAreaFrame,
|
|
7
|
-
} from "react-native-safe-area-context";
|
|
8
|
-
import { useGetBottomTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useGetBottomTabBarHeight";
|
|
9
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
10
|
-
import { isLive } from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
11
5
|
|
|
12
|
-
import { PROGRESS_BAR_HEIGHT } from "./utils";
|
|
13
6
|
import { useConfiguration } from "../utils";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
export enum PlayerAnimationStateEnum {
|
|
17
|
-
minimize = "minimize",
|
|
18
|
-
maximize = "maximize",
|
|
19
|
-
drag_player = "drag_player",
|
|
20
|
-
drag_scroll = "drag_scroll",
|
|
21
|
-
appear_as_docked = "appear_as_docked",
|
|
22
|
-
}
|
|
7
|
+
import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
|
|
8
|
+
import { isMenuVisible } from "../../Screen/navigationHandler";
|
|
23
9
|
|
|
24
|
-
|
|
10
|
+
import {
|
|
11
|
+
useSafeAreaFrame,
|
|
12
|
+
useSafeAreaInsets,
|
|
13
|
+
} from "react-native-safe-area-context";
|
|
14
|
+
import {
|
|
15
|
+
isAndroidPlatform,
|
|
16
|
+
isAndroidVersionAtLeast,
|
|
17
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
18
|
+
import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
|
|
19
|
+
import { PROGRESS_BAR_HEIGHT } from "./utils";
|
|
20
|
+
import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
21
|
+
import { useAppSelector } from "@applicaster/zapp-react-native-redux";
|
|
25
22
|
|
|
26
23
|
export type ModalAnimationContextT = {
|
|
27
|
-
yTranslate: React.MutableRefObject<Animated.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
setStartComponentsAnimation: (value: boolean) => void;
|
|
33
|
-
resetPlayerAnimationState: () => void;
|
|
24
|
+
yTranslate: React.MutableRefObject<Animated.AnimatedInterpolation<number>>;
|
|
25
|
+
offsetAnimatedValueRef: React.MutableRefObject<Animated.Value>;
|
|
26
|
+
offset: React.MutableRefObject<number>;
|
|
27
|
+
heightAboveMinimised: number;
|
|
28
|
+
gestureTranslationRef: React.MutableRefObject<Animated.Value>;
|
|
34
29
|
minimisedHeight: number;
|
|
35
|
-
animatedValues: {
|
|
36
|
-
lastScrollY: Animated.Value;
|
|
37
|
-
dragScrollY: Animated.Value;
|
|
38
|
-
dragVideoPlayerY: Animated.Value;
|
|
39
|
-
translateYOffset: Animated.Value;
|
|
40
|
-
};
|
|
41
|
-
lastScrollYValue: React.MutableRefObject<number>;
|
|
42
|
-
scrollPosition: React.MutableRefObject<number>;
|
|
43
|
-
modalSnapPoints: number[];
|
|
44
|
-
lastSnap: number;
|
|
45
|
-
setLastSnap: (value: number) => void;
|
|
46
|
-
tabletLandscapePlayerTopPosition: number;
|
|
47
|
-
setTabletLandscapePlayerTopPosition: (value: number) => void;
|
|
48
|
-
startComponentsAnimationDistance: number;
|
|
49
|
-
progressBarHeight: number;
|
|
50
30
|
};
|
|
51
31
|
|
|
52
32
|
export const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
53
33
|
yTranslate: React.createRef<Animated.Value | null>(),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
setStartComponentsAnimation: () => null,
|
|
59
|
-
resetPlayerAnimationState: () => null,
|
|
34
|
+
offsetAnimatedValueRef: React.createRef<Animated.Value>(),
|
|
35
|
+
offset: React.createRef<number>(),
|
|
36
|
+
heightAboveMinimised: 0,
|
|
37
|
+
gestureTranslationRef: React.createRef<Animated.Value>(),
|
|
60
38
|
minimisedHeight: 60,
|
|
61
|
-
animatedValues: {
|
|
62
|
-
lastScrollY: new Animated.Value(0),
|
|
63
|
-
dragScrollY: new Animated.Value(0),
|
|
64
|
-
dragVideoPlayerY: new Animated.Value(0),
|
|
65
|
-
translateYOffset: new Animated.Value(0),
|
|
66
|
-
},
|
|
67
|
-
lastScrollYValue: null,
|
|
68
|
-
scrollPosition: null,
|
|
69
|
-
modalSnapPoints: [0, 0],
|
|
70
|
-
lastSnap: 0,
|
|
71
|
-
setLastSnap: () => null,
|
|
72
|
-
tabletLandscapePlayerTopPosition: 0,
|
|
73
|
-
setTabletLandscapePlayerTopPosition: () => null,
|
|
74
|
-
startComponentsAnimationDistance: 0,
|
|
75
|
-
progressBarHeight: 0,
|
|
76
39
|
});
|
|
77
40
|
|
|
41
|
+
const SAFE_AREA_BREAKING_API_VERSION = 35;
|
|
42
|
+
|
|
43
|
+
export const isOldAndroidDevice =
|
|
44
|
+
isAndroidPlatform() &&
|
|
45
|
+
!isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION);
|
|
46
|
+
|
|
47
|
+
const bottomTabBarHeight = getTabBarHeight();
|
|
48
|
+
|
|
78
49
|
const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
50
|
+
const { height } = Dimensions.get("window");
|
|
51
|
+
|
|
79
52
|
const yTranslate = React.useRef(
|
|
80
|
-
new Animated.Value(
|
|
53
|
+
new Animated.Value(height).interpolate<number>({
|
|
54
|
+
inputRange: [0, height],
|
|
55
|
+
outputRange: [0, height],
|
|
56
|
+
})
|
|
81
57
|
);
|
|
82
58
|
|
|
83
|
-
const
|
|
84
|
-
React.useState<PlayerAnimationStateT>(null);
|
|
85
|
-
|
|
86
|
-
const [
|
|
87
|
-
tabletLandscapePlayerTopPosition,
|
|
88
|
-
setTabletLandscapePlayerTopPosition,
|
|
89
|
-
] = React.useState<number>(0);
|
|
90
|
-
|
|
91
|
-
const [startComponentsAnimation, setStartComponentsAnimation] =
|
|
92
|
-
React.useState<boolean>(false);
|
|
59
|
+
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
93
60
|
|
|
94
61
|
const {
|
|
95
|
-
videoModalState: {
|
|
62
|
+
videoModalState: { visible, mode },
|
|
63
|
+
currentRoute,
|
|
64
|
+
screenData,
|
|
96
65
|
} = useNavigation();
|
|
97
66
|
|
|
98
|
-
const
|
|
99
|
-
|
|
67
|
+
const isTabletPortrait = useAppSelector(
|
|
68
|
+
(state) => state.appData.isTabletPortrait
|
|
69
|
+
);
|
|
100
70
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// Reset player animation state when video modal is closed
|
|
123
|
-
if (!visible) {
|
|
124
|
-
resetPlayerAnimationState();
|
|
125
|
-
|
|
126
|
-
if (!isTabletLandscape) {
|
|
127
|
-
// restore to portrait ( in portrait mode height is bigger)
|
|
128
|
-
if (windowDimensions.height > windowDimensions.width) {
|
|
129
|
-
yTranslate.current?.setValue(windowDimensions.height);
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
yTranslate.current?.setValue(windowDimensions.height);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}, [
|
|
136
|
-
visible,
|
|
137
|
-
resetPlayerAnimationState,
|
|
138
|
-
windowDimensions.height,
|
|
139
|
-
isTabletLandscape,
|
|
140
|
-
]);
|
|
71
|
+
const plugins = usePlugins();
|
|
72
|
+
|
|
73
|
+
const menuVisible = isMenuVisible(currentRoute, screenData, plugins);
|
|
74
|
+
|
|
75
|
+
const frame = useSafeAreaFrame();
|
|
76
|
+
const insets = useSafeAreaInsets();
|
|
77
|
+
|
|
78
|
+
const [heightAboveMinimised, setHeightAboveMinimised] = React.useState(0);
|
|
79
|
+
|
|
80
|
+
// memoizing heightAboveMinimised value
|
|
81
|
+
const offset = React.useRef(heightAboveMinimised);
|
|
82
|
+
|
|
83
|
+
// Used for memoizing modal y position after start/end of transition
|
|
84
|
+
const offsetAnimatedValueRef = React.useRef(
|
|
85
|
+
new Animated.Value(-offset.current)
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Used for gesture handling
|
|
89
|
+
const gestureTranslationRef = React.useRef(new Animated.Value(0));
|
|
90
|
+
|
|
91
|
+
const videoModalStateRef = React.useRef({ visible, mode });
|
|
141
92
|
|
|
142
93
|
React.useEffect(() => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
}, [height, safeAreaFrameHeight, mode, visible]);
|
|
94
|
+
videoModalStateRef.current = { visible, mode };
|
|
95
|
+
}, [visible, mode]);
|
|
147
96
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
Because of this we need to minus bottom SafeArea offset.
|
|
151
|
-
*/
|
|
97
|
+
const translateY = useMemo(() => {
|
|
98
|
+
const maxRange = heightAboveMinimised;
|
|
152
99
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
100
|
+
const combined: Animated.AnimatedAddition<number> = Animated.add(
|
|
101
|
+
offsetAnimatedValueRef.current,
|
|
102
|
+
gestureTranslationRef.current
|
|
103
|
+
);
|
|
156
104
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
105
|
+
return combined.interpolate({
|
|
106
|
+
inputRange: [0, maxRange],
|
|
107
|
+
outputRange: [0, maxRange],
|
|
108
|
+
extrapolate: "clamp",
|
|
109
|
+
});
|
|
110
|
+
}, [visible, heightAboveMinimised]);
|
|
111
|
+
|
|
112
|
+
offset.current = heightAboveMinimised;
|
|
113
|
+
yTranslate.current = translateY;
|
|
114
|
+
|
|
115
|
+
React.useEffect(() => {
|
|
116
|
+
const collapsedHeight =
|
|
117
|
+
minimisedHeight +
|
|
118
|
+
(menuVisible ? bottomTabBarHeight : 0) +
|
|
119
|
+
(isOldAndroidDevice ? 0 : insets.bottom) + // insets.bottom is added to properly display docked modal
|
|
120
|
+
PROGRESS_BAR_HEIGHT;
|
|
121
|
+
|
|
122
|
+
const heightAboveMinimised = frame.height - collapsedHeight;
|
|
123
|
+
|
|
124
|
+
const isLandscape = frame.width > frame.height;
|
|
125
|
+
|
|
126
|
+
const isTablet = getIsTablet();
|
|
127
|
+
|
|
128
|
+
const shouldIgnoreLandscape = isTablet ? isTabletPortrait : true;
|
|
129
|
+
|
|
130
|
+
if (
|
|
131
|
+
heightAboveMinimised !== offset.current &&
|
|
132
|
+
videoModalStateRef.current.mode !== "PIP" &&
|
|
133
|
+
videoModalStateRef.current.mode !== "FULLSCREEN"
|
|
134
|
+
) {
|
|
135
|
+
if (isLandscape && shouldIgnoreLandscape) return;
|
|
136
|
+
setHeightAboveMinimised(heightAboveMinimised);
|
|
137
|
+
offset.current = heightAboveMinimised;
|
|
138
|
+
}
|
|
139
|
+
}, [frame.height, insets.bottom, menuVisible, minimisedHeight]);
|
|
163
140
|
|
|
164
141
|
return (
|
|
165
142
|
<ReactContext.Provider
|
|
166
143
|
value={useMemo(
|
|
167
144
|
() => ({
|
|
168
145
|
yTranslate,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
playerAnimationState,
|
|
173
|
-
setPlayerAnimationState,
|
|
174
|
-
resetPlayerAnimationState,
|
|
146
|
+
offsetAnimatedValueRef,
|
|
147
|
+
offset,
|
|
148
|
+
heightAboveMinimised,
|
|
175
149
|
minimisedHeight,
|
|
176
|
-
|
|
177
|
-
lastScrollY,
|
|
178
|
-
dragScrollY,
|
|
179
|
-
dragVideoPlayerY,
|
|
180
|
-
translateYOffset,
|
|
181
|
-
},
|
|
182
|
-
lastScrollYValue,
|
|
183
|
-
scrollPosition,
|
|
184
|
-
modalSnapPoints,
|
|
185
|
-
lastSnap,
|
|
186
|
-
setLastSnap,
|
|
187
|
-
tabletLandscapePlayerTopPosition,
|
|
188
|
-
setTabletLandscapePlayerTopPosition,
|
|
189
|
-
startComponentsAnimationDistance,
|
|
190
|
-
progressBarHeight,
|
|
150
|
+
gestureTranslationRef,
|
|
191
151
|
}),
|
|
192
|
-
|
|
193
|
-
[
|
|
194
|
-
startComponentsAnimation,
|
|
195
|
-
playerAnimationState,
|
|
196
|
-
minimisedHeight,
|
|
197
|
-
lastScrollY,
|
|
198
|
-
dragScrollY,
|
|
199
|
-
dragVideoPlayerY,
|
|
200
|
-
translateYOffset,
|
|
201
|
-
lastSnap,
|
|
202
|
-
modalSnapPoints,
|
|
203
|
-
lastScrollYValue,
|
|
204
|
-
scrollPosition,
|
|
205
|
-
tabletLandscapePlayerTopPosition,
|
|
206
|
-
startComponentsAnimationDistance,
|
|
207
|
-
progressBarHeight,
|
|
208
|
-
isLiveItem,
|
|
209
|
-
]
|
|
152
|
+
[minimisedHeight, heightAboveMinimised]
|
|
210
153
|
)}
|
|
211
154
|
>
|
|
212
155
|
{children}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
export { AnimatedScrollModal } from "./AnimatedScrollModal";
|
|
4
|
-
|
|
5
|
-
export { AnimatedVideoPlayerComponent } from "./AnimatedVideoPlayerComponent";
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
withModalAnimationProvider,
|
|
9
|
-
PlayerAnimationStateEnum,
|
|
10
|
-
} from "./ModalAnimationContext";
|
|
1
|
+
export { withModalAnimationProvider } from "./ModalAnimationContext";
|
|
11
2
|
|
|
12
3
|
export { useModalAnimationContext } from "./useModalAnimationContext";
|
|
13
4
|
|
|
14
|
-
export {
|
|
15
|
-
|
|
16
|
-
export { ComponentAnimationType, defaultAspectRatioWidth } from "./utils";
|
|
5
|
+
export { defaultAspectRatioWidth } from "./utils";
|
|
17
6
|
|
|
18
7
|
export { DURATION_TO_MINIMIZE, DURATION_TO_MAXIMIZE } from "./const";
|