@applicaster/quick-brick-core 13.0.0-alpha.4244246222 → 13.0.0-alpha.4302300656
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/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 +17 -47
- package/App/ModalProvider/ModalPresenter.tsx +1 -1
- package/App/ModalProvider/index.tsx +7 -3
- package/App/NavigationProvider/NavigationProvider.tsx +29 -43
- package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +0 -44
- package/App/index.tsx +4 -3
- package/package.json +8 -8
- 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/ModalProvider/ModalChildrenWrapper/{index.android.tsx → index.tsx} +0 -0
|
@@ -56,6 +56,7 @@ export class DraggableBottomSheet extends Component<Props, ComponentState> {
|
|
|
56
56
|
_translateYOffset: Animated.Value;
|
|
57
57
|
_translateY: Animated.AnimatedAddition;
|
|
58
58
|
_snapPoints: SnapPoints;
|
|
59
|
+
_prevContentHeight = 0;
|
|
59
60
|
|
|
60
61
|
_callWhenMounted: () => void | null;
|
|
61
62
|
|
|
@@ -89,6 +90,14 @@ export class DraggableBottomSheet extends Component<Props, ComponentState> {
|
|
|
89
90
|
this._lastScrollY
|
|
90
91
|
);
|
|
91
92
|
|
|
93
|
+
const initialSnapPoints = new SnapPoints(props.height, props.sheetHeight);
|
|
94
|
+
|
|
95
|
+
this._translateYOffset = new Animated.Value(
|
|
96
|
+
props.visible ? initialSnapPoints.top : initialSnapPoints.bottom
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
this._prevContentHeight = initialSnapPoints.contentHeight;
|
|
100
|
+
|
|
92
101
|
this.state = {
|
|
93
102
|
lastSnap: props.height,
|
|
94
103
|
dragging: false,
|
|
@@ -150,12 +159,25 @@ export class DraggableBottomSheet extends Component<Props, ComponentState> {
|
|
|
150
159
|
|
|
151
160
|
if (!this._snapPoints) {
|
|
152
161
|
this._snapPoints = new SnapPoints(windowHeight, totalSheetHeight);
|
|
162
|
+
this._prevContentHeight = totalSheetHeight;
|
|
153
163
|
} else {
|
|
154
164
|
this._snapPoints.windowHeight = windowHeight;
|
|
155
165
|
this._snapPoints.contentHeight = totalSheetHeight;
|
|
156
|
-
}
|
|
157
166
|
|
|
158
|
-
|
|
167
|
+
if (this.props.visible && this._isMounted) {
|
|
168
|
+
Animated.timing(this._translateYOffset, {
|
|
169
|
+
toValue: this._snapPoints.top,
|
|
170
|
+
duration: ANIMATION_DURATION,
|
|
171
|
+
easing: ANIMATION_EASING,
|
|
172
|
+
delay: ANIMATION_DELAY,
|
|
173
|
+
useNativeDriver: USE_NATIVE_DRIVER,
|
|
174
|
+
}).start();
|
|
175
|
+
} else {
|
|
176
|
+
this._translateYOffset.setValue(this._snapPoints.top);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
this._prevContentHeight = totalSheetHeight;
|
|
180
|
+
}
|
|
159
181
|
|
|
160
182
|
this._translateY = Animated.add(
|
|
161
183
|
this._translateYOffset,
|
|
@@ -254,6 +276,7 @@ export class DraggableBottomSheet extends Component<Props, ComponentState> {
|
|
|
254
276
|
getDraggableAreaStyles() {
|
|
255
277
|
return {
|
|
256
278
|
width: this.props.maxWidth,
|
|
279
|
+
top: 0,
|
|
257
280
|
left: (this.props.width - this.props.maxWidth) / 2 || 0,
|
|
258
281
|
};
|
|
259
282
|
}
|
|
@@ -300,7 +323,6 @@ export class DraggableBottomSheet extends Component<Props, ComponentState> {
|
|
|
300
323
|
simultaneousHandlers={this.drawer}
|
|
301
324
|
>
|
|
302
325
|
<Animated.ScrollView
|
|
303
|
-
style={{ marginBottom: this._snapPoints.top }}
|
|
304
326
|
bounces={false}
|
|
305
327
|
onScrollBeginDrag={this._onRegisterLastScroll}
|
|
306
328
|
scrollEventThrottle={1}
|
|
@@ -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,9 +1,7 @@
|
|
|
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,
|
|
4
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
7
5
|
import { Keyboard, StyleSheet, View } from "react-native";
|
|
8
6
|
|
|
9
7
|
import { Overlay } from "./Overlay";
|
|
@@ -29,61 +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
|
|
|
76
|
-
const
|
|
57
|
+
const dismiss = useCallback(() => setVisible(false), []);
|
|
77
58
|
|
|
78
|
-
const
|
|
79
|
-
() =>
|
|
80
|
-
isTablet
|
|
81
|
-
? Math.max(sheetTabletMaxWidth, dimensions.width)
|
|
82
|
-
: dimensions.width,
|
|
83
|
-
[isTablet]
|
|
84
|
-
);
|
|
59
|
+
const isTablet = useIsTablet();
|
|
85
60
|
|
|
86
|
-
const
|
|
61
|
+
const maxWidth = isTablet ? sheetTabletMaxWidth : dimensions.width;
|
|
87
62
|
|
|
88
63
|
return (
|
|
89
64
|
<View style={styles.container}>
|
|
@@ -95,12 +70,10 @@ export function ModalBottomSheet(props: Props) {
|
|
|
95
70
|
<ModalBottomSheetFrame
|
|
96
71
|
backgroundColor={sheetBackgroundColor}
|
|
97
72
|
cornerRadius={sheetCornerRadius}
|
|
98
|
-
|
|
99
|
-
maxHeight={sheetMaxHeight + bottomOffset}
|
|
100
|
-
paddingBottom={bottomOffset}
|
|
73
|
+
maxHeight={sheetMaxHeight}
|
|
101
74
|
maxWidth={maxWidth}
|
|
102
75
|
dimensions={dimensions}
|
|
103
|
-
visible={
|
|
76
|
+
visible={visible}
|
|
104
77
|
closeToast={dismiss}
|
|
105
78
|
handleProps={{
|
|
106
79
|
enabled: sheetHandleEnabled,
|
|
@@ -108,18 +81,15 @@ export function ModalBottomSheet(props: Props) {
|
|
|
108
81
|
focusedColor: sheetHandleFocusedColor,
|
|
109
82
|
}}
|
|
110
83
|
>
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
width
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
currentRoute={navigator.currentRoute}
|
|
121
|
-
/>
|
|
122
|
-
</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
|
+
/>
|
|
123
93
|
</ModalBottomSheetFrame>
|
|
124
94
|
</View>
|
|
125
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);
|
|
@@ -40,7 +40,11 @@ export function ModalProvider() {
|
|
|
40
40
|
return (
|
|
41
41
|
<PathnameContext.Provider value={pathname}>
|
|
42
42
|
<ScreenContextProvider pathname={pathname}>
|
|
43
|
-
<ModalPresenter
|
|
43
|
+
<ModalPresenter
|
|
44
|
+
visible={shouldShowModal}
|
|
45
|
+
{...modalState?.options}
|
|
46
|
+
statusBarTranslucent
|
|
47
|
+
>
|
|
44
48
|
<ModalChildrenWrapper>
|
|
45
49
|
<ModalContent modalScreenProps={modalScreenProps} />
|
|
46
50
|
</ModalChildrenWrapper>
|
|
@@ -58,13 +58,20 @@ import {
|
|
|
58
58
|
legacyScreenData,
|
|
59
59
|
openExternalUrl,
|
|
60
60
|
} from "./utils";
|
|
61
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
debounce,
|
|
63
|
+
getJsonReplacer,
|
|
64
|
+
} from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
62
65
|
|
|
63
66
|
import { findParent } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappPipesContext/ZappPipesEntryContext";
|
|
64
67
|
import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
65
68
|
import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
|
|
66
69
|
import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Components/LinkHandler/LinkHandler";
|
|
67
|
-
import {
|
|
70
|
+
import {
|
|
71
|
+
dismissModal,
|
|
72
|
+
modalStore,
|
|
73
|
+
openModal,
|
|
74
|
+
} from "@applicaster/zapp-react-native-utils/modalState";
|
|
68
75
|
import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
|
|
69
76
|
import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
|
|
70
77
|
import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
|
|
@@ -120,8 +127,6 @@ export function NavigationProvider({ children }: Props) {
|
|
|
120
127
|
|
|
121
128
|
const { context } = React.useContext(ZappPipesEntryContext.Context);
|
|
122
129
|
|
|
123
|
-
const { openModal, dismissModal } = useModalStore();
|
|
124
|
-
|
|
125
130
|
const playNextOverlayState = React.useRef();
|
|
126
131
|
|
|
127
132
|
const online = useConnectionInfo(true);
|
|
@@ -147,7 +152,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
147
152
|
);
|
|
148
153
|
|
|
149
154
|
const getModalState: () => ModalState = () => {
|
|
150
|
-
const { modalState } =
|
|
155
|
+
const { modalState } = modalStore.getState();
|
|
151
156
|
|
|
152
157
|
return modalState;
|
|
153
158
|
};
|
|
@@ -391,7 +396,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
391
396
|
}
|
|
392
397
|
|
|
393
398
|
if (hookPlugin.isModalHook()) {
|
|
394
|
-
|
|
399
|
+
openModal({
|
|
395
400
|
item: payload,
|
|
396
401
|
props: { screenType: "hooks" },
|
|
397
402
|
options: { ModalContainer: hookPlugin.getModalContainer() },
|
|
@@ -411,7 +416,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
411
416
|
}
|
|
412
417
|
|
|
413
418
|
if (hookPlugin.isModalHook()) {
|
|
414
|
-
|
|
419
|
+
dismissModal();
|
|
415
420
|
} else {
|
|
416
421
|
goBack(true, true);
|
|
417
422
|
}
|
|
@@ -423,7 +428,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
423
428
|
closeLoadingOverlay();
|
|
424
429
|
};
|
|
425
430
|
|
|
426
|
-
const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
|
|
431
|
+
const handleHookCancel = ({ hookPlugin, callback, abort }, dispose) => {
|
|
427
432
|
dispose();
|
|
428
433
|
setStartUpHooks(false);
|
|
429
434
|
|
|
@@ -431,10 +436,12 @@ export function NavigationProvider({ children }: Props) {
|
|
|
431
436
|
callback();
|
|
432
437
|
}
|
|
433
438
|
|
|
434
|
-
if (
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
439
|
+
if (!abort) {
|
|
440
|
+
if (hookPlugin.isModalHook()) {
|
|
441
|
+
dismissModal();
|
|
442
|
+
} else {
|
|
443
|
+
goBack(true, true);
|
|
444
|
+
}
|
|
438
445
|
}
|
|
439
446
|
|
|
440
447
|
closeLoadingOverlay();
|
|
@@ -444,7 +451,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
444
451
|
callback?.();
|
|
445
452
|
|
|
446
453
|
if (hookPlugin.isModalHook()) {
|
|
447
|
-
|
|
454
|
+
dismissModal();
|
|
448
455
|
}
|
|
449
456
|
};
|
|
450
457
|
|
|
@@ -681,33 +688,6 @@ export function NavigationProvider({ children }: Props) {
|
|
|
681
688
|
}
|
|
682
689
|
}, [state?.options?.videoModal?.previousMode]);
|
|
683
690
|
|
|
684
|
-
const openModalBottomSheet = React.useCallback(
|
|
685
|
-
({
|
|
686
|
-
ModalBottomSheetContent,
|
|
687
|
-
modalBottomSheetContentProps,
|
|
688
|
-
props = {},
|
|
689
|
-
options = {},
|
|
690
|
-
}) => {
|
|
691
|
-
openModal({
|
|
692
|
-
item: {
|
|
693
|
-
ModalBottomSheetContent,
|
|
694
|
-
modalBottomSheetContentProps,
|
|
695
|
-
},
|
|
696
|
-
props,
|
|
697
|
-
options: {
|
|
698
|
-
animationType: "none",
|
|
699
|
-
animated: false,
|
|
700
|
-
...options,
|
|
701
|
-
},
|
|
702
|
-
});
|
|
703
|
-
},
|
|
704
|
-
[openModal]
|
|
705
|
-
);
|
|
706
|
-
|
|
707
|
-
const closeModalBottomSheet = React.useCallback(() => {
|
|
708
|
-
dismissModal();
|
|
709
|
-
}, [dismissModal]);
|
|
710
|
-
|
|
711
691
|
const getNestedEntry = () => state?.location?.state?.nested?.entry ?? null;
|
|
712
692
|
|
|
713
693
|
// It will only work for the regular stack and pathname, It won't work for modals
|
|
@@ -748,8 +728,6 @@ export function NavigationProvider({ children }: Props) {
|
|
|
748
728
|
openModal,
|
|
749
729
|
dismissModal,
|
|
750
730
|
getModalState,
|
|
751
|
-
openModalBottomSheet,
|
|
752
|
-
closeModalBottomSheet,
|
|
753
731
|
videoModalState: state.options.videoModal,
|
|
754
732
|
openVideoModal,
|
|
755
733
|
closeVideoModal,
|
|
@@ -766,7 +744,15 @@ export function NavigationProvider({ children }: Props) {
|
|
|
766
744
|
getStackForPathname,
|
|
767
745
|
mainStack: state.stack.mainStack,
|
|
768
746
|
}),
|
|
769
|
-
[
|
|
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
|
+
]
|
|
770
756
|
);
|
|
771
757
|
|
|
772
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
|
});
|
package/App/index.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
+
|
|
3
4
|
import {
|
|
4
5
|
initialWindowMetrics,
|
|
5
6
|
SafeAreaProvider,
|
|
@@ -72,11 +73,11 @@ const App = ({
|
|
|
72
73
|
</SplashLoader>
|
|
73
74
|
<ModalProvider />
|
|
74
75
|
</URLSchemeListener>
|
|
75
|
-
<LogicAggregatorContainer
|
|
76
|
-
components={[InteractionManager, ApplyScreenHooks]}
|
|
77
|
-
/>
|
|
78
76
|
<LoadingOverlay />
|
|
79
77
|
</ErrorBoundary>
|
|
78
|
+
<LogicAggregatorContainer
|
|
79
|
+
components={[InteractionManager, ApplyScreenHooks]}
|
|
80
|
+
/>
|
|
80
81
|
</AppContainer>
|
|
81
82
|
</SafeAreaProvider>
|
|
82
83
|
</ThemeManager>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.4302300656",
|
|
4
4
|
"description": "Core package for Applicaster's Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "13.0.0-alpha.
|
|
32
|
-
"@applicaster/quick-brick-core-plugins": "13.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.
|
|
35
|
-
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.
|
|
36
|
-
"@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.4302300656",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "13.0.0-alpha.4302300656",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.4302300656",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.4302300656",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.4302300656",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.4302300656",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.4302300656",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Fragment as ModalChildrenWrapper } from "react";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Fragment as ModalChildrenWrapper } from "react";
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<NavigationProvider /> modal feature removes the visible flag when dismissing a modal 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"options": {
|
|
6
|
-
"animated": true,
|
|
7
|
-
"animationType": "slide",
|
|
8
|
-
"onDismiss": [Function],
|
|
9
|
-
"onRequestClose": [Function],
|
|
10
|
-
"onShow": [Function],
|
|
11
|
-
"presentationStyle": "overFullScreen",
|
|
12
|
-
"transparent": true,
|
|
13
|
-
},
|
|
14
|
-
"props": undefined,
|
|
15
|
-
"screen": {
|
|
16
|
-
"id": "A1234",
|
|
17
|
-
"navigations": [],
|
|
18
|
-
"ui_components": [],
|
|
19
|
-
},
|
|
20
|
-
"visible": true,
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
exports[`<NavigationProvider /> modal feature removes the visible flag when dismissing a modal 2`] = `
|
|
25
|
-
{
|
|
26
|
-
"options": {},
|
|
27
|
-
"props": {},
|
|
28
|
-
"screen": null,
|
|
29
|
-
"visible": false,
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
exports[`<NavigationProvider /> modal feature sets the modalState when opening a modal 1`] = `undefined`;
|
|
34
|
-
|
|
35
|
-
exports[`<NavigationProvider /> modal feature should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet 1`] = `
|
|
36
|
-
{
|
|
37
|
-
"options": {
|
|
38
|
-
"animated": false,
|
|
39
|
-
"animationType": "none",
|
|
40
|
-
"onDismiss": [Function],
|
|
41
|
-
"onRequestClose": [Function],
|
|
42
|
-
"onShow": [Function],
|
|
43
|
-
"presentationStyle": "overFullScreen",
|
|
44
|
-
"transparent": true,
|
|
45
|
-
},
|
|
46
|
-
"props": {},
|
|
47
|
-
"screen": {
|
|
48
|
-
"ModalBottomSheetContent": {
|
|
49
|
-
"id": "A1234",
|
|
50
|
-
"navigations": [],
|
|
51
|
-
"ui_components": [],
|
|
52
|
-
},
|
|
53
|
-
"modalBottomSheetContentProps": {
|
|
54
|
-
"some": "props",
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
"visible": true,
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
exports[`<NavigationProvider /> modal feature should reset state to initial when dismissing a modal ( closeModalBottomSheet ) opened by openModalBottomSheet 2`] = `
|
|
62
|
-
{
|
|
63
|
-
"options": {},
|
|
64
|
-
"props": {},
|
|
65
|
-
"screen": null,
|
|
66
|
-
"visible": false,
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
File without changes
|