@momo-kits/foundation 0.81.26 → 0.81.27-beta.3
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/Badge/Badge.tsx +1 -1
- package/Badge/styles.ts +2 -4
- package/Layout/Screen.tsx +81 -15
- package/Layout/types.ts +2 -0
- package/package.json +1 -1
package/Badge/Badge.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {View} from 'react-native';
|
|
|
4
4
|
import {ApplicationContext} from '../Application';
|
|
5
5
|
import {BadgeProps} from './types';
|
|
6
6
|
import styles from './styles';
|
|
7
|
-
import {Colors} from '../Consts';
|
|
7
|
+
import {Colors, Spacing} from '../Consts';
|
|
8
8
|
import {Text} from '../Text';
|
|
9
9
|
|
|
10
10
|
const Badge: FC<BadgeProps> = ({label = 'Label', style, backgroundColor}) => {
|
package/Badge/styles.ts
CHANGED
|
@@ -4,15 +4,13 @@ import {scaleSize} from '../Text';
|
|
|
4
4
|
|
|
5
5
|
export default StyleSheet.create({
|
|
6
6
|
badge: {
|
|
7
|
-
paddingHorizontal: Spacing.XS,
|
|
8
7
|
borderRadius: Radius.M,
|
|
9
8
|
justifyContent: 'center',
|
|
10
|
-
alignItems: 'center',
|
|
11
9
|
height: scaleSize(16),
|
|
12
10
|
flexDirection: 'row',
|
|
13
|
-
borderWidth: 1,
|
|
14
11
|
borderColor: Colors.black_01,
|
|
15
|
-
|
|
12
|
+
paddingHorizontal: Spacing.XS,
|
|
13
|
+
alignItems: 'center',
|
|
16
14
|
},
|
|
17
15
|
dot: {
|
|
18
16
|
width: 16,
|
package/Layout/Screen.tsx
CHANGED
|
@@ -28,6 +28,7 @@ import Navigation from '../Application/Navigation';
|
|
|
28
28
|
import styles from './styles';
|
|
29
29
|
import {AnimatedHeader, NavigationOptions} from '../Application/types';
|
|
30
30
|
import {Image} from '../Image';
|
|
31
|
+
import {HeaderType} from './types';
|
|
31
32
|
|
|
32
33
|
export interface ScreenProps extends ViewProps {
|
|
33
34
|
children: React.ReactNode;
|
|
@@ -47,9 +48,9 @@ export interface ScreenProps extends ViewProps {
|
|
|
47
48
|
scrollable?: boolean;
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
|
-
* Optional.
|
|
51
|
+
* Optional. Set type of header.
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
+
headerType?: HeaderType;
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
56
|
* Optional. Props for the animated component or bool used top navigation animated.
|
|
@@ -89,13 +90,13 @@ const Screen = forwardRef(
|
|
|
89
90
|
enableKeyboardAvoidingView = false,
|
|
90
91
|
scrollable = false,
|
|
91
92
|
navigation,
|
|
92
|
-
useExtendedHeader,
|
|
93
93
|
animatedHeader,
|
|
94
94
|
scrollViewProps,
|
|
95
95
|
headerComponent: Header,
|
|
96
96
|
footerComponent: Footer,
|
|
97
97
|
layoutOffset = -56,
|
|
98
98
|
backgroundColor,
|
|
99
|
+
headerType = 'default',
|
|
99
100
|
}: ScreenProps,
|
|
100
101
|
ref,
|
|
101
102
|
) => {
|
|
@@ -111,23 +112,14 @@ const Screen = forwardRef(
|
|
|
111
112
|
let keyboardVerticalOffset = heightHeader - 20;
|
|
112
113
|
animatedValue.current = undefined;
|
|
113
114
|
|
|
114
|
-
if (
|
|
115
|
+
if (headerType == 'extended' || animatedHeader) {
|
|
115
116
|
keyboardVerticalOffset = -20;
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
if (
|
|
119
|
+
if (headerType == 'extended') {
|
|
119
120
|
headerBackground = theme.assets?.headerBackground;
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
if (useExtendedHeader) {
|
|
124
|
-
navigation?.setOptions({
|
|
125
|
-
headerTransparent: true,
|
|
126
|
-
headerBackground: () => null,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}, [useExtendedHeader]);
|
|
130
|
-
|
|
131
123
|
useEffect(() => {
|
|
132
124
|
if (animatedHeader) {
|
|
133
125
|
styleAnimatedHeader = {
|
|
@@ -168,6 +160,69 @@ const Screen = forwardRef(
|
|
|
168
160
|
}
|
|
169
161
|
}, [animatedHeader]);
|
|
170
162
|
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if (!animatedHeader) {
|
|
165
|
+
let headerOptions: NavigationOptions = {};
|
|
166
|
+
switch (headerType) {
|
|
167
|
+
case 'none':
|
|
168
|
+
headerOptions = {
|
|
169
|
+
headerTransparent: true,
|
|
170
|
+
headerBackground: () => null,
|
|
171
|
+
headerShown: false,
|
|
172
|
+
};
|
|
173
|
+
break;
|
|
174
|
+
|
|
175
|
+
case 'surface':
|
|
176
|
+
headerOptions = {
|
|
177
|
+
headerTransparent: false,
|
|
178
|
+
headerShown: true,
|
|
179
|
+
headerTintColor: theme.colors.text.default,
|
|
180
|
+
headerBackground: (props: any) => (
|
|
181
|
+
<HeaderBackground
|
|
182
|
+
{...props}
|
|
183
|
+
image={null}
|
|
184
|
+
backgroundColor={theme.colors.background.surface}
|
|
185
|
+
useBorder={true}
|
|
186
|
+
animatedValue={animatedValue.current}
|
|
187
|
+
/>
|
|
188
|
+
),
|
|
189
|
+
headerTitle: (props: any) => (
|
|
190
|
+
<HeaderTitle {...props} animatedValue={animatedValue.current} />
|
|
191
|
+
),
|
|
192
|
+
};
|
|
193
|
+
break;
|
|
194
|
+
|
|
195
|
+
case 'extended':
|
|
196
|
+
headerOptions = {
|
|
197
|
+
headerShown: true,
|
|
198
|
+
headerTransparent: true,
|
|
199
|
+
headerTintColor: Colors.black_01,
|
|
200
|
+
headerBackground: () => null,
|
|
201
|
+
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
202
|
+
};
|
|
203
|
+
break;
|
|
204
|
+
|
|
205
|
+
default:
|
|
206
|
+
headerOptions = {
|
|
207
|
+
headerTransparent: false,
|
|
208
|
+
headerShown: true,
|
|
209
|
+
headerTintColor: Colors.black_01,
|
|
210
|
+
headerBackground: (props: any) => <HeaderBackground {...props} />,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
navigation?.setOptions(headerOptions);
|
|
215
|
+
const current: any = navigation;
|
|
216
|
+
const parent = current?.getParent?.();
|
|
217
|
+
if (parent) {
|
|
218
|
+
return current?.addListener?.('focus', () => {
|
|
219
|
+
const stackNavigation = new Navigation(parent, theme);
|
|
220
|
+
stackNavigation?.setOptions(headerOptions);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}, [headerType]);
|
|
225
|
+
|
|
171
226
|
/**
|
|
172
227
|
* animated when use scroll && animated value
|
|
173
228
|
*/
|
|
@@ -294,8 +349,19 @@ const Screen = forwardRef(
|
|
|
294
349
|
<View
|
|
295
350
|
style={{
|
|
296
351
|
paddingTop: Spacing.S,
|
|
297
|
-
paddingBottom: Math.min(insets.bottom,
|
|
352
|
+
paddingBottom: Math.min(insets.bottom, 21) + Spacing.S,
|
|
298
353
|
backgroundColor: theme.colors.background.surface,
|
|
354
|
+
...Platform.select({
|
|
355
|
+
android: {
|
|
356
|
+
elevation: 4,
|
|
357
|
+
},
|
|
358
|
+
ios: {
|
|
359
|
+
shadowColor: Colors.black_20,
|
|
360
|
+
shadowOffset: {width: 0, height: -2},
|
|
361
|
+
shadowOpacity: 0.1,
|
|
362
|
+
shadowRadius: 3,
|
|
363
|
+
},
|
|
364
|
+
}),
|
|
299
365
|
}}>
|
|
300
366
|
<Section>{Footer}</Section>
|
|
301
367
|
</View>
|
package/Layout/types.ts
CHANGED