@applicaster/zapp-react-native-ui-components 12.0.0-alpha.4337072244 → 12.0.0-alpha.4355141911
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/Layout/TV/index.tsx +3 -40
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/Navigator/StackNavigator.tsx +48 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/River/ComponentsMap/ComponentsMap.tsx +6 -0
- package/Components/River/RefreshControl.tsx +2 -2
- package/Components/RouteManager/index.tsx +2 -2
- package/Components/Screen/TV/index.web.tsx +5 -3
- package/Components/Transitioner/Scene.tsx +24 -19
- package/Components/Transitioner/Transitioner.tsx +9 -2
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
- package/Components/VideoLive/LiveImageManager.ts +3 -0
- package/Components/VideoModal/PlayerWrapper.tsx +69 -62
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Contexts/ScreenDataContext/index.ts +3 -0
- package/package.json +5 -5
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { pathOr } from "ramda";
|
|
3
|
+
|
|
3
4
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
4
|
-
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
5
|
-
import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
6
5
|
|
|
7
6
|
import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
8
|
-
import {
|
|
9
|
-
import { FocusableGroup } from "../../FocusableGroup";
|
|
10
|
-
import { Screen } from "../../Screen/TV/index.web";
|
|
11
|
-
|
|
12
|
-
export const ScreenDataContext = React.createContext(null);
|
|
7
|
+
import { StackNavigator } from "../../Navigator";
|
|
13
8
|
|
|
14
9
|
type Components = {
|
|
15
10
|
NavBar: React.ComponentType<any>;
|
|
@@ -20,38 +15,6 @@ type Props = {
|
|
|
20
15
|
Components: Components;
|
|
21
16
|
};
|
|
22
17
|
|
|
23
|
-
const StackNavigator = ({ Components }: Props) => {
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
const { mainStack, currentRoute } = useNavigation();
|
|
26
|
-
|
|
27
|
-
const renderScreen = ({ route, state }) => {
|
|
28
|
-
const pathAttributes = getPathAttributes({ pathname: route });
|
|
29
|
-
|
|
30
|
-
if (isEmpty(pathAttributes)) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const id = `${route}`;
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<FocusableGroup
|
|
38
|
-
id={id}
|
|
39
|
-
preferredFocus={route === currentRoute}
|
|
40
|
-
excludeFromFocusSearching
|
|
41
|
-
key={id}
|
|
42
|
-
>
|
|
43
|
-
<ScreenDataContext.Provider value={state}>
|
|
44
|
-
<PathnameContext.Provider value={route}>
|
|
45
|
-
<Screen route={route} Components={Components} />
|
|
46
|
-
</PathnameContext.Provider>
|
|
47
|
-
</ScreenDataContext.Provider>
|
|
48
|
-
</FocusableGroup>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return mainStack.map(renderScreen);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
18
|
const Layout = ({ Components }: Props) => {
|
|
56
19
|
const { appState } = usePickFromState(["appState"]);
|
|
57
20
|
const appReady = pathOr(false, ["appReady"], appState);
|
|
@@ -4,6 +4,7 @@ import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerM
|
|
|
4
4
|
|
|
5
5
|
type DynamicBadgeProps = {
|
|
6
6
|
cellUUID?: string;
|
|
7
|
+
uri?: string;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
const DynamicBadgeComponent = (props: DynamicBadgeProps) => {
|
|
@@ -12,11 +13,12 @@ const DynamicBadgeComponent = (props: DynamicBadgeProps) => {
|
|
|
12
13
|
// TODO: Initial value should depends on player state (playing or not)
|
|
13
14
|
const [showImage, setShowImage] = React.useState(true);
|
|
14
15
|
const player = usePlayer(playerId);
|
|
16
|
+
const uri = props?.uri;
|
|
15
17
|
|
|
16
18
|
React.useEffect(() => {
|
|
17
19
|
if (playerId && player) {
|
|
18
20
|
return player.addListener({
|
|
19
|
-
id:
|
|
21
|
+
id: `dynamic-badges-${uri}`,
|
|
20
22
|
listener: {
|
|
21
23
|
onPlayerClose: () => {
|
|
22
24
|
setShowImage(true);
|
|
@@ -35,7 +37,7 @@ const DynamicBadgeComponent = (props: DynamicBadgeProps) => {
|
|
|
35
37
|
} else {
|
|
36
38
|
setShowImage(true);
|
|
37
39
|
}
|
|
38
|
-
}, [player]);
|
|
40
|
+
}, [player, uri]);
|
|
39
41
|
|
|
40
42
|
if (!showImage) {
|
|
41
43
|
return null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { isEmpty } from "ramda";
|
|
3
|
+
|
|
4
|
+
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
5
|
+
import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
6
|
+
import { FocusableGroup } from "@applicaster/zapp-react-native-ui-components/Components/FocusableGroup";
|
|
7
|
+
import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
|
|
8
|
+
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
9
|
+
|
|
10
|
+
import { Screen } from "../Screen/TV/index.web";
|
|
11
|
+
|
|
12
|
+
type Components = {
|
|
13
|
+
NavBar: React.ComponentType<any>;
|
|
14
|
+
Background: React.ComponentType<any>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type Props = {
|
|
18
|
+
Components: Components;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const StackNavigator = ({ Components }: Props) => {
|
|
22
|
+
const { mainStack, currentRoute } = useNavigation();
|
|
23
|
+
|
|
24
|
+
const renderScreen = ({ route, state }) => {
|
|
25
|
+
const pathAttributes = getPathAttributes({ pathname: route });
|
|
26
|
+
|
|
27
|
+
if (isEmpty(pathAttributes)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<FocusableGroup
|
|
33
|
+
id={route}
|
|
34
|
+
preferredFocus={route === currentRoute}
|
|
35
|
+
excludeFromFocusSearching
|
|
36
|
+
key={route}
|
|
37
|
+
>
|
|
38
|
+
<ScreenDataContext.Provider value={state}>
|
|
39
|
+
<PathnameContext.Provider value={route}>
|
|
40
|
+
<Screen route={route} Components={Components} />
|
|
41
|
+
</PathnameContext.Provider>
|
|
42
|
+
</ScreenDataContext.Provider>
|
|
43
|
+
</FocusableGroup>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return <>{mainStack.map(renderScreen)}</>;
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StackNavigator } from "./StackNavigator";
|
|
@@ -271,6 +271,12 @@ function ComponentsMapComponent(props: Props) {
|
|
|
271
271
|
|
|
272
272
|
if (y >= 0 && y + height <= contentHeight) {
|
|
273
273
|
scrollY.setValue(y);
|
|
274
|
+
} else {
|
|
275
|
+
if (y <= 0) {
|
|
276
|
+
scrollY.setValue(0);
|
|
277
|
+
} else if (y + height > contentHeight) {
|
|
278
|
+
scrollY.setValue(contentHeight - height);
|
|
279
|
+
}
|
|
274
280
|
}
|
|
275
281
|
}, []);
|
|
276
282
|
|
|
@@ -134,10 +134,10 @@ export const useGetProgressViewOffset = () => {
|
|
|
134
134
|
switch (contentPosition) {
|
|
135
135
|
case "on_bottom_status_bar":
|
|
136
136
|
// navbar height
|
|
137
|
-
return offset + height
|
|
137
|
+
return offset + height;
|
|
138
138
|
case "on_top_screen":
|
|
139
139
|
// navbar height + status bar height
|
|
140
|
-
return offset + height;
|
|
140
|
+
return offset + height + top;
|
|
141
141
|
default:
|
|
142
142
|
return offset;
|
|
143
143
|
}
|
|
@@ -14,7 +14,7 @@ type Props = { pathname: string; screenData: Record<string, any> };
|
|
|
14
14
|
* @param {Props}: see props above
|
|
15
15
|
*/
|
|
16
16
|
export function RouteManager(props: Props) {
|
|
17
|
-
const { pathname, screenData
|
|
17
|
+
const { pathname, screenData } = useRoute();
|
|
18
18
|
const pathAttributes = getPathAttributes({ pathname });
|
|
19
19
|
|
|
20
20
|
const { screenType, screenId } = R.last(pathAttributes);
|
|
@@ -25,7 +25,7 @@ export function RouteManager(props: Props) {
|
|
|
25
25
|
screenType={screenType}
|
|
26
26
|
screenId={screenId}
|
|
27
27
|
{...props}
|
|
28
|
-
screenData={
|
|
28
|
+
screenData={screenData}
|
|
29
29
|
/>
|
|
30
30
|
</TestId>
|
|
31
31
|
);
|
|
@@ -36,7 +36,7 @@ type Props = {
|
|
|
36
36
|
Components: Components;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const
|
|
39
|
+
const isPlayerPlugin = (routeState): boolean => {
|
|
40
40
|
const pluginType = pathOr(
|
|
41
41
|
"unknown_plugin_type",
|
|
42
42
|
["state", "screen", "plugin_type"],
|
|
@@ -146,10 +146,12 @@ export const Screen = ({ route, Components }: Props) => {
|
|
|
146
146
|
const NavBar = (Components.NavBar ||
|
|
147
147
|
menuPlugin.module) as React.ComponentType<any>;
|
|
148
148
|
|
|
149
|
-
const
|
|
149
|
+
const isPlayer = isPlayerPlugin(routeState);
|
|
150
|
+
|
|
151
|
+
const isNavBarVisible = !isPlayer;
|
|
150
152
|
|
|
151
153
|
const screenData =
|
|
152
|
-
screenType === "hooks"
|
|
154
|
+
screenType === "hooks" || isPlayer
|
|
153
155
|
? routeState?.state?.entry
|
|
154
156
|
: routeState?.state?.screen;
|
|
155
157
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "react-native";
|
|
8
8
|
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
9
9
|
import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
10
|
+
import { ScreenDataContext } from "../../Contexts/ScreenDataContext";
|
|
10
11
|
|
|
11
12
|
type Props = {
|
|
12
13
|
children: any;
|
|
@@ -16,6 +17,8 @@ type Props = {
|
|
|
16
17
|
animating: boolean;
|
|
17
18
|
contentStyle: ViewStyle;
|
|
18
19
|
pathname: string;
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
screenData: NavigationScreenData;
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
/**
|
|
@@ -38,34 +41,36 @@ export function Scene({
|
|
|
38
41
|
animating,
|
|
39
42
|
contentStyle,
|
|
40
43
|
pathname,
|
|
44
|
+
isActive = false,
|
|
45
|
+
screenData,
|
|
41
46
|
}: Props) {
|
|
47
|
+
const [initialScreenData, setInitialScreenData] = React.useState(screenData);
|
|
48
|
+
|
|
49
|
+
React.useLayoutEffect(() => {
|
|
50
|
+
if (isActive) {
|
|
51
|
+
setInitialScreenData(screenData);
|
|
52
|
+
}
|
|
53
|
+
}, [screenData, isActive]);
|
|
54
|
+
|
|
42
55
|
const frame = useSafeAreaFrame();
|
|
43
56
|
const { height, width } = useWindowDimensions();
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<Animated.View
|
|
50
|
-
pointerEvents={pointerEvents}
|
|
51
|
-
style={[style, contentStyle, { height, width }]}
|
|
52
|
-
>
|
|
53
|
-
<PathnameContext.Provider value={pathname}>
|
|
54
|
-
{children}
|
|
55
|
-
</PathnameContext.Provider>
|
|
56
|
-
<Animated.View style={overlayStyle} />
|
|
57
|
-
</Animated.View>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
58
|
+
// Safe frame takes too long to update,
|
|
59
|
+
// so we can not rely on it there, and use height and width instead.
|
|
60
|
+
const isAnimating = animating && overlayStyle;
|
|
61
|
+
const dimensions = isAnimating ? { height, width } : frame;
|
|
60
62
|
|
|
61
63
|
return (
|
|
62
64
|
<Animated.View
|
|
63
65
|
pointerEvents={pointerEvents}
|
|
64
|
-
style={[style, contentStyle,
|
|
66
|
+
style={[style, contentStyle, dimensions]}
|
|
65
67
|
>
|
|
66
|
-
<
|
|
67
|
-
{
|
|
68
|
-
|
|
68
|
+
<ScreenDataContext.Provider value={initialScreenData}>
|
|
69
|
+
<PathnameContext.Provider value={pathname}>
|
|
70
|
+
{children}
|
|
71
|
+
</PathnameContext.Provider>
|
|
72
|
+
</ScreenDataContext.Provider>
|
|
73
|
+
{isAnimating && <Animated.View style={overlayStyle} />}
|
|
69
74
|
</Animated.View>
|
|
70
75
|
);
|
|
71
76
|
}
|
|
@@ -278,7 +278,8 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
278
278
|
// instead of dangerous nulls or duplicates.
|
|
279
279
|
renderSingleScene({ scenes, to }) {
|
|
280
280
|
const { contentStyle, layoutData } = this.props;
|
|
281
|
-
const screenData =
|
|
281
|
+
const screenData = this.props.children.props.screenData;
|
|
282
|
+
const pathname = scenes[to.index].key;
|
|
282
283
|
|
|
283
284
|
const orientation = getScreenOrientation({
|
|
284
285
|
screenData,
|
|
@@ -296,10 +297,12 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
296
297
|
}) && (
|
|
297
298
|
<Scene
|
|
298
299
|
{...{ style: to.style }}
|
|
299
|
-
pathname={
|
|
300
|
+
pathname={pathname}
|
|
301
|
+
isActive={pathname === this.props.navigator.currentRoute}
|
|
300
302
|
contentStyle={contentStyle}
|
|
301
303
|
key={scenes[to.index].key}
|
|
302
304
|
screenUniqueId={scenes[to.index].screenUniqueId}
|
|
305
|
+
screenData={screenData}
|
|
303
306
|
>
|
|
304
307
|
{scenes[to.index].children}
|
|
305
308
|
</Scene>
|
|
@@ -319,12 +322,14 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
319
322
|
<Scene
|
|
320
323
|
key={scenes[from.index].key}
|
|
321
324
|
pathname={scenes[from.index].key}
|
|
325
|
+
isActive={scenes[from.index].key === this.props.navigator.currentRoute}
|
|
322
326
|
style={from.style}
|
|
323
327
|
pointerEvents="none"
|
|
324
328
|
overlayStyle={from.overlayStyle}
|
|
325
329
|
animating={this.state.animating}
|
|
326
330
|
contentStyle={contentStyle}
|
|
327
331
|
screenUniqueId={scenes[from.index].screenUniqueId}
|
|
332
|
+
screenData={scenes[from.index].children.props.screenData}
|
|
328
333
|
>
|
|
329
334
|
{scenes[from.index].children}
|
|
330
335
|
</Scene>
|
|
@@ -333,12 +338,14 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
333
338
|
const toScene = scenes[to.index] && (
|
|
334
339
|
<Scene
|
|
335
340
|
pathname={scenes[to.index].key}
|
|
341
|
+
isActive={scenes[to.index].key === this.props.navigator.currentRoute}
|
|
336
342
|
key={scenes[to.index].key}
|
|
337
343
|
style={to.style}
|
|
338
344
|
overlayStyle={to.overlayStyle}
|
|
339
345
|
animating={this.state.animating}
|
|
340
346
|
contentStyle={contentStyle}
|
|
341
347
|
screenUniqueId={scenes[to.index].screenUniqueId}
|
|
348
|
+
screenData={this.props.children.props.screenData}
|
|
342
349
|
>
|
|
343
350
|
{scenes[to.index].children}
|
|
344
351
|
</Scene>
|
|
@@ -21,7 +21,9 @@ exports[`<Scene /> renders correctly 1`] = `
|
|
|
21
21
|
]
|
|
22
22
|
}
|
|
23
23
|
>
|
|
24
|
-
<ContextProvider
|
|
24
|
+
<ContextProvider>
|
|
25
|
+
<ContextProvider />
|
|
26
|
+
</ContextProvider>
|
|
25
27
|
</ForwardRef(AnimatedComponentWrapper)>
|
|
26
28
|
`;
|
|
27
29
|
|
|
@@ -43,7 +45,9 @@ exports[`<Scene /> renders the overlay while animating 1`] = `
|
|
|
43
45
|
]
|
|
44
46
|
}
|
|
45
47
|
>
|
|
46
|
-
<ContextProvider
|
|
48
|
+
<ContextProvider>
|
|
49
|
+
<ContextProvider />
|
|
50
|
+
</ContextProvider>
|
|
47
51
|
<ForwardRef(AnimatedComponentWrapper)
|
|
48
52
|
style={
|
|
49
53
|
Object {
|
|
@@ -351,6 +351,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
351
351
|
item,
|
|
352
352
|
playerId: this.currentlyPlaying?.playerId,
|
|
353
353
|
primaryPlayerId: this.primaryPlayer?.playerId,
|
|
354
|
+
entry: item.getPlayer().getEntry(),
|
|
354
355
|
},
|
|
355
356
|
});
|
|
356
357
|
};
|
|
@@ -385,6 +386,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
385
386
|
item,
|
|
386
387
|
playerId: this.currentlyPlaying?.playerId,
|
|
387
388
|
primaryPlayerId: this.primaryPlayer?.playerId,
|
|
389
|
+
entry: item.getPlayer().getEntry(),
|
|
388
390
|
},
|
|
389
391
|
});
|
|
390
392
|
};
|
|
@@ -419,6 +421,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
419
421
|
error,
|
|
420
422
|
playerId: currentItem?.playerId,
|
|
421
423
|
primaryPlayerId: currentItem?.playerId,
|
|
424
|
+
entry: item.getPlayer().getEntry(),
|
|
422
425
|
},
|
|
423
426
|
});
|
|
424
427
|
};
|
|
@@ -14,12 +14,13 @@ import { PlayerDetails } from "./PlayerDetails";
|
|
|
14
14
|
import { playerDimesionsHack } from "./utils";
|
|
15
15
|
import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
16
16
|
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
17
|
+
import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
|
|
17
18
|
|
|
18
19
|
import {
|
|
19
|
-
AnimationComponent,
|
|
20
|
-
ComponentAnimationType,
|
|
21
20
|
AnimatedScrollModal,
|
|
22
21
|
AnimatedVideoPlayerComponent,
|
|
22
|
+
AnimationComponent,
|
|
23
|
+
ComponentAnimationType,
|
|
23
24
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
24
25
|
|
|
25
26
|
type DimensionsT = {
|
|
@@ -96,7 +97,7 @@ const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
if (!isInlineModal && Platform.OS === "android") {
|
|
99
|
-
return [
|
|
100
|
+
return [];
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
return ["top"];
|
|
@@ -161,7 +162,7 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
161
162
|
width: isInlineModal && docked ? undefined : baseDimensions.width,
|
|
162
163
|
aspectRatio: !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9,
|
|
163
164
|
}),
|
|
164
|
-
[baseDimensions, isInlineModal, pip
|
|
165
|
+
[baseDimensions, isInlineModal, pip]
|
|
165
166
|
);
|
|
166
167
|
|
|
167
168
|
const containerDimensions: DimensionsT = React.useMemo(
|
|
@@ -180,65 +181,71 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
180
181
|
[containerDimensions, playerDimesionsHack]
|
|
181
182
|
);
|
|
182
183
|
|
|
184
|
+
const pathname = `${ROUTE_TYPES.VIDEO_MODAL}/${entry?.id}`;
|
|
185
|
+
|
|
183
186
|
return (
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
<
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
animationType={ComponentAnimationType.moveUpComponent}
|
|
210
|
-
style={isTabletLandscape ? defaultStyles.flex : undefined}
|
|
211
|
-
additionalData={{
|
|
212
|
-
useLayoutMeasure: isTabletLandscape,
|
|
213
|
-
disableAnimatedComponent: !isTabletLandscape,
|
|
214
|
-
resetAnimationValue: isTabletLandscape && docked,
|
|
215
|
-
}}
|
|
216
|
-
>
|
|
217
|
-
<AnimatedVideoPlayerComponent>
|
|
218
|
-
{children(childrenStyles)}
|
|
219
|
-
</AnimatedVideoPlayerComponent>
|
|
220
|
-
</AnimationComponent>
|
|
221
|
-
</View>
|
|
222
|
-
<AnimatedScrollModal>
|
|
223
|
-
{isInlineModal ? (
|
|
224
|
-
<AnimationComponent
|
|
225
|
-
animationType={ComponentAnimationType.componentFade}
|
|
226
|
-
style={defaultStyles.flex}
|
|
187
|
+
<ScreenContextProvider pathname={pathname}>
|
|
188
|
+
<PathnameContext.Provider value={pathname}>
|
|
189
|
+
<WrapperView
|
|
190
|
+
edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
|
|
191
|
+
style={[
|
|
192
|
+
safeAreaStyles(configuration, isTablet),
|
|
193
|
+
style,
|
|
194
|
+
playerDimesionsHack,
|
|
195
|
+
]}
|
|
196
|
+
>
|
|
197
|
+
<AnimationComponent
|
|
198
|
+
animationType={ComponentAnimationType.moveUpComponent}
|
|
199
|
+
additionalData={{ saveArea: true }}
|
|
200
|
+
style={directionStyles(isTabletLandscape)}
|
|
201
|
+
>
|
|
202
|
+
<ScreenContextProvider pathname={pathname}>
|
|
203
|
+
<PathnameContext.Provider value={pathname}>
|
|
204
|
+
<View
|
|
205
|
+
testID={`${entry?.id}-player-container`}
|
|
206
|
+
style={[
|
|
207
|
+
defaultStyles.playerContainer,
|
|
208
|
+
containerDimensions,
|
|
209
|
+
containerStyle,
|
|
210
|
+
playerDimesionsHack,
|
|
211
|
+
]}
|
|
227
212
|
>
|
|
228
|
-
<
|
|
229
|
-
|
|
230
|
-
style={defaultStyles.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
213
|
+
<AnimationComponent
|
|
214
|
+
animationType={ComponentAnimationType.moveUpComponent}
|
|
215
|
+
style={isTabletLandscape ? defaultStyles.flex : undefined}
|
|
216
|
+
additionalData={{
|
|
217
|
+
useLayoutMeasure: isTabletLandscape,
|
|
218
|
+
disableAnimatedComponent: !isTabletLandscape,
|
|
219
|
+
resetAnimationValue: isTabletLandscape && docked,
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
<AnimatedVideoPlayerComponent>
|
|
223
|
+
{children(childrenStyles)}
|
|
224
|
+
</AnimatedVideoPlayerComponent>
|
|
225
|
+
</AnimationComponent>
|
|
226
|
+
</View>
|
|
227
|
+
<AnimatedScrollModal>
|
|
228
|
+
{isInlineModal ? (
|
|
229
|
+
<AnimationComponent
|
|
230
|
+
animationType={ComponentAnimationType.componentFade}
|
|
231
|
+
style={defaultStyles.flex}
|
|
232
|
+
>
|
|
233
|
+
<PlayerDetails
|
|
234
|
+
configuration={configuration}
|
|
235
|
+
style={defaultStyles.playerDetails}
|
|
236
|
+
entry={entry}
|
|
237
|
+
isTabletLandscape={isTabletLandscape}
|
|
238
|
+
/>
|
|
239
|
+
</AnimationComponent>
|
|
240
|
+
) : (
|
|
241
|
+
<View style={defaultStyles.playerDetails} />
|
|
242
|
+
)}
|
|
243
|
+
</AnimatedScrollModal>
|
|
244
|
+
</PathnameContext.Provider>
|
|
245
|
+
</ScreenContextProvider>
|
|
246
|
+
</AnimationComponent>
|
|
247
|
+
</WrapperView>
|
|
248
|
+
</PathnameContext.Provider>
|
|
249
|
+
</ScreenContextProvider>
|
|
243
250
|
);
|
|
244
251
|
};
|
|
@@ -25,6 +25,13 @@ jest.mock("react-native-gesture-handler");
|
|
|
25
25
|
|
|
26
26
|
jest.mock("../PlayerDetails", () => ({ PlayerDetails: View }));
|
|
27
27
|
|
|
28
|
+
jest.mock(
|
|
29
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
|
|
30
|
+
() => ({
|
|
31
|
+
useScreenContext: jest.fn().mockReturnValue({ screen: {}, entry: {} }),
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
|
|
28
35
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/device", () => ({
|
|
29
36
|
useIsTablet,
|
|
30
37
|
}));
|
|
@@ -6,23 +6,23 @@ import { callOnChildren } from "../utils";
|
|
|
6
6
|
|
|
7
7
|
export function ViewportTracker(props) {
|
|
8
8
|
const viewportEvents = useViewportEventsContext();
|
|
9
|
-
const { children } = props;
|
|
10
|
-
const [width, setWidth] = React.useState(0);
|
|
11
|
-
const [height, setHeight] = React.useState(0);
|
|
12
|
-
const [offsetX, setOffsetX] = React.useState(0);
|
|
13
|
-
const [offsetY, setOffsetY] = React.useState(0);
|
|
14
9
|
const [nodeHandle, setNodeHandle] = React.useState(null);
|
|
15
10
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
const childrenRef = React.useRef(props.children);
|
|
12
|
+
|
|
13
|
+
const dimensionsRef = React.useRef({ width: 0, height: 0 });
|
|
14
|
+
const offsetRef = React.useRef({ offsetX: 0, offsetY: 0 });
|
|
15
|
+
|
|
16
|
+
const assignRef = React.useCallback((ref) => {
|
|
17
|
+
childrenRef.current?.ref?.(ref);
|
|
18
|
+
setNodeHandle(findNodeHandle(ref));
|
|
19
|
+
}, []);
|
|
23
20
|
|
|
24
21
|
const onViewportChange = React.useCallback(
|
|
25
|
-
(
|
|
22
|
+
({
|
|
23
|
+
event = { ...dimensionsRef.current, ...offsetRef.current },
|
|
24
|
+
shouldMeasureLayout = true,
|
|
25
|
+
} = {}) => {
|
|
26
26
|
if (nodeHandle && event?.width > 0 && event?.height > 0) {
|
|
27
27
|
viewportEvents?.notify?.({
|
|
28
28
|
parentHandle: nodeHandle,
|
|
@@ -36,54 +36,45 @@ export function ViewportTracker(props) {
|
|
|
36
36
|
|
|
37
37
|
const onLayout = React.useCallback(
|
|
38
38
|
(event) => {
|
|
39
|
-
callOnChildren(
|
|
40
|
-
|
|
41
|
-
setHeight(event?.nativeEvent?.layout?.height);
|
|
39
|
+
callOnChildren(childrenRef.current, "onLayout", event);
|
|
40
|
+
dimensionsRef.current = event?.nativeEvent?.layout;
|
|
42
41
|
|
|
43
|
-
onViewportChange(
|
|
44
|
-
width: event?.nativeEvent?.layout?.width,
|
|
45
|
-
height: event?.nativeEvent?.layout?.height,
|
|
46
|
-
offsetX,
|
|
47
|
-
offsetY,
|
|
48
|
-
});
|
|
42
|
+
onViewportChange();
|
|
49
43
|
},
|
|
50
|
-
[
|
|
44
|
+
[onViewportChange]
|
|
51
45
|
);
|
|
52
46
|
|
|
53
47
|
const onContentSizeChange = React.useCallback(
|
|
54
48
|
(contentWidth, contentHeight) => {
|
|
55
49
|
callOnChildren(
|
|
56
|
-
|
|
50
|
+
childrenRef.current,
|
|
57
51
|
"onContentSizeChange",
|
|
58
52
|
contentWidth,
|
|
59
53
|
contentHeight
|
|
60
54
|
);
|
|
61
55
|
|
|
62
|
-
onViewportChange(
|
|
56
|
+
onViewportChange();
|
|
63
57
|
},
|
|
64
|
-
[onViewportChange
|
|
58
|
+
[onViewportChange]
|
|
65
59
|
);
|
|
66
60
|
|
|
67
61
|
const onScroll = React.useCallback(
|
|
68
62
|
(event) => {
|
|
69
|
-
callOnChildren(
|
|
70
|
-
|
|
71
|
-
setOffsetY(event?.nativeEvent?.contentOffset?.y);
|
|
63
|
+
callOnChildren(childrenRef.current, "onScroll", event);
|
|
64
|
+
offsetRef.current = event?.nativeEvent?.contentOffset;
|
|
72
65
|
|
|
73
|
-
onViewportChange(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
height,
|
|
77
|
-
offsetX: event?.nativeEvent?.contentOffset?.x,
|
|
78
|
-
offsetY: event?.nativeEvent?.contentOffset?.y,
|
|
79
|
-
},
|
|
80
|
-
false
|
|
81
|
-
);
|
|
66
|
+
onViewportChange({
|
|
67
|
+
shouldMeasureLayout: false,
|
|
68
|
+
});
|
|
82
69
|
},
|
|
83
|
-
[onViewportChange
|
|
70
|
+
[onViewportChange]
|
|
84
71
|
);
|
|
85
72
|
|
|
86
|
-
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
childrenRef.current = props.children;
|
|
75
|
+
}, [props.children]);
|
|
76
|
+
|
|
77
|
+
return React.cloneElement(React.Children.only(props.children), {
|
|
87
78
|
ref: assignRef,
|
|
88
79
|
onLayout,
|
|
89
80
|
onContentSizeChange,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.4355141911",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"redux-mock-store": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@applicaster/applicaster-types": "12.0.0-alpha.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.0-alpha.4355141911",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.4355141911",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.4355141911",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.4355141911",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|