@applicaster/zapp-react-native-ui-components 15.0.0-rc.7 → 15.0.0-rc.71
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/BaseFocusable/index.ios.ts +12 -2
- package/Components/Cell/Cell.tsx +8 -3
- package/Components/Cell/FocusableWrapper.tsx +47 -0
- package/Components/Cell/TvOSCellComponent.tsx +106 -19
- package/Components/Focusable/Focusable.tsx +4 -2
- package/Components/Focusable/FocusableTvOS.tsx +18 -1
- package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
- package/Components/FocusableGroup/FocusableTvOS.tsx +32 -1
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +19 -3
- package/Components/HandlePlayable/HandlePlayable.tsx +17 -65
- package/Components/HandlePlayable/const.ts +3 -0
- package/Components/HandlePlayable/utils.ts +74 -0
- package/Components/Layout/TV/LayoutBackground.tsx +5 -2
- package/Components/Layout/TV/ScreenContainer.tsx +2 -6
- package/Components/Layout/TV/index.tsx +3 -4
- package/Components/Layout/TV/index.web.tsx +3 -4
- package/Components/LinkHandler/LinkHandler.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +10 -6
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +8 -8
- package/Components/MasterCell/index.tsx +2 -0
- package/Components/MasterCell/utils/__tests__/resolveColor.test.js +82 -3
- package/Components/MasterCell/utils/index.ts +61 -31
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +102 -87
- package/Components/MeasurmentsPortal/__tests__/MeasurementsPortal.test.tsx +355 -0
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
- package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
- package/Components/PlayerContainer/PlayerContainer.tsx +51 -55
- package/Components/PlayerContainer/useRestrictMobilePlayback.tsx +101 -0
- package/Components/PlayerImageBackground/index.tsx +3 -22
- package/Components/River/TV/River.tsx +31 -14
- package/Components/River/TV/index.tsx +8 -4
- package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
- package/Components/River/TV/utils/index.ts +4 -0
- package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
- package/Components/Screen/TV/index.web.tsx +4 -2
- package/Components/Screen/__tests__/Screen.test.tsx +65 -42
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -42
- package/Components/Screen/hooks.ts +2 -3
- package/Components/Screen/index.tsx +24 -8
- package/Components/Screen/navigationHandler.ts +49 -24
- package/Components/Screen/orientationHandler.ts +3 -3
- package/Components/ScreenResolver/index.tsx +13 -7
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
- 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/Transitioner/Scene.tsx +15 -2
- package/Components/Transitioner/index.js +3 -3
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +118 -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 +19 -9
- package/Decorators/Analytics/index.tsx +6 -5
- package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
- package/Decorators/ConfigurationWrapper/const.ts +1 -0
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
- package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
- package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
- package/Helpers/DataSourceHelper/index.ts +19 -0
- package/index.d.ts +7 -0
- package/package.json +6 -5
- package/Components/River/TV/withTVEventHandler.tsx +0 -27
- 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
- package/Helpers/DataSourceHelper/index.js +0 -19
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Player } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/player";
|
|
2
|
+
import NetInfo from "@react-native-community/netinfo";
|
|
3
|
+
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { showAlertDialog } from "@applicaster/zapp-react-native-utils/alertUtils";
|
|
6
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
7
|
+
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
8
|
+
import { log_info } from "./logger";
|
|
9
|
+
|
|
10
|
+
type RestrictMobilePlaybackProps = {
|
|
11
|
+
player?: Player;
|
|
12
|
+
entry?: ZappEntry;
|
|
13
|
+
pluginConfiguration?: Record<string, string>;
|
|
14
|
+
close: () => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const useRestrictMobilePlayback = ({
|
|
18
|
+
player,
|
|
19
|
+
entry,
|
|
20
|
+
pluginConfiguration,
|
|
21
|
+
close,
|
|
22
|
+
}: RestrictMobilePlaybackProps): { isRestricted: boolean } => {
|
|
23
|
+
const dialogVisibleRef = useRef<boolean>(false);
|
|
24
|
+
const theme = useTheme();
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
return () => {
|
|
28
|
+
if (isTV()) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
dialogVisibleRef.current = false;
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
const isConnectionRestricted = useMemo(() => {
|
|
37
|
+
if (isTV()) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return player && entry?.extensions?.connection_restricted;
|
|
42
|
+
}, [player, entry]);
|
|
43
|
+
|
|
44
|
+
const [isRestricted, setIsRestricted] = useState<boolean>(
|
|
45
|
+
isConnectionRestricted
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!isConnectionRestricted) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const stopPlayer = () => {
|
|
54
|
+
log_info(
|
|
55
|
+
"Stopping player due to mobile restriction, connection_restricted: true"
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
player?.close();
|
|
59
|
+
|
|
60
|
+
dialogVisibleRef.current = true;
|
|
61
|
+
|
|
62
|
+
showAlertDialog({
|
|
63
|
+
title:
|
|
64
|
+
pluginConfiguration?.mobile_connection_restricted_alert_title ||
|
|
65
|
+
"Restricted Connection Type",
|
|
66
|
+
message:
|
|
67
|
+
pluginConfiguration?.mobile_connection_restricted_alert_message ||
|
|
68
|
+
"This content can only be viewed over a Wi-Fi or LAN network.",
|
|
69
|
+
okButtonText: theme.ok_button || "OK",
|
|
70
|
+
completion: () => {
|
|
71
|
+
dialogVisibleRef.current = false;
|
|
72
|
+
|
|
73
|
+
close();
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return NetInfo.addEventListener((state) => {
|
|
79
|
+
if (state.type === "cellular") {
|
|
80
|
+
setIsRestricted(true);
|
|
81
|
+
|
|
82
|
+
if (dialogVisibleRef.current) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
stopPlayer();
|
|
87
|
+
} else {
|
|
88
|
+
setIsRestricted(false);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}, [
|
|
92
|
+
close,
|
|
93
|
+
entry?.extensions?.connection_restricted,
|
|
94
|
+
pluginConfiguration,
|
|
95
|
+
player,
|
|
96
|
+
theme.ok_button,
|
|
97
|
+
isConnectionRestricted,
|
|
98
|
+
]);
|
|
99
|
+
|
|
100
|
+
return { isRestricted };
|
|
101
|
+
};
|
|
@@ -2,12 +2,6 @@ import React, { PropsWithChildren } from "react";
|
|
|
2
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";
|
|
11
5
|
|
|
12
6
|
type Props = PropsWithChildren<{
|
|
13
7
|
entry: ZappEntry;
|
|
@@ -25,30 +19,17 @@ const PlayerImageBackgroundComponent = ({
|
|
|
25
19
|
style,
|
|
26
20
|
imageStyle,
|
|
27
21
|
imageKey,
|
|
28
|
-
defaultImageDimensions,
|
|
29
22
|
}: Props) => {
|
|
30
23
|
const source = React.useMemo(
|
|
31
24
|
() => ({ uri: imageSrcFromMediaItem(entry, [imageKey]) }),
|
|
32
25
|
[imageKey, entry]
|
|
33
26
|
);
|
|
34
27
|
|
|
35
|
-
const { playerAnimationState } = useModalAnimationContext();
|
|
36
|
-
|
|
37
28
|
if (!source) return <>{children}</>;
|
|
38
29
|
|
|
39
30
|
return (
|
|
40
|
-
<View
|
|
41
|
-
style={
|
|
42
|
-
playerAnimationState === PlayerAnimationStateEnum.maximize
|
|
43
|
-
? defaultImageDimensions
|
|
44
|
-
: style
|
|
45
|
-
}
|
|
46
|
-
>
|
|
47
|
-
<AnimationComponent
|
|
48
|
-
style={style}
|
|
49
|
-
animationType={ComponentAnimationType.player}
|
|
50
|
-
additionalData={defaultImageDimensions}
|
|
51
|
-
>
|
|
31
|
+
<View style={style}>
|
|
32
|
+
<View style={style}>
|
|
52
33
|
<ImageBackground
|
|
53
34
|
resizeMode="cover"
|
|
54
35
|
style={imageSize}
|
|
@@ -57,7 +38,7 @@ const PlayerImageBackgroundComponent = ({
|
|
|
57
38
|
>
|
|
58
39
|
{children}
|
|
59
40
|
</ImageBackground>
|
|
60
|
-
</
|
|
41
|
+
</View>
|
|
61
42
|
</View>
|
|
62
43
|
);
|
|
63
44
|
};
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Text } from "react-native";
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import { mergeRight } from "@applicaster/zapp-react-native-utils/utils";
|
|
6
7
|
|
|
7
8
|
import { GeneralContentScreen } from "../../GeneralContentScreen";
|
|
8
9
|
import { ScreenResolver } from "@applicaster/zapp-react-native-ui-components/Components/ScreenResolver";
|
|
@@ -13,6 +14,8 @@ import {
|
|
|
13
14
|
} from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
14
15
|
import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks/state";
|
|
15
16
|
|
|
17
|
+
import { toStringOrEmpty } from "./utils";
|
|
18
|
+
|
|
16
19
|
type Props = {
|
|
17
20
|
screenId: string;
|
|
18
21
|
screenData: ZappRiver | ZappEntry;
|
|
@@ -24,6 +27,7 @@ type Props = {
|
|
|
24
27
|
isInsideContainer?: boolean;
|
|
25
28
|
extraAnchorPointYOffset: number;
|
|
26
29
|
river?: ZappRiver | ZappEntry;
|
|
30
|
+
groupId: string;
|
|
27
31
|
};
|
|
28
32
|
|
|
29
33
|
export const River = (props: Props) => {
|
|
@@ -35,6 +39,7 @@ export const River = (props: Props) => {
|
|
|
35
39
|
componentsMapExtraProps,
|
|
36
40
|
isInsideContainer,
|
|
37
41
|
extraAnchorPointYOffset,
|
|
42
|
+
groupId,
|
|
38
43
|
} = props;
|
|
39
44
|
|
|
40
45
|
const { title: screenTitle, summary: screenSummary } = useNavbarState();
|
|
@@ -51,28 +56,41 @@ export const River = (props: Props) => {
|
|
|
51
56
|
[screenId]
|
|
52
57
|
);
|
|
53
58
|
|
|
54
|
-
const
|
|
55
|
-
|
|
59
|
+
const screenResolverData = React.useMemo(() => {
|
|
60
|
+
const extraData = mergeRight(extraProps, screenResolverExtraProps);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
extraData,
|
|
64
|
+
screenData: mergeRight(river, { groupId: extraData?.groupId }),
|
|
65
|
+
componentsMapExtraProps: mergeRight(componentsMapExtraProps, { groupId }),
|
|
66
|
+
};
|
|
67
|
+
}, [
|
|
68
|
+
extraProps,
|
|
69
|
+
screenResolverExtraProps,
|
|
70
|
+
river,
|
|
71
|
+
componentsMapExtraProps,
|
|
72
|
+
groupId,
|
|
73
|
+
]);
|
|
56
74
|
|
|
57
75
|
React.useEffect(() => {
|
|
58
76
|
if (!isInsideContainer) {
|
|
59
|
-
setScreenTitle(
|
|
60
|
-
setScreenSummary(
|
|
77
|
+
setScreenTitle(toStringOrEmpty(screenData?.title));
|
|
78
|
+
setScreenSummary(toStringOrEmpty(screenData?.summary));
|
|
61
79
|
}
|
|
62
80
|
}, [screenData.id]);
|
|
63
81
|
|
|
64
82
|
React.useEffect(() => {
|
|
65
83
|
if (feedData && !isInsideContainer) {
|
|
66
84
|
if (feedData.title && feedData.title !== screenTitle) {
|
|
67
|
-
setScreenTitle(
|
|
85
|
+
setScreenTitle(toStringOrEmpty(feedData.title));
|
|
68
86
|
}
|
|
69
87
|
|
|
70
88
|
if (feedData.summary && feedData.summary !== screenSummary) {
|
|
71
|
-
setScreenSummary(
|
|
89
|
+
setScreenSummary(toStringOrEmpty(feedData.summary));
|
|
72
90
|
}
|
|
73
91
|
} else {
|
|
74
|
-
setScreenTitle(
|
|
75
|
-
setScreenSummary(
|
|
92
|
+
setScreenTitle(toStringOrEmpty(screenData?.title));
|
|
93
|
+
setScreenSummary(toStringOrEmpty(screenData?.summary));
|
|
76
94
|
}
|
|
77
95
|
}, [feedData, screenData, screenTitle, screenSummary]);
|
|
78
96
|
|
|
@@ -86,15 +104,13 @@ export const River = (props: Props) => {
|
|
|
86
104
|
}
|
|
87
105
|
|
|
88
106
|
if (river.type !== "general_content") {
|
|
89
|
-
const extraData = { ...R.mergeRight(extraProps, screenResolverExtraProps) };
|
|
90
|
-
|
|
91
107
|
return (
|
|
92
108
|
<ScreenResolver
|
|
93
109
|
screenType={river.type}
|
|
94
110
|
screenId={screenId}
|
|
95
|
-
screenData={
|
|
96
|
-
componentsMapExtraProps={componentsMapExtraProps}
|
|
97
|
-
{...extraData}
|
|
111
|
+
screenData={screenResolverData.screenData}
|
|
112
|
+
componentsMapExtraProps={screenResolverData.componentsMapExtraProps}
|
|
113
|
+
{...screenResolverData.extraData}
|
|
98
114
|
/>
|
|
99
115
|
);
|
|
100
116
|
}
|
|
@@ -106,6 +122,7 @@ export const River = (props: Props) => {
|
|
|
106
122
|
isScreenWrappedInContainer={isInsideContainer}
|
|
107
123
|
extraAnchorPointYOffset={extraAnchorPointYOffset}
|
|
108
124
|
componentsMapExtraProps={componentsMapExtraProps}
|
|
125
|
+
groupId={groupId}
|
|
109
126
|
/>
|
|
110
127
|
);
|
|
111
128
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { compose } from "
|
|
1
|
+
import { compose, identity } from "@applicaster/zapp-react-native-utils/utils";
|
|
2
|
+
import { isTvOSPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
3
|
+
|
|
2
4
|
import { River as RiverComponent } from "./River";
|
|
3
|
-
import { withTvEventHandler } from "./withTVEventHandler";
|
|
4
5
|
import { withComponentsMapOffsetContext } from "../../../Contexts/ComponentsMapOffsetContext";
|
|
5
6
|
import { withRiverDataLoader } from "./withRiverDataLoader";
|
|
7
|
+
import { withFocusableGroupForContent } from "./withFocusableGroupForContent";
|
|
8
|
+
|
|
9
|
+
const isTVOS = isTvOSPlatform();
|
|
6
10
|
|
|
7
11
|
export const River = compose(
|
|
8
|
-
withTvEventHandler,
|
|
9
12
|
withComponentsMapOffsetContext,
|
|
10
|
-
withRiverDataLoader
|
|
13
|
+
withRiverDataLoader,
|
|
14
|
+
isTVOS ? withFocusableGroupForContent : identity
|
|
11
15
|
)(RiverComponent);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { toStringOrEmpty } from "..";
|
|
2
|
+
|
|
3
|
+
describe("toStringOrEmpty", () => {
|
|
4
|
+
test("returns empty string for undefined", () => {
|
|
5
|
+
expect(toStringOrEmpty(undefined)).toBe("");
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test("returns empty string for null", () => {
|
|
9
|
+
expect(toStringOrEmpty(null)).toBe("");
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("converts number to string", () => {
|
|
13
|
+
expect(toStringOrEmpty(0)).toBe("0");
|
|
14
|
+
expect(toStringOrEmpty(123)).toBe("123");
|
|
15
|
+
expect(toStringOrEmpty(-42)).toBe("-42");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("returns string as is", () => {
|
|
19
|
+
expect(toStringOrEmpty("hello")).toBe("hello");
|
|
20
|
+
expect(toStringOrEmpty("")).toBe("");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("works with numeric strings", () => {
|
|
24
|
+
expect(toStringOrEmpty("123")).toBe("123");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("does not throw on falsy values like 0", () => {
|
|
28
|
+
expect(toStringOrEmpty(0)).toBe("0");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { FocusableGroup } from "@applicaster/zapp-react-native-ui-components/Components/FocusableGroup";
|
|
5
|
+
import { riverFocusManager } from "@applicaster/zapp-react-native-utils/appUtils/RiverFocusManager";
|
|
6
|
+
|
|
7
|
+
import { topMenuLayoutChange$ } from "@applicaster/zapp-react-native-tvos-app/Layout/topMenu";
|
|
8
|
+
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
flexOne: {
|
|
11
|
+
flex: 1,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const withFocusableGroupForContent = (Component) => {
|
|
16
|
+
return function WithFocusableGroupForContent(props) {
|
|
17
|
+
const { screenId, isInsideContainer } = props;
|
|
18
|
+
|
|
19
|
+
const [topMenuHeight, setTopMenuHeight] = React.useState(0);
|
|
20
|
+
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
const subscription = topMenuLayoutChange$.subscribe((layout) => {
|
|
23
|
+
setTopMenuHeight(layout.height);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return () => {
|
|
27
|
+
subscription.unsubscribe();
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
const focusableId = React.useMemo(
|
|
32
|
+
() =>
|
|
33
|
+
riverFocusManager.screenFocusableGroupId({
|
|
34
|
+
screenId,
|
|
35
|
+
isInsideContainer,
|
|
36
|
+
}),
|
|
37
|
+
[screenId, isInsideContainer]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (isInsideContainer) {
|
|
41
|
+
return <Component {...props} />;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<FocusableGroup
|
|
46
|
+
key={focusableId}
|
|
47
|
+
id={focusableId}
|
|
48
|
+
// The top menu is rendered in its own FocusableGroup, anchored at the top of the screen.
|
|
49
|
+
// When the "content" FocusableGroup starts at y = 0 as well, the two groups visually overlap.
|
|
50
|
+
// On TvOS platform this overlap can confuse the focus engine, because the focusable bounds of
|
|
51
|
+
// the top-menu group and the content group intersect, leading to erratic navigation between
|
|
52
|
+
// the menu and the content (e.g. unexpected jumps or focus getting "stuck").
|
|
53
|
+
//
|
|
54
|
+
// To avoid this, we shift the entire content FocusableGroup down by the dynamic top menu
|
|
55
|
+
// height (marginTop: topMenuHeight). This separates the focus regions of the two groups in
|
|
56
|
+
// focus space, so they no longer intersect.
|
|
57
|
+
//
|
|
58
|
+
// The inner <View> below then applies the inverse margin (marginTop: -topMenuHeight) so that
|
|
59
|
+
// the actual visual position of the content on screen does not change; only the focusable
|
|
60
|
+
// bounds of the outer group are offset.
|
|
61
|
+
style={[styles.flexOne, { marginTop: topMenuHeight }]}
|
|
62
|
+
// this group does not have parent
|
|
63
|
+
groupId={undefined}
|
|
64
|
+
>
|
|
65
|
+
<View style={[styles.flexOne, { marginTop: -1 * topMenuHeight }]}>
|
|
66
|
+
<Component {...props} groupId={focusableId} />
|
|
67
|
+
</View>
|
|
68
|
+
</FocusableGroup>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
};
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
setFocusOnMenu,
|
|
11
11
|
} from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux";
|
|
12
12
|
|
|
13
|
+
import { waitUntilScreenRevealManagerIsReady } from "@applicaster/zapp-react-native-ui-components/Components/ScreenRevealManager/utils";
|
|
14
|
+
|
|
13
15
|
type Return =
|
|
14
16
|
| {
|
|
15
17
|
onContent: true;
|
|
@@ -57,14 +59,22 @@ export const useInitialFocus = (): void => {
|
|
|
57
59
|
React.useEffect(() => {
|
|
58
60
|
const initialFocus = getInitialFocus(focusOnContent, isNavBarVisible);
|
|
59
61
|
|
|
60
|
-
if (initialFocus.
|
|
61
|
-
|
|
62
|
+
if (initialFocus.onMenu) {
|
|
63
|
+
setFocusOnMenu(currentRoute);
|
|
62
64
|
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
if (initialFocus.
|
|
67
|
-
|
|
68
|
+
if (initialFocus.onContent) {
|
|
69
|
+
const subscription = waitUntilScreenRevealManagerIsReady().subscribe(
|
|
70
|
+
() => {
|
|
71
|
+
setFocusOnContent(currentRoute);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return () => {
|
|
76
|
+
subscription.unsubscribe();
|
|
77
|
+
};
|
|
68
78
|
}
|
|
69
79
|
}, []);
|
|
70
80
|
};
|
|
@@ -9,9 +9,10 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
useIsScreenActive,
|
|
11
11
|
useNavigation,
|
|
12
|
+
useRivers,
|
|
12
13
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
13
14
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
14
|
-
import {
|
|
15
|
+
import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
|
|
15
16
|
import {
|
|
16
17
|
useNavbarState,
|
|
17
18
|
useScreenBackgroundColor,
|
|
@@ -102,7 +103,8 @@ export const Screen = ({ route, Components }: Props) => {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
const navigator = useNavigation();
|
|
105
|
-
const
|
|
106
|
+
const plugins = usePlugins();
|
|
107
|
+
const rivers = useRivers();
|
|
106
108
|
|
|
107
109
|
const pathAttributes = getPathAttributes({ pathname: route });
|
|
108
110
|
const routeState = navigator.getStackForPathname(route);
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
4
4
|
|
|
5
5
|
const Mocked_RouteManager = jest.fn((props) => (
|
|
6
6
|
<View testID="routeManager" {...props} />
|
|
7
7
|
));
|
|
8
8
|
|
|
9
|
-
const mock_navBarVisibleFlag = true;
|
|
10
|
-
|
|
11
|
-
const mockIsNavBarVisible = jest.fn(() => mock_navBarVisibleFlag);
|
|
12
|
-
|
|
13
9
|
const mockIsOrientationCompatible = jest.fn(() => true);
|
|
14
10
|
|
|
15
11
|
jest.mock("react-native-safe-area-context", () => ({
|
|
12
|
+
...jest.requireActual("react-native-safe-area-context"),
|
|
16
13
|
useSafeAreaInsets: () => ({ top: 44 }),
|
|
17
14
|
}));
|
|
18
15
|
|
|
@@ -35,12 +32,14 @@ jest.mock(
|
|
|
35
32
|
);
|
|
36
33
|
|
|
37
34
|
jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils", () => ({
|
|
35
|
+
...jest.requireActual("@applicaster/zapp-react-native-utils/analyticsUtils"),
|
|
38
36
|
useAnalytics: jest.fn(() => ({
|
|
39
37
|
sendScreenEvent: jest.fn(),
|
|
40
38
|
})),
|
|
41
39
|
}));
|
|
42
40
|
|
|
43
41
|
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
42
|
+
...jest.requireActual("@applicaster/zapp-react-native-utils/theme"),
|
|
44
43
|
useTheme: jest.fn(() => ({
|
|
45
44
|
app_background_color: "blue",
|
|
46
45
|
})),
|
|
@@ -77,21 +76,44 @@ jest.mock(
|
|
|
77
76
|
})
|
|
78
77
|
);
|
|
79
78
|
|
|
80
|
-
jest.mock(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
94
|
-
|
|
79
|
+
jest.mock(
|
|
80
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
81
|
+
() => ({
|
|
82
|
+
...jest.requireActual(
|
|
83
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
|
|
84
|
+
),
|
|
85
|
+
useNavigation: jest.fn(() => ({
|
|
86
|
+
canGoBack: () => false,
|
|
87
|
+
currentRoute: "/river/testId",
|
|
88
|
+
activeRiver: { id: "testId" },
|
|
89
|
+
screenData: { id: "testId" },
|
|
90
|
+
data: { screen: { id: "testId" } },
|
|
91
|
+
})),
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
jest.mock(
|
|
96
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
|
|
97
|
+
() => ({
|
|
98
|
+
...jest.requireActual(
|
|
99
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive"
|
|
100
|
+
),
|
|
101
|
+
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
jest.mock(
|
|
106
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
|
|
107
|
+
() => ({
|
|
108
|
+
...jest.requireActual(
|
|
109
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute"
|
|
110
|
+
),
|
|
111
|
+
useRoute: jest.fn(() => ({
|
|
112
|
+
pathname: "/river/testId",
|
|
113
|
+
screenData: { id: "testId" },
|
|
114
|
+
})),
|
|
115
|
+
})
|
|
116
|
+
);
|
|
95
117
|
|
|
96
118
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
97
119
|
...jest.requireActual("@applicaster/zapp-react-native-utils/reactHooks"),
|
|
@@ -112,26 +134,6 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
|
112
134
|
useIsTablet: jest.fn(() => false),
|
|
113
135
|
}));
|
|
114
136
|
|
|
115
|
-
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => {
|
|
116
|
-
const View = jest.requireActual("react-native").View;
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
...jest.requireActual("@applicaster/zapp-react-native-redux/hooks"),
|
|
120
|
-
usePickFromState: () => ({
|
|
121
|
-
plugins: [
|
|
122
|
-
{
|
|
123
|
-
name: "Offline Plugin",
|
|
124
|
-
identifier: "offline-experience",
|
|
125
|
-
type: "general",
|
|
126
|
-
module: {
|
|
127
|
-
OfflineFallbackScreen: ({ children }) => <View>{children}</View>, // eslint-disable-line
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
}),
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
|
|
135
137
|
const {
|
|
136
138
|
allowedOrientationsForScreen,
|
|
137
139
|
getOrientation,
|
|
@@ -151,6 +153,19 @@ const screenProps = {
|
|
|
151
153
|
|
|
152
154
|
const { Screen } = require("..");
|
|
153
155
|
|
|
156
|
+
const store = {
|
|
157
|
+
plugins: [
|
|
158
|
+
{
|
|
159
|
+
name: "Offline Plugin",
|
|
160
|
+
identifier: "offline-experience",
|
|
161
|
+
type: "general",
|
|
162
|
+
module: {
|
|
163
|
+
OfflineFallbackScreen: ({ children }) => <View>{children}</View>, // eslint-disable-line
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
};
|
|
168
|
+
|
|
154
169
|
describe("<Screen Component />", () => {
|
|
155
170
|
beforeEach(() => {
|
|
156
171
|
allowedOrientationsForScreen.mockClear();
|
|
@@ -160,14 +175,22 @@ describe("<Screen Component />", () => {
|
|
|
160
175
|
|
|
161
176
|
describe("when the navbar should show", () => {
|
|
162
177
|
it("renders correctly", () => {
|
|
163
|
-
const { toJSON } =
|
|
178
|
+
const { toJSON } = renderWithProviders(
|
|
179
|
+
<Screen {...screenProps} />,
|
|
180
|
+
store
|
|
181
|
+
);
|
|
182
|
+
|
|
164
183
|
expect(toJSON()).toMatchSnapshot();
|
|
165
184
|
});
|
|
166
185
|
});
|
|
167
186
|
|
|
168
187
|
describe("when the navbar should be hidden", () => {
|
|
169
188
|
it("renders correctly", () => {
|
|
170
|
-
const { toJSON } =
|
|
189
|
+
const { toJSON } = renderWithProviders(
|
|
190
|
+
<Screen {...screenProps} />,
|
|
191
|
+
store
|
|
192
|
+
);
|
|
193
|
+
|
|
171
194
|
expect(toJSON()).toMatchSnapshot();
|
|
172
195
|
});
|
|
173
196
|
});
|