@momo-kits/foundation 0.81.8 → 0.81.9
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/BottomTab.tsx +9 -2
- package/Application/StackScreen.tsx +3 -1
- package/Application/types.ts +1 -0
- package/Image/index.tsx +9 -8
- package/Input/Input.tsx +3 -1
- package/Input/InputSearch.tsx +1 -1
- package/Input/index.tsx +2 -0
- package/Layout/Screen.tsx +0 -1
- package/Popup/PopupNotify.tsx +21 -5
- package/Title/index.tsx +16 -4
- package/Title/styles.ts +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,12 @@ import {ApplicationContext} from './index';
|
|
|
8
8
|
|
|
9
9
|
const Tab = createBottomTabNavigator();
|
|
10
10
|
|
|
11
|
-
const BottomTab: React.FC<BottomTabProps> = ({
|
|
11
|
+
const BottomTab: React.FC<BottomTabProps> = ({
|
|
12
|
+
tabs,
|
|
13
|
+
listeners,
|
|
14
|
+
navigation,
|
|
15
|
+
initialRouteName,
|
|
16
|
+
}) => {
|
|
12
17
|
const {theme} = useContext(ApplicationContext);
|
|
13
18
|
|
|
14
19
|
const defaultListener = {
|
|
@@ -21,7 +26,9 @@ const BottomTab: React.FC<BottomTabProps> = ({tabs, listeners, navigation}) => {
|
|
|
21
26
|
};
|
|
22
27
|
|
|
23
28
|
return (
|
|
24
|
-
<Tab.Navigator
|
|
29
|
+
<Tab.Navigator
|
|
30
|
+
initialRouteName={initialRouteName}
|
|
31
|
+
backBehavior={'firstRoute'}>
|
|
25
32
|
{tabs.map(item => {
|
|
26
33
|
return (
|
|
27
34
|
<Tab.Screen
|
|
@@ -3,11 +3,13 @@ import {ScreenParams} from './types';
|
|
|
3
3
|
import Navigation from './Navigation';
|
|
4
4
|
import {ApplicationContext} from './index';
|
|
5
5
|
import {GridSystem} from '../Layout';
|
|
6
|
+
import {useHeaderHeight} from '@react-navigation/stack';
|
|
6
7
|
|
|
7
8
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
8
9
|
const {screen: Component, options}: ScreenParams = props.route.params;
|
|
9
10
|
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
10
11
|
const navigation = new Navigation(props.navigation, theme);
|
|
12
|
+
const heightHeader = useHeaderHeight();
|
|
11
13
|
|
|
12
14
|
const params = {
|
|
13
15
|
...props.route.params,
|
|
@@ -50,7 +52,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
50
52
|
|
|
51
53
|
return (
|
|
52
54
|
<>
|
|
53
|
-
<Component {...params} />
|
|
55
|
+
<Component heightHeader={heightHeader} {...params} />
|
|
54
56
|
{showGrid && <GridSystem />}
|
|
55
57
|
</>
|
|
56
58
|
);
|
package/Application/types.ts
CHANGED
package/Image/index.tsx
CHANGED
|
@@ -20,13 +20,12 @@ const Image: React.FC<ImageProps> = ({
|
|
|
20
20
|
style,
|
|
21
21
|
source,
|
|
22
22
|
accessibilityLabel,
|
|
23
|
+
loading,
|
|
23
24
|
...rest
|
|
24
25
|
}) => {
|
|
25
26
|
const {theme} = useContext(ApplicationContext);
|
|
26
27
|
const error = useRef(false);
|
|
27
|
-
const [status, setStatus] = useState<Status>(
|
|
28
|
-
rest.loading ? 'loading' : 'success',
|
|
29
|
-
);
|
|
28
|
+
const [status, setStatus] = useState<Status>('success');
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* render content loading | fail | rendered
|
|
@@ -65,16 +64,18 @@ const Image: React.FC<ImageProps> = ({
|
|
|
65
64
|
<FastImage
|
|
66
65
|
{...rest}
|
|
67
66
|
source={source}
|
|
67
|
+
fallback={false}
|
|
68
68
|
style={styles.image}
|
|
69
|
+
onProgress={() => {
|
|
70
|
+
if (status != 'loading' && loading) setStatus('loading');
|
|
71
|
+
}}
|
|
69
72
|
onLoadStart={() => {
|
|
70
73
|
error.current = false;
|
|
71
74
|
}}
|
|
72
75
|
onLoadEnd={() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
setStatus('success');
|
|
77
|
-
}
|
|
76
|
+
let current: Status = 'success';
|
|
77
|
+
if (error.current) current = 'error';
|
|
78
|
+
if (status != current) setStatus(current);
|
|
78
79
|
}}
|
|
79
80
|
onError={() => {
|
|
80
81
|
error.current = true;
|
package/Input/Input.tsx
CHANGED
|
@@ -35,6 +35,7 @@ const Input = forwardRef(
|
|
|
35
35
|
loading,
|
|
36
36
|
leadingIcon,
|
|
37
37
|
leadingIconColor,
|
|
38
|
+
fontWeight = 'normal',
|
|
38
39
|
style,
|
|
39
40
|
...props
|
|
40
41
|
}: InputProps,
|
|
@@ -80,6 +81,7 @@ const Input = forwardRef(
|
|
|
80
81
|
let textColor = theme.colors.text.default;
|
|
81
82
|
let placeholderColor = theme.colors.text.hint;
|
|
82
83
|
let iconTintColor = iconColor;
|
|
84
|
+
const inputTextWeight = fontWeight === 'bold' ? 'Bold' : 'Regular';
|
|
83
85
|
|
|
84
86
|
if (disabled) {
|
|
85
87
|
textColor = disabledColor;
|
|
@@ -122,7 +124,7 @@ const Input = forwardRef(
|
|
|
122
124
|
styles.input,
|
|
123
125
|
{
|
|
124
126
|
color: textColor,
|
|
125
|
-
fontFamily: `${theme.font}
|
|
127
|
+
fontFamily: `${theme.font}-${inputTextWeight}`,
|
|
126
128
|
},
|
|
127
129
|
]}
|
|
128
130
|
textBreakStrategy="highQuality"
|
package/Input/InputSearch.tsx
CHANGED
package/Input/index.tsx
CHANGED
package/Layout/Screen.tsx
CHANGED
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, {useContext} from 'react';
|
|
2
|
-
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
1
|
+
import React, {useContext, useState} from 'react';
|
|
2
|
+
import {ScrollView, StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {PopupNotifyProps} from './types';
|
|
4
4
|
import {Radius, Spacing, Styles} from '../Consts';
|
|
5
5
|
import {Image} from '../Image';
|
|
@@ -19,6 +19,14 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
19
19
|
onIconClose,
|
|
20
20
|
}) => {
|
|
21
21
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
22
|
+
const [scrollContent, setScrollContent] = useState(false);
|
|
23
|
+
|
|
24
|
+
let descriptionStyle = {};
|
|
25
|
+
let Description: any = View;
|
|
26
|
+
if (scrollContent) {
|
|
27
|
+
Description = ScrollView;
|
|
28
|
+
descriptionStyle = {height: 80};
|
|
29
|
+
}
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* on action popup
|
|
@@ -143,11 +151,19 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
143
151
|
<Text typography={'title_xs'} numberOfLines={1}>
|
|
144
152
|
{title}
|
|
145
153
|
</Text>
|
|
146
|
-
<
|
|
147
|
-
<Text
|
|
154
|
+
<Description style={[styles.description, descriptionStyle]}>
|
|
155
|
+
<Text
|
|
156
|
+
typography={'paragraph_default'}
|
|
157
|
+
numberOfLines={4}
|
|
158
|
+
onTextLayout={({nativeEvent: {lines}}) => {
|
|
159
|
+
const enableScroll = lines.length > 3;
|
|
160
|
+
if (enableScroll != scrollContent) {
|
|
161
|
+
setScrollContent(enableScroll);
|
|
162
|
+
}
|
|
163
|
+
}}>
|
|
148
164
|
{description}
|
|
149
165
|
</Text>
|
|
150
|
-
</
|
|
166
|
+
</Description>
|
|
151
167
|
{!!information && (
|
|
152
168
|
<View style={styles.information}>
|
|
153
169
|
<Text
|
package/Title/index.tsx
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import React, {FC, useContext} from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, {FC, useContext, useState} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
LayoutChangeEvent,
|
|
4
|
+
Text as RNText,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
View,
|
|
7
|
+
} from 'react-native';
|
|
3
8
|
import {TitleProps} from './types';
|
|
4
9
|
import {Icon} from '../Icon';
|
|
5
10
|
import styles from './styles';
|
|
@@ -19,6 +24,7 @@ const Title: FC<TitleProps> = ({
|
|
|
19
24
|
description,
|
|
20
25
|
}) => {
|
|
21
26
|
const {theme} = useContext(ApplicationContext);
|
|
27
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
22
28
|
const flexStyle = titleFlex ? {flex: 1} : {};
|
|
23
29
|
const typeStyle =
|
|
24
30
|
type === 'screen' ? styles.screen : styles[`${type}_${size}`];
|
|
@@ -31,7 +37,7 @@ const Title: FC<TitleProps> = ({
|
|
|
31
37
|
const actionSize = titleFlex ? scaleSize(22) : scaleSize(18);
|
|
32
38
|
const titleWeight = type === 'screen' ? 'Semibold' : 'Bold';
|
|
33
39
|
const marginStyle = type === 'section' ? {marginTop: Spacing.M} : {};
|
|
34
|
-
|
|
40
|
+
const numberOfLines = type === 'section' ? 1 : 2;
|
|
35
41
|
const renderAction = () => {
|
|
36
42
|
return !!actionTitle && titleFlex ? (
|
|
37
43
|
<TouchableOpacity onPress={onPressAction}>
|
|
@@ -56,13 +62,18 @@ const Title: FC<TitleProps> = ({
|
|
|
56
62
|
);
|
|
57
63
|
};
|
|
58
64
|
|
|
65
|
+
const onLayout = (e: LayoutChangeEvent) => {
|
|
66
|
+
setContainerWidth(e.nativeEvent.layout.width);
|
|
67
|
+
};
|
|
68
|
+
|
|
59
69
|
return (
|
|
60
|
-
<View style={styles.wrapper}>
|
|
70
|
+
<View onLayout={onLayout} style={styles.wrapper}>
|
|
61
71
|
<View style={[styles.container, marginStyle]}>
|
|
62
72
|
{!!icon && type !== 'screen' && (
|
|
63
73
|
<Icon style={styles.icon} source={icon} />
|
|
64
74
|
)}
|
|
65
75
|
<RNText
|
|
76
|
+
numberOfLines={numberOfLines}
|
|
66
77
|
style={[
|
|
67
78
|
typeStyle,
|
|
68
79
|
flexStyle,
|
|
@@ -70,6 +81,7 @@ const Title: FC<TitleProps> = ({
|
|
|
70
81
|
{
|
|
71
82
|
fontFamily: `${theme.font}-${titleWeight}`,
|
|
72
83
|
color: theme.colors.text.default,
|
|
84
|
+
maxWidth: containerWidth - scaleSize(22),
|
|
73
85
|
},
|
|
74
86
|
]}>
|
|
75
87
|
{title}
|
package/Title/styles.ts
CHANGED