@momo-kits/foundation 0.92.26-beta.13 → 0.92.26-beta.14

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,18 @@
1
- import React, {useRef, useEffect, useCallback, useContext} from 'react';
1
+ import React, {useCallback, useContext, useEffect, useRef} from 'react';
2
2
  import {
3
3
  Animated,
4
4
  Dimensions,
5
5
  KeyboardAvoidingView,
6
+ Modal,
6
7
  PanResponder,
7
8
  Platform,
8
9
  StyleSheet,
9
10
  TouchableOpacity,
10
11
  View,
11
- Modal,
12
12
  } from 'react-native';
13
- import {useSafeAreaInsets} from 'react-native-safe-area-context';
14
13
  import {ApplicationContext} from './index';
15
14
  import {BottomSheetParams} from './types';
15
+ import {useSafeAreaInsets} from 'react-native-safe-area-context';
16
16
  import {Colors, Radius, Spacing, Styles} from '../Consts';
17
17
  import {Text} from '../Text';
18
18
  import {Icon} from '../Icon';
@@ -24,7 +24,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
24
24
  const {
25
25
  screen: Screen,
26
26
  options,
27
- useNativeModal = false,
28
27
  surface,
29
28
  barrierDismissible = false,
30
29
  draggable = true,
@@ -37,7 +36,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
37
36
  x: 0,
38
37
  })
39
38
  ).current;
40
-
41
39
  const panResponder = useRef(
42
40
  PanResponder.create({
43
41
  onStartShouldSetPanResponder: () => draggable,
@@ -63,10 +61,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
63
61
  },
64
62
  })
65
63
  ).current;
66
- let Container: any = View;
67
- if (useNativeModal) {
68
- Container = Modal;
69
- }
64
+
70
65
  let backgroundColor = theme.colors.background.default;
71
66
  if (surface) {
72
67
  backgroundColor = theme.colors.background.surface;
@@ -95,20 +90,21 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
95
90
  }
96
91
  setTimeout(() => {
97
92
  callback?.();
98
- }, 300);
93
+ }, 350);
94
+
99
95
  Animated.timing(pan, {
100
96
  toValue: {x: 0, y: heightDevice},
101
97
  useNativeDriver: false,
102
- duration: 200,
98
+ duration: 100,
103
99
  }).start(() => {
104
100
  navigator?.pop();
105
101
  });
106
102
  };
107
103
 
108
104
  /**
109
- * on request close
105
+ * manual close
110
106
  */
111
- const onRequestClose = useCallback((callback?: () => void) => {
107
+ const requestClose = useCallback((callback?: () => void) => {
112
108
  onDismiss(true, callback);
113
109
  }, []);
114
110
 
@@ -153,11 +149,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
153
149
  }, []);
154
150
 
155
151
  return (
156
- <Container
157
- transparent
158
- visible={true}
159
- onRequestClose={() => onDismiss()}
160
- style={styles.overlay}>
152
+ <Modal transparent visible={true} onRequestClose={() => onDismiss()}>
161
153
  <KeyboardAvoidingView
162
154
  behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
163
155
  keyboardVerticalOffset={keyboardVerticalOffset ?? -20}
@@ -173,7 +165,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
173
165
  <Screen
174
166
  {...props}
175
167
  {...props.route.params}
176
- onRequestClose={onRequestClose}
168
+ requestClose={requestClose}
177
169
  />
178
170
  {useBottomInset && (
179
171
  <View style={{height: Math.min(insets.bottom, 21)}} />
@@ -181,14 +173,23 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
181
173
  </View>
182
174
  </Animated.View>
183
175
  </KeyboardAvoidingView>
184
- </Container>
176
+ </Modal>
185
177
  );
186
178
  };
187
179
 
180
+ export default BottomSheet;
181
+
188
182
  const styles = StyleSheet.create({
189
- overlay: {
190
- ...StyleSheet.absoluteFillObject,
191
- justifyContent: 'flex-end',
183
+ container: {
184
+ width: '100%',
185
+ height: 0,
186
+ overflow: 'hidden',
187
+ borderTopLeftRadius: Radius.M,
188
+ borderTopRightRadius: Radius.M,
189
+ },
190
+ draggableContainer: {
191
+ width: '100%',
192
+ alignItems: 'center',
192
193
  },
193
194
  indicator: {
194
195
  width: 40,
@@ -212,5 +213,3 @@ const styles = StyleSheet.create({
212
213
  marginHorizontal: Spacing.M,
213
214
  },
214
215
  });
215
-
216
- export default BottomSheet;
@@ -314,7 +314,7 @@ const HeaderRight: React.FC<any> = ({type, children, onLayout, ...props}) => {
314
314
 
315
315
  return (
316
316
  <View style={styles.headerRightButton} onLayout={onLayout}>
317
- {children ?? <HeaderToolkitAction {...props} />}
317
+ <HeaderToolkitAction {...props} />
318
318
  </View>
319
319
  );
320
320
  };
@@ -115,7 +115,6 @@ export type BottomSheetParams = {
115
115
  title: string;
116
116
  surface?: boolean;
117
117
  };
118
- useNativeModal?: boolean;
119
118
  surface?: boolean;
120
119
  onDismiss?: (type?: string) => void;
121
120
  barrierDismissible?: boolean;
@@ -20,7 +20,7 @@ const ItemList = forwardRef(
20
20
  contentContainerStyle,
21
21
  ...props
22
22
  }: ItemListProps,
23
- ref
23
+ ref,
24
24
  ) => {
25
25
  const {gutterSize, numberOfColumns} = useContext(GridContext);
26
26
  const widthItem = (widthSpan ?? numberOfColumns) as SpanNumber;
@@ -41,7 +41,6 @@ const ItemList = forwardRef(
41
41
  <FlatList
42
42
  ref={ref as React.RefObject<FlatList>}
43
43
  {...props}
44
- key={`ItemList-${numColumns}`}
45
44
  numColumns={numColumns}
46
45
  renderItem={_renderItem}
47
46
  horizontal={false}
@@ -50,7 +49,7 @@ const ItemList = forwardRef(
50
49
  contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
51
50
  />
52
51
  );
53
- }
52
+ },
54
53
  );
55
54
 
56
55
  export default ItemList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.26-beta.13",
3
+ "version": "0.92.26-beta.14",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},