@momo-kits/foundation 0.79.6-beta.4 → 0.79.6-beta.6
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 +5 -1
- package/Application/ModalScreen.tsx +11 -3
- package/Application/NavigationContainer.tsx +7 -2
- package/Switch/index.tsx +3 -5
- package/Title/index.tsx +89 -0
- package/Title/styles.ts +46 -0
- package/Title/types.ts +11 -0
- package/index.ts +2 -0
- package/package.json +2 -2
- package/verify.js +17 -7
|
@@ -225,7 +225,11 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
225
225
|
barStyle={headerImage || theme.dark ? 'light-content' : 'dark-content'}
|
|
226
226
|
/>
|
|
227
227
|
{!!headerImage && (
|
|
228
|
-
<Image
|
|
228
|
+
<Image
|
|
229
|
+
style={styles.headerBackground}
|
|
230
|
+
source={{uri: headerImage}}
|
|
231
|
+
loading={false}
|
|
232
|
+
/>
|
|
229
233
|
)}
|
|
230
234
|
</Animated.View>
|
|
231
235
|
);
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
StyleSheet,
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
|
-
import {SafeAreaView} from 'react-native-safe-area-context';
|
|
9
|
+
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
10
10
|
import {
|
|
11
11
|
BottomSheetBackdrop,
|
|
12
12
|
BottomSheetModal,
|
|
@@ -87,6 +87,7 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
90
|
+
const insets = useSafeAreaInsets();
|
|
90
91
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
91
92
|
const {screen, options, snapPoint}: BottomSheetParams = props.route.params;
|
|
92
93
|
const Component = useRef(screen).current;
|
|
@@ -102,7 +103,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
102
103
|
if (snapPoint) {
|
|
103
104
|
return [snapPoint];
|
|
104
105
|
}
|
|
105
|
-
return ['50%', '90%'];
|
|
106
|
+
return ['50%', '70%', '90%'];
|
|
106
107
|
}, []);
|
|
107
108
|
|
|
108
109
|
const bottomSheetRef = useRef<any>(null);
|
|
@@ -141,7 +142,14 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
141
142
|
handleComponent={null}
|
|
142
143
|
backdropComponent={backdropComponent}>
|
|
143
144
|
<BottomSheetView accessibilityLabel={'BottomSheet'}>
|
|
144
|
-
<View
|
|
145
|
+
<View
|
|
146
|
+
style={[
|
|
147
|
+
styles.sheetContainer,
|
|
148
|
+
{
|
|
149
|
+
backgroundColor,
|
|
150
|
+
paddingBottom: Math.min(insets.bottom, 20) + Spacing.S,
|
|
151
|
+
},
|
|
152
|
+
]}>
|
|
145
153
|
<View style={styles.indicatorContainer}>
|
|
146
154
|
<View
|
|
147
155
|
style={[
|
|
@@ -10,9 +10,10 @@ import StackScreen from './StackScreen';
|
|
|
10
10
|
import ModalScreen from './ModalScreen';
|
|
11
11
|
import Navigator from './Navigator';
|
|
12
12
|
import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
13
|
-
import {NavigationContainerProps} from './types';
|
|
13
|
+
import {LocalizationObject, NavigationContainerProps} from './types';
|
|
14
14
|
import {ApplicationContext} from './index';
|
|
15
15
|
import {DeviceEventEmitter} from 'react-native';
|
|
16
|
+
import kitLocalization from '../Assets/language.json';
|
|
16
17
|
|
|
17
18
|
const Stack = createStackNavigator();
|
|
18
19
|
|
|
@@ -52,7 +53,11 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
52
53
|
navigator.current.maxApi = maxApi;
|
|
53
54
|
|
|
54
55
|
const translate = (key: string) => {
|
|
55
|
-
|
|
56
|
+
const mergedLocalization: LocalizationObject = {
|
|
57
|
+
vi: {...localization?.vi, ...kitLocalization.vi},
|
|
58
|
+
en: {...localization?.en, ...kitLocalization.en},
|
|
59
|
+
};
|
|
60
|
+
return mergedLocalization?.[language]?.[key] || key;
|
|
56
61
|
};
|
|
57
62
|
|
|
58
63
|
return (
|
package/Switch/index.tsx
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import React, {FC
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
2
|
import {TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {SwitchProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {ApplicationContext} from '../Application';
|
|
6
5
|
import {Colors} from '../Consts';
|
|
7
6
|
|
|
8
7
|
const Switch: FC<SwitchProps> = props => {
|
|
9
|
-
const {theme} = useContext(ApplicationContext);
|
|
10
8
|
const {value, onChange, disabled, style} = props;
|
|
11
9
|
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
12
10
|
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
13
11
|
|
|
14
|
-
let backgroundColor = value ?
|
|
12
|
+
let backgroundColor = value ? Colors.green_03 : Colors.black_07;
|
|
15
13
|
if (disabled) {
|
|
16
|
-
backgroundColor = value ?
|
|
14
|
+
backgroundColor = value ? Colors.green_09 : Colors.black_05;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
return (
|
package/Title/index.tsx
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {Text as RNText, TouchableOpacity, View} from 'react-native';
|
|
3
|
+
import {TitleProps} from './types';
|
|
4
|
+
import {Icon} from '../Icon';
|
|
5
|
+
import styles from './styles';
|
|
6
|
+
import {ApplicationContext} from '../Application';
|
|
7
|
+
import {Colors, Spacing} from '../Consts';
|
|
8
|
+
import {Button} from '../Button';
|
|
9
|
+
import {scaleSize, Text} from '../Text';
|
|
10
|
+
|
|
11
|
+
const Title: FC<TitleProps> = ({
|
|
12
|
+
size = 'large',
|
|
13
|
+
type = 'section',
|
|
14
|
+
onPressAction,
|
|
15
|
+
actionTitle,
|
|
16
|
+
title = 'Title',
|
|
17
|
+
titleFlex = true,
|
|
18
|
+
showAction = true,
|
|
19
|
+
icon,
|
|
20
|
+
description,
|
|
21
|
+
}) => {
|
|
22
|
+
const {theme} = useContext(ApplicationContext);
|
|
23
|
+
const flexStyle = titleFlex ? {flex: 1} : {};
|
|
24
|
+
const typeStyle =
|
|
25
|
+
type === 'screen' ? styles.screen : styles[`${type}_${size}`];
|
|
26
|
+
const actionColor = titleFlex
|
|
27
|
+
? theme.colors.primary
|
|
28
|
+
: theme.colors.text.default;
|
|
29
|
+
const actionBackground = titleFlex ? Colors.pink_08 + '4D' : Colors.black_06;
|
|
30
|
+
const actionSize = titleFlex ? scaleSize(22) : scaleSize(18);
|
|
31
|
+
const titleWeight = type === 'screen' ? 'Semibold' : 'Bold';
|
|
32
|
+
const marginStyle = type === 'section' ? {marginTop: Spacing.M} : {};
|
|
33
|
+
|
|
34
|
+
const renderAction = () => {
|
|
35
|
+
return !!actionTitle && titleFlex ? (
|
|
36
|
+
<Button
|
|
37
|
+
onPress={() => onPressAction?.()}
|
|
38
|
+
type={'text'}
|
|
39
|
+
full={false}
|
|
40
|
+
size={'small'}
|
|
41
|
+
title={actionTitle}
|
|
42
|
+
/>
|
|
43
|
+
) : (
|
|
44
|
+
<TouchableOpacity
|
|
45
|
+
style={[
|
|
46
|
+
{backgroundColor: actionBackground},
|
|
47
|
+
styles.actionIcon,
|
|
48
|
+
{width: actionSize, height: actionSize},
|
|
49
|
+
]}
|
|
50
|
+
onPress={onPressAction}>
|
|
51
|
+
<Icon
|
|
52
|
+
size={actionSize}
|
|
53
|
+
color={actionColor}
|
|
54
|
+
source={'arrow_chevron_right_small'}
|
|
55
|
+
/>
|
|
56
|
+
</TouchableOpacity>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View style={styles.wrapper}>
|
|
62
|
+
<View style={[styles.container, marginStyle]}>
|
|
63
|
+
{!!icon && type !== 'screen' && (
|
|
64
|
+
<Icon style={styles.icon} source={icon} />
|
|
65
|
+
)}
|
|
66
|
+
<RNText
|
|
67
|
+
style={[
|
|
68
|
+
typeStyle,
|
|
69
|
+
flexStyle,
|
|
70
|
+
styles.title,
|
|
71
|
+
{
|
|
72
|
+
fontFamily: `${theme.font}-${titleWeight}`,
|
|
73
|
+
},
|
|
74
|
+
]}>
|
|
75
|
+
{title}
|
|
76
|
+
</RNText>
|
|
77
|
+
{showAction && type !== 'screen' && renderAction()}
|
|
78
|
+
</View>
|
|
79
|
+
{!!description && !!icon && type !== 'screen' && (
|
|
80
|
+
<Text typography={'description_s'} color={theme.colors.text.secondary}>
|
|
81
|
+
{description}
|
|
82
|
+
</Text>
|
|
83
|
+
)}
|
|
84
|
+
</View>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export {Title};
|
|
89
|
+
export type {TitleProps};
|
package/Title/styles.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {scaleSize} from '../Text';
|
|
3
|
+
import {Radius, Spacing} from '../Consts';
|
|
4
|
+
|
|
5
|
+
export default StyleSheet.create({
|
|
6
|
+
card_small: {
|
|
7
|
+
fontSize: scaleSize(16),
|
|
8
|
+
lineHeight: scaleSize(22),
|
|
9
|
+
},
|
|
10
|
+
card_large: {
|
|
11
|
+
fontSize: scaleSize(18),
|
|
12
|
+
lineHeight: scaleSize(26),
|
|
13
|
+
},
|
|
14
|
+
section_small: {
|
|
15
|
+
fontSize: scaleSize(20),
|
|
16
|
+
lineHeight: scaleSize(28),
|
|
17
|
+
},
|
|
18
|
+
section_large: {
|
|
19
|
+
fontSize: scaleSize(24),
|
|
20
|
+
lineHeight: scaleSize(34),
|
|
21
|
+
},
|
|
22
|
+
screen: {
|
|
23
|
+
fontSize: scaleSize(36),
|
|
24
|
+
lineHeight: scaleSize(44),
|
|
25
|
+
},
|
|
26
|
+
title: {
|
|
27
|
+
marginRight: Spacing.XS,
|
|
28
|
+
},
|
|
29
|
+
container: {
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
width: '100%',
|
|
33
|
+
},
|
|
34
|
+
actionIcon: {
|
|
35
|
+
borderRadius: Radius.M,
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
justifyContent: 'center',
|
|
38
|
+
},
|
|
39
|
+
icon: {
|
|
40
|
+
marginRight: Spacing.XS,
|
|
41
|
+
borderRadius: Radius.XS,
|
|
42
|
+
},
|
|
43
|
+
wrapper: {
|
|
44
|
+
width: '100%',
|
|
45
|
+
},
|
|
46
|
+
});
|
package/Title/types.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type TitleProps = {
|
|
2
|
+
type?: 'screen' | 'section' | 'card';
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
size?: 'large' | 'small';
|
|
6
|
+
icon?: string;
|
|
7
|
+
titleFlex?: boolean;
|
|
8
|
+
actionTitle?: string;
|
|
9
|
+
onPressAction?: () => void;
|
|
10
|
+
showAction?: boolean;
|
|
11
|
+
};
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.79.6-beta.
|
|
3
|
+
"version": "0.79.6-beta.6",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -42,4 +42,4 @@
|
|
|
42
42
|
},
|
|
43
43
|
"author": "@momo-kits/foundation",
|
|
44
44
|
"license": "ISC"
|
|
45
|
-
}
|
|
45
|
+
}
|
package/verify.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
try {
|
|
5
|
+
const package = path.join(`${__dirname}`, 'package.json');
|
|
6
|
+
const packageInfo = JSON.parse(fs.readFileSync(package, 'utf8'));
|
|
7
|
+
const packageVersion = parseInt(packageInfo?.version.split('.')?.[1]);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const app = path.join(`${__dirname}/../../../`, 'app.json');
|
|
10
|
+
const appInfo = JSON.parse(fs.readFileSync(app, 'utf8'));
|
|
11
|
+
const iOSAppTarget = appInfo?.client?.ios.deploymentTarget;
|
|
12
|
+
const androidAppTarget = appInfo?.client?.android.deploymentTarget;
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
if (packageVersion > iOSAppTarget || packageVersion > androidAppTarget) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Package ${packageInfo.name} version: ${packageInfo.version} require deploymentTarget ${packageVersion}`,
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(`Installation failed: ${error.message}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|