@momo-kits/foundation 0.81.32 → 0.81.33
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/utils.tsx +23 -1
- package/Button/index.tsx +22 -3
- package/Button/styles.ts +15 -0
- package/Consts/theme.ts +2 -2
- package/package.json +1 -1
package/Application/utils.tsx
CHANGED
|
@@ -12,6 +12,11 @@ import {
|
|
|
12
12
|
} from './Components';
|
|
13
13
|
import {NavigationOptions, Theme} from './types';
|
|
14
14
|
import {Colors} from '../Consts';
|
|
15
|
+
import {NativeModules} from 'react-native';
|
|
16
|
+
|
|
17
|
+
let config: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
15
20
|
|
|
16
21
|
/**
|
|
17
22
|
* default options for stack screen
|
|
@@ -132,4 +137,21 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
132
137
|
};
|
|
133
138
|
};
|
|
134
139
|
|
|
135
|
-
|
|
140
|
+
const getThemeConfig = () => {
|
|
141
|
+
if (!config) {
|
|
142
|
+
try {
|
|
143
|
+
config = JSON.parse(
|
|
144
|
+
NativeModules?.ConfigsModule?.getConfigSync?.('DESIGN_SYSTEM'),
|
|
145
|
+
);
|
|
146
|
+
} catch (e) {}
|
|
147
|
+
}
|
|
148
|
+
return config;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
getStackOptions,
|
|
153
|
+
getDialogOptions,
|
|
154
|
+
getModalOptions,
|
|
155
|
+
getOptions,
|
|
156
|
+
getThemeConfig,
|
|
157
|
+
};
|
package/Button/index.tsx
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React, {FC, useContext} from 'react';
|
|
2
2
|
import {
|
|
3
|
+
Animated,
|
|
3
4
|
StyleSheet,
|
|
4
5
|
TouchableOpacity,
|
|
5
6
|
TouchableOpacityProps,
|
|
6
7
|
View,
|
|
7
8
|
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
import LinearGradient from 'react-native-linear-gradient';
|
|
8
11
|
import {ApplicationContext} from '../Application';
|
|
9
12
|
import {Text} from '../Text';
|
|
10
13
|
import {Typography} from '../Text/types';
|
|
@@ -12,6 +15,9 @@ import {Colors, Spacing} from '../Consts';
|
|
|
12
15
|
import styles from './styles';
|
|
13
16
|
import {Icon} from '../Icon';
|
|
14
17
|
import {Loader} from '../Loader';
|
|
18
|
+
import {getThemeConfig} from '../Application/utils';
|
|
19
|
+
|
|
20
|
+
const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
|
|
15
21
|
|
|
16
22
|
export interface ButtonProps extends TouchableOpacityProps {
|
|
17
23
|
/**
|
|
@@ -80,6 +86,15 @@ const Button: FC<ButtonProps> = ({
|
|
|
80
86
|
...rest
|
|
81
87
|
}) => {
|
|
82
88
|
const {theme} = useContext(ApplicationContext);
|
|
89
|
+
const {gradient, color} = getThemeConfig()?.navigationBar?.buttonColors ?? {};
|
|
90
|
+
let gradientPros;
|
|
91
|
+
if (gradient?.length > 0 && type == 'primary') {
|
|
92
|
+
gradientPros = {
|
|
93
|
+
colors: gradient,
|
|
94
|
+
start: {x: 1, y: 0.5},
|
|
95
|
+
end: {x: 0, y: 0.5},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
83
98
|
const getSizeStyle = () => {
|
|
84
99
|
const styleSheet: {[key: string]: any} = styles;
|
|
85
100
|
return styleSheet[size ?? 'small'];
|
|
@@ -103,7 +118,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
103
118
|
return {
|
|
104
119
|
backgroundColor: theme.colors.background.surface,
|
|
105
120
|
borderWidth: 1,
|
|
106
|
-
borderColor: theme.colors.primary,
|
|
121
|
+
borderColor: color ?? theme.colors.primary,
|
|
107
122
|
};
|
|
108
123
|
case 'tonal':
|
|
109
124
|
return {
|
|
@@ -178,13 +193,13 @@ const Button: FC<ButtonProps> = ({
|
|
|
178
193
|
case 'secondary':
|
|
179
194
|
return theme.colors.text.default;
|
|
180
195
|
case 'outline':
|
|
181
|
-
return theme.colors.primary;
|
|
196
|
+
return color ?? theme.colors.primary;
|
|
182
197
|
case 'tonal':
|
|
183
198
|
return theme.colors.primary;
|
|
184
199
|
case 'danger':
|
|
185
200
|
return Colors.black_01;
|
|
186
201
|
case 'text':
|
|
187
|
-
return theme.colors.primary;
|
|
202
|
+
return color ?? theme.colors.primary;
|
|
188
203
|
default:
|
|
189
204
|
return Colors.black_01;
|
|
190
205
|
}
|
|
@@ -286,6 +301,10 @@ const Button: FC<ButtonProps> = ({
|
|
|
286
301
|
{renderLeading()}
|
|
287
302
|
{renderTitle()}
|
|
288
303
|
{renderTrailing()}
|
|
304
|
+
{gradientPros && (
|
|
305
|
+
<AnimationLinear {...gradientPros} style={styles.gradientView} />
|
|
306
|
+
)}
|
|
307
|
+
{gradientPros && <View style={styles.strokeView} />}
|
|
289
308
|
</TouchableOpacity>
|
|
290
309
|
);
|
|
291
310
|
};
|
package/Button/styles.ts
CHANGED
|
@@ -38,4 +38,19 @@ export default StyleSheet.create({
|
|
|
38
38
|
alignItems: 'center',
|
|
39
39
|
justifyContent: 'center',
|
|
40
40
|
},
|
|
41
|
+
gradientView: {
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
zIndex: -1,
|
|
44
|
+
borderRadius: 8,
|
|
45
|
+
},
|
|
46
|
+
strokeView: {
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
top: 2,
|
|
49
|
+
bottom: 2,
|
|
50
|
+
left: 2,
|
|
51
|
+
right: 2,
|
|
52
|
+
borderRadius: 6,
|
|
53
|
+
borderWidth: 0.5,
|
|
54
|
+
borderColor: '#FFF9E1',
|
|
55
|
+
},
|
|
41
56
|
});
|
package/Consts/theme.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {Colors} from './colors+spacing+radius';
|
|
|
4
4
|
const defaultTheme: Theme = {
|
|
5
5
|
dark: false,
|
|
6
6
|
colors: {
|
|
7
|
-
primary:
|
|
7
|
+
primary: '#FF0073',
|
|
8
8
|
secondary: Colors.pink_07,
|
|
9
9
|
background: {
|
|
10
10
|
default: '#f2f2f6',
|
|
@@ -53,7 +53,7 @@ const defaultTheme: Theme = {
|
|
|
53
53
|
font: 'SFProText',
|
|
54
54
|
assets: {
|
|
55
55
|
headerBackground:
|
|
56
|
-
'https://static.momocdn.net/app/img/
|
|
56
|
+
'https://static.momocdn.net/app/img/kits/background/header/header_banner_tet_2024.png',
|
|
57
57
|
},
|
|
58
58
|
};
|
|
59
59
|
|