@momo-kits/foundation 0.79.5 → 0.79.6-beta.10
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 +23 -37
- package/Application/NavigationContainer.tsx +7 -2
- package/Application/types.ts +1 -1
- 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 +22 -0
|
@@ -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
|
);
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useCallback,
|
|
3
|
-
useContext,
|
|
4
|
-
useEffect,
|
|
5
|
-
useMemo,
|
|
6
|
-
useRef,
|
|
7
|
-
useState,
|
|
8
|
-
} from 'react';
|
|
1
|
+
import React, {useContext, useEffect, useMemo, useRef} from 'react';
|
|
9
2
|
import {
|
|
10
3
|
KeyboardAvoidingView,
|
|
11
4
|
Platform,
|
|
@@ -13,8 +6,12 @@ import {
|
|
|
13
6
|
StyleSheet,
|
|
14
7
|
View,
|
|
15
8
|
} from 'react-native';
|
|
16
|
-
import {SafeAreaView} from 'react-native-safe-area-context';
|
|
17
|
-
import {
|
|
9
|
+
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
10
|
+
import {
|
|
11
|
+
BottomSheetBackdrop,
|
|
12
|
+
BottomSheetModal,
|
|
13
|
+
BottomSheetView,
|
|
14
|
+
} from '@gorhom/bottom-sheet';
|
|
18
15
|
import Navigation from './Navigation';
|
|
19
16
|
import {BottomSheetParams, ModalParams} from './types';
|
|
20
17
|
import {Radius, Spacing, Styles} from '../Consts';
|
|
@@ -90,12 +87,9 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
90
87
|
};
|
|
91
88
|
|
|
92
89
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
90
|
+
const insets = useSafeAreaInsets();
|
|
93
91
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
94
|
-
const {
|
|
95
|
-
screen,
|
|
96
|
-
options,
|
|
97
|
-
useSnap = true,
|
|
98
|
-
}: BottomSheetParams = props.route.params;
|
|
92
|
+
const {screen, options, snapPoint}: BottomSheetParams = props.route.params;
|
|
99
93
|
const Component = useRef(screen).current;
|
|
100
94
|
const navigation = new Navigation(props.navigation, theme);
|
|
101
95
|
const params = {
|
|
@@ -105,31 +99,16 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
105
99
|
|
|
106
100
|
delete params.screen;
|
|
107
101
|
|
|
108
|
-
const [contentHeight, setContentHeight] = useState(undefined);
|
|
109
102
|
const snapPoints = useMemo(() => {
|
|
110
|
-
if (
|
|
111
|
-
return [
|
|
103
|
+
if (snapPoint) {
|
|
104
|
+
return [snapPoint];
|
|
112
105
|
}
|
|
113
|
-
return [
|
|
114
|
-
}, [
|
|
106
|
+
return ['50%', '70%', '90%'];
|
|
107
|
+
}, []);
|
|
115
108
|
|
|
116
109
|
const bottomSheetRef = useRef<any>(null);
|
|
117
110
|
const mountedRef = useRef(true);
|
|
118
111
|
|
|
119
|
-
let handleOnLayout;
|
|
120
|
-
if (!useSnap) {
|
|
121
|
-
handleOnLayout = useCallback(
|
|
122
|
-
({
|
|
123
|
-
nativeEvent: {
|
|
124
|
-
layout: {height},
|
|
125
|
-
},
|
|
126
|
-
}) => {
|
|
127
|
-
setContentHeight(height);
|
|
128
|
-
},
|
|
129
|
-
[],
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
112
|
let backgroundColor = theme.colors.background.default;
|
|
134
113
|
if (options?.surface) {
|
|
135
114
|
backgroundColor = theme.colors.background.surface;
|
|
@@ -162,8 +141,15 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
162
141
|
}}
|
|
163
142
|
handleComponent={null}
|
|
164
143
|
backdropComponent={backdropComponent}>
|
|
165
|
-
<
|
|
166
|
-
<View
|
|
144
|
+
<BottomSheetView accessibilityLabel={'BottomSheet'}>
|
|
145
|
+
<View
|
|
146
|
+
style={[
|
|
147
|
+
styles.sheetContainer,
|
|
148
|
+
{
|
|
149
|
+
backgroundColor,
|
|
150
|
+
paddingBottom: Math.min(insets.bottom, 20) + Spacing.S,
|
|
151
|
+
},
|
|
152
|
+
]}>
|
|
167
153
|
<View style={styles.indicatorContainer}>
|
|
168
154
|
<View
|
|
169
155
|
style={[
|
|
@@ -222,7 +208,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
222
208
|
}}
|
|
223
209
|
/>
|
|
224
210
|
</View>
|
|
225
|
-
</
|
|
211
|
+
</BottomSheetView>
|
|
226
212
|
</BottomSheetModal>
|
|
227
213
|
</SafeAreaView>
|
|
228
214
|
);
|
|
@@ -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/Application/types.ts
CHANGED
|
@@ -107,7 +107,7 @@ export interface ModalParams extends ScreenParams {
|
|
|
107
107
|
export interface BottomSheetParams extends ScreenParams {
|
|
108
108
|
[key: string]: any;
|
|
109
109
|
onDismiss?: () => void;
|
|
110
|
-
|
|
110
|
+
snapPoint?: '30%' | '50%' | '70%' | '90%';
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export type NavigationButtonProps = {
|
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,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.79.
|
|
3
|
+
"version": "0.79.6-beta.10",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"postinstall": "node verify.js"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
10
10
|
"@momo-kits/foundation"
|
package/verify.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
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
|
+
|
|
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;
|
|
13
|
+
|
|
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
|
+
}
|