@momo-kits/foundation 0.92.26-beta.17 → 0.92.26-beta.18

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, {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,
11
+ Modal,
12
12
  } from 'react-native';
13
+ import {useSafeAreaInsets} from 'react-native-safe-area-context';
13
14
  import {ApplicationContext} from './index';
14
15
  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,6 +24,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
24
24
  const {
25
25
  screen: Screen,
26
26
  options,
27
+ useNativeModal = false,
27
28
  surface,
28
29
  barrierDismissible = false,
29
30
  draggable = true,
@@ -36,6 +37,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
36
37
  x: 0,
37
38
  })
38
39
  ).current;
40
+
39
41
  const panResponder = useRef(
40
42
  PanResponder.create({
41
43
  onStartShouldSetPanResponder: () => draggable,
@@ -61,7 +63,10 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
61
63
  },
62
64
  })
63
65
  ).current;
64
-
66
+ let Container: any = View;
67
+ if (useNativeModal) {
68
+ Container = Modal;
69
+ }
65
70
  let backgroundColor = theme.colors.background.default;
66
71
  if (surface) {
67
72
  backgroundColor = theme.colors.background.surface;
@@ -90,21 +95,20 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
90
95
  }
91
96
  setTimeout(() => {
92
97
  callback?.();
93
- }, 350);
94
-
98
+ }, 300);
95
99
  Animated.timing(pan, {
96
100
  toValue: {x: 0, y: heightDevice},
97
101
  useNativeDriver: false,
98
- duration: 100,
102
+ duration: 200,
99
103
  }).start(() => {
100
104
  navigator?.pop();
101
105
  });
102
106
  };
103
107
 
104
108
  /**
105
- * manual close
109
+ * on request close
106
110
  */
107
- const requestClose = useCallback((callback?: () => void) => {
111
+ const onRequestClose = useCallback((callback?: () => void) => {
108
112
  onDismiss(true, callback);
109
113
  }, []);
110
114
 
@@ -149,7 +153,11 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
149
153
  }, []);
150
154
 
151
155
  return (
152
- <Modal transparent visible={true} onRequestClose={() => onDismiss()}>
156
+ <Container
157
+ transparent
158
+ visible={true}
159
+ onRequestClose={() => onDismiss()}
160
+ style={styles.overlay}>
153
161
  <KeyboardAvoidingView
154
162
  behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
155
163
  keyboardVerticalOffset={keyboardVerticalOffset ?? -20}
@@ -165,7 +173,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
165
173
  <Screen
166
174
  {...props}
167
175
  {...props.route.params}
168
- requestClose={requestClose}
176
+ onRequestClose={onRequestClose}
169
177
  />
170
178
  {useBottomInset && (
171
179
  <View style={{height: Math.min(insets.bottom, 21)}} />
@@ -173,23 +181,14 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
173
181
  </View>
174
182
  </Animated.View>
175
183
  </KeyboardAvoidingView>
176
- </Modal>
184
+ </Container>
177
185
  );
178
186
  };
179
187
 
180
- export default BottomSheet;
181
-
182
188
  const styles = StyleSheet.create({
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',
189
+ overlay: {
190
+ ...StyleSheet.absoluteFillObject,
191
+ justifyContent: 'flex-end',
193
192
  },
194
193
  indicator: {
195
194
  width: 40,
@@ -213,3 +212,5 @@ const styles = StyleSheet.create({
213
212
  marginHorizontal: Spacing.M,
214
213
  },
215
214
  });
215
+
216
+ export default BottomSheet;
@@ -123,7 +123,12 @@ const StackScreen: React.FC<ScreenParams> = props => {
123
123
  */
124
124
  useLayoutEffect(() => {
125
125
  if (options) {
126
- navigation.setOptions(options);
126
+ navigation.setOptions({
127
+ headerRight: {
128
+ type: 'toolkit',
129
+ },
130
+ ...options,
131
+ });
127
132
  }
128
133
  }, [options]);
129
134
 
@@ -115,6 +115,7 @@ export type BottomSheetParams = {
115
115
  title: string;
116
116
  surface?: boolean;
117
117
  };
118
+ useNativeModal?: boolean;
118
119
  surface?: boolean;
119
120
  onDismiss?: (type?: string) => void;
120
121
  barrierDismissible?: boolean;
@@ -11,7 +11,7 @@ export interface AnimatedInputSearchProps extends InputSearchProps {
11
11
  }
12
12
 
13
13
  const SCREEN_PADDING = 12;
14
- const BACK_WIDTH = scaleSize(28);
14
+ const BACK_WIDTH = 28;
15
15
 
16
16
  const AnimatedInputSearch: FC<AnimatedInputSearchProps> = ({
17
17
  animatedValue,
@@ -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,6 +41,7 @@ const ItemList = forwardRef(
41
41
  <FlatList
42
42
  ref={ref as React.RefObject<FlatList>}
43
43
  {...props}
44
+ key={`ItemList-${numColumns}`}
44
45
  numColumns={numColumns}
45
46
  renderItem={_renderItem}
46
47
  horizontal={false}
@@ -49,7 +50,7 @@ const ItemList = forwardRef(
49
50
  contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
50
51
  />
51
52
  );
52
- },
53
+ }
53
54
  );
54
55
 
55
56
  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.17",
3
+ "version": "0.92.26-beta.18",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},