@momo-kits/foundation 0.80.8-beta.11 → 0.80.8-beta.13
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/Components.tsx +1 -3
- package/Application/ModalScreen.tsx +23 -7
- package/Layout/Card.tsx +2 -5
- package/Layout/Screen.tsx +2 -8
- package/Layout/styles.ts +7 -1
- package/Layout/utils.ts +2 -4
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {Fragment, useContext, useEffect, useState} from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Alert,
|
|
4
3
|
Animated,
|
|
5
4
|
DeviceEventEmitter,
|
|
6
5
|
Platform,
|
|
@@ -276,8 +275,7 @@ const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
|
|
|
276
275
|
const validateType = (child: React.ReactElement) => {
|
|
277
276
|
const valid = child?.type === NavigationButton || child?.type == Fragment;
|
|
278
277
|
if (__DEV__ && !valid) {
|
|
279
|
-
|
|
280
|
-
'Rule',
|
|
278
|
+
console.warn(
|
|
281
279
|
'HeaderRightAction contains element type of NavigationButton, Please check again.',
|
|
282
280
|
);
|
|
283
281
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React, {useContext, useEffect, useMemo, useRef} from 'react';
|
|
1
|
+
import React, {useContext, useEffect, useMemo, useRef, useState} from 'react';
|
|
2
2
|
import {
|
|
3
|
+
Dimensions,
|
|
4
|
+
Keyboard,
|
|
3
5
|
KeyboardAvoidingView,
|
|
4
6
|
Platform,
|
|
5
7
|
Pressable,
|
|
6
8
|
StyleSheet,
|
|
7
9
|
View,
|
|
8
|
-
Keyboard,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
11
12
|
import {
|
|
@@ -90,6 +91,7 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
90
91
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
91
92
|
const insets = useSafeAreaInsets();
|
|
92
93
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
94
|
+
const [keyboardSnap, setKeyboardSnap] = useState(0);
|
|
93
95
|
const {screen, options, snapPoint}: BottomSheetParams = props.route.params;
|
|
94
96
|
const Component = useRef(screen).current;
|
|
95
97
|
const navigation = new Navigation(props.navigation, theme);
|
|
@@ -102,28 +104,41 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
102
104
|
|
|
103
105
|
const snapPoints = useMemo(() => {
|
|
104
106
|
if (snapPoint) {
|
|
105
|
-
|
|
107
|
+
const current = parseInt(snapPoint) + keyboardSnap * 100;
|
|
108
|
+
return [`${current}%`];
|
|
106
109
|
}
|
|
107
110
|
return ['50%', '70%', '90%'];
|
|
108
|
-
}, []);
|
|
111
|
+
}, [keyboardSnap]);
|
|
109
112
|
|
|
110
113
|
const bottomSheetRef = useRef<any>(null);
|
|
111
114
|
const mountedRef = useRef(true);
|
|
112
115
|
|
|
113
116
|
let backgroundColor = theme.colors.background.default;
|
|
117
|
+
let bottomInset = keyboardSnap * Dimensions.get('window').height;
|
|
118
|
+
if (bottomInset > 16) {
|
|
119
|
+
bottomInset -= 16;
|
|
120
|
+
}
|
|
114
121
|
if (options?.surface) {
|
|
115
122
|
backgroundColor = theme.colors.background.surface;
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
useEffect(() => {
|
|
119
|
-
const keyboardDidShow = Keyboard.addListener('keyboardDidShow',
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
const keyboardDidShow = Keyboard.addListener('keyboardDidShow', e => {
|
|
127
|
+
setKeyboardSnap(
|
|
128
|
+
e.endCoordinates.height / Dimensions.get('window').height,
|
|
129
|
+
);
|
|
130
|
+
bottomSheetRef.current?.expand();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const keyboardDidHide = Keyboard.addListener('keyboardDidHide', () => {
|
|
134
|
+
setKeyboardSnap(0);
|
|
135
|
+
});
|
|
122
136
|
|
|
123
137
|
bottomSheetRef.current?.present();
|
|
124
138
|
return () => {
|
|
125
139
|
mountedRef.current = false;
|
|
126
140
|
keyboardDidShow.remove();
|
|
141
|
+
keyboardDidHide.remove();
|
|
127
142
|
};
|
|
128
143
|
}, []);
|
|
129
144
|
|
|
@@ -145,6 +160,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
145
160
|
navigator?.pop();
|
|
146
161
|
}
|
|
147
162
|
}}
|
|
163
|
+
bottomInset={bottomInset}
|
|
148
164
|
handleComponent={null}
|
|
149
165
|
backdropComponent={backdropComponent}>
|
|
150
166
|
<BottomSheetView accessibilityLabel={'BottomSheet'}>
|
package/Layout/Card.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import Item from './Item';
|
|
|
7
7
|
import {Image} from '../Image';
|
|
8
8
|
import {ApplicationContext} from '../Application';
|
|
9
9
|
import styles from './styles';
|
|
10
|
-
import {Colors,
|
|
10
|
+
import {Colors, Shadow, Spacing} from '../Consts';
|
|
11
11
|
|
|
12
12
|
export interface CardProps extends ViewProps {
|
|
13
13
|
/**
|
|
@@ -140,15 +140,12 @@ const Card: React.FC<CardProps> = ({
|
|
|
140
140
|
<View
|
|
141
141
|
accessibilityLabel={`Card`}
|
|
142
142
|
style={[
|
|
143
|
-
{
|
|
144
|
-
backgroundColor: theme.colors.background.surface,
|
|
145
|
-
borderRadius: Radius.M,
|
|
146
|
-
},
|
|
147
143
|
style,
|
|
148
144
|
styles.card,
|
|
149
145
|
{
|
|
150
146
|
width: widthSection,
|
|
151
147
|
marginHorizontal: gridContext.margin,
|
|
148
|
+
backgroundColor: theme.colors.background.surface,
|
|
152
149
|
},
|
|
153
150
|
useShadow && Shadow.Light,
|
|
154
151
|
]}>
|
package/Layout/Screen.tsx
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
HeaderTitle,
|
|
25
25
|
} from '../Application';
|
|
26
26
|
import Navigation from '../Application/Navigation';
|
|
27
|
+
import styles from './styles';
|
|
27
28
|
|
|
28
29
|
export interface ScreenProps extends ViewProps {
|
|
29
30
|
children: React.ReactNode;
|
|
@@ -238,14 +239,7 @@ const Screen = forwardRef(
|
|
|
238
239
|
<View
|
|
239
240
|
style={[Styles.flex, {backgroundColor}]}
|
|
240
241
|
accessibilityLabel={`ScreenContainer`}>
|
|
241
|
-
<View
|
|
242
|
-
style={{
|
|
243
|
-
position: 'absolute',
|
|
244
|
-
width: '100%',
|
|
245
|
-
maxHeight: 215,
|
|
246
|
-
}}>
|
|
247
|
-
{renderHeader()}
|
|
248
|
-
</View>
|
|
242
|
+
<View style={styles.screenBanner}>{renderHeader()}</View>
|
|
249
243
|
<KeyboardAvoidingView
|
|
250
244
|
style={[Styles.flex, {paddingTop: marginHeader}]}
|
|
251
245
|
enabled={enableKeyboardAvoidingView}
|
package/Layout/styles.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Spacing} from '../Consts';
|
|
2
|
+
import {Radius, Spacing} from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
|
+
screenBanner: {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
width: '100%',
|
|
8
|
+
maxHeight: 215,
|
|
9
|
+
},
|
|
5
10
|
boxGrid: {
|
|
6
11
|
position: 'absolute',
|
|
7
12
|
top: 0,
|
|
@@ -35,6 +40,7 @@ export default StyleSheet.create({
|
|
|
35
40
|
card: {
|
|
36
41
|
flexDirection: 'row',
|
|
37
42
|
flexWrap: 'wrap',
|
|
43
|
+
borderRadius: Radius.M,
|
|
38
44
|
paddingTop: undefined,
|
|
39
45
|
paddingBottom: undefined,
|
|
40
46
|
paddingLeft: undefined,
|
package/Layout/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Dimensions} from 'react-native';
|
|
2
2
|
import React, {Fragment, ReactElement, useEffect, useState} from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -17,14 +17,12 @@ const validateChildren = (
|
|
|
17
17
|
childrenType => child?.type === childrenType || child?.type == Fragment,
|
|
18
18
|
);
|
|
19
19
|
if (!valid) {
|
|
20
|
-
|
|
21
|
-
'Component Kits',
|
|
20
|
+
console.warn(
|
|
22
21
|
`Wrong children type for this component, expected are ${childrenTypes
|
|
23
22
|
.map(type => type.displayName)
|
|
24
23
|
.join(', ')}.`,
|
|
25
24
|
);
|
|
26
25
|
}
|
|
27
|
-
return valid;
|
|
28
26
|
};
|
|
29
27
|
|
|
30
28
|
if (Array.isArray(children)) {
|