@applicaster/quick-brick-core 13.0.0-rc.14 → 13.0.0-rc.140
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/App/ActionsProvider/__tests__/__snapshots__/ActionsProvider.test.js.snap +7 -7
- package/App/AssetCache/__tests__/__snapshots__/assetCache.test.ts.snap +103 -103
- package/App/AssetCache/__tests__/assetCache.test.ts +3 -2
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/__snapshots__/schemeHandlerHooks.test.ts.snap +1 -1
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +45 -116
- package/App/DeepLinking/URLSchemeHandler/__tests__/__snapshots__/URLSchemeHandler.test.tsx.snap +3 -3
- package/App/DeepLinking/URLSchemeListener/URLSchemeContextProvider.tsx +30 -3
- package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListener.test.js +40 -0
- package/App/DeepLinking/URLSchemeListener/index.tsx +1 -1
- package/App/ErrorBoundary/__tests__/errorBoundary.test.jsx +232 -0
- package/App/ErrorBoundary/__tests__/store.test.js +143 -0
- package/App/ErrorBoundary/index.tsx +45 -21
- package/App/ErrorBoundary/store.ts +26 -0
- package/App/LoadingOverlay/LoadingOverlayManager.tsx +27 -0
- package/App/LoadingOverlay/index.tsx +49 -0
- package/App/LoadingOverlay/useLoadingOverlayVisibility.tsx +18 -0
- package/App/ModalProvider/ModalBottomSheet/DraggableBottomSheet/index.tsx +25 -3
- package/App/ModalProvider/ModalBottomSheet/ModalBottomSheetFrame.tsx +68 -11
- package/App/ModalProvider/ModalBottomSheet/Overlay.tsx +5 -7
- package/App/ModalProvider/ModalBottomSheet/index.tsx +18 -46
- package/App/ModalProvider/ModalPresenter.tsx +1 -1
- package/App/ModalProvider/index.tsx +6 -3
- package/App/NavigationProvider/NavigationProvider.tsx +57 -45
- package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +0 -44
- package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +189 -189
- package/App/NetworkStatusProvider/utils.ts +0 -1
- package/App/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +2 -2
- package/App/StoreConnector/__tests__/storeConnector.test.js +17 -11
- package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.tsx +146 -0
- package/App/appLifeCycleManager/index.tsx +6 -7
- package/App/index.tsx +6 -3
- package/App/remoteContextReloader/__tests__/remoteContextReloader.test.js +11 -21
- package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +14 -0
- package/createZappApp/__tests__/__snapshots__/createZappApp.test.js.snap +5 -128
- package/createZappApp/__tests__/createZappApp.test.js +7 -20
- package/defaults/__tests__/defaults.test.js +3 -4
- package/index.d.ts +1 -1
- package/package.json +26 -14
- package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListenerTest.js +0 -177
- package/App/ErrorBoundary/__tests__/__snapshots__/errorBoundary.test.js.snap +0 -9
- package/App/ErrorBoundary/__tests__/errorBoundary.test.js +0 -72
- package/App/ModalProvider/ModalChildrenWrapper/index.ios.ts +0 -1
- package/App/ModalProvider/ModalChildrenWrapper/index.web.ts +0 -1
- package/App/NavigationProvider/__tests__/__snapshots__/navigationProvider.test.tsx.snap +0 -68
- package/App/StoreConnector/__tests__/__snapshots__/storeConnector.test.js.snap +0 -35
- package/App/appLifeCycleManager/__tests__/__snapshots__/appLifeCycleManager.test.js.snap +0 -30
- package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.js +0 -134
- package/App/remoteContextReloader/__tests__/__snapshots__/remoteContextReloader.test.js.snap +0 -43
- /package/App/ModalProvider/ModalChildrenWrapper/{index.android.tsx → index.tsx} +0 -0
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StyleSheet, View } from "react-native";
|
|
2
|
+
import { LayoutChangeEvent, Platform, StyleSheet, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { Handle, HandleProps } from "./Handle";
|
|
5
5
|
import { DraggableBottomSheet } from "./DraggableBottomSheet";
|
|
6
|
+
import {
|
|
7
|
+
SafeAreaView,
|
|
8
|
+
useSafeAreaFrame,
|
|
9
|
+
useSafeAreaInsets,
|
|
10
|
+
} from "react-native-safe-area-context";
|
|
11
|
+
import {
|
|
12
|
+
isAndroidPlatform,
|
|
13
|
+
isAndroidVersionAtLeast,
|
|
14
|
+
platformSelect,
|
|
15
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
6
16
|
|
|
7
17
|
type Props = {
|
|
8
18
|
children: React.ReactChild;
|
|
9
19
|
backgroundColor: string;
|
|
10
20
|
cornerRadius: number;
|
|
11
|
-
contentHeight: number;
|
|
12
21
|
maxHeight: number;
|
|
13
22
|
maxWidth: number;
|
|
14
23
|
visible: boolean;
|
|
15
24
|
handleProps: HandleProps;
|
|
16
25
|
closeToast: () => void;
|
|
17
|
-
dimensions: {
|
|
18
|
-
|
|
26
|
+
dimensions: {
|
|
27
|
+
statusBarHeight: any;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
19
31
|
};
|
|
20
32
|
|
|
21
33
|
const styles = StyleSheet.create({
|
|
@@ -25,6 +37,32 @@ const styles = StyleSheet.create({
|
|
|
25
37
|
},
|
|
26
38
|
});
|
|
27
39
|
|
|
40
|
+
const defaultBottomOffset = platformSelect({
|
|
41
|
+
ios: 34,
|
|
42
|
+
android: 0,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const getSheetHeight = ({ height, bottomOffset, maxHeight }) => {
|
|
46
|
+
return platformSelect({
|
|
47
|
+
ios: height - bottomOffset,
|
|
48
|
+
default:
|
|
49
|
+
(height || maxHeight) -
|
|
50
|
+
(!isAndroidVersionAtLeast(35) && isAndroidPlatform() ? bottomOffset : 0),
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const useGetSheetHeight = (height, maxHeight) => {
|
|
55
|
+
const { bottom = defaultBottomOffset } = useSafeAreaInsets();
|
|
56
|
+
|
|
57
|
+
const bottomOffset = bottom;
|
|
58
|
+
|
|
59
|
+
return getSheetHeight({
|
|
60
|
+
height,
|
|
61
|
+
bottomOffset,
|
|
62
|
+
maxHeight,
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
28
66
|
export function ModalBottomSheetFrame(props: Props) {
|
|
29
67
|
const {
|
|
30
68
|
children,
|
|
@@ -34,31 +72,50 @@ export function ModalBottomSheetFrame(props: Props) {
|
|
|
34
72
|
maxWidth,
|
|
35
73
|
visible,
|
|
36
74
|
handleProps,
|
|
37
|
-
contentHeight,
|
|
38
75
|
dimensions,
|
|
39
|
-
paddingBottom,
|
|
40
76
|
} = props;
|
|
41
77
|
|
|
78
|
+
const safeAreaDims = useSafeAreaFrame();
|
|
79
|
+
|
|
42
80
|
const extraStyles = {
|
|
43
81
|
backgroundColor,
|
|
44
82
|
borderTopLeftRadius: cornerRadius,
|
|
45
83
|
borderTopRightRadius: cornerRadius,
|
|
46
84
|
maxHeight,
|
|
47
|
-
|
|
48
|
-
|
|
85
|
+
maxWidth: Math.min(Number(maxWidth), safeAreaDims.width),
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const [height, setHeight] = React.useState(0);
|
|
89
|
+
|
|
90
|
+
const onLayout = (event: LayoutChangeEvent) => {
|
|
91
|
+
const { height } = event.nativeEvent.layout;
|
|
92
|
+
|
|
93
|
+
if (height !== 0) {
|
|
94
|
+
setHeight(height);
|
|
95
|
+
}
|
|
49
96
|
};
|
|
50
97
|
|
|
98
|
+
const { bottom = defaultBottomOffset } = useSafeAreaInsets();
|
|
99
|
+
|
|
100
|
+
const sheetHeight = useGetSheetHeight(height, maxHeight);
|
|
101
|
+
|
|
51
102
|
return (
|
|
52
103
|
<DraggableBottomSheet
|
|
53
|
-
sheetHeight={
|
|
54
|
-
visible={visible}
|
|
104
|
+
sheetHeight={sheetHeight}
|
|
105
|
+
visible={height > 0 && visible}
|
|
55
106
|
dismiss={props.closeToast}
|
|
56
107
|
hasHeader={handleProps.enabled}
|
|
57
108
|
header={(dragging) => <Handle {...handleProps} focused={dragging} />}
|
|
58
109
|
maxWidth={maxWidth}
|
|
59
110
|
{...dimensions}
|
|
111
|
+
height={safeAreaDims.height - (Platform.OS === "ios" ? bottom : 0)}
|
|
60
112
|
>
|
|
61
|
-
<
|
|
113
|
+
<SafeAreaView
|
|
114
|
+
edges={["left", "right", "bottom"]}
|
|
115
|
+
style={[styles.toastFrameContainer, extraStyles]}
|
|
116
|
+
>
|
|
117
|
+
<View onLayout={onLayout}>{children}</View>
|
|
118
|
+
</SafeAreaView>
|
|
62
119
|
</DraggableBottomSheet>
|
|
63
120
|
);
|
|
64
121
|
}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { StyleSheet, TouchableOpacity, Easing, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { AnimatedInOut } from "@applicaster/zapp-react-native-ui-components/Components/AnimatedInOut";
|
|
5
|
-
import {
|
|
5
|
+
import { dismissModal } from "@applicaster/zapp-react-native-utils/modalState";
|
|
6
6
|
|
|
7
7
|
type Props = {
|
|
8
8
|
overlayColor: string;
|
|
@@ -35,21 +35,19 @@ const fadeInAnimation = {
|
|
|
35
35
|
delay,
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
const animationConfig =
|
|
38
|
+
const animationConfig = {
|
|
39
39
|
in: fadeInAnimation,
|
|
40
40
|
out: {
|
|
41
41
|
...fadeInAnimation,
|
|
42
|
-
onAnimationEnd,
|
|
42
|
+
onAnimationEnd: dismissModal,
|
|
43
43
|
},
|
|
44
|
-
}
|
|
44
|
+
};
|
|
45
45
|
|
|
46
46
|
export function Overlay(props: Props) {
|
|
47
|
-
const navigator = useNavigation();
|
|
48
|
-
|
|
49
47
|
return (
|
|
50
48
|
<AnimatedInOut
|
|
51
49
|
visible={props.visible}
|
|
52
|
-
animationConfig={animationConfig
|
|
50
|
+
animationConfig={animationConfig}
|
|
53
51
|
staticStyles={styles.container}
|
|
54
52
|
>
|
|
55
53
|
<TouchableOpacity
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
3
|
-
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
3
|
|
|
6
|
-
import React, { useCallback, useEffect,
|
|
7
|
-
import {
|
|
4
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
5
|
+
import { Keyboard, StyleSheet, View } from "react-native";
|
|
8
6
|
|
|
9
7
|
import { Overlay } from "./Overlay";
|
|
10
8
|
import { ModalBottomSheetFrame } from "./ModalBottomSheetFrame";
|
|
@@ -29,59 +27,38 @@ type Props = {
|
|
|
29
27
|
modalBottomSheetContentProps: Record<string, any>;
|
|
30
28
|
};
|
|
31
29
|
|
|
32
|
-
const defaultBottomOffset = platformSelect({
|
|
33
|
-
ios: 34,
|
|
34
|
-
android: 0,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
30
|
export function ModalBottomSheet(props: Props) {
|
|
38
31
|
const theme = useTheme<BaseThemePropertiesMobile>();
|
|
39
32
|
const navigator = useNavigation();
|
|
40
33
|
const dimensions = useDimensions();
|
|
41
|
-
const [sheetHeight, setSheetHeight] = useState(0);
|
|
42
34
|
const [visible, setVisible] = useState(true);
|
|
43
|
-
const dismiss = () => setVisible(false);
|
|
44
|
-
const { bottom = defaultBottomOffset } = useSafeAreaInsets();
|
|
45
|
-
|
|
46
|
-
const bottomOffset = bottom + dimensions.statusBarHeight;
|
|
47
35
|
|
|
48
36
|
const {
|
|
49
37
|
modal_bottom_sheet_background_color: sheetBackgroundColor,
|
|
50
38
|
modal_bottom_sheet_overlay_color: sheetOverlayColor,
|
|
51
39
|
modal_bottom_sheet_top_corner_radius: sheetCornerRadius,
|
|
52
|
-
modal_bottom_sheet_max_height: sheetMaxHeight,
|
|
53
40
|
modal_bottom_sheet_handle: sheetHandleEnabled,
|
|
54
41
|
modal_bottom_sheet_handle_color: sheetHandleColor,
|
|
55
42
|
modal_bottom_sheet_handle_focus_color: sheetHandleFocusedColor,
|
|
56
43
|
modal_bottom_sheet_tablet_max_width: sheetTabletMaxWidth,
|
|
57
44
|
} = theme;
|
|
58
45
|
|
|
46
|
+
const sheetMaxHeight = dimensions.height * 0.75; // Set a default max height
|
|
47
|
+
|
|
59
48
|
const {
|
|
60
49
|
ModalBottomSheetContent = ModalComponent,
|
|
61
50
|
modalBottomSheetContentProps,
|
|
62
51
|
} = props;
|
|
63
52
|
|
|
64
|
-
const onLayout = useCallback(({ nativeEvent }) => {
|
|
65
|
-
const calculatedHeight = nativeEvent?.layout?.height;
|
|
66
|
-
|
|
67
|
-
if (calculatedHeight > 0 && sheetHeight === 0) {
|
|
68
|
-
setSheetHeight(Math.min(calculatedHeight, sheetMaxHeight));
|
|
69
|
-
}
|
|
70
|
-
}, []);
|
|
71
|
-
|
|
72
53
|
useEffect(() => {
|
|
73
54
|
Keyboard.dismiss();
|
|
74
55
|
}, []);
|
|
75
56
|
|
|
57
|
+
const dismiss = useCallback(() => setVisible(false), []);
|
|
58
|
+
|
|
76
59
|
const isTablet = useIsTablet();
|
|
77
60
|
|
|
78
|
-
const maxWidth =
|
|
79
|
-
() =>
|
|
80
|
-
isTablet
|
|
81
|
-
? Math.max(sheetTabletMaxWidth, dimensions.width)
|
|
82
|
-
: dimensions.width,
|
|
83
|
-
[isTablet]
|
|
84
|
-
);
|
|
61
|
+
const maxWidth = isTablet ? sheetTabletMaxWidth : dimensions.width;
|
|
85
62
|
|
|
86
63
|
return (
|
|
87
64
|
<View style={styles.container}>
|
|
@@ -93,12 +70,10 @@ export function ModalBottomSheet(props: Props) {
|
|
|
93
70
|
<ModalBottomSheetFrame
|
|
94
71
|
backgroundColor={sheetBackgroundColor}
|
|
95
72
|
cornerRadius={sheetCornerRadius}
|
|
96
|
-
|
|
97
|
-
maxHeight={sheetMaxHeight + bottomOffset}
|
|
98
|
-
paddingBottom={bottomOffset}
|
|
73
|
+
maxHeight={sheetMaxHeight}
|
|
99
74
|
maxWidth={maxWidth}
|
|
100
75
|
dimensions={dimensions}
|
|
101
|
-
visible={visible
|
|
76
|
+
visible={visible}
|
|
102
77
|
closeToast={dismiss}
|
|
103
78
|
handleProps={{
|
|
104
79
|
enabled: sheetHandleEnabled,
|
|
@@ -106,18 +81,15 @@ export function ModalBottomSheet(props: Props) {
|
|
|
106
81
|
focusedColor: sheetHandleFocusedColor,
|
|
107
82
|
}}
|
|
108
83
|
>
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
width
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
currentRoute={navigator.currentRoute}
|
|
119
|
-
/>
|
|
120
|
-
</View>
|
|
84
|
+
<ModalBottomSheetContent
|
|
85
|
+
width={
|
|
86
|
+
Math.min(sheetTabletMaxWidth, dimensions.width) || dimensions.width
|
|
87
|
+
}
|
|
88
|
+
maxHeight={sheetMaxHeight}
|
|
89
|
+
{...modalBottomSheetContentProps}
|
|
90
|
+
dismiss={dismiss}
|
|
91
|
+
currentRoute={navigator.currentRoute}
|
|
92
|
+
/>
|
|
121
93
|
</ModalBottomSheetFrame>
|
|
122
94
|
</View>
|
|
123
95
|
);
|
|
@@ -6,10 +6,10 @@ import { ModalChildrenWrapper } from "./ModalChildrenWrapper";
|
|
|
6
6
|
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
7
7
|
import { ScreenContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
|
|
8
8
|
import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
|
|
9
|
-
import {
|
|
9
|
+
import { useModalStoreState } from "@applicaster/zapp-react-native-utils/modalState";
|
|
10
10
|
|
|
11
11
|
export function ModalProvider() {
|
|
12
|
-
const
|
|
12
|
+
const modalState = useModalStoreState();
|
|
13
13
|
|
|
14
14
|
const [modalVisible, setModalVisible] = React.useState(false);
|
|
15
15
|
const [modalShown, setModalShown] = React.useState(false);
|
|
@@ -35,12 +35,15 @@ export function ModalProvider() {
|
|
|
35
35
|
|
|
36
36
|
const pathname = `${ROUTE_TYPES.MODAL}/${modalScreenProps?.screenId}`;
|
|
37
37
|
|
|
38
|
+
const shouldShowModal = modalVisible && modalState?.visible;
|
|
39
|
+
|
|
38
40
|
return (
|
|
39
41
|
<PathnameContext.Provider value={pathname}>
|
|
40
42
|
<ScreenContextProvider pathname={pathname}>
|
|
41
43
|
<ModalPresenter
|
|
42
|
-
visible={
|
|
44
|
+
visible={shouldShowModal}
|
|
43
45
|
{...modalState?.options}
|
|
46
|
+
statusBarTranslucent
|
|
44
47
|
>
|
|
45
48
|
<ModalChildrenWrapper>
|
|
46
49
|
<ModalContent modalScreenProps={modalScreenProps} />
|
|
@@ -49,6 +49,7 @@ import { coreAppLogger } from "../logger";
|
|
|
49
49
|
import {
|
|
50
50
|
getPlatform,
|
|
51
51
|
isTV,
|
|
52
|
+
isVizioPlatform,
|
|
52
53
|
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
53
54
|
import { useConnectionInfo } from "@applicaster/zapp-react-native-utils/reactHooks/connection";
|
|
54
55
|
import {
|
|
@@ -57,16 +58,26 @@ import {
|
|
|
57
58
|
legacyScreenData,
|
|
58
59
|
openExternalUrl,
|
|
59
60
|
} from "./utils";
|
|
60
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
debounce,
|
|
63
|
+
getJsonReplacer,
|
|
64
|
+
} from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
61
65
|
|
|
62
66
|
import { findParent } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappPipesContext/ZappPipesEntryContext";
|
|
63
67
|
import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
64
68
|
import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
|
|
65
69
|
import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Components/LinkHandler/LinkHandler";
|
|
66
|
-
import {
|
|
70
|
+
import {
|
|
71
|
+
dismissModal,
|
|
72
|
+
modalStore,
|
|
73
|
+
openModal,
|
|
74
|
+
} from "@applicaster/zapp-react-native-utils/modalState";
|
|
67
75
|
import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
|
|
68
76
|
import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
|
|
69
77
|
import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
|
|
78
|
+
import { URLSchemeContext } from "../DeepLinking/URLSchemeListener/URLSchemeContextProvider";
|
|
79
|
+
|
|
80
|
+
import { loadingOverlayManager } from "../LoadingOverlay";
|
|
70
81
|
|
|
71
82
|
const logger = coreAppLogger.addSubsystem("Navigator");
|
|
72
83
|
|
|
@@ -86,6 +97,8 @@ const navigationActions = {
|
|
|
86
97
|
const platform = getPlatform();
|
|
87
98
|
|
|
88
99
|
export function NavigationProvider({ children }: Props) {
|
|
100
|
+
const { url: deepLinkURL } = React.useContext(URLSchemeContext);
|
|
101
|
+
|
|
89
102
|
const {
|
|
90
103
|
appData: { layoutVersion },
|
|
91
104
|
rivers,
|
|
@@ -114,8 +127,6 @@ export function NavigationProvider({ children }: Props) {
|
|
|
114
127
|
|
|
115
128
|
const { context } = React.useContext(ZappPipesEntryContext.Context);
|
|
116
129
|
|
|
117
|
-
const { openModal, dismissModal } = useModalStore();
|
|
118
|
-
|
|
119
130
|
const playNextOverlayState = React.useRef();
|
|
120
131
|
|
|
121
132
|
const online = useConnectionInfo(true);
|
|
@@ -141,7 +152,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
141
152
|
);
|
|
142
153
|
|
|
143
154
|
const getModalState: () => ModalState = () => {
|
|
144
|
-
const { modalState } =
|
|
155
|
+
const { modalState } = modalStore.getState();
|
|
145
156
|
|
|
146
157
|
return modalState;
|
|
147
158
|
};
|
|
@@ -385,7 +396,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
385
396
|
}
|
|
386
397
|
|
|
387
398
|
if (hookPlugin.isModalHook()) {
|
|
388
|
-
|
|
399
|
+
openModal({
|
|
389
400
|
item: payload,
|
|
390
401
|
props: { screenType: "hooks" },
|
|
391
402
|
options: { ModalContainer: hookPlugin.getModalContainer() },
|
|
@@ -393,6 +404,8 @@ export function NavigationProvider({ children }: Props) {
|
|
|
393
404
|
} else {
|
|
394
405
|
dispatch(push(route, { entry: payload, screen: hookPlugin }));
|
|
395
406
|
}
|
|
407
|
+
|
|
408
|
+
closeLoadingOverlay();
|
|
396
409
|
};
|
|
397
410
|
|
|
398
411
|
const handleHookError = ({ error, hookPlugin, callback }, dispose) => {
|
|
@@ -403,7 +416,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
403
416
|
}
|
|
404
417
|
|
|
405
418
|
if (hookPlugin.isModalHook()) {
|
|
406
|
-
|
|
419
|
+
dismissModal();
|
|
407
420
|
} else {
|
|
408
421
|
goBack(true, true);
|
|
409
422
|
}
|
|
@@ -411,9 +424,11 @@ export function NavigationProvider({ children }: Props) {
|
|
|
411
424
|
if (callback && typeof callback === "function") {
|
|
412
425
|
callback();
|
|
413
426
|
}
|
|
427
|
+
|
|
428
|
+
closeLoadingOverlay();
|
|
414
429
|
};
|
|
415
430
|
|
|
416
|
-
const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
|
|
431
|
+
const handleHookCancel = ({ hookPlugin, callback, abort }, dispose) => {
|
|
417
432
|
dispose();
|
|
418
433
|
setStartUpHooks(false);
|
|
419
434
|
|
|
@@ -421,21 +436,29 @@ export function NavigationProvider({ children }: Props) {
|
|
|
421
436
|
callback();
|
|
422
437
|
}
|
|
423
438
|
|
|
424
|
-
if (
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
439
|
+
if (!abort) {
|
|
440
|
+
if (hookPlugin.isModalHook()) {
|
|
441
|
+
dismissModal();
|
|
442
|
+
} else {
|
|
443
|
+
goBack(true, true);
|
|
444
|
+
}
|
|
428
445
|
}
|
|
446
|
+
|
|
447
|
+
closeLoadingOverlay();
|
|
429
448
|
};
|
|
430
449
|
|
|
431
450
|
const handleHookSuccess = ({ hookPlugin, callback }) => {
|
|
432
451
|
callback?.();
|
|
433
452
|
|
|
434
453
|
if (hookPlugin.isModalHook()) {
|
|
435
|
-
|
|
454
|
+
dismissModal();
|
|
436
455
|
}
|
|
437
456
|
};
|
|
438
457
|
|
|
458
|
+
const handleBackgroundHook = () => {
|
|
459
|
+
openLoadingOverlay();
|
|
460
|
+
};
|
|
461
|
+
|
|
439
462
|
const checkStartUpHooks = React.useMemo(() => {
|
|
440
463
|
if (!pluginConfigurations) return false;
|
|
441
464
|
|
|
@@ -497,8 +520,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
497
520
|
({ hookPlugin, payload, callback }, dispose) => {
|
|
498
521
|
if (hookPlugin?.lastHook) {
|
|
499
522
|
dispose({ disposeAll: true });
|
|
500
|
-
|
|
501
|
-
startUpHooks.current && setStartUpHooks(false);
|
|
523
|
+
currentStartUpHooks.current && setStartUpHooks(false);
|
|
502
524
|
}
|
|
503
525
|
|
|
504
526
|
dispatch(
|
|
@@ -506,6 +528,8 @@ export function NavigationProvider({ children }: Props) {
|
|
|
506
528
|
);
|
|
507
529
|
|
|
508
530
|
callback?.();
|
|
531
|
+
|
|
532
|
+
closeLoadingOverlay();
|
|
509
533
|
};
|
|
510
534
|
|
|
511
535
|
const offlinePlugin = React.useMemo(() => {
|
|
@@ -620,6 +644,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
620
644
|
.on(HOOKS_EVENTS.ERROR, handleHookError)
|
|
621
645
|
.on(HOOKS_EVENTS.CANCEL, handleHookCancel)
|
|
622
646
|
.on(HOOKS_EVENTS.SUCCESS, handleHookSuccess)
|
|
647
|
+
.on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
|
|
623
648
|
.on(
|
|
624
649
|
HOOKS_EVENTS.COMPLETE,
|
|
625
650
|
handleHookComplete(navigationAction, targetRoute, {
|
|
@@ -635,6 +660,14 @@ export function NavigationProvider({ children }: Props) {
|
|
|
635
660
|
},
|
|
636
661
|
});
|
|
637
662
|
|
|
663
|
+
const openLoadingOverlay = React.useCallback(() => {
|
|
664
|
+
deepLinkURL && isVizioPlatform() && loadingOverlayManager.show();
|
|
665
|
+
}, [deepLinkURL]);
|
|
666
|
+
|
|
667
|
+
const closeLoadingOverlay = React.useCallback(() => {
|
|
668
|
+
loadingOverlayManager.hide();
|
|
669
|
+
}, []);
|
|
670
|
+
|
|
638
671
|
const openPiP = React.useCallback(() => {
|
|
639
672
|
dispatch(setVideoPiP());
|
|
640
673
|
}, []);
|
|
@@ -655,33 +688,6 @@ export function NavigationProvider({ children }: Props) {
|
|
|
655
688
|
}
|
|
656
689
|
}, [state?.options?.videoModal?.previousMode]);
|
|
657
690
|
|
|
658
|
-
const openModalBottomSheet = React.useCallback(
|
|
659
|
-
({
|
|
660
|
-
ModalBottomSheetContent,
|
|
661
|
-
modalBottomSheetContentProps,
|
|
662
|
-
props = {},
|
|
663
|
-
options = {},
|
|
664
|
-
}) => {
|
|
665
|
-
openModal({
|
|
666
|
-
item: {
|
|
667
|
-
ModalBottomSheetContent,
|
|
668
|
-
modalBottomSheetContentProps,
|
|
669
|
-
},
|
|
670
|
-
props,
|
|
671
|
-
options: {
|
|
672
|
-
animationType: "none",
|
|
673
|
-
animated: false,
|
|
674
|
-
...options,
|
|
675
|
-
},
|
|
676
|
-
});
|
|
677
|
-
},
|
|
678
|
-
[openModal]
|
|
679
|
-
);
|
|
680
|
-
|
|
681
|
-
const closeModalBottomSheet = React.useCallback(() => {
|
|
682
|
-
dismissModal();
|
|
683
|
-
}, [dismissModal]);
|
|
684
|
-
|
|
685
691
|
const getNestedEntry = () => state?.location?.state?.nested?.entry ?? null;
|
|
686
692
|
|
|
687
693
|
// It will only work for the regular stack and pathname, It won't work for modals
|
|
@@ -722,8 +728,6 @@ export function NavigationProvider({ children }: Props) {
|
|
|
722
728
|
openModal,
|
|
723
729
|
dismissModal,
|
|
724
730
|
getModalState,
|
|
725
|
-
openModalBottomSheet,
|
|
726
|
-
closeModalBottomSheet,
|
|
727
731
|
videoModalState: state.options.videoModal,
|
|
728
732
|
openVideoModal,
|
|
729
733
|
closeVideoModal,
|
|
@@ -740,7 +744,15 @@ export function NavigationProvider({ children }: Props) {
|
|
|
740
744
|
getStackForPathname,
|
|
741
745
|
mainStack: state.stack.mainStack,
|
|
742
746
|
}),
|
|
743
|
-
[
|
|
747
|
+
[
|
|
748
|
+
rivers,
|
|
749
|
+
plugins,
|
|
750
|
+
// TODO: Compare entire screen data from state must be removed
|
|
751
|
+
// State size could be large ~150kb and take 80ms on android tv on 8 rails
|
|
752
|
+
JSON.stringify(state, getJsonReplacer()),
|
|
753
|
+
appLaunched,
|
|
754
|
+
startUpHooks,
|
|
755
|
+
]
|
|
744
756
|
);
|
|
745
757
|
|
|
746
758
|
// when running the tests, we pass the dispatch function
|
|
@@ -461,48 +461,4 @@ describe("<NavigationProvider />", () => {
|
|
|
461
461
|
});
|
|
462
462
|
});
|
|
463
463
|
});
|
|
464
|
-
|
|
465
|
-
describe("modal feature", () => {
|
|
466
|
-
it("sets the modalState when opening a modal", () => {
|
|
467
|
-
act(() => {
|
|
468
|
-
wrapper = renderContextConsumer();
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
const view = getByTestId(wrapper, "WrapperView");
|
|
472
|
-
act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
|
|
473
|
-
expect(view.props.navigator.get).toMatchSnapshot();
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
it("removes the visible flag when dismissing a modal", () => {
|
|
477
|
-
act(() => {
|
|
478
|
-
wrapper = renderContextConsumer();
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
const view = getByTestId(wrapper, "WrapperView");
|
|
482
|
-
act(() => view.props.navigator.openModal({ item: rivers.A1234 }));
|
|
483
|
-
expect(view.props.navigator.getModalState()).toMatchSnapshot();
|
|
484
|
-
act(() => view.props.navigator.dismissModal());
|
|
485
|
-
expect(view.props.navigator.getModalState().visible).toBeFalsy();
|
|
486
|
-
expect(view.props.navigator.getModalState()).toMatchSnapshot();
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
it("should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet", () => {
|
|
490
|
-
act(() => {
|
|
491
|
-
wrapper = renderContextConsumer();
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
const view = getByTestId(wrapper, "WrapperView");
|
|
495
|
-
|
|
496
|
-
act(() =>
|
|
497
|
-
view.props.navigator.openModalBottomSheet({
|
|
498
|
-
ModalBottomSheetContent: rivers.A1234,
|
|
499
|
-
modalBottomSheetContentProps: { some: "props" },
|
|
500
|
-
})
|
|
501
|
-
);
|
|
502
|
-
|
|
503
|
-
expect(view.props.navigator.getModalState()).toMatchSnapshot();
|
|
504
|
-
act(() => view.props.navigator.closeModalBottomSheet());
|
|
505
|
-
expect(view.props.navigator.getModalState()).toMatchSnapshot();
|
|
506
|
-
});
|
|
507
|
-
});
|
|
508
464
|
});
|