@momo-kits/foundation 0.77.1-optimzie.6 → 0.77.1-optimzie.7
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/ModalScreen.tsx +68 -46
- package/Application/types.ts +2 -2
- package/package.json +1 -1
|
@@ -85,11 +85,13 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
85
85
|
|
|
86
86
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
87
87
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
88
|
+
const insets = useSafeAreaInsets();
|
|
89
|
+
|
|
88
90
|
const {
|
|
89
91
|
screen: Screen,
|
|
90
92
|
options,
|
|
91
93
|
footerComponent,
|
|
92
|
-
|
|
94
|
+
scrollViewProps,
|
|
93
95
|
backgroundColor,
|
|
94
96
|
}: BottomSheetParams = props.route.params;
|
|
95
97
|
|
|
@@ -101,14 +103,59 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
101
103
|
};
|
|
102
104
|
|
|
103
105
|
delete params.screen;
|
|
104
|
-
const
|
|
106
|
+
const modalRef = useRef<Modalize>(null);
|
|
105
107
|
|
|
106
108
|
useEffect(() => {
|
|
107
|
-
|
|
109
|
+
modalRef.current?.open();
|
|
108
110
|
}, []);
|
|
109
111
|
|
|
110
112
|
const handleClose = () => {
|
|
111
|
-
|
|
113
|
+
modalRef?.current?.close();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* build header
|
|
118
|
+
* @param title
|
|
119
|
+
* @param onClose
|
|
120
|
+
*/
|
|
121
|
+
const headerDefault = (title: string, onClose: () => void) => {
|
|
122
|
+
return (
|
|
123
|
+
<View
|
|
124
|
+
style={[
|
|
125
|
+
styles.header,
|
|
126
|
+
{borderBottomColor: theme.colors.border.default},
|
|
127
|
+
]}>
|
|
128
|
+
<View style={styles.iconButton} />
|
|
129
|
+
<Text
|
|
130
|
+
style={styles.textOption}
|
|
131
|
+
numberOfLines={1}
|
|
132
|
+
typography="header_default_bold">
|
|
133
|
+
{title ?? ''}
|
|
134
|
+
</Text>
|
|
135
|
+
<TouchableOpacity style={styles.iconButton} onPress={onClose}>
|
|
136
|
+
<Icon source="navigation_close" />
|
|
137
|
+
</TouchableOpacity>
|
|
138
|
+
</View>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* build footer
|
|
144
|
+
* @param footerComponent
|
|
145
|
+
*/
|
|
146
|
+
const footerDefault = (footerComponent: React.ReactNode) => {
|
|
147
|
+
if (footerComponent) {
|
|
148
|
+
return (
|
|
149
|
+
<View
|
|
150
|
+
style={{
|
|
151
|
+
marginBottom: Math.min(insets.bottom, 21),
|
|
152
|
+
paddingHorizontal: Spacing.M,
|
|
153
|
+
paddingVertical: Spacing.S,
|
|
154
|
+
}}>
|
|
155
|
+
{footerComponent}
|
|
156
|
+
</View>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
112
159
|
};
|
|
113
160
|
|
|
114
161
|
return (
|
|
@@ -121,9 +168,12 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
121
168
|
onClosed={() => {
|
|
122
169
|
navigator?.pop();
|
|
123
170
|
}}
|
|
124
|
-
|
|
125
|
-
withHandle={
|
|
126
|
-
|
|
171
|
+
handlePosition="inside"
|
|
172
|
+
withHandle={true}
|
|
173
|
+
disableScrollIfPossible={true}
|
|
174
|
+
modalTopOffset={insets.top}
|
|
175
|
+
ref={modalRef}
|
|
176
|
+
scrollViewProps={scrollViewProps}
|
|
127
177
|
HeaderComponent={headerDefault(
|
|
128
178
|
options?.title ?? options?.customTitle?.title ?? '',
|
|
129
179
|
handleClose,
|
|
@@ -140,38 +190,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
140
190
|
);
|
|
141
191
|
};
|
|
142
192
|
|
|
143
|
-
const headerDefault = (title: string, onClose: () => void) => {
|
|
144
|
-
return (
|
|
145
|
-
<View style={styles.header}>
|
|
146
|
-
<Text
|
|
147
|
-
style={styles.textOption}
|
|
148
|
-
numberOfLines={1}
|
|
149
|
-
typography="header_default_bold">
|
|
150
|
-
{title ?? ''}
|
|
151
|
-
</Text>
|
|
152
|
-
<TouchableOpacity style={styles.buttonClose} onPress={onClose}>
|
|
153
|
-
<Icon source="navigation_close" />
|
|
154
|
-
</TouchableOpacity>
|
|
155
|
-
</View>
|
|
156
|
-
);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const footerDefault = (footerComponent: React.ReactNode) => {
|
|
160
|
-
const insets = useSafeAreaInsets();
|
|
161
|
-
if (footerComponent) {
|
|
162
|
-
return (
|
|
163
|
-
<View
|
|
164
|
-
style={{
|
|
165
|
-
marginBottom: Math.min(insets.bottom, 21),
|
|
166
|
-
paddingHorizontal: Spacing.M,
|
|
167
|
-
paddingVertical: Spacing.S,
|
|
168
|
-
}}>
|
|
169
|
-
{footerComponent}
|
|
170
|
-
</View>
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
193
|
const styles = StyleSheet.create({
|
|
176
194
|
container: {flex: 1, flexDirection: 'row'},
|
|
177
195
|
modalContent: {
|
|
@@ -212,10 +230,12 @@ const styles = StyleSheet.create({
|
|
|
212
230
|
width: '100%',
|
|
213
231
|
},
|
|
214
232
|
header: {
|
|
215
|
-
|
|
233
|
+
marginTop: 10,
|
|
234
|
+
height: 56,
|
|
216
235
|
width: '100%',
|
|
217
236
|
alignItems: 'center',
|
|
218
|
-
|
|
237
|
+
flexDirection: 'row',
|
|
238
|
+
borderBottomWidth: 1,
|
|
219
239
|
},
|
|
220
240
|
textOption: {
|
|
221
241
|
fontSize: 16,
|
|
@@ -223,12 +243,14 @@ const styles = StyleSheet.create({
|
|
|
223
243
|
textAlign: 'center',
|
|
224
244
|
fontWeight: 'bold',
|
|
225
245
|
paddingHorizontal: Spacing.L,
|
|
246
|
+
flex: 1,
|
|
226
247
|
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
248
|
+
iconButton: {
|
|
249
|
+
width: 24,
|
|
250
|
+
height: 24,
|
|
251
|
+
alignItems: 'center',
|
|
252
|
+
justifyContent: 'center',
|
|
253
|
+
marginHorizontal: Spacing.M,
|
|
232
254
|
},
|
|
233
255
|
icon: {
|
|
234
256
|
width: 24,
|
package/Application/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {StackNavigationOptions} from '@react-navigation/stack';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {Animated,
|
|
3
|
+
import {Animated, ScrollViewProps, ViewProps} from 'react-native';
|
|
4
4
|
import {PopupNotifyProps} from '../Popup/types';
|
|
5
5
|
import Navigation from './Navigation';
|
|
6
6
|
import Navigator from './Navigator';
|
|
@@ -121,7 +121,7 @@ export interface BottomSheetParams extends ScreenParams {
|
|
|
121
121
|
onDismiss?: () => void;
|
|
122
122
|
backgroundColor?: string;
|
|
123
123
|
footerComponent?: React.ReactNode;
|
|
124
|
-
|
|
124
|
+
scrollViewProps?: ScrollViewProps;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
export type NavigationButtonProps = {
|