@applicaster/zapp-react-native-ui-components 12.0.0-alpha.8454200631 → 12.0.0-alpha.8521132326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/BaseFocusable/index.tsx +3 -3
- package/Components/Cell/Cell.tsx +5 -5
- package/Components/Cell/CellWithFocusable.tsx +23 -9
- package/Components/Cell/TvOSCellComponent.tsx +3 -7
- package/Components/Focusable/Focusable.tsx +6 -1
- package/Components/FocusableGroup/index.tsx +11 -2
- package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
- package/Components/Layout/TV/__tests__/index.test.tsx +19 -75
- package/Components/Layout/TV/index.tsx +0 -2
- package/Components/Layout/TV/index.web.tsx +33 -0
- package/Components/Layout/index.tsx +15 -11
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +7 -2
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
- package/Components/MasterCell/utils/index.ts +17 -30
- package/Components/Navigator/StackNavigator.tsx +54 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +8 -1
- package/Components/River/TV/River.tsx +0 -23
- package/Components/Screen/TV/hooks/index.ts +3 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
- package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
- package/Components/Screen/TV/index.web.tsx +186 -0
- package/Components/Screen/__tests__/Screen.test.tsx +3 -0
- package/Components/Screen/index.tsx +29 -1
- package/Components/ScreenResolver/index.tsx +3 -1
- package/Components/Transitioner/Transitioner.tsx +15 -29
- package/Components/VideoLive/LiveImageManager.ts +25 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +48 -38
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +40 -33
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +98 -81
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +13 -5
- package/Components/VideoModal/ModalAnimation/utils.ts +6 -4
- package/Components/VideoModal/PlayerWrapper.tsx +9 -9
- package/Components/VideoModal/VideoModal.tsx +4 -4
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +32 -12
- package/Components/VideoModal/utils.ts +5 -2
- package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
- package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
- package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
- package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
- package/Contexts/FocusableGroupContext/index.ts +7 -0
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
- package/Contexts/ScreenDataContext/index.tsx +20 -0
- package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
- package/package.json +5 -5
- package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
- package/Contexts/ScreenDataContext/index.ts +0 -3
- /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
- /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useMemo } from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
+
import validateColor from "validate-color";
|
|
3
4
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
5
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
5
6
|
|
|
@@ -9,6 +10,7 @@ import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerM
|
|
|
9
10
|
import { PushTopicManager } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
|
|
10
11
|
import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
|
|
11
12
|
import { getCellState } from "../../Cell/utils";
|
|
13
|
+
import { getColorFromData } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
12
14
|
|
|
13
15
|
const hasElementSpecificViewType = (viewType) => (element) => {
|
|
14
16
|
if (R.isNil(element)) {
|
|
@@ -47,44 +49,29 @@ export const hasElementsSpecificViewType = (viewType) => (elements) => {
|
|
|
47
49
|
return R.any(hasElementSpecificViewType(viewType))(elements);
|
|
48
50
|
};
|
|
49
51
|
|
|
50
|
-
const isColorOrEmpty = (value) =>
|
|
51
|
-
value === null ||
|
|
52
|
-
value === undefined ||
|
|
53
|
-
value === "" ||
|
|
54
|
-
value.startsWith("#") ||
|
|
55
|
-
value.startsWith("rgba") ||
|
|
56
|
-
value === "transparent";
|
|
57
|
-
|
|
58
52
|
function resolveColorForProp(entry, style, colorProp) {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
const colorFromProp = style[colorProp];
|
|
54
|
+
const nestedEntryValue = R.path(colorFromProp.split("."), entry);
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
nestedEntryValue === undefined &&
|
|
58
|
+
!validateColor(colorFromProp.replace(".00", "")) // https://github.com/dreamyguy/validate-color/issues/44
|
|
59
|
+
) {
|
|
60
|
+
logWarning(colorFromProp, style, entry, nestedEntryValue);
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (nestedEntryValue === null || typeof nestedEntryValue !== "object") {
|
|
70
|
-
logWarning(colorValue, style, entry, nestedEntryValue);
|
|
71
|
-
|
|
72
|
-
return style;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
nestedEntryValue = nestedEntryValue[part];
|
|
76
|
-
}
|
|
63
|
+
const colorValue = getColorFromData({
|
|
64
|
+
data: entry,
|
|
65
|
+
valueFromLayout: colorFromProp,
|
|
66
|
+
});
|
|
77
67
|
|
|
78
|
-
if (
|
|
79
|
-
logWarning(
|
|
68
|
+
if (!colorValue) {
|
|
69
|
+
logWarning(colorProp, style, entry, colorValue);
|
|
80
70
|
|
|
81
71
|
return style;
|
|
82
72
|
}
|
|
83
73
|
|
|
84
|
-
|
|
85
|
-
style[colorProp] = nestedEntryValue;
|
|
86
|
-
|
|
87
|
-
return style;
|
|
74
|
+
return { ...style, [colorProp]: colorValue };
|
|
88
75
|
}
|
|
89
76
|
|
|
90
77
|
export function resolveColor(entry, style) {
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
import { isLast } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
12
|
+
|
|
13
|
+
type Components = {
|
|
14
|
+
NavBar: React.ComponentType<any>;
|
|
15
|
+
Background: React.ComponentType<any>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type Props = {
|
|
19
|
+
Components: Components;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const StackNavigator = ({ Components }: Props) => {
|
|
23
|
+
const { mainStack } = useNavigation();
|
|
24
|
+
|
|
25
|
+
const renderScreen = ({ route, state }, index) => {
|
|
26
|
+
const pathAttributes = getPathAttributes({ pathname: route });
|
|
27
|
+
|
|
28
|
+
if (isEmpty(pathAttributes)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// HACK: Adding index to route to avoid conflicts in the navigator.
|
|
33
|
+
// Startup hooks are all using PUSH navigation action to navigate, but their routes are always like root routes.
|
|
34
|
+
// This means some hooks can have the same routes, e.g., ["hooks/context-setter", "/hooks/login-plug", "hooks/context-setter"].
|
|
35
|
+
const routeId = `${route}--${index}`;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<FocusableGroup
|
|
39
|
+
id={route}
|
|
40
|
+
preferredFocus={isLast(index, mainStack.length)}
|
|
41
|
+
excludeFromFocusSearching
|
|
42
|
+
key={routeId}
|
|
43
|
+
>
|
|
44
|
+
<ScreenDataContext.Provider value={state}>
|
|
45
|
+
<PathnameContext.Provider value={route}>
|
|
46
|
+
<Screen route={route} Components={Components} />
|
|
47
|
+
</PathnameContext.Provider>
|
|
48
|
+
</ScreenDataContext.Provider>
|
|
49
|
+
</FocusableGroup>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return <>{mainStack.map(renderScreen)}</>;
|
|
54
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StackNavigator } from "./StackNavigator";
|
|
@@ -68,6 +68,7 @@ type Props = {
|
|
|
68
68
|
mode?: VideoModalMode;
|
|
69
69
|
loadPipesData: (url: string, options: {}) => void;
|
|
70
70
|
disableCastAction?: boolean;
|
|
71
|
+
groupId?: string;
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
type ScreenStyles = ZappRiver["styles"] & {
|
|
@@ -200,6 +201,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
200
201
|
style: videoStyle,
|
|
201
202
|
mode = VideoModalMode.MAXIMIZED,
|
|
202
203
|
disableCastAction = false,
|
|
204
|
+
groupId,
|
|
203
205
|
} = props;
|
|
204
206
|
|
|
205
207
|
// Hooks
|
|
@@ -249,8 +251,12 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
249
251
|
return;
|
|
250
252
|
}
|
|
251
253
|
|
|
252
|
-
navigator.goBack();
|
|
253
254
|
showNavBar(true);
|
|
255
|
+
|
|
256
|
+
// Hack to close player screen on mobile only (tv handles that in InteractionManager)
|
|
257
|
+
if (!isTV()) {
|
|
258
|
+
navigator.goBack();
|
|
259
|
+
}
|
|
254
260
|
}, [isModal, navigator.goBack, showNavBar]);
|
|
255
261
|
|
|
256
262
|
const playEntry = (entry) => navigator.replaceTop(entry, { mode });
|
|
@@ -629,6 +635,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
629
635
|
style={styles.focusableGroup}
|
|
630
636
|
preferredFocus
|
|
631
637
|
shouldUsePreferredFocus
|
|
638
|
+
groupId={groupId}
|
|
632
639
|
>
|
|
633
640
|
{/* Video player and components */}
|
|
634
641
|
<View
|
|
@@ -7,14 +7,10 @@ import * as R from "ramda";
|
|
|
7
7
|
import {
|
|
8
8
|
useFeedLoader,
|
|
9
9
|
useLayoutVersion,
|
|
10
|
-
useNavigationPluginData,
|
|
11
10
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
11
|
import { GeneralContentScreen } from "../../GeneralContentScreen";
|
|
13
12
|
import { ScreenResolver } from "@applicaster/zapp-react-native-ui-components/Components/ScreenResolver";
|
|
14
13
|
import { utilsLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
15
|
-
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
16
|
-
import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
17
|
-
import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
18
14
|
import {
|
|
19
15
|
useNavbarState,
|
|
20
16
|
useSetNavbarState,
|
|
@@ -51,8 +47,6 @@ export const River = (props: Props) => {
|
|
|
51
47
|
const { setTitle: setScreenTitle, setSummary: setScreenSummary } =
|
|
52
48
|
useSetNavbarState();
|
|
53
49
|
|
|
54
|
-
const navigationPluginData = useNavigationPluginData();
|
|
55
|
-
|
|
56
50
|
const rivers = useRivers();
|
|
57
51
|
const isV2 = useLayoutVersion({ isV2: true });
|
|
58
52
|
|
|
@@ -99,23 +93,6 @@ export const River = (props: Props) => {
|
|
|
99
93
|
}
|
|
100
94
|
}, [feedData, screenData, screenTitle, screenSummary]);
|
|
101
95
|
|
|
102
|
-
React.useEffect(() => {
|
|
103
|
-
if (
|
|
104
|
-
isWeb() &&
|
|
105
|
-
toBooleanWithDefaultFalse(
|
|
106
|
-
navigationPluginData?.rules?.focus_on_content
|
|
107
|
-
) &&
|
|
108
|
-
river &&
|
|
109
|
-
river.type !== "general_content"
|
|
110
|
-
) {
|
|
111
|
-
const groupId = R.pathOr("river", ["groupId"], componentsMapExtraProps);
|
|
112
|
-
|
|
113
|
-
focusManager.setupInitialFocus(groupId, true);
|
|
114
|
-
focusManager.setInitialFocus();
|
|
115
|
-
focusManager.enableAutomaticFocus();
|
|
116
|
-
}
|
|
117
|
-
}, [river, componentsMapExtraProps]);
|
|
118
|
-
|
|
119
96
|
if (!river) {
|
|
120
97
|
utilsLogger.error({
|
|
121
98
|
message: `River ${screenData.id} not found!`,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
useNavigationPluginData,
|
|
4
|
+
useIsNavBarVisible,
|
|
5
|
+
useRoute,
|
|
6
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
7
|
+
import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
8
|
+
import {
|
|
9
|
+
setFocusOnContent,
|
|
10
|
+
setFocusOnMenu,
|
|
11
|
+
} from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux";
|
|
12
|
+
|
|
13
|
+
type Return =
|
|
14
|
+
| {
|
|
15
|
+
onContent: true;
|
|
16
|
+
onMenu: false;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
onContent: false;
|
|
20
|
+
onMenu: true;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getInitialFocus = (focusOnContent, isNavBarVisible): Return => {
|
|
24
|
+
if (focusOnContent) {
|
|
25
|
+
return {
|
|
26
|
+
onContent: true,
|
|
27
|
+
onMenu: false,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!focusOnContent && isNavBarVisible) {
|
|
32
|
+
// put focus on navbar
|
|
33
|
+
return {
|
|
34
|
+
onContent: false,
|
|
35
|
+
onMenu: true,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// we don't have navbar, put focus on content anyway
|
|
40
|
+
return {
|
|
41
|
+
onContent: true,
|
|
42
|
+
onMenu: false,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const useInitialFocus = (): void => {
|
|
47
|
+
const navigationPluginData = useNavigationPluginData();
|
|
48
|
+
|
|
49
|
+
const focusOnContent = toBooleanWithDefaultFalse(
|
|
50
|
+
navigationPluginData?.rules?.focus_on_content
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const isNavBarVisible = useIsNavBarVisible();
|
|
54
|
+
|
|
55
|
+
const { pathname: currentRoute } = useRoute();
|
|
56
|
+
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
const initialFocus = getInitialFocus(focusOnContent, isNavBarVisible);
|
|
59
|
+
|
|
60
|
+
if (initialFocus.onContent) {
|
|
61
|
+
setFocusOnContent(currentRoute);
|
|
62
|
+
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (initialFocus.onMenu) {
|
|
67
|
+
setFocusOnMenu(currentRoute);
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { isNil } from "ramda";
|
|
3
|
+
import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
4
|
+
import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
|
|
5
|
+
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
6
|
+
|
|
7
|
+
export const useRestoreFocus = (): void => {
|
|
8
|
+
const isScreenActive = useIsScreenActive();
|
|
9
|
+
const previousIsScreenActive = usePrevious(isScreenActive);
|
|
10
|
+
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
if (isNil(previousIsScreenActive)) {
|
|
13
|
+
// it's initial mounting of the screen, do nothing here
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!previousIsScreenActive && isScreenActive) {
|
|
18
|
+
// restore focus when we go back from next screen
|
|
19
|
+
focusManager.setInitialFocus();
|
|
20
|
+
}
|
|
21
|
+
}, [previousIsScreenActive, isScreenActive]);
|
|
22
|
+
};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { last, pathOr } from "ramda";
|
|
3
|
+
import { View, StyleSheet } from "react-native";
|
|
4
|
+
import {
|
|
5
|
+
getNavigationProps,
|
|
6
|
+
getPathAttributes,
|
|
7
|
+
resolveNavigationPlugin,
|
|
8
|
+
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
9
|
+
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
10
|
+
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
11
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
12
|
+
import { useScreenBackgroundColor } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
13
|
+
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
14
|
+
|
|
15
|
+
import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
|
|
16
|
+
import { ScreenResolver } from "../../ScreenResolver";
|
|
17
|
+
import { useInitialFocus, useRestoreFocus } from "./hooks";
|
|
18
|
+
|
|
19
|
+
const styles = StyleSheet.create({
|
|
20
|
+
container: {
|
|
21
|
+
position: "absolute",
|
|
22
|
+
top: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
right: 0,
|
|
25
|
+
bottom: 0,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
type Components = {
|
|
30
|
+
NavBar: React.ComponentType<any>;
|
|
31
|
+
Background: React.ComponentType<any>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type Props = {
|
|
35
|
+
route: string;
|
|
36
|
+
Components: Components;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const getPluginType = pathOr("unknown_plugin_type", [
|
|
40
|
+
"state",
|
|
41
|
+
"screen",
|
|
42
|
+
"plugin_type",
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
export const isPresentFullScreen = pathOr(false, [
|
|
46
|
+
"state",
|
|
47
|
+
"screen",
|
|
48
|
+
"module",
|
|
49
|
+
"presentFullScreen",
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
const isPlayerPlugin = (routeState): boolean =>
|
|
53
|
+
getPluginType(routeState) === "player";
|
|
54
|
+
|
|
55
|
+
const isLoginPlugin = (routeState): boolean =>
|
|
56
|
+
getPluginType(routeState) === "login";
|
|
57
|
+
|
|
58
|
+
const getActiveRiver = ({
|
|
59
|
+
screenId,
|
|
60
|
+
screenType,
|
|
61
|
+
routeState,
|
|
62
|
+
rivers,
|
|
63
|
+
fallbackActiveRiver,
|
|
64
|
+
}) => {
|
|
65
|
+
if (rivers[screenId]) {
|
|
66
|
+
if (screenType === "hooks") {
|
|
67
|
+
const navigations = routeState?.state?.entry?.payload?.navigations;
|
|
68
|
+
|
|
69
|
+
if (navigations) {
|
|
70
|
+
return routeState.state.entry.payload;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return routeState?.state?.screen;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// screenId is not presented into rivers, use fallback instead
|
|
78
|
+
return fallbackActiveRiver;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const getNavigations = ({
|
|
82
|
+
screenId,
|
|
83
|
+
screenType,
|
|
84
|
+
routeState,
|
|
85
|
+
rivers,
|
|
86
|
+
fallbackNavigations,
|
|
87
|
+
}) => {
|
|
88
|
+
if (rivers[screenId]) {
|
|
89
|
+
// river presents
|
|
90
|
+
if (screenType === "hooks") {
|
|
91
|
+
const navigations = routeState?.state?.entry?.payload?.navigations;
|
|
92
|
+
|
|
93
|
+
if (navigations) {
|
|
94
|
+
return navigations;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return routeState?.state?.screen?.navigations;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// screenId is not presented into rivers, use fallback instead
|
|
102
|
+
return fallbackNavigations;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const Screen = ({ route, Components }: Props) => {
|
|
106
|
+
if (isNilOrEmpty(route)) {
|
|
107
|
+
throw Error("Required props: route is missing");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const navigator = useNavigation();
|
|
111
|
+
const { plugins = [], rivers = [] } = usePickFromState(["plugins", "rivers"]);
|
|
112
|
+
|
|
113
|
+
const pathAttributes = getPathAttributes({ pathname: route });
|
|
114
|
+
const routeState = navigator.getStackForPathname(route);
|
|
115
|
+
|
|
116
|
+
const { screenType, screenId } = last(pathAttributes);
|
|
117
|
+
|
|
118
|
+
const backgroundColor = useScreenBackgroundColor(screenId);
|
|
119
|
+
|
|
120
|
+
useInitialFocus();
|
|
121
|
+
useRestoreFocus();
|
|
122
|
+
|
|
123
|
+
const activeRiver = getActiveRiver({
|
|
124
|
+
screenId,
|
|
125
|
+
screenType,
|
|
126
|
+
routeState,
|
|
127
|
+
rivers,
|
|
128
|
+
fallbackActiveRiver: navigator.activeRiver,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const navigationProps = getNavigationProps({
|
|
132
|
+
navigator: {
|
|
133
|
+
// @ts-ignore
|
|
134
|
+
activeRiver,
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
screenTitle: routeState.state.entry?.title || routeState.screen?.name,
|
|
137
|
+
},
|
|
138
|
+
category: "menu",
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const navigations = getNavigations({
|
|
142
|
+
screenId,
|
|
143
|
+
screenType,
|
|
144
|
+
routeState,
|
|
145
|
+
rivers,
|
|
146
|
+
fallbackNavigations: navigator.activeRiver.navigations,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const menuPlugin = resolveNavigationPlugin({
|
|
150
|
+
category: "menu",
|
|
151
|
+
navigations,
|
|
152
|
+
plugins,
|
|
153
|
+
}) as QuickBrickPlugin;
|
|
154
|
+
|
|
155
|
+
const NavBar = (Components.NavBar ||
|
|
156
|
+
menuPlugin.module) as React.ComponentType<any>;
|
|
157
|
+
|
|
158
|
+
const isPlayer = isPlayerPlugin(routeState);
|
|
159
|
+
const isLogin = isLoginPlugin(routeState);
|
|
160
|
+
const isFullScreen = isPresentFullScreen(routeState);
|
|
161
|
+
|
|
162
|
+
const isNavBarVisible = !isPlayer && !isLogin && !isFullScreen;
|
|
163
|
+
|
|
164
|
+
const screenData =
|
|
165
|
+
screenType === "hooks" || isPlayer
|
|
166
|
+
? routeState?.state?.entry
|
|
167
|
+
: routeState?.state?.screen;
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<View style={[styles.container, { backgroundColor }]}>
|
|
171
|
+
<NavBarContainer isVisible={isNavBarVisible} onReady={noop}>
|
|
172
|
+
<NavBar
|
|
173
|
+
isVisible={isNavBarVisible}
|
|
174
|
+
menuPlugin={menuPlugin}
|
|
175
|
+
navigationProps={navigationProps}
|
|
176
|
+
/>
|
|
177
|
+
</NavBarContainer>
|
|
178
|
+
<ScreenResolver
|
|
179
|
+
screenType={screenType}
|
|
180
|
+
screenId={screenId}
|
|
181
|
+
screenData={screenData}
|
|
182
|
+
groupId={route}
|
|
183
|
+
/>
|
|
184
|
+
</View>
|
|
185
|
+
);
|
|
186
|
+
};
|
|
@@ -10,6 +10,8 @@ const mock_navBarVisibleFlag = true;
|
|
|
10
10
|
|
|
11
11
|
const mockIsNavBarVisible = jest.fn(() => mock_navBarVisibleFlag);
|
|
12
12
|
|
|
13
|
+
const mockIsOrientationCompatible = jest.fn(() => true);
|
|
14
|
+
|
|
13
15
|
jest.mock("react-native-safe-area-context", () => ({
|
|
14
16
|
useSafeAreaInsets: () => ({ top: 44 }),
|
|
15
17
|
}));
|
|
@@ -21,6 +23,7 @@ jest.mock("../../RouteManager", () => ({
|
|
|
21
23
|
jest.mock(
|
|
22
24
|
"@applicaster/zapp-react-native-utils/appUtils/orientationHelper",
|
|
23
25
|
() => ({
|
|
26
|
+
isOrientationCompatible: mockIsOrientationCompatible,
|
|
24
27
|
allowedOrientationsForScreen: jest.fn(),
|
|
25
28
|
getOrientation: jest.fn(),
|
|
26
29
|
getScreenOrientation: jest.fn(),
|
|
@@ -3,6 +3,10 @@ import React from "react";
|
|
|
3
3
|
import * as R from "ramda";
|
|
4
4
|
import { View } from "react-native";
|
|
5
5
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
6
|
+
import {
|
|
7
|
+
isOrientationCompatible,
|
|
8
|
+
useGetScreenOrientation,
|
|
9
|
+
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
6
10
|
|
|
7
11
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
8
12
|
import { getComponentModule } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
@@ -69,7 +73,11 @@ export function Screen(_props: Props) {
|
|
|
69
73
|
const { backgroundColor } = useScreenConfiguration(currentScreenData.id);
|
|
70
74
|
const insets = useSafeAreaInsets();
|
|
71
75
|
|
|
72
|
-
const {
|
|
76
|
+
const {
|
|
77
|
+
width: screenWidth,
|
|
78
|
+
height,
|
|
79
|
+
deviceInfo,
|
|
80
|
+
} = useDimensions("screen", {
|
|
73
81
|
fullDimensions: true,
|
|
74
82
|
});
|
|
75
83
|
|
|
@@ -81,6 +89,13 @@ export function Screen(_props: Props) {
|
|
|
81
89
|
|
|
82
90
|
const { title } = useNavbarState();
|
|
83
91
|
|
|
92
|
+
const isTablet = deviceInfo?.isTablet;
|
|
93
|
+
|
|
94
|
+
const { appData } = usePickFromState(["appData"]);
|
|
95
|
+
const isTabletPortrait = appData?.isTabletPortrait;
|
|
96
|
+
|
|
97
|
+
const layoutData = { isTablet, isTabletPortrait, width: screenWidth, height };
|
|
98
|
+
|
|
84
99
|
const hasMenu =
|
|
85
100
|
resolveNavigationPlugin({
|
|
86
101
|
category: "menu",
|
|
@@ -143,6 +158,19 @@ export function Screen(_props: Props) {
|
|
|
143
158
|
|
|
144
159
|
useScreenOrientationHandler({ screenData: targetScreenData });
|
|
145
160
|
|
|
161
|
+
const orientation = useGetScreenOrientation(targetScreenData);
|
|
162
|
+
|
|
163
|
+
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
164
|
+
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
165
|
+
if (
|
|
166
|
+
!isOrientationCompatible({
|
|
167
|
+
orientation,
|
|
168
|
+
layoutData,
|
|
169
|
+
})
|
|
170
|
+
) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
146
174
|
return (
|
|
147
175
|
<ScreenContextProvider pathname={pathname}>
|
|
148
176
|
<View style={style}>
|
|
@@ -32,12 +32,13 @@ type Props = {
|
|
|
32
32
|
nextFocusLeft?: React.Ref<any>;
|
|
33
33
|
nextFocusUp?: React.Ref<any>;
|
|
34
34
|
};
|
|
35
|
+
groupId?: string;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
export function ScreenResolverComponent(props: Props) {
|
|
38
39
|
useScreenAnalytics(props);
|
|
39
40
|
|
|
40
|
-
const { screenType, screenId, screenData } = props;
|
|
41
|
+
const { screenType, screenId, screenData, groupId } = props;
|
|
41
42
|
|
|
42
43
|
const { hookPlugin } = screenData || {};
|
|
43
44
|
|
|
@@ -81,6 +82,7 @@ export function ScreenResolverComponent(props: Props) {
|
|
|
81
82
|
item={screenData}
|
|
82
83
|
mode={mode === "PIP" ? "PIP" : "FULLSCREEN"}
|
|
83
84
|
isModal={false}
|
|
85
|
+
groupId={groupId}
|
|
84
86
|
/>
|
|
85
87
|
);
|
|
86
88
|
}
|
|
@@ -4,10 +4,7 @@ import * as R from "ramda";
|
|
|
4
4
|
|
|
5
5
|
import { AnimationManager } from "./AnimationManager";
|
|
6
6
|
import { Scene } from "./Scene";
|
|
7
|
-
|
|
8
|
-
getScreenOrientation,
|
|
9
|
-
isOrientationCompatible,
|
|
10
|
-
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
7
|
+
|
|
11
8
|
import {
|
|
12
9
|
getSceneByRoute,
|
|
13
10
|
shouldSkipAnimationForPreviousWebViewScene,
|
|
@@ -277,36 +274,25 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
277
274
|
// so only a single scene should be rendered,
|
|
278
275
|
// instead of dangerous nulls or duplicates.
|
|
279
276
|
renderSingleScene({ scenes, to }) {
|
|
280
|
-
const { contentStyle
|
|
277
|
+
const { contentStyle } = this.props;
|
|
281
278
|
const screenData = this.props.children.props.screenData;
|
|
282
279
|
const pathname = scenes[to.index].key;
|
|
283
280
|
|
|
284
|
-
const orientation = getScreenOrientation({
|
|
285
|
-
screenData,
|
|
286
|
-
layoutData,
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
290
|
-
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
291
281
|
return (
|
|
292
282
|
<View style={styles.container}>
|
|
293
|
-
{scenes[to.index] &&
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
>
|
|
307
|
-
{scenes[to.index].children}
|
|
308
|
-
</Scene>
|
|
309
|
-
)}
|
|
283
|
+
{scenes[to.index] && (
|
|
284
|
+
<Scene
|
|
285
|
+
{...{ style: to.style }}
|
|
286
|
+
pathname={pathname}
|
|
287
|
+
isActive={pathname === this.props.navigator.currentRoute}
|
|
288
|
+
contentStyle={contentStyle}
|
|
289
|
+
key={scenes[to.index].key}
|
|
290
|
+
screenUniqueId={scenes[to.index].screenUniqueId}
|
|
291
|
+
screenData={screenData}
|
|
292
|
+
>
|
|
293
|
+
{scenes[to.index].children}
|
|
294
|
+
</Scene>
|
|
295
|
+
)}
|
|
310
296
|
</View>
|
|
311
297
|
);
|
|
312
298
|
}
|