@momo-kits/foundation 0.81.1-optimize.15 → 0.81.1-optimize.17
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 +71 -108
- package/Application/BottomTab/BottomTabBar.tsx +4 -17
- package/Application/BottomTab/index.tsx +1 -5
- package/Application/StackScreen.tsx +1 -3
- package/Application/types.ts +0 -2
- package/Layout/Card.tsx +1 -0
- package/Layout/Screen.tsx +4 -2
- package/Layout/Section.tsx +1 -0
- package/Loader/index.tsx +2 -0
- package/Popup/PopupNotify.tsx +1 -1
- package/Popup/PopupPromotion.tsx +1 -1
- package/Popup/types.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {useContext, useEffect, useRef
|
|
1
|
+
import React, {useCallback, useContext, useEffect, useRef} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Animated,
|
|
4
4
|
Dimensions,
|
|
@@ -26,19 +26,20 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
26
26
|
options,
|
|
27
27
|
surface,
|
|
28
28
|
barrierDismissible = false,
|
|
29
|
-
snapPoint = 'content',
|
|
30
29
|
draggable = true,
|
|
31
|
-
dragOnContent = false,
|
|
32
30
|
useBottomInset = true,
|
|
33
31
|
}: BottomSheetParams = props.route.params;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const pan = useRef(
|
|
33
|
+
new Animated.ValueXY({
|
|
34
|
+
y: heightDevice,
|
|
35
|
+
x: 0,
|
|
36
|
+
}),
|
|
37
|
+
).current;
|
|
37
38
|
const panResponder = useRef(
|
|
38
39
|
PanResponder.create({
|
|
39
40
|
onStartShouldSetPanResponder: () => draggable,
|
|
40
41
|
onMoveShouldSetPanResponder: (_, gestureState) => {
|
|
41
|
-
return draggable &&
|
|
42
|
+
return draggable && gestureState.dy > 0;
|
|
42
43
|
},
|
|
43
44
|
onPanResponderMove: (e, gestureState) => {
|
|
44
45
|
gestureState.dy > 0 &&
|
|
@@ -59,44 +60,26 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
59
60
|
},
|
|
60
61
|
}),
|
|
61
62
|
).current;
|
|
62
|
-
const [estimate, setEstimate] = useState(0.9);
|
|
63
|
-
const timeoutMount = useRef<any>();
|
|
64
63
|
|
|
65
64
|
let backgroundColor = theme.colors.background.default;
|
|
66
65
|
if (surface) {
|
|
67
66
|
backgroundColor = theme.colors.background.surface;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
/**
|
|
71
|
-
* handle open & emit dismiss event
|
|
72
|
-
*/
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
clearTimeout(timeoutMount.current);
|
|
75
|
-
timeoutMount.current = setTimeout(() => {
|
|
76
|
-
const mapSnapPoint: any = {
|
|
77
|
-
'30%': 0.3,
|
|
78
|
-
'50%': 0.5,
|
|
79
|
-
'70%': 0.7,
|
|
80
|
-
'90%': 0.9,
|
|
81
|
-
};
|
|
82
|
-
const point = mapSnapPoint[snapPoint] ?? estimate;
|
|
83
|
-
setModalVisible(true);
|
|
84
|
-
Animated.timing(animatedHeight, {
|
|
85
|
-
useNativeDriver: false,
|
|
86
|
-
toValue: heightDevice * point,
|
|
87
|
-
duration: 150,
|
|
88
|
-
}).start();
|
|
89
|
-
}, 50);
|
|
90
|
-
}, [estimate]);
|
|
91
|
-
|
|
92
69
|
/**
|
|
93
70
|
* emit dismiss event
|
|
94
71
|
*/
|
|
95
72
|
useEffect(() => {
|
|
73
|
+
Animated.timing(pan, {
|
|
74
|
+
toValue: {x: 0, y: 0},
|
|
75
|
+
useNativeDriver: false,
|
|
76
|
+
duration: 150,
|
|
77
|
+
}).start();
|
|
96
78
|
return () => {
|
|
97
79
|
props.route.params?.onDismiss?.();
|
|
98
80
|
};
|
|
99
81
|
}, []);
|
|
82
|
+
|
|
100
83
|
/**
|
|
101
84
|
* handler dismiss
|
|
102
85
|
*/
|
|
@@ -104,94 +87,74 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
104
87
|
if (barrierDismissible && !force) {
|
|
105
88
|
return;
|
|
106
89
|
}
|
|
107
|
-
Animated.timing(
|
|
90
|
+
Animated.timing(pan, {
|
|
91
|
+
toValue: {x: 0, y: heightDevice},
|
|
108
92
|
useNativeDriver: false,
|
|
109
|
-
|
|
110
|
-
duration: 200,
|
|
93
|
+
duration: 100,
|
|
111
94
|
}).start(() => {
|
|
112
|
-
pan.setValue({x: 0, y: 0});
|
|
113
95
|
navigator?.pop();
|
|
114
96
|
});
|
|
115
97
|
};
|
|
116
98
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
99
|
+
const renderHeader = useCallback(() => {
|
|
100
|
+
return (
|
|
101
|
+
<View
|
|
102
|
+
style={{
|
|
103
|
+
backgroundColor,
|
|
104
|
+
borderTopLeftRadius: Radius.M,
|
|
105
|
+
borderTopRightRadius: Radius.M,
|
|
106
|
+
}}
|
|
107
|
+
{...panResponder.panHandlers}>
|
|
108
|
+
<View style={{height: 16}}>
|
|
109
|
+
<View style={styles.indicator} />
|
|
110
|
+
</View>
|
|
111
|
+
<View
|
|
112
|
+
style={[
|
|
113
|
+
styles.header,
|
|
114
|
+
surface && {
|
|
115
|
+
borderBottomColor: theme.colors.border.default,
|
|
116
|
+
borderBottomWidth: 1,
|
|
117
|
+
},
|
|
118
|
+
]}>
|
|
119
|
+
<View style={styles.iconButton} />
|
|
120
|
+
<Text
|
|
121
|
+
style={[Styles.flex, {textAlign: 'center'}]}
|
|
122
|
+
numberOfLines={1}
|
|
123
|
+
typography="header_default_bold">
|
|
124
|
+
{options.title ?? ''}
|
|
125
|
+
</Text>
|
|
127
126
|
<TouchableOpacity
|
|
128
|
-
style={
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
styles.header,
|
|
152
|
-
surface && {
|
|
153
|
-
borderBottomColor: theme.colors.border.default,
|
|
154
|
-
borderBottomWidth: 1,
|
|
155
|
-
},
|
|
156
|
-
]}>
|
|
157
|
-
<View style={styles.iconButton} />
|
|
158
|
-
<Text
|
|
159
|
-
style={[Styles.flex, {textAlign: 'center'}]}
|
|
160
|
-
numberOfLines={1}
|
|
161
|
-
typography="header_default_bold">
|
|
162
|
-
{options.title ?? ''}
|
|
163
|
-
</Text>
|
|
164
|
-
<TouchableOpacity
|
|
165
|
-
style={styles.iconButton}
|
|
166
|
-
onPress={() => onDismiss(true)}>
|
|
167
|
-
<Icon source="navigation_close" />
|
|
168
|
-
</TouchableOpacity>
|
|
169
|
-
</View>
|
|
170
|
-
</View>
|
|
171
|
-
)}
|
|
127
|
+
style={styles.iconButton}
|
|
128
|
+
onPress={() => onDismiss(true)}>
|
|
129
|
+
<Icon source="navigation_close" />
|
|
130
|
+
</TouchableOpacity>
|
|
131
|
+
</View>
|
|
132
|
+
</View>
|
|
133
|
+
);
|
|
134
|
+
}, []);
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<Modal transparent visible={true} onRequestClose={() => onDismiss()}>
|
|
138
|
+
<KeyboardAvoidingView
|
|
139
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
140
|
+
keyboardVerticalOffset={-20}
|
|
141
|
+
style={[Styles.flex, {justifyContent: 'flex-end'}]}>
|
|
142
|
+
<TouchableOpacity
|
|
143
|
+
style={Styles.flex}
|
|
144
|
+
activeOpacity={1}
|
|
145
|
+
onPress={() => onDismiss()}
|
|
146
|
+
/>
|
|
147
|
+
<Animated.View style={{transform: pan.getTranslateTransform()}}>
|
|
148
|
+
{renderHeader()}
|
|
149
|
+
<View style={{backgroundColor: backgroundColor}}>
|
|
172
150
|
<Screen {...props} {...props.route.params} />
|
|
173
151
|
{useBottomInset && (
|
|
174
152
|
<View style={{height: Math.min(insets.bottom, 21)}} />
|
|
175
153
|
)}
|
|
176
|
-
</
|
|
177
|
-
</
|
|
178
|
-
</
|
|
179
|
-
|
|
180
|
-
<View
|
|
181
|
-
style={styles.estimate}
|
|
182
|
-
onLayout={e => {
|
|
183
|
-
const current = (e.nativeEvent.layout.height + 72) / heightDevice;
|
|
184
|
-
if (current != estimate) {
|
|
185
|
-
setEstimate(current);
|
|
186
|
-
}
|
|
187
|
-
}}>
|
|
188
|
-
<Screen {...props} {...props.route.params} />
|
|
189
|
-
{useBottomInset && (
|
|
190
|
-
<View style={{height: Math.min(insets.bottom, 21)}} />
|
|
191
|
-
)}
|
|
192
|
-
</View>
|
|
193
|
-
)}
|
|
194
|
-
</>
|
|
154
|
+
</View>
|
|
155
|
+
</Animated.View>
|
|
156
|
+
</KeyboardAvoidingView>
|
|
157
|
+
</Modal>
|
|
195
158
|
);
|
|
196
159
|
};
|
|
197
160
|
export default BottomSheet;
|
|
@@ -26,7 +26,6 @@ type Props = BottomTabBarProps & {
|
|
|
26
26
|
activeTintColor?: string;
|
|
27
27
|
inactiveTintColor?: string;
|
|
28
28
|
floatingButton?: FloatingButtonProps;
|
|
29
|
-
accessibilityLabel?: string;
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
const getPaddingBottom = (insets: EdgeInsets) => {
|
|
@@ -65,7 +64,7 @@ export default function BottomTabBar({
|
|
|
65
64
|
*/
|
|
66
65
|
const renderTabItem = useCallback(
|
|
67
66
|
(data: any[]) => {
|
|
68
|
-
return data?.map((route,
|
|
67
|
+
return data?.map((route, _) => {
|
|
69
68
|
const focused = route.params.name === focusedTab;
|
|
70
69
|
const {options} = descriptors[route?.key] as any;
|
|
71
70
|
const onPress = () => {
|
|
@@ -90,19 +89,7 @@ export default function BottomTabBar({
|
|
|
90
89
|
});
|
|
91
90
|
};
|
|
92
91
|
|
|
93
|
-
const label =
|
|
94
|
-
options.tabBarLabel !== undefined
|
|
95
|
-
? options.tabBarLabel
|
|
96
|
-
: options.title !== undefined
|
|
97
|
-
? options.title
|
|
98
|
-
: route.name;
|
|
99
|
-
|
|
100
|
-
const accessibilityLabel =
|
|
101
|
-
options.tabBarAccessibilityLabel !== undefined
|
|
102
|
-
? options.tabBarAccessibilityLabel
|
|
103
|
-
: typeof label === 'string'
|
|
104
|
-
? `${label}, tab, ${index + 1} of ${routes.length}`
|
|
105
|
-
: undefined;
|
|
92
|
+
const label = options.tabBarLabel || options.title || route.name;
|
|
106
93
|
|
|
107
94
|
return (
|
|
108
95
|
<NavigationContext.Provider
|
|
@@ -115,7 +102,7 @@ export default function BottomTabBar({
|
|
|
115
102
|
horizontal={false}
|
|
116
103
|
onPress={onPress}
|
|
117
104
|
onLongPress={onLongPress}
|
|
118
|
-
accessibilityLabel={
|
|
105
|
+
accessibilityLabel={`tab_item_${route.name}`}
|
|
119
106
|
to={buildLink(route.name, route.params)}
|
|
120
107
|
testID={options.tabBarTestID}
|
|
121
108
|
allowFontScaling={allowFontScaling}
|
|
@@ -232,7 +219,7 @@ export default function BottomTabBar({
|
|
|
232
219
|
style,
|
|
233
220
|
]}
|
|
234
221
|
pointerEvents={'auto'}>
|
|
235
|
-
<View style={styles.content}>
|
|
222
|
+
<View style={styles.content} accessibilityLabel={'bottom_tab_bar'}>
|
|
236
223
|
{useFloating && floatingButton?.container}
|
|
237
224
|
<Animated.View
|
|
238
225
|
style={{
|
|
@@ -81,11 +81,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
81
81
|
initialRouteName={initialRouteName}
|
|
82
82
|
backBehavior={'firstRoute'}
|
|
83
83
|
tabBar={props => (
|
|
84
|
-
<BottomTabBar
|
|
85
|
-
{...props}
|
|
86
|
-
accessibilityLabel={'BottomTabBar'}
|
|
87
|
-
floatingButton={floatingButton}
|
|
88
|
-
/>
|
|
84
|
+
<BottomTabBar {...props} floatingButton={floatingButton} />
|
|
89
85
|
)}
|
|
90
86
|
tabBarOptions={{
|
|
91
87
|
style: {
|
|
@@ -50,9 +50,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
50
50
|
* tracking for screen
|
|
51
51
|
*/
|
|
52
52
|
useEffect(() => {
|
|
53
|
-
|
|
54
|
-
Alert.alert('Design system', `Unvalidated screen name "${screenName}" !`);
|
|
55
|
-
}
|
|
53
|
+
Alert.alert(screenName);
|
|
56
54
|
|
|
57
55
|
navigator?.maxApi?.of?.({screenName});
|
|
58
56
|
|
package/Application/types.ts
CHANGED
|
@@ -114,12 +114,10 @@ export type BottomSheetParams = {
|
|
|
114
114
|
title: string;
|
|
115
115
|
surface?: boolean;
|
|
116
116
|
};
|
|
117
|
-
snapPoint?: '30%' | '50%' | '70%' | '90%' | 'content';
|
|
118
117
|
surface?: boolean;
|
|
119
118
|
onDismiss?: (type?: string) => void;
|
|
120
119
|
barrierDismissible?: boolean;
|
|
121
120
|
draggable?: boolean;
|
|
122
|
-
dragOnContent?: boolean;
|
|
123
121
|
useBottomInset?: boolean;
|
|
124
122
|
};
|
|
125
123
|
|
package/Layout/Card.tsx
CHANGED
package/Layout/Screen.tsx
CHANGED
|
@@ -296,7 +296,8 @@ const Screen = forwardRef(
|
|
|
296
296
|
style={{
|
|
297
297
|
marginTop: space,
|
|
298
298
|
flex: item.props?.expanded ? 1 : undefined,
|
|
299
|
-
}}
|
|
299
|
+
}}
|
|
300
|
+
onLayout={item.props?.onLayout}>
|
|
300
301
|
{item}
|
|
301
302
|
</View>
|
|
302
303
|
);
|
|
@@ -314,7 +315,8 @@ const Screen = forwardRef(
|
|
|
314
315
|
style={{
|
|
315
316
|
marginTop: space,
|
|
316
317
|
flex: item?.props?.expanded ? 1 : undefined,
|
|
317
|
-
}}
|
|
318
|
+
}}
|
|
319
|
+
onLayout={item?.props?.onLayout}>
|
|
318
320
|
{children}
|
|
319
321
|
</View>
|
|
320
322
|
);
|
package/Layout/Section.tsx
CHANGED
package/Loader/index.tsx
CHANGED
package/Popup/PopupNotify.tsx
CHANGED
package/Popup/PopupPromotion.tsx
CHANGED
package/Popup/types.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type PopupNotifyProps = {
|
|
|
18
18
|
/**
|
|
19
19
|
* `description`: Represents the description text to be displayed in the PopupNotify component.
|
|
20
20
|
*/
|
|
21
|
-
description
|
|
21
|
+
description?: string | React.ReactNode;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* `error`: Optional. Represents additional error text to be displayed in the PopupNotify component.
|