@momo-kits/foundation 0.92.26-beta.6 → 0.92.26-beta.7

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,18 +1,17 @@
1
- import React, {useCallback, useContext, useEffect, useRef} from 'react';
1
+ import React, {useRef, useEffect, useCallback, useContext} from 'react';
2
2
  import {
3
3
  Animated,
4
4
  Dimensions,
5
5
  KeyboardAvoidingView,
6
- Modal,
7
6
  PanResponder,
8
7
  Platform,
9
8
  StyleSheet,
10
9
  TouchableOpacity,
11
10
  View,
12
11
  } from 'react-native';
12
+ import {useSafeAreaInsets} from 'react-native-safe-area-context';
13
13
  import {ApplicationContext} from './index';
14
14
  import {BottomSheetParams} from './types';
15
- import {useSafeAreaInsets} from 'react-native-safe-area-context';
16
15
  import {Colors, Radius, Spacing, Styles} from '../Consts';
17
16
  import {Text} from '../Text';
18
17
  import {Icon} from '../Icon';
@@ -36,6 +35,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
36
35
  x: 0,
37
36
  })
38
37
  ).current;
38
+
39
39
  const panResponder = useRef(
40
40
  PanResponder.create({
41
41
  onStartShouldSetPanResponder: () => draggable,
@@ -67,14 +67,11 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
67
67
  backgroundColor = theme.colors.background.surface;
68
68
  }
69
69
 
70
- /**
71
- * emit dismiss event
72
- */
73
70
  useEffect(() => {
74
71
  Animated.timing(pan, {
75
72
  toValue: {x: 0, y: 0},
76
73
  useNativeDriver: false,
77
- duration: 200,
74
+ duration: 50,
78
75
  }).start();
79
76
  return () => {
80
77
  props.route.params?.onDismiss?.();
@@ -82,7 +79,9 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
82
79
  }, []);
83
80
 
84
81
  /**
85
- * handler dismiss
82
+ * on dismiss
83
+ * @param force
84
+ * @param callback
86
85
  */
87
86
  const onDismiss = (force = false, callback?: () => void) => {
88
87
  if (barrierDismissible && !force) {
@@ -101,15 +100,12 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
101
100
  };
102
101
 
103
102
  /**
104
- * manual close
103
+ * on request close
105
104
  */
106
- const requestClose = useCallback((callback?: () => void) => {
105
+ const onRequestClose = useCallback((callback?: () => void) => {
107
106
  onDismiss(true, callback);
108
107
  }, []);
109
108
 
110
- /**
111
- * render header
112
- */
113
109
  const renderHeader = useCallback(() => {
114
110
  return (
115
111
  <View
@@ -148,7 +144,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
148
144
  }, []);
149
145
 
150
146
  return (
151
- <Modal transparent visible={true} onRequestClose={() => onDismiss()}>
147
+ <View style={styles.overlay}>
152
148
  <KeyboardAvoidingView
153
149
  behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
154
150
  keyboardVerticalOffset={keyboardVerticalOffset ?? -20}
@@ -161,30 +157,25 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
161
157
  <Animated.View style={{transform: pan.getTranslateTransform()}}>
162
158
  {renderHeader()}
163
159
  <View style={{backgroundColor: backgroundColor}}>
164
- <Screen {...props} {...props.route.params} />
160
+ <Screen
161
+ {...props}
162
+ {...props.route.params}
163
+ onRequestClose={onRequestClose}
164
+ />
165
165
  {useBottomInset && (
166
166
  <View style={{height: Math.min(insets.bottom, 21)}} />
167
167
  )}
168
168
  </View>
169
169
  </Animated.View>
170
170
  </KeyboardAvoidingView>
171
- </Modal>
171
+ </View>
172
172
  );
173
173
  };
174
174
 
175
- export default BottomSheet;
176
-
177
175
  const styles = StyleSheet.create({
178
- container: {
179
- width: '100%',
180
- height: 0,
181
- overflow: 'hidden',
182
- borderTopLeftRadius: Radius.M,
183
- borderTopRightRadius: Radius.M,
184
- },
185
- draggableContainer: {
186
- width: '100%',
187
- alignItems: 'center',
176
+ overlay: {
177
+ ...StyleSheet.absoluteFillObject,
178
+ justifyContent: 'flex-end',
188
179
  },
189
180
  indicator: {
190
181
  width: 40,
@@ -208,3 +199,5 @@ const styles = StyleSheet.create({
208
199
  marginHorizontal: Spacing.M,
209
200
  },
210
201
  });
202
+
203
+ export default BottomSheet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.26-beta.6",
3
+ "version": "0.92.26-beta.7",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},