@momo-kits/foundation 0.115.2-beta.11 → 0.115.2-beta.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.
- package/Application/BottomSheet.tsx +30 -2
- package/Divider/index.tsx +9 -25
- package/Input/InputMoney.tsx +3 -2
- package/package.json +1 -1
- package/Divider/DashDivider.tsx +0 -45
|
@@ -18,6 +18,9 @@ import {Text} from '../Text';
|
|
|
18
18
|
import {Icon} from '../Icon';
|
|
19
19
|
import {useHeaderHeight} from '@react-navigation/stack';
|
|
20
20
|
import Animated, {Easing, Extrapolate} from 'react-native-reanimated';
|
|
21
|
+
import {Keyboard, LayoutAnimation} from 'react-native';
|
|
22
|
+
import {useState} from 'react';
|
|
23
|
+
import {ScrollView} from 'react-native-gesture-handler';
|
|
21
24
|
|
|
22
25
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
23
26
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
@@ -26,6 +29,26 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
26
29
|
const insets = useSafeAreaInsets();
|
|
27
30
|
const heightHeader = useHeaderHeight();
|
|
28
31
|
const keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
|
|
32
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const onKeyboardShow = (e: any) => {
|
|
36
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
37
|
+
setKeyboardHeight(e.endCoordinates.height);
|
|
38
|
+
};
|
|
39
|
+
const onKeyboardHide = () => {
|
|
40
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
41
|
+
setKeyboardHeight(0);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const showSub = Keyboard.addListener('keyboardDidShow', onKeyboardShow);
|
|
45
|
+
const hideSub = Keyboard.addListener('keyboardDidHide', onKeyboardHide);
|
|
46
|
+
|
|
47
|
+
return () => {
|
|
48
|
+
showSub.remove();
|
|
49
|
+
hideSub.remove();
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
29
52
|
|
|
30
53
|
const {
|
|
31
54
|
screen: Screen,
|
|
@@ -216,9 +239,14 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
216
239
|
<Animated.View
|
|
217
240
|
style={{
|
|
218
241
|
transform: [{translateY}],
|
|
242
|
+
maxHeight: keyboardHeight > 0 ? heightDevice / 2 : undefined,
|
|
219
243
|
}}>
|
|
220
244
|
{renderHeader()}
|
|
221
|
-
<
|
|
245
|
+
<ScrollView
|
|
246
|
+
scrollEnabled={keyboardHeight > 0 ? true : false}
|
|
247
|
+
keyboardShouldPersistTaps="handled"
|
|
248
|
+
contentContainerStyle={{flexGrow: 1}}
|
|
249
|
+
style={{backgroundColor: backgroundColor}}>
|
|
222
250
|
<Screen
|
|
223
251
|
{...props}
|
|
224
252
|
{...props.route.params}
|
|
@@ -227,7 +255,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
227
255
|
{useBottomInset && (
|
|
228
256
|
<View style={{height: Math.min(insets.bottom, 21)}} />
|
|
229
257
|
)}
|
|
230
|
-
</
|
|
258
|
+
</ScrollView>
|
|
231
259
|
</Animated.View>
|
|
232
260
|
</KeyboardAvoidingView>
|
|
233
261
|
</Container>
|
package/Divider/index.tsx
CHANGED
|
@@ -1,37 +1,21 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
|
-
import {View
|
|
2
|
+
import {View} from 'react-native';
|
|
3
3
|
import {ApplicationContext} from '../Application';
|
|
4
4
|
import {Spacing} from '../Consts';
|
|
5
|
-
import {DashDivider} from './DashDivider';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Custom styles for divider
|
|
10
|
-
*/
|
|
11
|
-
style?: ViewStyle;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Enable margin vertical 4px
|
|
15
|
-
*/
|
|
16
|
-
useMargin?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const Divider: React.FC<DividerProps> = ({style, useMargin = true}) => {
|
|
6
|
+
const Divider = () => {
|
|
20
7
|
const {theme} = useContext(ApplicationContext);
|
|
21
8
|
|
|
22
9
|
return (
|
|
23
10
|
<View
|
|
24
|
-
style={
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
marginVertical: useMargin ? Spacing.XS : 0,
|
|
31
|
-
},
|
|
32
|
-
]}
|
|
11
|
+
style={{
|
|
12
|
+
height: 1,
|
|
13
|
+
width: '100%',
|
|
14
|
+
backgroundColor: theme.colors.border.default,
|
|
15
|
+
marginVertical: Spacing.XS,
|
|
16
|
+
}}
|
|
33
17
|
/>
|
|
34
18
|
);
|
|
35
19
|
};
|
|
36
20
|
|
|
37
|
-
export {Divider
|
|
21
|
+
export {Divider};
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -97,10 +97,10 @@ const InputMoney = forwardRef(
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
const onClearText = () => {
|
|
100
|
+
inputRef?.current?.clear();
|
|
100
101
|
setDisplayValue('');
|
|
101
102
|
setNumericValue('');
|
|
102
103
|
onChangeText?.('');
|
|
103
|
-
inputRef?.current?.focus();
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
const _onChangeText = (text: string) => {
|
|
@@ -113,7 +113,8 @@ const InputMoney = forwardRef(
|
|
|
113
113
|
|
|
114
114
|
if (text.length < lastDisplayValue.length) {
|
|
115
115
|
const lastChar = lastDisplayValue.charAt(lastDisplayValue.length - 1);
|
|
116
|
-
const isRemovingCurrency =
|
|
116
|
+
const isRemovingCurrency =
|
|
117
|
+
lastDisplayValue.endsWith(currency) || lastChar === ' ';
|
|
117
118
|
const isRemovingDot = lastChar === '.';
|
|
118
119
|
|
|
119
120
|
if (isRemovingCurrency || isRemovingDot) {
|
package/package.json
CHANGED
package/Divider/DashDivider.tsx
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React, {useContext} from 'react';
|
|
2
|
-
import {View, ViewStyle} from 'react-native';
|
|
3
|
-
import {ApplicationContext} from '../Application';
|
|
4
|
-
import {Spacing} from '../Consts';
|
|
5
|
-
import Svg, {Line} from 'react-native-svg';
|
|
6
|
-
|
|
7
|
-
export interface DashDividerProps {
|
|
8
|
-
/**
|
|
9
|
-
* Custom styles for dash divider
|
|
10
|
-
*/
|
|
11
|
-
style?: ViewStyle;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const DashDivider: React.FC<DashDividerProps> = ({style}) => {
|
|
15
|
-
const {theme} = useContext(ApplicationContext);
|
|
16
|
-
const borderColor = theme.colors.border.default;
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<View
|
|
20
|
-
style={[
|
|
21
|
-
{
|
|
22
|
-
width: '100%',
|
|
23
|
-
height: 1,
|
|
24
|
-
marginVertical: Spacing.XS,
|
|
25
|
-
},
|
|
26
|
-
style,
|
|
27
|
-
]}>
|
|
28
|
-
<Svg height="1" width="100%">
|
|
29
|
-
<Line
|
|
30
|
-
x1="0"
|
|
31
|
-
y1="0"
|
|
32
|
-
x2="100%"
|
|
33
|
-
y2="0"
|
|
34
|
-
stroke={borderColor}
|
|
35
|
-
strokeWidth="1"
|
|
36
|
-
strokeDasharray={`4, 4`}
|
|
37
|
-
strokeLinecap={'round'}
|
|
38
|
-
strokeLinejoin={'miter'}
|
|
39
|
-
/>
|
|
40
|
-
</Svg>
|
|
41
|
-
</View>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export {DashDivider};
|