@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5208030571 → 12.0.0-alpha.5230293331
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 +30 -13
- package/Components/Cell/CellWithFocusable.tsx +6 -4
- package/Components/Cell/TvOSCellComponent.tsx +3 -7
- package/Components/Focusable/Focusable.tsx +6 -1
- package/Components/FocusableGroup/index.tsx +10 -2
- package/Components/FreezeWithCallback/Freeze.tsx +31 -0
- package/Components/FreezeWithCallback/LICENSE +21 -0
- package/Components/FreezeWithCallback/Suspender.tsx +17 -0
- package/Components/FreezeWithCallback/__tests__/index.test.tsx +170 -0
- package/Components/FreezeWithCallback/index.tsx +3 -0
- package/Components/Layout/TV/ScreenContainer.tsx +79 -5
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
- package/Components/Layout/TV/__tests__/index.test.tsx +20 -75
- package/Components/Layout/TV/index.tsx +29 -181
- package/Components/Layout/TV/index.web.tsx +33 -0
- package/Components/Layout/index.tsx +15 -11
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +86 -116
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +17 -1
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +71 -0
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +20 -0
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
- package/Components/MasterCell/DefaultComponents/index.ts +2 -0
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +7 -1
- package/Components/MasterCell/dataAdapter.ts +21 -7
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
- package/Components/MasterCell/index.tsx +5 -3
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
- package/Components/MasterCell/utils/index.ts +17 -30
- package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
- package/Components/Navigator/StackNavigator.tsx +57 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +14 -3
- package/Components/River/ComponentsMap/ComponentsMap.tsx +24 -17
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/River/TV/River.tsx +0 -22
- package/Components/RouteManager/index.tsx +2 -2
- package/Components/Screen/TV/hooks/index.ts +1 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
- package/Components/Screen/TV/index.web.tsx +85 -58
- package/Components/Screen/__tests__/Screen.test.tsx +3 -49
- package/Components/Screen/index.tsx +55 -76
- package/Components/Screen/navigationHandler.ts +6 -3
- package/Components/Screen/orientationHandler.ts +18 -7
- package/Components/Screen/utils.ts +16 -0
- package/Components/ScreenResolver/index.tsx +6 -11
- package/Components/Transitioner/Scene.tsx +39 -26
- package/Components/Transitioner/Transitioner.tsx +56 -48
- package/Components/Transitioner/__tests__/Scene.test.js +7 -0
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -4
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -0
- package/Components/VideoLive/LiveImageManager.ts +28 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +52 -24
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +26 -24
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +2 -14
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +81 -46
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +47 -33
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +129 -86
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +44 -5
- package/Components/VideoModal/ModalAnimation/utils.ts +7 -4
- package/Components/VideoModal/PlayerDetails.tsx +19 -5
- package/Components/VideoModal/PlayerWrapper.tsx +104 -67
- package/Components/VideoModal/VideoModal.tsx +27 -21
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +7 -0
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +134 -22
- package/Components/VideoModal/hooks/useModalSize.ts +10 -12
- package/Components/VideoModal/utils.ts +5 -2
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -3
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +4 -4
- package/Contexts/ConfirmDialogState/index.ts +1 -1
- 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/ScreenContext/index.tsx +2 -2
- package/Contexts/ScreenDataContext/index.tsx +20 -0
- package/const.ts +6 -0
- package/events/index.ts +1 -0
- package/index.js +3 -0
- package/package.json +5 -5
- package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
- /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
- /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
|
@@ -1,15 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { last
|
|
3
|
-
import {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { last } from "ramda";
|
|
3
|
+
import { StyleSheet, View } from "react-native";
|
|
4
4
|
import {
|
|
5
|
+
findMenuPlugin,
|
|
5
6
|
getNavigationProps,
|
|
6
7
|
getPathAttributes,
|
|
7
|
-
resolveNavigationPlugin,
|
|
8
8
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
useIsScreenActive,
|
|
11
|
+
useNavigation,
|
|
12
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
11
13
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
12
14
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
15
|
+
import {
|
|
16
|
+
useNavbarState,
|
|
17
|
+
useScreenBackgroundColor,
|
|
18
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
19
|
+
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
20
|
+
|
|
21
|
+
import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
|
|
22
|
+
import { ScreenResolver } from "../../ScreenResolver";
|
|
23
|
+
import { useInitialFocus } from "./hooks";
|
|
24
|
+
import { isPlayerPlugin } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
25
|
+
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
26
|
+
import { FreezeWithCallback } from "../../FreezeWithCallback";
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
container: {
|
|
30
|
+
position: "absolute",
|
|
31
|
+
top: 0,
|
|
32
|
+
left: 0,
|
|
33
|
+
right: 0,
|
|
34
|
+
bottom: 0,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
13
37
|
|
|
14
38
|
type Components = {
|
|
15
39
|
NavBar: React.ComponentType<any>;
|
|
@@ -21,16 +45,6 @@ type Props = {
|
|
|
21
45
|
Components: Components;
|
|
22
46
|
};
|
|
23
47
|
|
|
24
|
-
const isPlayer = (routeState): boolean => {
|
|
25
|
-
const pluginType = pathOr(
|
|
26
|
-
"unknown_plugin_type",
|
|
27
|
-
["state", "screen", "plugin_type"],
|
|
28
|
-
routeState
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
return pluginType === "player";
|
|
32
|
-
};
|
|
33
|
-
|
|
34
48
|
const getActiveRiver = ({
|
|
35
49
|
screenId,
|
|
36
50
|
screenType,
|
|
@@ -39,10 +53,15 @@ const getActiveRiver = ({
|
|
|
39
53
|
fallbackActiveRiver,
|
|
40
54
|
}) => {
|
|
41
55
|
if (rivers[screenId]) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
if (screenType === "hooks") {
|
|
57
|
+
const navigations = routeState?.state?.entry?.payload?.navigations;
|
|
58
|
+
|
|
59
|
+
if (navigations) {
|
|
60
|
+
return routeState.state.entry.payload;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return routeState?.state?.screen;
|
|
46
65
|
}
|
|
47
66
|
|
|
48
67
|
// screenId is not presented into rivers, use fallback instead
|
|
@@ -58,34 +77,37 @@ const getNavigations = ({
|
|
|
58
77
|
}) => {
|
|
59
78
|
if (rivers[screenId]) {
|
|
60
79
|
// river presents
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
if (screenType === "hooks") {
|
|
81
|
+
const navigations = routeState?.state?.entry?.payload?.navigations;
|
|
82
|
+
|
|
83
|
+
if (navigations) {
|
|
84
|
+
return navigations;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return routeState?.state?.screen?.navigations;
|
|
64
89
|
}
|
|
65
90
|
|
|
66
91
|
// screenId is not presented into rivers, use fallback instead
|
|
67
92
|
return fallbackNavigations;
|
|
68
93
|
};
|
|
69
94
|
|
|
70
|
-
export const Screen = (
|
|
71
|
-
if (
|
|
72
|
-
throw
|
|
95
|
+
export const Screen = ({ route, Components }: Props) => {
|
|
96
|
+
if (isNilOrEmpty(route)) {
|
|
97
|
+
throw Error("Required props: route is missing");
|
|
73
98
|
}
|
|
74
99
|
|
|
75
100
|
const navigator = useNavigation();
|
|
76
101
|
const { plugins = [], rivers = [] } = usePickFromState(["plugins", "rivers"]);
|
|
77
102
|
|
|
78
|
-
const pathAttributes = getPathAttributes({ pathname:
|
|
79
|
-
const routeState = navigator.getStackForPathname(
|
|
103
|
+
const pathAttributes = getPathAttributes({ pathname: route });
|
|
104
|
+
const routeState = navigator.getStackForPathname(route);
|
|
80
105
|
|
|
81
106
|
const { screenType, screenId } = last(pathAttributes);
|
|
82
107
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// route: props.route,
|
|
87
|
-
// navigator,
|
|
88
|
-
// });
|
|
108
|
+
const backgroundColor = useScreenBackgroundColor(screenId);
|
|
109
|
+
|
|
110
|
+
useInitialFocus();
|
|
89
111
|
|
|
90
112
|
const activeRiver = getActiveRiver({
|
|
91
113
|
screenId,
|
|
@@ -113,39 +135,44 @@ export const Screen = (props: Props) => {
|
|
|
113
135
|
fallbackNavigations: navigator.activeRiver.navigations,
|
|
114
136
|
});
|
|
115
137
|
|
|
116
|
-
const menuPlugin =
|
|
117
|
-
category: "menu",
|
|
118
|
-
navigations,
|
|
119
|
-
plugins,
|
|
120
|
-
}) as QuickBrickPlugin;
|
|
138
|
+
const menuPlugin = findMenuPlugin(navigations, plugins);
|
|
121
139
|
|
|
122
|
-
const NavBar = (
|
|
140
|
+
const NavBar = (Components.NavBar ||
|
|
123
141
|
menuPlugin.module) as React.ComponentType<any>;
|
|
124
142
|
|
|
125
|
-
const
|
|
143
|
+
const isPlayer = isPlayerPlugin(routeState);
|
|
144
|
+
|
|
145
|
+
const { visible: isNavBarVisible } = useNavbarState();
|
|
126
146
|
|
|
127
147
|
const screenData =
|
|
128
|
-
screenType === "hooks"
|
|
148
|
+
screenType === "hooks" || isPlayer
|
|
129
149
|
? routeState?.state?.entry
|
|
130
150
|
: routeState?.state?.screen;
|
|
131
151
|
|
|
152
|
+
const isScreenActive = useIsScreenActive();
|
|
153
|
+
|
|
132
154
|
return (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
155
|
+
<FreezeWithCallback
|
|
156
|
+
freeze={!isScreenActive}
|
|
157
|
+
onRelease={() => {
|
|
158
|
+
focusManager.setInitialFocus();
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<View style={[styles.container, { backgroundColor }]}>
|
|
162
|
+
<NavBarContainer isVisible={isNavBarVisible} onReady={noop}>
|
|
163
|
+
<NavBar
|
|
164
|
+
isVisible={isNavBarVisible}
|
|
165
|
+
menuPlugin={menuPlugin}
|
|
166
|
+
navigationProps={navigationProps}
|
|
167
|
+
/>
|
|
168
|
+
</NavBarContainer>
|
|
169
|
+
<ScreenResolver
|
|
170
|
+
screenType={screenType}
|
|
171
|
+
screenId={screenId}
|
|
172
|
+
screenData={screenData}
|
|
173
|
+
groupId={route}
|
|
141
174
|
/>
|
|
142
|
-
</
|
|
143
|
-
|
|
144
|
-
screenType={screenType}
|
|
145
|
-
screenId={screenId}
|
|
146
|
-
screenData={screenData}
|
|
147
|
-
groupId={props.route}
|
|
148
|
-
/>
|
|
149
|
-
</>
|
|
175
|
+
</View>
|
|
176
|
+
</FreezeWithCallback>
|
|
150
177
|
);
|
|
151
178
|
};
|
|
@@ -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(),
|
|
@@ -96,14 +99,6 @@ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
|
96
99
|
}),
|
|
97
100
|
}));
|
|
98
101
|
|
|
99
|
-
const {
|
|
100
|
-
ORIENTATIONS,
|
|
101
|
-
} = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
|
|
102
|
-
|
|
103
|
-
const {
|
|
104
|
-
useCurrentScreenData,
|
|
105
|
-
} = require("@applicaster/zapp-react-native-utils/reactHooks/screen");
|
|
106
|
-
|
|
107
102
|
const {
|
|
108
103
|
allowedOrientationsForScreen,
|
|
109
104
|
getOrientation,
|
|
@@ -155,45 +150,4 @@ describe("<Screen Component />", () => {
|
|
|
155
150
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
156
151
|
});
|
|
157
152
|
});
|
|
158
|
-
|
|
159
|
-
it("invokes the orientation hook when the route changes", () => {
|
|
160
|
-
act(() => {
|
|
161
|
-
wrapper = create(<Screen {...screenProps} />);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// @ts-ignore
|
|
165
|
-
useCurrentScreenData.mockReturnValue({
|
|
166
|
-
id: "player-testId",
|
|
167
|
-
general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
168
|
-
plugin_type: "player",
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
act(() => {
|
|
172
|
-
wrapper.update(
|
|
173
|
-
<Screen
|
|
174
|
-
{...screenProps}
|
|
175
|
-
pathname="/playable"
|
|
176
|
-
screenData={{
|
|
177
|
-
id: "player-testId",
|
|
178
|
-
general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
179
|
-
plugin_type: "player",
|
|
180
|
-
}}
|
|
181
|
-
/>
|
|
182
|
-
);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
useCurrentScreenData.mockReturnValue({
|
|
186
|
-
id: "player-testId",
|
|
187
|
-
general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
act(() => {
|
|
191
|
-
wrapper.update(<Screen {...screenProps} />);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
expect(allowedOrientationsForScreen).toHaveBeenNthCalledWith(
|
|
195
|
-
1,
|
|
196
|
-
ORIENTATIONS.landscapeSensor
|
|
197
|
-
);
|
|
198
|
-
});
|
|
199
153
|
});
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import * as R from "ramda";
|
|
4
3
|
import { View } from "react-native";
|
|
5
4
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
|
+
import {
|
|
6
|
+
isOrientationCompatible,
|
|
7
|
+
useGetScreenOrientation,
|
|
8
|
+
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
6
9
|
|
|
7
10
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
8
11
|
import { getComponentModule } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
9
12
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
shouldNavBarDisplayMenu,
|
|
14
|
+
getNavBarProps,
|
|
15
|
+
getScreenId,
|
|
12
16
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
13
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
14
17
|
import {
|
|
15
18
|
useDimensions,
|
|
16
19
|
useRoute,
|
|
@@ -21,39 +24,18 @@ import {
|
|
|
21
24
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
22
25
|
import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers";
|
|
23
26
|
|
|
24
|
-
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
25
27
|
import { RouteManager } from "../RouteManager";
|
|
26
28
|
import { useScreenConfiguration } from "../River/useScreenConfiguration";
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
: "screen_id" in screenData
|
|
36
|
-
? screenData.screen_id
|
|
37
|
-
: fallbackRiver.id;
|
|
29
|
+
import { isValidColor } from "./utils";
|
|
30
|
+
|
|
31
|
+
const screenStyles = {
|
|
32
|
+
flex: 1,
|
|
33
|
+
paddingTop: 0,
|
|
34
|
+
// paddingBottom: insets.bottom, // Should be applied directly by UI plugin
|
|
35
|
+
// paddingLeft: insets.left, // Should be applied directly by UI plugin
|
|
36
|
+
// paddingRight: insets.right, // Should be applied directly by UI plugin
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
function colorIsNotTransparent(color) {
|
|
41
|
-
const layers = R.compose(
|
|
42
|
-
R.map(R.trim),
|
|
43
|
-
R.split(","),
|
|
44
|
-
R.replace(")", ""),
|
|
45
|
-
R.replace("rgba(", "")
|
|
46
|
-
)(color);
|
|
47
|
-
|
|
48
|
-
const alpha = Number(layers?.[3]);
|
|
49
|
-
|
|
50
|
-
return alpha > 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function isValidColor(string) {
|
|
54
|
-
return string && string !== "transparent" && colorIsNotTransparent(string);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
39
|
type Props = {
|
|
58
40
|
pathname: unknown;
|
|
59
41
|
screenData: unknown;
|
|
@@ -67,9 +49,12 @@ export function Screen(_props: Props) {
|
|
|
67
49
|
// Gets the data for the current screen configuration
|
|
68
50
|
const currentScreenData = useCurrentScreenData();
|
|
69
51
|
const { backgroundColor } = useScreenConfiguration(currentScreenData.id);
|
|
70
|
-
const insets = useSafeAreaInsets();
|
|
71
52
|
|
|
72
|
-
const {
|
|
53
|
+
const {
|
|
54
|
+
width: screenWidth,
|
|
55
|
+
height,
|
|
56
|
+
deviceInfo,
|
|
57
|
+
} = useDimensions("screen", {
|
|
73
58
|
fullDimensions: true,
|
|
74
59
|
});
|
|
75
60
|
|
|
@@ -81,30 +66,19 @@ export function Screen(_props: Props) {
|
|
|
81
66
|
|
|
82
67
|
const { title } = useNavbarState();
|
|
83
68
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (props) {
|
|
99
|
-
return {
|
|
100
|
-
...props,
|
|
101
|
-
id: pathname,
|
|
102
|
-
pathname: pathname,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return null;
|
|
107
|
-
}, [currentRiver, pathname]);
|
|
69
|
+
const isTablet = deviceInfo?.isTablet;
|
|
70
|
+
|
|
71
|
+
const { appData } = usePickFromState(["appData"]);
|
|
72
|
+
const isTabletPortrait = appData?.isTabletPortrait;
|
|
73
|
+
|
|
74
|
+
const layoutData = { isTablet, isTabletPortrait, width: screenWidth, height };
|
|
75
|
+
|
|
76
|
+
const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
|
|
77
|
+
|
|
78
|
+
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
|
|
79
|
+
getNavBarProps(currentRiver, pathname, title),
|
|
80
|
+
[currentRiver, pathname]
|
|
81
|
+
);
|
|
108
82
|
|
|
109
83
|
const NavBar = React.useMemo(
|
|
110
84
|
() =>
|
|
@@ -126,33 +100,38 @@ export function Screen(_props: Props) {
|
|
|
126
100
|
|
|
127
101
|
const style = React.useMemo(
|
|
128
102
|
() => ({
|
|
129
|
-
|
|
103
|
+
...screenStyles,
|
|
130
104
|
backgroundColor: isValidColor(backgroundColor)
|
|
131
105
|
? backgroundColor
|
|
132
106
|
: theme.app_background_color,
|
|
133
|
-
paddingTop: 0,
|
|
134
|
-
// paddingBottom: insets.bottom, // Should be applied directly by UI plugin
|
|
135
|
-
// paddingLeft: insets.left, // Should be applied directly by UI plugin
|
|
136
|
-
// paddingRight: insets.right, // Should be applied directly by UI plugin
|
|
137
107
|
}),
|
|
138
|
-
[
|
|
108
|
+
[theme.app_background_color, backgroundColor]
|
|
139
109
|
);
|
|
140
110
|
|
|
141
111
|
const targetScreenData =
|
|
142
112
|
currentScreenData || (screenData as any)?.targetScreen || screenData;
|
|
143
113
|
|
|
144
|
-
|
|
114
|
+
const orientation = useGetScreenOrientation(targetScreenData);
|
|
115
|
+
|
|
116
|
+
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
117
|
+
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
118
|
+
if (
|
|
119
|
+
!isOrientationCompatible({
|
|
120
|
+
orientation,
|
|
121
|
+
layoutData,
|
|
122
|
+
})
|
|
123
|
+
) {
|
|
124
|
+
return <View style={style} />;
|
|
125
|
+
}
|
|
145
126
|
|
|
146
127
|
return (
|
|
147
|
-
<
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
</View>
|
|
156
|
-
</ScreenContextProvider>
|
|
128
|
+
<View style={style}>
|
|
129
|
+
{navBarProps && <NavBar {...navBarProps} hasMenu={hasMenu} />}
|
|
130
|
+
|
|
131
|
+
<OfflineFallbackScreen screenData={targetScreenData}>
|
|
132
|
+
{/* @TODO RouteManager doesn't use props, can they be removed ? */}
|
|
133
|
+
<RouteManager pathname={pathname} screenData={screenData} />
|
|
134
|
+
</OfflineFallbackScreen>
|
|
135
|
+
</View>
|
|
157
136
|
);
|
|
158
137
|
}
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* is similar to the navbar, except that it covers scenarios where only the navbar (and not)
|
|
6
6
|
* the menu, will be hidden
|
|
7
7
|
*
|
|
8
|
+
* - playable screens
|
|
9
|
+
* - qb_search_screen
|
|
10
|
+
* - screen hooks that specify showNavBar or presentFullScreen
|
|
11
|
+
* - screens or nested screens that have allow_screen_plugin_presentation set to true
|
|
12
|
+
*
|
|
8
13
|
* @param {String} route current route of the screen
|
|
9
14
|
* @param {Object} screenData payload associated with the currently presented screen
|
|
10
15
|
* @returns {Boolean}
|
|
@@ -21,9 +26,7 @@ export function isMenuVisible(route, screenData) {
|
|
|
21
26
|
if (screenData?.hookPlugin) {
|
|
22
27
|
const hookPlugin = screenData?.hookPlugin?.module;
|
|
23
28
|
|
|
24
|
-
return
|
|
25
|
-
hookPlugin?.showNavBar || hookPlugin?.presentFullScreen !== true || false
|
|
26
|
-
);
|
|
29
|
+
return hookPlugin?.showNavBar || hookPlugin?.presentFullScreen !== true;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
if (
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React, { useLayoutEffect } from "react";
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
allowedOrientationsForScreen,
|
|
4
5
|
ORIENTATIONS,
|
|
5
6
|
getOrientation,
|
|
6
7
|
useGetScreenOrientation,
|
|
7
8
|
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
8
|
-
|
|
9
|
+
import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
|
|
9
10
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
10
11
|
import { findPluginByType } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
11
12
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
13
|
+
|
|
12
14
|
import { ZappHookModalContext } from "../../Contexts";
|
|
13
15
|
import { HookModalContextT } from "../../Contexts/ZappHookModalContext";
|
|
14
16
|
|
|
@@ -79,14 +81,23 @@ export function useNewOrientationForScreenData({
|
|
|
79
81
|
screenOrientation;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
screenData
|
|
84
|
-
|
|
84
|
+
type Props = {
|
|
85
|
+
screenData: {
|
|
86
|
+
screen: {};
|
|
87
|
+
};
|
|
88
|
+
isActive: boolean;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export function useScreenOrientationHandler({ screenData, isActive }: Props) {
|
|
85
92
|
const { isHooksExecutionInProgress } = React.useContext<HookModalContextT>(
|
|
86
93
|
ZappHookModalContext.ReactContext
|
|
87
94
|
);
|
|
88
95
|
|
|
89
|
-
const
|
|
96
|
+
const prevIsActive = usePrevious(isActive);
|
|
97
|
+
|
|
98
|
+
const newOrientation = useNewOrientationForScreenData({
|
|
99
|
+
screenData: screenData.screen,
|
|
100
|
+
});
|
|
90
101
|
|
|
91
102
|
useLayoutEffect(() => {
|
|
92
103
|
// Null means screen does not have orientation preference, so we can skip rotate
|
|
@@ -100,12 +111,12 @@ export function useScreenOrientationHandler({
|
|
|
100
111
|
return;
|
|
101
112
|
}
|
|
102
113
|
|
|
103
|
-
if (newOrientation !== current) {
|
|
114
|
+
if (!prevIsActive && isActive && newOrientation !== current) {
|
|
104
115
|
current = newOrientation;
|
|
105
116
|
|
|
106
117
|
setOrientation(newOrientation);
|
|
107
118
|
}
|
|
108
|
-
}, [newOrientation, isHooksExecutionInProgress]);
|
|
119
|
+
}, [newOrientation, isHooksExecutionInProgress, prevIsActive, isActive]);
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
export function useOrientationHandler({ screenData }: OrientationHookArgs) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { map, split, replace, compose, trim } from "ramda";
|
|
2
|
+
|
|
3
|
+
function colorIsNotTransparent(color) {
|
|
4
|
+
const layers = compose(
|
|
5
|
+
map(trim),
|
|
6
|
+
split(","),
|
|
7
|
+
replace(")", ""),
|
|
8
|
+
replace("rgba(", "")
|
|
9
|
+
)(color);
|
|
10
|
+
|
|
11
|
+
return Number(layers?.[3]) > 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isValidColor(string) {
|
|
15
|
+
return string && string !== "transparent" && colorIsNotTransparent(string);
|
|
16
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
import { useDispatch } from "react-redux";
|
|
2
|
+
import { path, prop } from "ramda";
|
|
4
3
|
import {
|
|
5
4
|
findPluginByType,
|
|
6
5
|
findPluginByIdentifier,
|
|
@@ -15,7 +14,6 @@ import { componentsLogger } from "../../Helpers/logger";
|
|
|
15
14
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
16
15
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
17
16
|
import { useScreenAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks";
|
|
18
|
-
import { setAppStateHasFinishedTransitioning } from "@applicaster/zapp-react-native-redux/appState";
|
|
19
17
|
|
|
20
18
|
const logger = componentsLogger.addSubsystem("ScreenResolver");
|
|
21
19
|
|
|
@@ -54,11 +52,8 @@ export function ScreenResolverComponent(props: Props) {
|
|
|
54
52
|
|
|
55
53
|
const [, setScreenContext] = ZappPipesScreenContext.useZappPipesContext();
|
|
56
54
|
|
|
57
|
-
const dispatch = useDispatch();
|
|
58
|
-
|
|
59
55
|
React.useEffect(() => {
|
|
60
56
|
setScreenContext(rivers[screenId]);
|
|
61
|
-
dispatch(setAppStateHasFinishedTransitioning());
|
|
62
57
|
}, [screenId]);
|
|
63
58
|
|
|
64
59
|
const ScreenPlugin =
|
|
@@ -100,14 +95,14 @@ export function ScreenResolverComponent(props: Props) {
|
|
|
100
95
|
}
|
|
101
96
|
|
|
102
97
|
const ScreenComponent =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
path(["module", "Component"], ScreenPlugin) ||
|
|
99
|
+
prop("module", ScreenPlugin) ||
|
|
100
|
+
prop("Component", ScreenPlugin) ||
|
|
106
101
|
ScreenPlugin;
|
|
107
102
|
|
|
108
103
|
const configuration =
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
prop("configuration", ScreenPlugin) ||
|
|
105
|
+
prop("__plugin_configuration", ScreenComponent);
|
|
111
106
|
|
|
112
107
|
if (ScreenComponent) {
|
|
113
108
|
return (
|