@momo-kits/foundation 0.92.1-tracking.12 → 0.92.1-tracking.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.
- package/Application/Components.tsx +1 -1
- package/Application/ModalScreen.tsx +107 -131
- package/Application/NavigationContainer.tsx +47 -50
- package/Application/types.ts +3 -3
- package/Text/styles.ts +2 -2
- package/package.json +2 -2
|
@@ -93,7 +93,7 @@ const HeaderTitle: React.FC<any> = props => {
|
|
|
93
93
|
return (
|
|
94
94
|
<Animated.Text
|
|
95
95
|
{...props}
|
|
96
|
-
|
|
96
|
+
{...getAccessibilityID('title_navigation_header')}
|
|
97
97
|
style={[
|
|
98
98
|
styles.title,
|
|
99
99
|
{fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
import React, {useContext, useEffect,
|
|
1
|
+
import React, {useContext, useEffect, useRef} from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Dimensions,
|
|
4
|
-
Keyboard,
|
|
5
3
|
KeyboardAvoidingView,
|
|
6
4
|
Platform,
|
|
7
5
|
Pressable,
|
|
8
6
|
StyleSheet,
|
|
7
|
+
TouchableOpacity,
|
|
9
8
|
View,
|
|
10
9
|
} from 'react-native';
|
|
10
|
+
import {Modalize} from 'react-native-modalize';
|
|
11
11
|
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from '
|
|
12
|
+
|
|
13
|
+
import {ApplicationContext} from '.';
|
|
14
|
+
import {Radius, Spacing, Styles} from '../Consts';
|
|
15
|
+
import {Icon} from '../Icon';
|
|
16
|
+
import {Text} from '../Text';
|
|
17
17
|
import Navigation from './Navigation';
|
|
18
18
|
import {BottomSheetParams, ModalParams} from './types';
|
|
19
|
-
import {Radius, Spacing, Styles} from '../Consts';
|
|
20
|
-
import {
|
|
21
|
-
ApplicationContext,
|
|
22
|
-
HeaderRightAction,
|
|
23
|
-
NavigationButton,
|
|
24
|
-
NavigationContainer,
|
|
25
|
-
} from './index';
|
|
26
|
-
import {HeaderBackground, HeaderLeft, HeaderTitle} from './Components';
|
|
27
19
|
|
|
28
20
|
const ModalScreen: React.FC<any> = props => {
|
|
29
21
|
/**
|
|
@@ -92,141 +84,88 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
92
84
|
};
|
|
93
85
|
|
|
94
86
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
95
|
-
const insets = useSafeAreaInsets();
|
|
96
87
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
const {
|
|
89
|
+
screen: Screen,
|
|
90
|
+
options,
|
|
91
|
+
footerComponent,
|
|
92
|
+
flatListProps,
|
|
93
|
+
}: BottomSheetParams = props.route.params;
|
|
94
|
+
|
|
101
95
|
const navigation = new Navigation(props.navigation, theme);
|
|
96
|
+
|
|
102
97
|
const params = {
|
|
103
98
|
...props.route.params,
|
|
104
99
|
navigation,
|
|
105
100
|
};
|
|
106
101
|
|
|
107
102
|
delete params.screen;
|
|
108
|
-
|
|
109
|
-
const snapPoints = useMemo(() => {
|
|
110
|
-
if (snapPoint) {
|
|
111
|
-
const current = parseInt(snapPoint) + keyboardSnap * 100;
|
|
112
|
-
return [`${current}%`];
|
|
113
|
-
}
|
|
114
|
-
return ['50%', '70%', '90%'];
|
|
115
|
-
}, [keyboardSnap]);
|
|
116
|
-
|
|
117
|
-
const bottomSheetRef = useRef<any>(null);
|
|
118
|
-
const mountedRef = useRef(true);
|
|
119
|
-
|
|
120
|
-
let backgroundColor = theme.colors.background.default;
|
|
121
|
-
let bottomInset = keyboardSnap * Dimensions.get('window').height;
|
|
122
|
-
if (bottomInset > 16) {
|
|
123
|
-
bottomInset -= 16;
|
|
124
|
-
}
|
|
125
|
-
if (options?.surface) {
|
|
126
|
-
backgroundColor = theme.colors.background.surface;
|
|
127
|
-
}
|
|
103
|
+
const modalizeRef = useRef<Modalize>(null);
|
|
128
104
|
|
|
129
105
|
useEffect(() => {
|
|
130
|
-
|
|
131
|
-
setKeyboardSnap(
|
|
132
|
-
e.endCoordinates.height / Dimensions.get('window').height,
|
|
133
|
-
);
|
|
134
|
-
bottomSheetRef.current?.expand();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const keyboardDidHide = Keyboard.addListener('keyboardDidHide', () => {
|
|
138
|
-
setKeyboardSnap(0);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
bottomSheetRef.current?.present();
|
|
142
|
-
return () => {
|
|
143
|
-
mountedRef.current = false;
|
|
144
|
-
keyboardDidShow.remove();
|
|
145
|
-
keyboardDidHide.remove();
|
|
146
|
-
};
|
|
106
|
+
modalizeRef.current?.open();
|
|
147
107
|
}, []);
|
|
148
108
|
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
appearsOnIndex={0}
|
|
153
|
-
{...backdropProps}
|
|
154
|
-
/>
|
|
155
|
-
);
|
|
109
|
+
const handleClose = () => {
|
|
110
|
+
modalizeRef?.current?.close();
|
|
111
|
+
};
|
|
156
112
|
|
|
157
113
|
return (
|
|
158
114
|
<SafeAreaView style={Styles.flex}>
|
|
159
|
-
<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
115
|
+
<Modalize
|
|
116
|
+
keyboardAvoidingOffset={-20}
|
|
117
|
+
adjustToContentHeight
|
|
118
|
+
closeOnOverlayTap
|
|
119
|
+
closeSnapPointStraightEnabled
|
|
120
|
+
onClosed={() => {
|
|
121
|
+
navigator?.pop();
|
|
166
122
|
}}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
</View>
|
|
180
|
-
<NavigationContainer
|
|
181
|
-
maxApi={navigator?.maxApi}
|
|
182
|
-
theme={{
|
|
183
|
-
...theme,
|
|
184
|
-
assets: {...theme.assets, headerBackground: undefined},
|
|
185
|
-
}}
|
|
186
|
-
screen={props => <Component {...props} {...params} />}
|
|
187
|
-
options={{
|
|
188
|
-
...options,
|
|
189
|
-
...{
|
|
190
|
-
headerLeft: (props: any) => {
|
|
191
|
-
if (props.canGoBack) {
|
|
192
|
-
return <HeaderLeft {...props} useBorder={false} />;
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
headerTitle: (props: any) => {
|
|
196
|
-
return <HeaderTitle {...props} />;
|
|
197
|
-
},
|
|
198
|
-
headerTintColor: theme.colors.text.default,
|
|
199
|
-
headerBackground: () => (
|
|
200
|
-
<HeaderBackground backgroundColor={backgroundColor} />
|
|
201
|
-
),
|
|
202
|
-
headerTransparent: false,
|
|
203
|
-
},
|
|
204
|
-
headerTitleAlign: 'center',
|
|
205
|
-
headerRight: props => (
|
|
206
|
-
<HeaderRightAction>
|
|
207
|
-
<NavigationButton
|
|
208
|
-
{...props}
|
|
209
|
-
icon="24_navigation_close"
|
|
210
|
-
useBorder={false}
|
|
211
|
-
onPress={() => bottomSheetRef.current?.dismiss()}
|
|
212
|
-
/>
|
|
213
|
-
</HeaderRightAction>
|
|
214
|
-
),
|
|
215
|
-
}}
|
|
216
|
-
/>
|
|
217
|
-
<View
|
|
218
|
-
style={{
|
|
219
|
-
height: Math.min(insets.bottom, 20),
|
|
220
|
-
backgroundColor: indicatorColor ?? backgroundColor,
|
|
221
|
-
}}
|
|
222
|
-
/>
|
|
223
|
-
</View>
|
|
224
|
-
</BottomSheetView>
|
|
225
|
-
</BottomSheetModal>
|
|
123
|
+
ref={modalizeRef}
|
|
124
|
+
withHandle={false}
|
|
125
|
+
flatListProps={flatListProps}
|
|
126
|
+
HeaderComponent={headerDefault(
|
|
127
|
+
options?.title ?? options?.customTitle?.title ?? '',
|
|
128
|
+
handleClose,
|
|
129
|
+
)}
|
|
130
|
+
FooterComponent={footerDefault(footerComponent)}>
|
|
131
|
+
<View style={styles.bottomSheetContainer}>
|
|
132
|
+
<Screen {...props} {...params} />
|
|
133
|
+
</View>
|
|
134
|
+
</Modalize>
|
|
226
135
|
</SafeAreaView>
|
|
227
136
|
);
|
|
228
137
|
};
|
|
229
138
|
|
|
139
|
+
const headerDefault = (title: string, onClose: () => void) => {
|
|
140
|
+
return (
|
|
141
|
+
<View style={styles.header}>
|
|
142
|
+
<Text
|
|
143
|
+
style={styles.textOption}
|
|
144
|
+
numberOfLines={2}
|
|
145
|
+
typography="header_default_bold">
|
|
146
|
+
{title ?? ''}
|
|
147
|
+
</Text>
|
|
148
|
+
<TouchableOpacity style={styles.buttonClose} onPress={onClose}>
|
|
149
|
+
<Icon source="navigation_close" />
|
|
150
|
+
</TouchableOpacity>
|
|
151
|
+
</View>
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const footerDefault = (footerComponent: React.ReactNode) => {
|
|
156
|
+
const insets = useSafeAreaInsets();
|
|
157
|
+
if (!footerComponent) return;
|
|
158
|
+
return (
|
|
159
|
+
<View
|
|
160
|
+
style={{
|
|
161
|
+
marginBottom: Math.min(insets.bottom, 21) + Spacing.S,
|
|
162
|
+
paddingHorizontal: 12,
|
|
163
|
+
}}>
|
|
164
|
+
{footerComponent}
|
|
165
|
+
</View>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
|
|
230
169
|
const styles = StyleSheet.create({
|
|
231
170
|
container: {flex: 1, flexDirection: 'row'},
|
|
232
171
|
modalContent: {
|
|
@@ -263,6 +202,43 @@ const styles = StyleSheet.create({
|
|
|
263
202
|
height: 4,
|
|
264
203
|
borderRadius: Radius.S,
|
|
265
204
|
},
|
|
205
|
+
bottomSheetContainer: {
|
|
206
|
+
width: '100%',
|
|
207
|
+
backgroundColor: 'white',
|
|
208
|
+
borderTopRightRadius: 16,
|
|
209
|
+
borderTopLeftRadius: 16,
|
|
210
|
+
},
|
|
211
|
+
header: {
|
|
212
|
+
height: 50,
|
|
213
|
+
width: '100%',
|
|
214
|
+
alignItems: 'center',
|
|
215
|
+
justifyContent: 'center',
|
|
216
|
+
},
|
|
217
|
+
textOption: {
|
|
218
|
+
fontSize: 16,
|
|
219
|
+
color: '#303233',
|
|
220
|
+
textAlign: 'center',
|
|
221
|
+
fontWeight: 'bold',
|
|
222
|
+
paddingHorizontal: 60,
|
|
223
|
+
},
|
|
224
|
+
imageOption: {
|
|
225
|
+
height: 1,
|
|
226
|
+
backgroundColor: '#ebebeb',
|
|
227
|
+
width: '100%',
|
|
228
|
+
position: 'absolute',
|
|
229
|
+
bottom: 1,
|
|
230
|
+
},
|
|
231
|
+
buttonClose: {
|
|
232
|
+
padding: 12,
|
|
233
|
+
position: 'absolute',
|
|
234
|
+
right: 0,
|
|
235
|
+
},
|
|
236
|
+
icon: {
|
|
237
|
+
width: 24,
|
|
238
|
+
height: 24,
|
|
239
|
+
tintColor: '#303233',
|
|
240
|
+
backgroundColor: 'red',
|
|
241
|
+
},
|
|
266
242
|
});
|
|
267
243
|
|
|
268
244
|
export default ModalScreen;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef, useState} from 'react';
|
|
2
|
-
import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
|
|
3
2
|
import {SafeAreaProvider} from 'react-native-safe-area-context';
|
|
4
3
|
import {
|
|
5
4
|
NavigationContainer as ReactNavigationContainer,
|
|
@@ -69,55 +68,53 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
69
68
|
|
|
70
69
|
return (
|
|
71
70
|
<SafeAreaProvider>
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
theme
|
|
83
|
-
|
|
84
|
-
colors
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
<Stack.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
</ApplicationContext.Provider>
|
|
120
|
-
</BottomSheetModalProvider>
|
|
71
|
+
<ApplicationContext.Provider
|
|
72
|
+
value={{
|
|
73
|
+
navigator: navigator.current,
|
|
74
|
+
config: config.current,
|
|
75
|
+
theme,
|
|
76
|
+
showGrid,
|
|
77
|
+
translate,
|
|
78
|
+
}}>
|
|
79
|
+
<ReactNavigationContainer
|
|
80
|
+
theme={{
|
|
81
|
+
...theme,
|
|
82
|
+
colors: {
|
|
83
|
+
...theme.colors,
|
|
84
|
+
background: theme.colors.background.default,
|
|
85
|
+
card: theme.colors.background.surface,
|
|
86
|
+
text: theme.colors.text.default,
|
|
87
|
+
border: theme.colors.border.default,
|
|
88
|
+
notification: theme.colors.error.primary,
|
|
89
|
+
},
|
|
90
|
+
}}
|
|
91
|
+
ref={navigator.current?.ref}
|
|
92
|
+
onReady={() => {
|
|
93
|
+
isReady.current = true;
|
|
94
|
+
}}
|
|
95
|
+
independent={true}>
|
|
96
|
+
<Stack.Navigator initialRouteName="Stack" headerMode="screen">
|
|
97
|
+
<Stack.Screen
|
|
98
|
+
name="Stack"
|
|
99
|
+
component={StackScreen}
|
|
100
|
+
initialParams={{screen, initialParams}}
|
|
101
|
+
options={{...getStackOptions(), ...options}}
|
|
102
|
+
/>
|
|
103
|
+
<Stack.Screen
|
|
104
|
+
name="Dialog"
|
|
105
|
+
component={StackScreen}
|
|
106
|
+
options={getDialogOptions()}
|
|
107
|
+
initialParams={{screen}}
|
|
108
|
+
/>
|
|
109
|
+
<Stack.Screen
|
|
110
|
+
name="Modal"
|
|
111
|
+
component={ModalScreen}
|
|
112
|
+
options={getModalOptions()}
|
|
113
|
+
initialParams={{screen}}
|
|
114
|
+
/>
|
|
115
|
+
</Stack.Navigator>
|
|
116
|
+
</ReactNavigationContainer>
|
|
117
|
+
</ApplicationContext.Provider>
|
|
121
118
|
</SafeAreaProvider>
|
|
122
119
|
);
|
|
123
120
|
};
|
package/Application/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Animated, ViewProps} from 'react-native';
|
|
1
|
+
import {Animated, FlatListProps, ViewProps} from 'react-native';
|
|
2
2
|
import {StackNavigationOptions} from '@react-navigation/stack';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Navigator from './Navigator';
|
|
@@ -119,8 +119,8 @@ export interface ModalParams extends ScreenParams {
|
|
|
119
119
|
export interface BottomSheetParams extends ScreenParams {
|
|
120
120
|
[key: string]: any;
|
|
121
121
|
onDismiss?: () => void;
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
footerComponent?: React.ReactNode;
|
|
123
|
+
flatListProps: FlatListProps<any>;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
export type NavigationButtonProps = {
|
package/Text/styles.ts
CHANGED
|
@@ -22,8 +22,8 @@ export default {
|
|
|
22
22
|
fontWeight: '400',
|
|
23
23
|
textDecorationLine: 'line-through',
|
|
24
24
|
},
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
description_xs_regular: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
|
|
26
|
+
description_xs_regularstrikethrought: {
|
|
27
27
|
fontSize: 10,
|
|
28
28
|
lineHeight: 14,
|
|
29
29
|
fontWeight: '400',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.92.1-tracking.
|
|
3
|
+
"version": "0.92.1-tracking.14",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"@momo-kits/foundation"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@gorhom/bottom-sheet": "git+https://gitlab.com/momo-platform/bottom-sheet.git#main",
|
|
14
13
|
"react-native-safe-area-context": "3.1.4",
|
|
15
14
|
"react-native-linear-gradient": "2.8.3",
|
|
16
15
|
"react-native-gesture-handler": "1.10.3",
|
|
16
|
+
"react-native-modalize": "2.1.1",
|
|
17
17
|
"react-native-fast-image": "8.1.5",
|
|
18
18
|
"@react-navigation/bottom-tabs": "git+https://gitlab.com/momo-platform/react-navigation-bottom-tabs.git#main",
|
|
19
19
|
"@react-navigation/core": "5.16.1",
|