@applicaster/zapp-react-native-ui-components 12.0.0-alpha.3977160850 → 12.0.0-alpha.4300857220
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/Cell/Cell.tsx +2 -2
- package/Components/Cell/CellWithFocusable.tsx +21 -14
- package/Components/Cell/TvOSCellComponent.tsx +2 -2
- package/Components/ErrorScreen/index.tsx +1 -1
- package/Components/FocusableCell/index.tsx +7 -7
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
- package/Components/HookRenderer/index.tsx +1 -3
- package/Components/Image/Image.android.tsx +3 -25
- package/Components/Image/Image.tsx +18 -2
- package/Components/Image/utils/index.ts +39 -0
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +41 -1
- package/Components/Layout/TV/__tests__/index.test.tsx +1 -13
- package/Components/Layout/TV/index.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +17 -2
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
- package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/utils/index.ts +18 -7
- package/Components/PlayerContainer/PlayerContainer.tsx +60 -30
- package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
- package/Components/PlayerImageBackground/index.tsx +34 -8
- package/Components/River/ComponentsMap/ComponentsMap.tsx +85 -22
- package/Components/River/__tests__/componentsMap.test.js +7 -0
- package/Components/RouteManager/index.tsx +2 -2
- package/Components/Screen/__tests__/Screen.test.tsx +5 -1
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +14 -0
- package/Components/Screen/index.tsx +48 -28
- package/Components/Tabs/TV/styles.ts +1 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +31 -28
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +18 -28
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +342 -0
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +151 -0
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +438 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +143 -0
- package/Components/VideoModal/ModalAnimation/index.ts +15 -0
- package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
- package/Components/VideoModal/PlayerWrapper.tsx +64 -41
- package/Components/VideoModal/VideoModal.tsx +8 -25
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +6 -1
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +246 -166
- package/Components/VideoModal/utils.ts +3 -3
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +1 -1
- package/Components/Viewport/ViewportTracker/index.tsx +1 -0
- package/Components/Viewport/utils.js +1 -1
- package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
- package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
- package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
- package/Contexts/ScreenContext/index.tsx +94 -25
- package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
- package/package.json +5 -5
- package/Components/VideoModal/hooks/usePosition.ts +0 -50
- /package/Contexts/{index.js → index.ts} +0 -0
|
@@ -54,6 +54,11 @@ import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
|
54
54
|
import { usePlayNextOverlay } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayNextOverlay";
|
|
55
55
|
import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
|
|
56
56
|
|
|
57
|
+
import {
|
|
58
|
+
useModalAnimationContext,
|
|
59
|
+
PlayerAnimationStateEnum,
|
|
60
|
+
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
61
|
+
|
|
57
62
|
type Props = {
|
|
58
63
|
Player: React.ComponentType<any>;
|
|
59
64
|
PlayerLoadingView?: React.ComponentType<any>; // 👀 we are not receiving this prop
|
|
@@ -145,34 +150,30 @@ const renderApplePlayer = ({
|
|
|
145
150
|
}) => {
|
|
146
151
|
const { title, summary } = item || {};
|
|
147
152
|
|
|
148
|
-
if (!
|
|
153
|
+
if (!isAppleTV() || !player) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (isAudioContent) {
|
|
158
|
+
return (
|
|
159
|
+
<AudioPlayer
|
|
160
|
+
audio_item={item}
|
|
161
|
+
plugin_configuration={pluginConfiguration}
|
|
162
|
+
/>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!playNextData && player.isPaused() && player.isAd() === false) {
|
|
149
167
|
return null;
|
|
150
168
|
}
|
|
151
169
|
|
|
152
170
|
return (
|
|
153
|
-
|
|
154
|
-
{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
<ProgramInfo
|
|
160
|
-
title={title}
|
|
161
|
-
subtitle={summary}
|
|
162
|
-
plugin_configuration={pluginConfiguration}
|
|
163
|
-
videoStyle={videoStyle}
|
|
164
|
-
/>
|
|
165
|
-
)}
|
|
166
|
-
</>
|
|
167
|
-
)}
|
|
168
|
-
|
|
169
|
-
{isAudioContent && (
|
|
170
|
-
<AudioPlayer
|
|
171
|
-
audio_item={item}
|
|
172
|
-
plugin_configuration={pluginConfiguration}
|
|
173
|
-
/>
|
|
174
|
-
)}
|
|
175
|
-
</>
|
|
171
|
+
<ProgramInfo
|
|
172
|
+
title={title}
|
|
173
|
+
subtitle={summary}
|
|
174
|
+
plugin_configuration={pluginConfiguration}
|
|
175
|
+
videoStyle={videoStyle}
|
|
176
|
+
/>
|
|
176
177
|
);
|
|
177
178
|
};
|
|
178
179
|
|
|
@@ -233,6 +234,9 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
233
234
|
const screenData = useTargetScreenData(item);
|
|
234
235
|
const { setVisible: showNavBar } = useSetNavbarState();
|
|
235
236
|
|
|
237
|
+
const { isActiveGesture, startComponentsAnimation, setPlayerAnimationState } =
|
|
238
|
+
useModalAnimationContext();
|
|
239
|
+
|
|
236
240
|
const playerEvent = (event, ...args) => {
|
|
237
241
|
playerManager.invokeHandler(event, ...args);
|
|
238
242
|
};
|
|
@@ -339,6 +343,18 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
339
343
|
}
|
|
340
344
|
}, [item?.id, item?.extensions?.resumeTime, player]);
|
|
341
345
|
|
|
346
|
+
const onVideoFullscreenPlayerWillPresent = React.useCallback(() => {
|
|
347
|
+
playerManager.invokeHandler("toggleFullscreen", {
|
|
348
|
+
fullscreen: true,
|
|
349
|
+
});
|
|
350
|
+
}, []);
|
|
351
|
+
|
|
352
|
+
const onVideoFullscreenPlayerWillDismiss = React.useCallback(() => {
|
|
353
|
+
playerManager.invokeHandler("toggleFullscreen", {
|
|
354
|
+
fullscreen: false,
|
|
355
|
+
});
|
|
356
|
+
}, []);
|
|
357
|
+
|
|
342
358
|
// Util methods
|
|
343
359
|
const toggleFullscreen = (event) => {
|
|
344
360
|
const { fullscreen = false } = event || {};
|
|
@@ -381,17 +397,27 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
381
397
|
id: playerContainerId,
|
|
382
398
|
listener: {
|
|
383
399
|
onVideoEnd,
|
|
384
|
-
onError
|
|
385
|
-
onLoad
|
|
400
|
+
onError,
|
|
401
|
+
onLoad,
|
|
386
402
|
onPlayerClose: close,
|
|
387
403
|
onPlayerDetached: close,
|
|
404
|
+
onVideoFullscreenPlayerWillDismiss,
|
|
405
|
+
onVideoFullscreenPlayerWillPresent,
|
|
388
406
|
},
|
|
389
407
|
});
|
|
390
408
|
|
|
391
409
|
return () => {
|
|
392
410
|
player.removeListener(playerContainerId);
|
|
393
411
|
};
|
|
394
|
-
}, [
|
|
412
|
+
}, [
|
|
413
|
+
player,
|
|
414
|
+
onVideoEnd,
|
|
415
|
+
onError,
|
|
416
|
+
onLoad,
|
|
417
|
+
close,
|
|
418
|
+
onVideoFullscreenPlayerWillDismiss,
|
|
419
|
+
onVideoFullscreenPlayerWillPresent,
|
|
420
|
+
]);
|
|
395
421
|
|
|
396
422
|
useEffect(() => {
|
|
397
423
|
// TODO: We should not use playerManager here to connect buttons to player container
|
|
@@ -428,7 +454,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
428
454
|
if (disableMiniPlayer) {
|
|
429
455
|
navigator.closeVideoModal();
|
|
430
456
|
} else {
|
|
431
|
-
|
|
457
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
432
458
|
}
|
|
433
459
|
}
|
|
434
460
|
|
|
@@ -621,9 +647,13 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
621
647
|
}}
|
|
622
648
|
focused={isInlineTV ? true : undefined}
|
|
623
649
|
autoplay={true}
|
|
624
|
-
controls={
|
|
650
|
+
controls={false}
|
|
625
651
|
disableCastAction={disableCastAction}
|
|
626
|
-
docked={
|
|
652
|
+
docked={
|
|
653
|
+
navigator.isVideoModalDocked() &&
|
|
654
|
+
!startComponentsAnimation &&
|
|
655
|
+
!isActiveGesture
|
|
656
|
+
}
|
|
627
657
|
entry={item}
|
|
628
658
|
fullscreen={mode === VideoModalMode.FULLSCREEN}
|
|
629
659
|
inline={inline}
|
|
@@ -4,7 +4,9 @@ import { styleKeys } from "@applicaster/zapp-react-native-utils/styleKeysUtils";
|
|
|
4
4
|
import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform";
|
|
5
5
|
import * as R from "ramda";
|
|
6
6
|
import * as React from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { Text, TextStyle, View, ViewStyle } from "react-native";
|
|
8
|
+
import { QBImage as Image } from "@applicaster/zapp-react-native-ui-components/Components/Image";
|
|
9
|
+
|
|
8
10
|
import * as programStyles from "./styles";
|
|
9
11
|
|
|
10
12
|
type Props = {
|
|
@@ -1,38 +1,64 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { ImageBackground } from "react-native";
|
|
2
|
+
import { ImageBackground, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { imageSrcFromMediaItem } from "@applicaster/zapp-react-native-utils/configurationUtils";
|
|
5
|
+
import {
|
|
6
|
+
AnimationComponent,
|
|
7
|
+
ComponentAnimationType,
|
|
8
|
+
useModalAnimationContext,
|
|
9
|
+
PlayerAnimationStateEnum,
|
|
10
|
+
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
5
11
|
|
|
6
12
|
type Props = PropsWithChildren<{
|
|
7
13
|
entry: ZappEntry;
|
|
8
14
|
style?: { [K: string]: any };
|
|
9
15
|
imageStyle?: { [K: string]: any };
|
|
10
16
|
imageKey?: string;
|
|
17
|
+
defaultImageDimensions?: { [K: string]: any };
|
|
11
18
|
}>;
|
|
12
19
|
|
|
20
|
+
const imageSize = { width: "100%", height: "100%" };
|
|
21
|
+
|
|
13
22
|
const PlayerImageBackgroundComponent = ({
|
|
14
23
|
entry,
|
|
15
24
|
children,
|
|
16
25
|
style,
|
|
17
26
|
imageStyle,
|
|
18
27
|
imageKey,
|
|
28
|
+
defaultImageDimensions,
|
|
19
29
|
}: Props) => {
|
|
20
30
|
const source = React.useMemo(
|
|
21
31
|
() => ({ uri: imageSrcFromMediaItem(entry, imageKey) }),
|
|
22
32
|
[imageKey, entry]
|
|
23
33
|
);
|
|
24
34
|
|
|
35
|
+
const { playerAnimationState } = useModalAnimationContext();
|
|
36
|
+
|
|
25
37
|
if (!source) return <>{children}</>;
|
|
26
38
|
|
|
27
39
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
<View
|
|
41
|
+
style={
|
|
42
|
+
playerAnimationState === PlayerAnimationStateEnum.maximaze
|
|
43
|
+
? defaultImageDimensions
|
|
44
|
+
: style
|
|
45
|
+
}
|
|
33
46
|
>
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
<AnimationComponent
|
|
48
|
+
style={style}
|
|
49
|
+
animationType={ComponentAnimationType.player}
|
|
50
|
+
additionalData={defaultImageDimensions}
|
|
51
|
+
>
|
|
52
|
+
<ImageBackground
|
|
53
|
+
resizeMode="cover"
|
|
54
|
+
style={imageSize}
|
|
55
|
+
imageStyle={imageStyle}
|
|
56
|
+
source={source}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
</ImageBackground>
|
|
60
|
+
</AnimationComponent>
|
|
61
|
+
</View>
|
|
36
62
|
);
|
|
37
63
|
};
|
|
38
64
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
-
import { View,
|
|
3
|
+
import { View, StyleSheet, Platform, Animated, FlatList } from "react-native";
|
|
4
4
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
5
5
|
import { RiverItem } from "../RiverItem";
|
|
6
6
|
import { RiverFooter } from "../RiverFooter";
|
|
@@ -21,7 +21,8 @@ import {
|
|
|
21
21
|
import { useScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData";
|
|
22
22
|
import { isLast } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
23
23
|
import { withComponentsMapProvider } from "@applicaster/zapp-react-native-ui-components/Decorators/ComponentsMapWrapper";
|
|
24
|
-
import {
|
|
24
|
+
import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
25
|
+
import { useShallow } from "zustand/react/shallow";
|
|
25
26
|
|
|
26
27
|
type Props = {
|
|
27
28
|
feed: ZappFeed;
|
|
@@ -41,8 +42,10 @@ const styles = StyleSheet.create({
|
|
|
41
42
|
},
|
|
42
43
|
});
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
+
const getNearestValue = (value, optionA, optionB) =>
|
|
46
|
+
Math.abs(value - optionA) < Math.abs(value - optionB) ? optionA : optionB;
|
|
45
47
|
|
|
48
|
+
const scrollIndicatorInsets = { right: 1 };
|
|
46
49
|
const keyExtractor = R.compose(String, R.prop("id"));
|
|
47
50
|
|
|
48
51
|
function ComponentsMapComponent(props: Props) {
|
|
@@ -60,6 +63,7 @@ function ComponentsMapComponent(props: Props) {
|
|
|
60
63
|
refreshingPipesV1,
|
|
61
64
|
} = props;
|
|
62
65
|
|
|
66
|
+
const flatListRef = React.useRef<FlatList | null>(null);
|
|
63
67
|
const screenConfig = useScreenConfiguration(riverId);
|
|
64
68
|
const screenData = useScreenData(riverId);
|
|
65
69
|
const pullToRefreshEnabled = screenData?.rules?.pull_to_refresh_enabled;
|
|
@@ -194,26 +198,67 @@ function ComponentsMapComponent(props: Props) {
|
|
|
194
198
|
[]
|
|
195
199
|
);
|
|
196
200
|
|
|
197
|
-
const
|
|
198
|
-
({ nativeEvent }, isScrollingDone = false) => {
|
|
199
|
-
const {
|
|
200
|
-
contentOffset: { y },
|
|
201
|
-
} = nativeEvent;
|
|
201
|
+
const navBarStore = useScreenContextV2()._navBarStore;
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
scrollPosition: y,
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
[]
|
|
203
|
+
const scrollY = navBarStore(
|
|
204
|
+
useShallow(({ scrollYAnimated }) => scrollYAnimated)
|
|
209
205
|
);
|
|
210
206
|
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
207
|
+
const canMomentum = React.useRef(false);
|
|
208
|
+
|
|
209
|
+
const onScrollBeginDrag = React.useCallback(() => {
|
|
210
|
+
canMomentum.current = true;
|
|
211
|
+
}, []);
|
|
212
|
+
|
|
213
|
+
/* onMomentumScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
|
|
214
|
+
const _onMomentumScrollEnd = React.useCallback(({ nativeEvent }) => {
|
|
215
|
+
if (!canMomentum.current) return;
|
|
216
|
+
canMomentum.current = false;
|
|
217
|
+
|
|
218
|
+
const { height: headerHeight, scrollState } = navBarStore.getState();
|
|
219
|
+
|
|
220
|
+
const offsetY = nativeEvent.contentOffset.y;
|
|
221
|
+
|
|
222
|
+
if (
|
|
223
|
+
!(scrollState === 0 || scrollState === -headerHeight) &&
|
|
224
|
+
flatListRef.current
|
|
225
|
+
) {
|
|
226
|
+
const offset =
|
|
227
|
+
getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
|
|
228
|
+
-headerHeight
|
|
229
|
+
? Math.round(offsetY + scrollState + headerHeight)
|
|
230
|
+
: Math.round(offsetY + scrollState);
|
|
231
|
+
|
|
232
|
+
flatListRef.current.scrollToOffset({
|
|
233
|
+
animated: true,
|
|
234
|
+
offset,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}, []);
|
|
238
|
+
|
|
239
|
+
/* onScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
|
|
240
|
+
const _onScrollEndDrag = React.useCallback(({ nativeEvent }) => {
|
|
241
|
+
const { height: headerHeight, scrollState } = navBarStore.getState();
|
|
242
|
+
|
|
243
|
+
const offsetY = nativeEvent.contentOffset.y;
|
|
244
|
+
|
|
245
|
+
if (
|
|
246
|
+
!(scrollState === 0 || scrollState === -headerHeight) &&
|
|
247
|
+
flatListRef.current &&
|
|
248
|
+
nativeEvent.velocity.y === 0
|
|
249
|
+
) {
|
|
250
|
+
const offset =
|
|
251
|
+
getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
|
|
252
|
+
-headerHeight
|
|
253
|
+
? Math.round(offsetY + scrollState + headerHeight)
|
|
254
|
+
: Math.round(offsetY + scrollState);
|
|
255
|
+
|
|
256
|
+
flatListRef.current.scrollToOffset({
|
|
257
|
+
animated: true,
|
|
258
|
+
offset,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}, []);
|
|
217
262
|
|
|
218
263
|
if (shouldShowLoadingError) {
|
|
219
264
|
return <RiverError />;
|
|
@@ -230,6 +275,9 @@ function ComponentsMapComponent(props: Props) {
|
|
|
230
275
|
>
|
|
231
276
|
<ViewportTracker>
|
|
232
277
|
<FlatList
|
|
278
|
+
ref={(ref) => {
|
|
279
|
+
flatListRef.current = ref;
|
|
280
|
+
}}
|
|
233
281
|
// Fix for WebView rerender crashes on Android API 28+
|
|
234
282
|
// https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
|
|
235
283
|
overScrollMode={Platform.OS === "android" ? "never" : "auto"}
|
|
@@ -249,8 +297,23 @@ function ComponentsMapComponent(props: Props) {
|
|
|
249
297
|
}
|
|
250
298
|
ListFooterComponent={renderFooter}
|
|
251
299
|
refreshControl={refreshControl}
|
|
252
|
-
|
|
253
|
-
|
|
300
|
+
onScrollBeginDrag={onScrollBeginDrag}
|
|
301
|
+
onScroll={Animated.event(
|
|
302
|
+
[
|
|
303
|
+
{
|
|
304
|
+
nativeEvent: {
|
|
305
|
+
contentOffset: {
|
|
306
|
+
y: scrollY,
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
{
|
|
312
|
+
useNativeDriver: false,
|
|
313
|
+
}
|
|
314
|
+
)}
|
|
315
|
+
onMomentumScrollEnd={_onMomentumScrollEnd}
|
|
316
|
+
onScrollEndDrag={_onScrollEndDrag}
|
|
254
317
|
scrollEventThrottle={16}
|
|
255
318
|
{...scrollViewExtraProps}
|
|
256
319
|
/>
|
|
@@ -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
|
}));
|
|
@@ -83,6 +89,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
83
89
|
useNavigation: jest.fn(() => ({ currentRoute: "/river/A1234" })),
|
|
84
90
|
useRoute: jest.fn(() => ({ pathname: "/river/A1234", screenData })),
|
|
85
91
|
useProfilerLogging: jest.fn(),
|
|
92
|
+
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
86
93
|
}));
|
|
87
94
|
|
|
88
95
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
|
|
@@ -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 } = useRoute();
|
|
17
|
+
const { pathname, screenData: _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={screenData}
|
|
28
|
+
screenData={props.screenData}
|
|
29
29
|
/>
|
|
30
30
|
</TestId>
|
|
31
31
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { act, create } from "react-test-renderer";
|
|
4
4
|
|
|
5
5
|
const Mocked_RouteManager = jest.fn((props) => (
|
|
6
6
|
<View testID="routeManager" {...props} />
|
|
@@ -69,12 +69,16 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
69
69
|
isNavBarVisible: mockIsNavBarVisible,
|
|
70
70
|
useRoute: jest.fn(() => ({
|
|
71
71
|
pathname: "/river/testId",
|
|
72
|
+
screenData: { id: "testId" },
|
|
72
73
|
})),
|
|
73
74
|
useNavigation: jest.fn(() => ({
|
|
74
75
|
canGoBack: () => false,
|
|
75
76
|
currentRoute: "/river/testId",
|
|
77
|
+
activeRiver: { id: "testId" },
|
|
78
|
+
screenData: { id: "testId" },
|
|
76
79
|
data: { screen: { id: "testId" } },
|
|
77
80
|
})),
|
|
81
|
+
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
78
82
|
}));
|
|
79
83
|
|
|
80
84
|
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
@@ -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=""
|
|
@@ -19,6 +21,11 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
|
|
|
19
21
|
<View>
|
|
20
22
|
<View
|
|
21
23
|
pathname="/river/testId"
|
|
24
|
+
screenData={
|
|
25
|
+
Object {
|
|
26
|
+
"id": "testId",
|
|
27
|
+
}
|
|
28
|
+
}
|
|
22
29
|
testID="routeManager"
|
|
23
30
|
/>
|
|
24
31
|
</View>
|
|
@@ -36,7 +43,9 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
|
|
|
36
43
|
}
|
|
37
44
|
>
|
|
38
45
|
<View
|
|
46
|
+
hasMenu={false}
|
|
39
47
|
id="/river/testId"
|
|
48
|
+
pathname="/river/testId"
|
|
40
49
|
selected="testId"
|
|
41
50
|
testID="navBar"
|
|
42
51
|
title=""
|
|
@@ -44,6 +53,11 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
|
|
|
44
53
|
<View>
|
|
45
54
|
<View
|
|
46
55
|
pathname="/river/testId"
|
|
56
|
+
screenData={
|
|
57
|
+
Object {
|
|
58
|
+
"id": "testId",
|
|
59
|
+
}
|
|
60
|
+
}
|
|
47
61
|
testID="routeManager"
|
|
48
62
|
/>
|
|
49
63
|
</View>
|
|
@@ -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 {
|
|
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,
|
|
@@ -14,6 +17,7 @@ import {
|
|
|
14
17
|
useCurrentScreenData,
|
|
15
18
|
useNavbarState,
|
|
16
19
|
useScreenData,
|
|
20
|
+
useNavigation,
|
|
17
21
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
18
22
|
import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers";
|
|
19
23
|
|
|
@@ -22,6 +26,17 @@ import { RouteManager } from "../RouteManager";
|
|
|
22
26
|
import { useScreenConfiguration } from "../River/useScreenConfiguration";
|
|
23
27
|
import { useScreenOrientationHandler } from "./orientationHandler";
|
|
24
28
|
|
|
29
|
+
const getScreenId = (
|
|
30
|
+
screenData: LegacyNavigationScreenData,
|
|
31
|
+
fallbackRiver: ZappRiver
|
|
32
|
+
) => {
|
|
33
|
+
return screenData?.targetScreen
|
|
34
|
+
? screenData?.targetScreen?.id ?? fallbackRiver.id
|
|
35
|
+
: "screen_id" in screenData
|
|
36
|
+
? screenData.screen_id
|
|
37
|
+
: fallbackRiver.id;
|
|
38
|
+
};
|
|
39
|
+
|
|
25
40
|
function colorIsNotTransparent(color) {
|
|
26
41
|
const layers = R.compose(
|
|
27
42
|
R.map(R.trim),
|
|
@@ -40,14 +55,13 @@ function isValidColor(string) {
|
|
|
40
55
|
}
|
|
41
56
|
|
|
42
57
|
type Props = {
|
|
43
|
-
pathname:
|
|
58
|
+
pathname: unknown;
|
|
44
59
|
screenData: unknown;
|
|
45
|
-
setToggleMenu: () => void;
|
|
46
|
-
setCloseMenu: () => void;
|
|
47
60
|
};
|
|
48
61
|
|
|
49
|
-
export function Screen(
|
|
62
|
+
export function Screen(_props: Props) {
|
|
50
63
|
const theme = useTheme<BaseThemePropertiesMobile>();
|
|
64
|
+
const navigation = useNavigation();
|
|
51
65
|
const { plugins } = usePickFromState(["plugins"]);
|
|
52
66
|
|
|
53
67
|
// Gets the data for the current screen configuration
|
|
@@ -59,28 +73,38 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
|
|
|
59
73
|
fullDimensions: true,
|
|
60
74
|
});
|
|
61
75
|
|
|
62
|
-
const
|
|
76
|
+
const { screenData, pathname } = useRoute();
|
|
63
77
|
|
|
64
78
|
const currentRiver = useScreenData(
|
|
65
|
-
(
|
|
66
|
-
? (routeData.screenData as ZappRiver)?.targetScreen.id
|
|
67
|
-
: (routeData.screenData as ZappRiver)?.screen_id
|
|
79
|
+
getScreenId(screenData, navigation.activeRiver)
|
|
68
80
|
);
|
|
69
81
|
|
|
70
82
|
const { title } = useNavbarState();
|
|
71
83
|
|
|
72
|
-
const
|
|
73
|
-
(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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]);
|
|
84
108
|
|
|
85
109
|
const NavBar = React.useMemo(
|
|
86
110
|
() =>
|
|
@@ -88,12 +112,10 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
|
|
|
88
112
|
"nav_bar",
|
|
89
113
|
currentRiver,
|
|
90
114
|
plugins
|
|
91
|
-
) as React.ComponentType<MobileNavBarPluginProps>,
|
|
115
|
+
) as React.ComponentType<MobileNavBarPluginProps & { hasMenu: boolean }>,
|
|
92
116
|
[]
|
|
93
117
|
);
|
|
94
118
|
|
|
95
|
-
const { screenData, pathname } = routeData;
|
|
96
|
-
|
|
97
119
|
const offlinePlugin = getComponentModule({
|
|
98
120
|
plugins,
|
|
99
121
|
components: {},
|
|
@@ -124,11 +146,9 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
|
|
|
124
146
|
return (
|
|
125
147
|
<ScreenContextProvider pathname={pathname}>
|
|
126
148
|
<View style={style}>
|
|
127
|
-
<NavBar
|
|
128
|
-
{...{ ...(navBarProps as MobileNavBarPluginProps), id: pathname }}
|
|
129
|
-
/>
|
|
149
|
+
{navBarProps && <NavBar {...navBarProps} hasMenu={hasMenu} />}
|
|
130
150
|
|
|
131
|
-
<OfflineFallbackScreen screenData={
|
|
151
|
+
<OfflineFallbackScreen screenData={targetScreenData}>
|
|
132
152
|
{/* @TODO RouteManager doesn't use props, can they be removed ? */}
|
|
133
153
|
<RouteManager pathname={pathname} screenData={screenData} />
|
|
134
154
|
</OfflineFallbackScreen>
|