@momo-kits/foundation 0.81.1-optimize.10 → 0.81.1-optimize.11
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/Application/BottomSheet.tsx +21 -8
- package/Application/types.ts +1 -0
- package/package.json +1 -1
|
@@ -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 + 68) / 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
|
</>
|
package/Application/types.ts
CHANGED