@momo-kits/foundation 0.81.1-optimize.10 → 0.81.1-optimize.12
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.
|
@@ -29,6 +29,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
29
29
|
snapPoint = 'content',
|
|
30
30
|
draggable = true,
|
|
31
31
|
dragOnContent = false,
|
|
32
|
+
useBottomInset = true,
|
|
32
33
|
}: BottomSheetParams = props.route.params;
|
|
33
34
|
const [modalVisible, setModalVisible] = useState(false);
|
|
34
35
|
const animatedHeight = useRef(new Animated.Value(0)).current;
|
|
@@ -58,7 +59,8 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
58
59
|
},
|
|
59
60
|
}),
|
|
60
61
|
).current;
|
|
61
|
-
const estimate =
|
|
62
|
+
const [estimate, setEstimate] = useState(0.9);
|
|
63
|
+
const timeoutMount = useRef<any>();
|
|
62
64
|
|
|
63
65
|
let backgroundColor = theme.colors.background.default;
|
|
64
66
|
if (surface) {
|
|
@@ -69,14 +71,15 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
69
71
|
* handle open & emit dismiss event
|
|
70
72
|
*/
|
|
71
73
|
useEffect(() => {
|
|
72
|
-
|
|
74
|
+
clearTimeout(timeoutMount.current);
|
|
75
|
+
timeoutMount.current = setTimeout(() => {
|
|
73
76
|
const mapSnapPoint: any = {
|
|
74
77
|
'30%': 0.3,
|
|
75
78
|
'50%': 0.5,
|
|
76
79
|
'70%': 0.7,
|
|
77
80
|
'90%': 0.9,
|
|
78
81
|
};
|
|
79
|
-
const point = mapSnapPoint[snapPoint] ?? estimate
|
|
82
|
+
const point = mapSnapPoint[snapPoint] ?? estimate;
|
|
80
83
|
setModalVisible(true);
|
|
81
84
|
Animated.timing(animatedHeight, {
|
|
82
85
|
useNativeDriver: false,
|
|
@@ -84,12 +87,16 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
84
87
|
duration: 300,
|
|
85
88
|
}).start();
|
|
86
89
|
}, 100);
|
|
90
|
+
}, [estimate]);
|
|
87
91
|
|
|
92
|
+
/**
|
|
93
|
+
* emit dismiss event
|
|
94
|
+
*/
|
|
95
|
+
useEffect(() => {
|
|
88
96
|
return () => {
|
|
89
97
|
props.route.params?.onDismiss?.();
|
|
90
98
|
};
|
|
91
99
|
}, []);
|
|
92
|
-
|
|
93
100
|
/**
|
|
94
101
|
* handler dismiss
|
|
95
102
|
*/
|
|
@@ -163,7 +170,9 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
163
170
|
</View>
|
|
164
171
|
)}
|
|
165
172
|
<Screen {...props} {...props.route.params} />
|
|
166
|
-
|
|
173
|
+
{useBottomInset && (
|
|
174
|
+
<View style={{height: Math.min(insets.bottom, 21)}} />
|
|
175
|
+
)}
|
|
167
176
|
</Animated.View>
|
|
168
177
|
</KeyboardAvoidingView>
|
|
169
178
|
</Modal>
|
|
@@ -171,11 +180,15 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
171
180
|
<View
|
|
172
181
|
style={styles.estimate}
|
|
173
182
|
onLayout={e => {
|
|
174
|
-
|
|
175
|
-
|
|
183
|
+
const current = (e.nativeEvent.layout.height + 72) / heightDevice;
|
|
184
|
+
if (current != estimate) {
|
|
185
|
+
setEstimate(current);
|
|
186
|
+
}
|
|
176
187
|
}}>
|
|
177
188
|
<Screen {...props} {...props.route.params} />
|
|
178
|
-
|
|
189
|
+
{useBottomInset && (
|
|
190
|
+
<View style={{height: Math.min(insets.bottom, 21)}} />
|
|
191
|
+
)}
|
|
179
192
|
</View>
|
|
180
193
|
)}
|
|
181
194
|
</>
|
|
@@ -22,13 +22,18 @@ const TabScreen: React.FC<NavigationScreenProps> = ({route}) => {
|
|
|
22
22
|
if (route.params?.options) {
|
|
23
23
|
options = getOptions(route.params?.options, theme);
|
|
24
24
|
}
|
|
25
|
+
|
|
25
26
|
if (route.params?.nested) {
|
|
26
27
|
return (
|
|
27
28
|
<Stack.Navigator>
|
|
28
29
|
<Stack.Screen
|
|
29
30
|
name="Stack"
|
|
30
31
|
component={StackScreen}
|
|
31
|
-
initialParams={{
|
|
32
|
+
initialParams={{
|
|
33
|
+
screen: route.params?.screen,
|
|
34
|
+
options,
|
|
35
|
+
initialParams: route.params?.initialParams,
|
|
36
|
+
}}
|
|
32
37
|
options={{...getStackOptions()}}
|
|
33
38
|
/>
|
|
34
39
|
</Stack.Navigator>
|
|
@@ -40,7 +45,11 @@ const TabScreen: React.FC<NavigationScreenProps> = ({route}) => {
|
|
|
40
45
|
<Stack.Screen
|
|
41
46
|
name="Stack"
|
|
42
47
|
component={StackScreen}
|
|
43
|
-
initialParams={{
|
|
48
|
+
initialParams={{
|
|
49
|
+
screen: route.params?.screen,
|
|
50
|
+
options,
|
|
51
|
+
initialParams: route.params?.initialParams,
|
|
52
|
+
}}
|
|
44
53
|
options={{...getStackOptions(), ...route.params?.options}}
|
|
45
54
|
/>
|
|
46
55
|
</Stack.Navigator>
|
package/Application/types.ts
CHANGED
|
@@ -102,14 +102,14 @@ export type ScreenParams = {
|
|
|
102
102
|
|
|
103
103
|
export type ModalParams = {
|
|
104
104
|
[key: string]: any;
|
|
105
|
-
screen:
|
|
105
|
+
screen: React.ComponentType;
|
|
106
106
|
onDismiss?: () => void;
|
|
107
107
|
barrierDismissible?: boolean;
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
export type BottomSheetParams = {
|
|
111
111
|
[key: string]: any;
|
|
112
|
-
screen:
|
|
112
|
+
screen: React.ComponentType;
|
|
113
113
|
options: {
|
|
114
114
|
title: string;
|
|
115
115
|
surface?: boolean;
|
|
@@ -120,6 +120,7 @@ export type BottomSheetParams = {
|
|
|
120
120
|
barrierDismissible?: boolean;
|
|
121
121
|
draggable?: boolean;
|
|
122
122
|
dragOnContent?: boolean;
|
|
123
|
+
useBottomInset?: boolean;
|
|
123
124
|
};
|
|
124
125
|
|
|
125
126
|
export type NavigationButtonProps = {
|