@momo-kits/foundation 0.81.51-beta.0 → 0.81.52
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/index.tsx → BottomTab.tsx} +18 -42
- package/Application/Components.tsx +91 -356
- package/Application/ModalScreen.tsx +185 -14
- package/Application/Navigation.ts +19 -5
- package/Application/NavigationContainer.tsx +72 -62
- package/Application/Navigator.ts +48 -154
- package/Application/StackScreen.tsx +32 -289
- package/Application/index.ts +15 -13
- package/Application/types.ts +35 -81
- package/Application/utils.tsx +30 -76
- package/Assets/icon_bank.json +1 -1
- package/Badge/Badge.tsx +1 -1
- package/Badge/index.tsx +1 -2
- package/Badge/styles.ts +6 -50
- package/Button/index.tsx +26 -44
- package/CheckBox/index.tsx +26 -37
- package/CheckBox/types.ts +3 -5
- package/Consts/colors+spacing+radius.ts +0 -14
- package/Icon/index.tsx +8 -9
- package/Icon/types.ts +2 -2
- package/IconButton/index.tsx +14 -24
- package/Image/index.tsx +8 -23
- package/Image/types.ts +0 -2
- package/Input/Input.tsx +26 -116
- package/Input/InputDropDown.tsx +51 -66
- package/Input/InputMoney.tsx +15 -106
- package/Input/InputOTP.tsx +26 -49
- package/Input/InputSearch.tsx +99 -252
- package/Input/InputTextArea.tsx +6 -26
- package/Input/common.tsx +22 -48
- package/Input/index.tsx +77 -112
- package/Input/styles.ts +11 -48
- package/Input/utils.ts +1 -1
- package/Layout/Card.tsx +3 -4
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/ItemList.tsx +2 -3
- package/Layout/Screen.tsx +121 -242
- package/Layout/Section.tsx +3 -4
- package/Layout/styles.ts +13 -11
- package/Layout/types.ts +1 -1
- package/Layout/utils.ts +4 -4
- package/Loader/index.tsx +0 -2
- package/Pagination/PaginationScroll.tsx +2 -2
- package/Pagination/styles.ts +1 -1
- package/Popup/PopupNotify.tsx +46 -57
- package/Popup/PopupPromotion.tsx +8 -6
- package/Popup/types.ts +7 -1
- package/Radio/index.tsx +20 -35
- package/Radio/types.ts +3 -5
- package/Switch/index.tsx +18 -32
- package/Switch/types.ts +3 -5
- package/Tag/index.tsx +2 -9
- package/Tag/styles.ts +2 -3
- package/Tag/types.ts +0 -12
- package/Text/index.tsx +5 -24
- package/Text/styles.ts +8 -8
- package/Title/index.tsx +103 -170
- package/Title/styles.ts +9 -36
- package/Title/types.ts +48 -16
- package/code-scanner.js +16 -125
- package/index.ts +0 -7
- package/package.json +7 -8
- package/publish.sh +21 -16
- package/tsconfig.json +1 -1
- package/Application/BottomSheet.tsx +0 -216
- package/Application/BottomTab/BottomTabBar.tsx +0 -278
- package/Application/Localize.ts +0 -44
- package/Application/constants.ts +0 -9
- package/Badge/BadgeDotAnimation.tsx +0 -95
- package/Input/TextTyping.tsx +0 -113
- package/Layout/FloatingButton.tsx +0 -168
package/Application/types.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Animated} from 'react-native';
|
|
2
2
|
import {StackNavigationOptions} from '@react-navigation/stack';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import
|
|
4
|
+
import Navigator from './Navigator';
|
|
5
5
|
import {PopupNotifyProps} from '../Popup/types';
|
|
6
|
-
import Localize from './Localize';
|
|
7
6
|
import Navigation from './Navigation';
|
|
8
|
-
import Navigator from './Navigator';
|
|
9
|
-
import {
|
|
10
|
-
NavigationActionCallbackErrorEnum,
|
|
11
|
-
NavigationActionCallbackStatusEnum,
|
|
12
|
-
} from './constants';
|
|
13
7
|
|
|
14
8
|
type Screen = React.ComponentType<NavigationScreenProps>;
|
|
15
9
|
|
|
@@ -76,6 +70,16 @@ export type Context = {
|
|
|
76
70
|
translate?: (key: string) => string;
|
|
77
71
|
};
|
|
78
72
|
|
|
73
|
+
export type MiniAppInfo = {
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
code: string;
|
|
76
|
+
appId: string;
|
|
77
|
+
buildNumber: number;
|
|
78
|
+
flowPartnerId?: string;
|
|
79
|
+
toolkitConfig?: any;
|
|
80
|
+
fromCode?: string;
|
|
81
|
+
};
|
|
82
|
+
|
|
79
83
|
export type LocalizationObject = {
|
|
80
84
|
vi: {
|
|
81
85
|
[key: string]: string;
|
|
@@ -90,8 +94,7 @@ export type NavigationContainerProps = {
|
|
|
90
94
|
options?: NavigationOptions;
|
|
91
95
|
theme: Theme;
|
|
92
96
|
maxApi: any;
|
|
93
|
-
|
|
94
|
-
localize: Localize;
|
|
97
|
+
localization?: LocalizationObject;
|
|
95
98
|
};
|
|
96
99
|
|
|
97
100
|
export type NavigationScreenProps = {
|
|
@@ -106,43 +109,32 @@ export type ScreenParams = {
|
|
|
106
109
|
options?: NavigationOptions;
|
|
107
110
|
};
|
|
108
111
|
|
|
109
|
-
export
|
|
112
|
+
export interface ModalParams extends ScreenParams {
|
|
110
113
|
[key: string]: any;
|
|
111
|
-
screen: React.ComponentType;
|
|
112
114
|
onDismiss?: () => void;
|
|
113
115
|
barrierDismissible?: boolean;
|
|
114
|
-
}
|
|
116
|
+
}
|
|
115
117
|
|
|
116
|
-
export
|
|
118
|
+
export interface BottomSheetParams extends ScreenParams {
|
|
117
119
|
[key: string]: any;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
123
|
-
useNativeModal?: boolean;
|
|
124
|
-
surface?: boolean;
|
|
125
|
-
onDismiss?: (type?: string) => void;
|
|
126
|
-
barrierDismissible?: boolean;
|
|
127
|
-
draggable?: boolean;
|
|
128
|
-
useBottomInset?: boolean;
|
|
129
|
-
keyboardVerticalOffset?: number;
|
|
130
|
-
};
|
|
120
|
+
onDismiss?: () => void;
|
|
121
|
+
snapPoint?: '30%' | '50%' | '70%' | '90%' | 'content';
|
|
122
|
+
indicatorColor?: string;
|
|
123
|
+
}
|
|
131
124
|
|
|
132
125
|
export type NavigationButtonProps = {
|
|
133
126
|
icon: string;
|
|
134
127
|
tintColor?: string;
|
|
135
128
|
useBorder?: boolean;
|
|
136
129
|
onPress: () => void;
|
|
137
|
-
badgeType?: 'dot' | 'number'
|
|
130
|
+
badgeType?: 'dot' | 'number';
|
|
138
131
|
badgeValue?: number;
|
|
139
|
-
accessibilityLabel?: string;
|
|
140
132
|
};
|
|
141
133
|
|
|
142
134
|
export type PinnedToolType = {
|
|
143
135
|
key: string;
|
|
144
136
|
badgeValue?: number;
|
|
145
|
-
badgeType?: 'number' | 'dot'
|
|
137
|
+
badgeType?: 'number' | 'dot';
|
|
146
138
|
};
|
|
147
139
|
|
|
148
140
|
export type RuntimeToolType = {
|
|
@@ -151,29 +143,18 @@ export type RuntimeToolType = {
|
|
|
151
143
|
key: string;
|
|
152
144
|
};
|
|
153
145
|
|
|
154
|
-
export interface NavigationOptions
|
|
155
|
-
extends Omit<StackNavigationOptions, 'headerRight'> {
|
|
146
|
+
export interface NavigationOptions extends StackNavigationOptions {
|
|
156
147
|
preventBack?: PopupNotifyProps;
|
|
157
148
|
onPressLeftHeader?: () => void;
|
|
158
149
|
surface?: boolean;
|
|
159
150
|
hiddenBack?: boolean;
|
|
160
151
|
customTitle?: TitleCustomProps;
|
|
161
|
-
|
|
152
|
+
toolkitParams?: {
|
|
153
|
+
pinnedTool?: PinnedToolType;
|
|
154
|
+
runtimeTools?: RuntimeToolType[];
|
|
155
|
+
};
|
|
162
156
|
}
|
|
163
157
|
|
|
164
|
-
export type HeaderRightToolkit = {
|
|
165
|
-
type?: 'toolkit';
|
|
166
|
-
pinnedTool?: PinnedToolType;
|
|
167
|
-
runtimeTools?: RuntimeToolType[];
|
|
168
|
-
preventClose?: PopupNotifyProps;
|
|
169
|
-
useMore?: boolean;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export type HeaderRightActions = {
|
|
173
|
-
type?: 'icon';
|
|
174
|
-
buttons: NavigationButtonProps[];
|
|
175
|
-
};
|
|
176
|
-
|
|
177
158
|
export interface HeaderBackProps extends NavigationButtonProps {
|
|
178
159
|
preventBack?: PopupNotifyProps;
|
|
179
160
|
onPressLeftHeader?: () => void;
|
|
@@ -181,8 +162,9 @@ export interface HeaderBackProps extends NavigationButtonProps {
|
|
|
181
162
|
|
|
182
163
|
export type HeaderBackgroundProps = {
|
|
183
164
|
image?: string | null;
|
|
165
|
+
backgroundColor?: string | null;
|
|
184
166
|
animatedValue?: Animated.Value;
|
|
185
|
-
|
|
167
|
+
useBorder?: boolean;
|
|
186
168
|
};
|
|
187
169
|
|
|
188
170
|
export type TitleCustomProps = {
|
|
@@ -201,25 +183,20 @@ export type HeaderToolkitProps = {
|
|
|
201
183
|
configs: any[];
|
|
202
184
|
};
|
|
203
185
|
|
|
204
|
-
export
|
|
186
|
+
export type HeaderAnimatedProps = {
|
|
205
187
|
animatedValue: Animated.Value;
|
|
206
188
|
image: string;
|
|
207
|
-
|
|
189
|
+
onPress?: () => void;
|
|
190
|
+
};
|
|
208
191
|
|
|
209
192
|
export type BottomTabItemProps = {
|
|
210
193
|
name: string;
|
|
211
194
|
label: string;
|
|
212
195
|
icon: string;
|
|
213
196
|
showDot?: boolean;
|
|
214
|
-
badgeLabel?: string
|
|
197
|
+
badgeLabel?: string;
|
|
215
198
|
screen: Screen;
|
|
216
199
|
options: NavigationOptions;
|
|
217
|
-
initialParams?: any;
|
|
218
|
-
listeners?: {
|
|
219
|
-
tabPress?: (e: EventArg<'tabPress', true, undefined>) => void;
|
|
220
|
-
focus?: (e: EventArg<'focus', false, unknown>) => void;
|
|
221
|
-
blur?: (e: EventArg<'blur', false, unknown>) => void;
|
|
222
|
-
};
|
|
223
200
|
};
|
|
224
201
|
|
|
225
202
|
export type BottomTabProps = {
|
|
@@ -228,35 +205,12 @@ export type BottomTabProps = {
|
|
|
228
205
|
initialRouteName?: string;
|
|
229
206
|
navigation: Navigation;
|
|
230
207
|
listeners?: {
|
|
231
|
-
tabPress?:
|
|
232
|
-
focus?:
|
|
233
|
-
blur?: (e: EventArg<'blur', false, unknown>) => void;
|
|
208
|
+
tabPress?: any;
|
|
209
|
+
focus?: any;
|
|
234
210
|
};
|
|
235
|
-
floatingButton?: FloatingButtonProps;
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
export type FloatingButtonProps = {
|
|
239
|
-
container?: React.ReactNode;
|
|
240
|
-
icon: string | React.ReactNode;
|
|
241
|
-
label: string;
|
|
242
|
-
onPress: () => void;
|
|
243
211
|
};
|
|
244
212
|
|
|
245
213
|
export type AnimatedHeader = {
|
|
246
214
|
type: 'default' | 'surface';
|
|
247
215
|
component?: (props?: any) => React.ReactElement;
|
|
248
|
-
headerTitle?: (props?: any) => React.ReactElement;
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
type NavigatorActionSuccessCallbackType = {
|
|
252
|
-
status: NavigationActionCallbackStatusEnum.Success;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
type NavigatorActionFailCallbackType = {
|
|
256
|
-
status: NavigationActionCallbackStatusEnum.Failed;
|
|
257
|
-
type: NavigationActionCallbackErrorEnum;
|
|
258
216
|
};
|
|
259
|
-
|
|
260
|
-
export type NavigatorCallbackParamsType =
|
|
261
|
-
| NavigatorActionSuccessCallbackType
|
|
262
|
-
| NavigatorActionFailCallbackType;
|
package/Application/utils.tsx
CHANGED
|
@@ -7,13 +7,11 @@ import {
|
|
|
7
7
|
HeaderBackground,
|
|
8
8
|
HeaderCustom,
|
|
9
9
|
HeaderLeft,
|
|
10
|
-
HeaderRight,
|
|
11
10
|
HeaderTitle,
|
|
11
|
+
HeaderToolkitAction,
|
|
12
12
|
} from './Components';
|
|
13
|
-
import {NavigationOptions} from './types';
|
|
13
|
+
import {NavigationOptions, Theme} from './types';
|
|
14
14
|
import {Colors} from '../Consts';
|
|
15
|
-
import Navigation from './Navigation';
|
|
16
|
-
import {LayoutChangeEvent} from 'react-native';
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* default options for stack screen
|
|
@@ -24,7 +22,7 @@ const getStackOptions = (): StackNavigationOptions => {
|
|
|
24
22
|
headerTitle: HeaderTitle,
|
|
25
23
|
headerBackground: (props: any) => <HeaderBackground {...props} />,
|
|
26
24
|
headerLeft: (props: any) => <HeaderLeft {...props} />,
|
|
27
|
-
headerRight: (props: any) => <
|
|
25
|
+
headerRight: (props: any) => <HeaderToolkitAction {...props} />,
|
|
28
26
|
headerTintColor: Colors.black_01,
|
|
29
27
|
};
|
|
30
28
|
};
|
|
@@ -74,44 +72,39 @@ const getModalOptions = (): StackNavigationOptions => {
|
|
|
74
72
|
/**
|
|
75
73
|
* build react-navigation options
|
|
76
74
|
*/
|
|
77
|
-
const getOptions = (params: NavigationOptions,
|
|
75
|
+
const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
78
76
|
let options = {};
|
|
79
77
|
|
|
80
|
-
/**
|
|
81
|
-
* left header factory
|
|
82
|
-
*/
|
|
83
78
|
if (
|
|
84
79
|
typeof params.onPressLeftHeader === 'function' ||
|
|
85
80
|
params.preventBack !== undefined ||
|
|
86
81
|
typeof params.hiddenBack === 'boolean'
|
|
87
82
|
) {
|
|
88
|
-
let headerLeft: any = (props: any) => (
|
|
89
|
-
<HeaderLeft
|
|
90
|
-
{...props}
|
|
91
|
-
preventBack={params.preventBack}
|
|
92
|
-
onPressLeftHeader={params.onPressLeftHeader}
|
|
93
|
-
/>
|
|
94
|
-
);
|
|
95
|
-
if (params.hiddenBack) {
|
|
96
|
-
headerLeft = null;
|
|
97
|
-
}
|
|
98
83
|
options = {
|
|
99
84
|
...options,
|
|
100
|
-
headerLeft
|
|
85
|
+
headerLeft: params.hiddenBack
|
|
86
|
+
? null
|
|
87
|
+
: (props: any) => (
|
|
88
|
+
<HeaderLeft
|
|
89
|
+
{...props}
|
|
90
|
+
preventBack={params.preventBack}
|
|
91
|
+
onPressLeftHeader={params.onPressLeftHeader}
|
|
92
|
+
/>
|
|
93
|
+
),
|
|
101
94
|
};
|
|
102
95
|
}
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
* surface header style
|
|
106
|
-
*/
|
|
107
|
-
if (typeof params.surface === 'boolean') {
|
|
108
|
-
console.warn('surface options is deprecated, headerType instead in screen');
|
|
97
|
+
if (typeof params.surface == 'boolean') {
|
|
109
98
|
if (params.surface) {
|
|
110
99
|
options = {
|
|
111
100
|
...options,
|
|
112
|
-
headerTintColor:
|
|
101
|
+
headerTintColor: theme.colors.text.default,
|
|
113
102
|
headerBackground: () => (
|
|
114
|
-
<HeaderBackground
|
|
103
|
+
<HeaderBackground
|
|
104
|
+
image={null}
|
|
105
|
+
backgroundColor={theme.colors.background.surface}
|
|
106
|
+
useBorder={true}
|
|
107
|
+
/>
|
|
115
108
|
),
|
|
116
109
|
};
|
|
117
110
|
} else {
|
|
@@ -123,13 +116,7 @@ const getOptions = (params: NavigationOptions, navigation?: Navigation) => {
|
|
|
123
116
|
}
|
|
124
117
|
}
|
|
125
118
|
|
|
126
|
-
/**
|
|
127
|
-
* custom title
|
|
128
|
-
*/
|
|
129
119
|
if (params.customTitle) {
|
|
130
|
-
console.warn(
|
|
131
|
-
'customTitle options is deprecated, please used headerTitle instead'
|
|
132
|
-
);
|
|
133
120
|
options = {
|
|
134
121
|
...options,
|
|
135
122
|
headerTitleAlign: 'left',
|
|
@@ -139,39 +126,19 @@ const getOptions = (params: NavigationOptions, navigation?: Navigation) => {
|
|
|
139
126
|
};
|
|
140
127
|
}
|
|
141
128
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (params.headerRight) {
|
|
146
|
-
let headerRight: any = (props: any) => {
|
|
147
|
-
return (
|
|
148
|
-
<HeaderRight
|
|
149
|
-
{...props}
|
|
150
|
-
{...params.headerRight}
|
|
151
|
-
onLayout={(e: LayoutChangeEvent) => {
|
|
152
|
-
navigation?.onHeaderRightChange?.(e.nativeEvent.layout.width);
|
|
153
|
-
}}
|
|
154
|
-
/>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
if (typeof params.headerRight === 'function') {
|
|
158
|
-
headerRight = (props: any) => {
|
|
129
|
+
options = {
|
|
130
|
+
...options,
|
|
131
|
+
headerRight: (props: any) => {
|
|
159
132
|
return (
|
|
160
|
-
<
|
|
133
|
+
<HeaderToolkitAction
|
|
134
|
+
preventBack={params.preventBack}
|
|
135
|
+
pinnedTool={params.toolkitParams?.pinnedTool}
|
|
136
|
+
runtimeTools={params.toolkitParams?.runtimeTools}
|
|
161
137
|
{...props}
|
|
162
|
-
|
|
163
|
-
navigation?.onHeaderRightChange?.(e.nativeEvent.layout.width);
|
|
164
|
-
}}>
|
|
165
|
-
{params.headerRight(props)}
|
|
166
|
-
</HeaderRight>
|
|
138
|
+
/>
|
|
167
139
|
);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
options = {
|
|
171
|
-
...options,
|
|
172
|
-
headerRight,
|
|
140
|
+
},
|
|
173
141
|
};
|
|
174
|
-
}
|
|
175
142
|
|
|
176
143
|
return {
|
|
177
144
|
...params,
|
|
@@ -179,17 +146,4 @@ const getOptions = (params: NavigationOptions, navigation?: Navigation) => {
|
|
|
179
146
|
};
|
|
180
147
|
};
|
|
181
148
|
|
|
182
|
-
|
|
183
|
-
let formattedName = name;
|
|
184
|
-
if (formattedName.length > 100) {
|
|
185
|
-
formattedName = formattedName.substring(0, 100);
|
|
186
|
-
}
|
|
187
|
-
return formattedName;
|
|
188
|
-
};
|
|
189
|
-
export {
|
|
190
|
-
getStackOptions,
|
|
191
|
-
getDialogOptions,
|
|
192
|
-
getModalOptions,
|
|
193
|
-
getOptions,
|
|
194
|
-
formatNameLength,
|
|
195
|
-
};
|
|
149
|
+
export {getStackOptions, getDialogOptions, getModalOptions, getOptions};
|
package/Assets/icon_bank.json
CHANGED
package/Badge/Badge.tsx
CHANGED
|
@@ -46,7 +46,7 @@ const Badge: FC<BadgeProps> = ({label = 'Label', style, backgroundColor}) => {
|
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<View style={[style, styles.badge, {backgroundColor: badgeColor}]}>
|
|
49
|
-
<Text color={Colors.black_01} typography={'
|
|
49
|
+
<Text color={Colors.black_01} typography={'action_xs_bold'}>
|
|
50
50
|
{formatTitle()}
|
|
51
51
|
</Text>
|
|
52
52
|
</View>
|
package/Badge/index.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Badge from './Badge';
|
|
2
2
|
import BadgeDot from './BadgeDot';
|
|
3
3
|
import BadgeRibbon from './BadgeRibbon';
|
|
4
|
-
import BadgeDotAnimation from './BadgeDotAnimation';
|
|
5
4
|
import {BadgeProps, BadgeDotProps, BadgeRibbonProps} from './types';
|
|
6
5
|
|
|
7
|
-
export {Badge, BadgeRibbon, BadgeDot
|
|
6
|
+
export {Badge, BadgeRibbon, BadgeDot};
|
|
8
7
|
export type {BadgeProps, BadgeDotProps, BadgeRibbonProps};
|
package/Badge/styles.ts
CHANGED
|
@@ -2,10 +2,6 @@ import {StyleSheet} from 'react-native';
|
|
|
2
2
|
import {Colors, Radius, Spacing} from '../Consts';
|
|
3
3
|
import {scaleSize} from '../Text';
|
|
4
4
|
|
|
5
|
-
const DOT_SIZE = 16;
|
|
6
|
-
|
|
7
|
-
const DOT_SMALL_SIZE = 10;
|
|
8
|
-
|
|
9
5
|
export default StyleSheet.create({
|
|
10
6
|
badge: {
|
|
11
7
|
paddingHorizontal: Spacing.XS,
|
|
@@ -19,61 +15,21 @@ export default StyleSheet.create({
|
|
|
19
15
|
borderColor: Colors.black_01,
|
|
20
16
|
alignSelf: 'baseline',
|
|
21
17
|
},
|
|
22
|
-
dotAnimationContainer: {
|
|
23
|
-
position: 'relative',
|
|
24
|
-
alignItems: 'center',
|
|
25
|
-
justifyContent: 'center',
|
|
26
|
-
},
|
|
27
18
|
dot: {
|
|
28
|
-
width:
|
|
29
|
-
height:
|
|
19
|
+
width: 16,
|
|
20
|
+
height: 16,
|
|
30
21
|
borderWidth: 2,
|
|
31
22
|
borderColor: Colors.black_01,
|
|
32
23
|
backgroundColor: Colors.red_03,
|
|
33
|
-
borderRadius:
|
|
24
|
+
borderRadius: 8,
|
|
34
25
|
},
|
|
35
26
|
dotSmall: {
|
|
36
|
-
width:
|
|
37
|
-
height:
|
|
27
|
+
width: 10,
|
|
28
|
+
height: 10,
|
|
38
29
|
borderWidth: 1,
|
|
39
30
|
borderColor: Colors.black_01,
|
|
40
31
|
backgroundColor: Colors.red_03,
|
|
41
|
-
borderRadius:
|
|
42
|
-
},
|
|
43
|
-
dotAnimation: {
|
|
44
|
-
width: DOT_SIZE,
|
|
45
|
-
height: DOT_SIZE,
|
|
46
|
-
borderColor: Colors.black_01,
|
|
47
|
-
backgroundColor: Colors.red_03,
|
|
48
|
-
borderRadius: DOT_SIZE / 2,
|
|
49
|
-
borderWidth: 0,
|
|
50
|
-
},
|
|
51
|
-
dotAnimationSmall: {
|
|
52
|
-
width: DOT_SMALL_SIZE,
|
|
53
|
-
height: DOT_SMALL_SIZE,
|
|
54
|
-
borderColor: Colors.black_01,
|
|
55
|
-
backgroundColor: Colors.red_03,
|
|
56
|
-
borderRadius: DOT_SMALL_SIZE / 2,
|
|
57
|
-
borderWidth: 0,
|
|
58
|
-
},
|
|
59
|
-
wave: {
|
|
60
|
-
width: DOT_SIZE,
|
|
61
|
-
height: DOT_SIZE,
|
|
62
|
-
borderColor: Colors.black_01,
|
|
63
|
-
backgroundColor: Colors.red_03,
|
|
64
|
-
borderRadius: DOT_SIZE / 2,
|
|
65
|
-
opacity: 0,
|
|
66
|
-
position: 'absolute',
|
|
67
|
-
borderWidth: 0,
|
|
68
|
-
},
|
|
69
|
-
waveSmall: {
|
|
70
|
-
width: DOT_SMALL_SIZE,
|
|
71
|
-
height: DOT_SMALL_SIZE,
|
|
72
|
-
borderColor: Colors.black_01,
|
|
73
|
-
backgroundColor: Colors.red_03,
|
|
74
|
-
borderRadius: DOT_SMALL_SIZE / 2,
|
|
75
|
-
borderWidth: 0,
|
|
76
|
-
position: 'absolute',
|
|
32
|
+
borderRadius: 5,
|
|
77
33
|
},
|
|
78
34
|
ribbon: {
|
|
79
35
|
alignSelf: 'baseline',
|
package/Button/index.tsx
CHANGED
|
@@ -6,8 +6,9 @@ import {
|
|
|
6
6
|
TouchableOpacityProps,
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
|
+
|
|
9
10
|
import LinearGradient from 'react-native-linear-gradient';
|
|
10
|
-
import {ApplicationContext
|
|
11
|
+
import {ApplicationContext} from '../Application';
|
|
11
12
|
import {Text} from '../Text';
|
|
12
13
|
import {Typography} from '../Text/types';
|
|
13
14
|
import {Colors, Spacing} from '../Consts';
|
|
@@ -58,7 +59,7 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
58
59
|
/**
|
|
59
60
|
* If true, the icon of button will use the tint color provided by its container.
|
|
60
61
|
*/
|
|
61
|
-
|
|
62
|
+
useTintColor?: boolean;
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
65
|
* If true, the icon of button will use be show indicator loading.
|
|
@@ -69,39 +70,30 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
69
70
|
* A callback function that is called when the button is pressed.
|
|
70
71
|
*/
|
|
71
72
|
onPress: () => void;
|
|
72
|
-
|
|
73
|
-
params?: any;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
const Button: FC<ButtonProps> = ({
|
|
77
76
|
type = 'primary',
|
|
78
77
|
size = 'large',
|
|
79
|
-
|
|
78
|
+
useTintColor = true,
|
|
80
79
|
full = true,
|
|
81
80
|
iconRight,
|
|
82
81
|
iconLeft,
|
|
83
82
|
loading = false,
|
|
84
83
|
title = 'Button',
|
|
85
84
|
onPress,
|
|
86
|
-
params,
|
|
87
|
-
accessibilityLabel,
|
|
88
85
|
...rest
|
|
89
86
|
}) => {
|
|
90
87
|
const {theme, config} = useContext(ApplicationContext);
|
|
91
88
|
const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
|
|
92
89
|
let gradientPros;
|
|
93
|
-
|
|
94
|
-
if (loading) {
|
|
95
|
-
state = 'loading';
|
|
96
|
-
}
|
|
97
|
-
if (gradient?.length > 0 && type === 'primary') {
|
|
90
|
+
if (gradient?.length > 0 && type == 'primary') {
|
|
98
91
|
gradientPros = {
|
|
99
92
|
colors: gradient,
|
|
100
93
|
start: {x: 1, y: 0.5},
|
|
101
94
|
end: {x: 0, y: 0.5},
|
|
102
95
|
};
|
|
103
96
|
}
|
|
104
|
-
|
|
105
97
|
const getSizeStyle = () => {
|
|
106
98
|
const styleSheet: {[key: string]: any} = styles;
|
|
107
99
|
return styleSheet[size ?? 'small'];
|
|
@@ -217,9 +209,9 @@ const Button: FC<ButtonProps> = ({
|
|
|
217
209
|
*/
|
|
218
210
|
const renderTitle = () => {
|
|
219
211
|
const typography = getTypography();
|
|
220
|
-
const
|
|
212
|
+
const color = getTextColor();
|
|
221
213
|
return (
|
|
222
|
-
<Text typography={typography} color={
|
|
214
|
+
<Text typography={typography} color={color} numberOfLines={1}>
|
|
223
215
|
{title}
|
|
224
216
|
</Text>
|
|
225
217
|
);
|
|
@@ -231,7 +223,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
231
223
|
const renderLeading = () => {
|
|
232
224
|
const iconSize = getIconSize();
|
|
233
225
|
const marginRight = getIconSpace();
|
|
234
|
-
const
|
|
226
|
+
const color = useTintColor ? getTextColor() : undefined;
|
|
235
227
|
|
|
236
228
|
if (loading) {
|
|
237
229
|
return (
|
|
@@ -245,7 +237,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
245
237
|
borderRadius: Spacing.M,
|
|
246
238
|
},
|
|
247
239
|
]}>
|
|
248
|
-
<Loader type="spinner" color={
|
|
240
|
+
<Loader type="spinner" color={color} />
|
|
249
241
|
</View>
|
|
250
242
|
);
|
|
251
243
|
}
|
|
@@ -256,7 +248,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
256
248
|
styles.leading,
|
|
257
249
|
{width: iconSize, height: iconSize, marginRight},
|
|
258
250
|
]}>
|
|
259
|
-
<Icon color={
|
|
251
|
+
<Icon color={color} source={iconLeft} size={iconSize} />
|
|
260
252
|
</View>
|
|
261
253
|
);
|
|
262
254
|
}
|
|
@@ -266,7 +258,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
266
258
|
* render trailing
|
|
267
259
|
*/
|
|
268
260
|
const renderTrailing = () => {
|
|
269
|
-
const
|
|
261
|
+
const color = useTintColor ? getTextColor() : undefined;
|
|
270
262
|
const marginLeft = getIconSpace();
|
|
271
263
|
|
|
272
264
|
if (iconRight) {
|
|
@@ -277,7 +269,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
277
269
|
styles.trailing,
|
|
278
270
|
{width: iconSize, height: iconSize, marginLeft},
|
|
279
271
|
]}>
|
|
280
|
-
<Icon color={
|
|
272
|
+
<Icon color={color} source={iconRight} size={iconSize} />
|
|
281
273
|
</View>
|
|
282
274
|
);
|
|
283
275
|
}
|
|
@@ -297,31 +289,21 @@ const Button: FC<ButtonProps> = ({
|
|
|
297
289
|
};
|
|
298
290
|
|
|
299
291
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
292
|
+
|
|
300
293
|
return (
|
|
301
|
-
<
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
onPress={onPressButton}
|
|
315
|
-
style={buttonStyle}>
|
|
316
|
-
{renderLeading()}
|
|
317
|
-
{renderTitle()}
|
|
318
|
-
{renderTrailing()}
|
|
319
|
-
{gradientPros && (
|
|
320
|
-
<AnimationLinear {...gradientPros} style={styles.gradientView} />
|
|
321
|
-
)}
|
|
322
|
-
{gradientPros && <View style={styles.strokeView} />}
|
|
323
|
-
</TouchableOpacity>
|
|
324
|
-
</ComponentContext.Provider>
|
|
294
|
+
<TouchableOpacity
|
|
295
|
+
{...rest}
|
|
296
|
+
activeOpacity={activeOpacity}
|
|
297
|
+
onPress={onPressButton}
|
|
298
|
+
style={buttonStyle}>
|
|
299
|
+
{renderLeading()}
|
|
300
|
+
{renderTitle()}
|
|
301
|
+
{renderTrailing()}
|
|
302
|
+
{gradientPros && (
|
|
303
|
+
<AnimationLinear {...gradientPros} style={styles.gradientView} />
|
|
304
|
+
)}
|
|
305
|
+
{gradientPros && <View style={styles.strokeView} />}
|
|
306
|
+
</TouchableOpacity>
|
|
325
307
|
);
|
|
326
308
|
};
|
|
327
309
|
|