@applicaster/quick-brick-core 13.0.0-alpha.5131435627 → 13.0.0-alpha.5145183145
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.
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { LayoutChangeEvent, 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 {
|
|
6
|
+
import {
|
|
7
|
+
SafeAreaView,
|
|
8
|
+
useSafeAreaInsets,
|
|
9
|
+
} from "react-native-safe-area-context";
|
|
10
|
+
import {
|
|
11
|
+
isAndroidPlatform,
|
|
12
|
+
platformSelect,
|
|
13
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
7
14
|
|
|
8
15
|
type Props = {
|
|
9
16
|
children: React.ReactChild;
|
|
@@ -14,7 +21,11 @@ type Props = {
|
|
|
14
21
|
visible: boolean;
|
|
15
22
|
handleProps: HandleProps;
|
|
16
23
|
closeToast: () => void;
|
|
17
|
-
dimensions: {
|
|
24
|
+
dimensions: {
|
|
25
|
+
statusBarHeight: any;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
18
29
|
};
|
|
19
30
|
|
|
20
31
|
const styles = StyleSheet.create({
|
|
@@ -24,6 +35,38 @@ const styles = StyleSheet.create({
|
|
|
24
35
|
},
|
|
25
36
|
});
|
|
26
37
|
|
|
38
|
+
const defaultBottomOffset = platformSelect({
|
|
39
|
+
ios: 34,
|
|
40
|
+
android: 0,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const getIsAndroidVersionIsAtLeast = (expectedVersion: number) => {
|
|
44
|
+
return parseFloat(Platform.Version.toString()) >= expectedVersion;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const getSheetHeight = ({ height, bottomOffset, maxHeight, dimensions }) => {
|
|
48
|
+
return platformSelect({
|
|
49
|
+
ios: height - bottomOffset,
|
|
50
|
+
default:
|
|
51
|
+
!getIsAndroidVersionIsAtLeast(35) && isAndroidPlatform()
|
|
52
|
+
? (height || maxHeight) - (bottomOffset + dimensions.statusBarHeight)
|
|
53
|
+
: height || maxHeight,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const useGetSheetHeight = (height, maxHeight, dimensions) => {
|
|
58
|
+
const { bottom = defaultBottomOffset } = useSafeAreaInsets();
|
|
59
|
+
|
|
60
|
+
const bottomOffset = bottom;
|
|
61
|
+
|
|
62
|
+
return getSheetHeight({
|
|
63
|
+
height,
|
|
64
|
+
bottomOffset,
|
|
65
|
+
maxHeight,
|
|
66
|
+
dimensions,
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
27
70
|
export function ModalBottomSheetFrame(props: Props) {
|
|
28
71
|
const {
|
|
29
72
|
children,
|
|
@@ -54,22 +97,28 @@ export function ModalBottomSheetFrame(props: Props) {
|
|
|
54
97
|
}
|
|
55
98
|
};
|
|
56
99
|
|
|
100
|
+
const { bottom = defaultBottomOffset } = useSafeAreaInsets();
|
|
101
|
+
|
|
102
|
+
const bottomOffset = bottom;
|
|
103
|
+
|
|
104
|
+
const sheetHeight = useGetSheetHeight(height, maxHeight, dimensions);
|
|
105
|
+
|
|
57
106
|
return (
|
|
58
107
|
<DraggableBottomSheet
|
|
59
|
-
sheetHeight={
|
|
60
|
-
visible={visible}
|
|
108
|
+
sheetHeight={sheetHeight}
|
|
109
|
+
visible={height > 0 && visible}
|
|
61
110
|
dismiss={props.closeToast}
|
|
62
111
|
hasHeader={handleProps.enabled}
|
|
63
112
|
header={(dragging) => <Handle {...handleProps} focused={dragging} />}
|
|
64
113
|
maxWidth={maxWidth}
|
|
65
114
|
{...dimensions}
|
|
115
|
+
height={dimensions.height - bottomOffset}
|
|
66
116
|
>
|
|
67
117
|
<SafeAreaView
|
|
68
118
|
edges={["left", "right", "bottom"]}
|
|
69
119
|
style={[styles.toastFrameContainer, extraStyles]}
|
|
70
|
-
onLayout={onLayout}
|
|
71
120
|
>
|
|
72
|
-
<View>{children}</View>
|
|
121
|
+
<View onLayout={onLayout}>{children}</View>
|
|
73
122
|
</SafeAreaView>
|
|
74
123
|
</DraggableBottomSheet>
|
|
75
124
|
);
|
|
@@ -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, { useEffect, useState } from "react";
|
|
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,32 +27,24 @@ 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
34
|
const [visible, setVisible] = useState(true);
|
|
42
|
-
const dismiss = () => setVisible(false);
|
|
43
|
-
const { bottom = defaultBottomOffset } = useSafeAreaInsets();
|
|
44
|
-
|
|
45
|
-
const bottomOffset = bottom;
|
|
46
35
|
|
|
47
36
|
const {
|
|
48
37
|
modal_bottom_sheet_background_color: sheetBackgroundColor,
|
|
49
38
|
modal_bottom_sheet_overlay_color: sheetOverlayColor,
|
|
50
39
|
modal_bottom_sheet_top_corner_radius: sheetCornerRadius,
|
|
51
|
-
modal_bottom_sheet_max_height: sheetMaxHeight,
|
|
52
40
|
modal_bottom_sheet_handle: sheetHandleEnabled,
|
|
53
41
|
modal_bottom_sheet_handle_color: sheetHandleColor,
|
|
54
42
|
modal_bottom_sheet_handle_focus_color: sheetHandleFocusedColor,
|
|
55
43
|
modal_bottom_sheet_tablet_max_width: sheetTabletMaxWidth,
|
|
56
44
|
} = theme;
|
|
57
45
|
|
|
46
|
+
const sheetMaxHeight = dimensions.height * 0.75; // Set a default max height
|
|
47
|
+
|
|
58
48
|
const {
|
|
59
49
|
ModalBottomSheetContent = ModalComponent,
|
|
60
50
|
modalBottomSheetContentProps,
|
|
@@ -64,6 +54,8 @@ export function ModalBottomSheet(props: Props) {
|
|
|
64
54
|
Keyboard.dismiss();
|
|
65
55
|
}, []);
|
|
66
56
|
|
|
57
|
+
const dismiss = useCallback(() => setVisible(false), []);
|
|
58
|
+
|
|
67
59
|
const isTablet = useIsTablet();
|
|
68
60
|
|
|
69
61
|
const maxWidth = isTablet ? sheetTabletMaxWidth : dimensions.width;
|
|
@@ -78,7 +70,7 @@ export function ModalBottomSheet(props: Props) {
|
|
|
78
70
|
<ModalBottomSheetFrame
|
|
79
71
|
backgroundColor={sheetBackgroundColor}
|
|
80
72
|
cornerRadius={sheetCornerRadius}
|
|
81
|
-
maxHeight={sheetMaxHeight
|
|
73
|
+
maxHeight={sheetMaxHeight}
|
|
82
74
|
maxWidth={maxWidth}
|
|
83
75
|
dimensions={dimensions}
|
|
84
76
|
visible={visible}
|
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.5145183145",
|
|
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.5145183145",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "13.0.0-alpha.5145183145",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "13.0.0-alpha.5145183145",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.5145183145",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.5145183145",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.5145183145",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.5145183145",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|