@momo-kits/foundation 0.151.2-beta.1 → 0.152.1-beta.1
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/BottomSheet.tsx +1 -1
- package/Application/BottomTab/Badge.tsx +15 -2
- package/Application/BottomTab/BottomTabBar.tsx +1 -1
- package/Application/BottomTab/CustomBottomTabItem.tsx +5 -3
- package/Application/BottomTab/TabBarIcon.tsx +8 -6
- package/Application/BottomTab/index.tsx +8 -14
- package/Application/Components/BackgroundImageView.tsx +1 -1
- package/Application/Components/HeaderAnimated.tsx +12 -11
- package/Application/Components/HeaderBackground.tsx +1 -1
- package/Application/Components/HeaderExtendHeader.tsx +31 -26
- package/Application/Components/HeaderLeft.tsx +1 -1
- package/Application/Components/HeaderRight.tsx +24 -20
- package/Application/Components/HeaderTitle.tsx +6 -2
- package/Application/Components/NavigationButton.tsx +12 -11
- package/Application/Components/SearchHeader.tsx +1 -1
- package/Application/ModalScreen.tsx +1 -1
- package/Application/NavigationContainer.tsx +5 -7
- package/Application/StackScreen.tsx +27 -23
- package/Application/WidgetContainer.tsx +1 -1
- package/Application/index.ts +12 -31
- package/Application/types.ts +45 -8
- package/Application/utils.tsx +41 -17
- package/Badge/Badge.tsx +14 -11
- package/Badge/BadgeRibbon.tsx +1 -1
- package/Button/index.tsx +32 -27
- package/CheckBox/index.tsx +23 -19
- package/Context/index.ts +23 -0
- package/Divider/DashDivider.tsx +10 -9
- package/Divider/index.tsx +7 -7
- package/Icon/index.tsx +9 -9
- package/IconButton/index.tsx +12 -10
- package/Image/index.tsx +9 -2
- package/Input/Input.tsx +2 -5
- package/Input/InputDropDown.tsx +31 -23
- package/Input/InputMoney.tsx +2 -5
- package/Input/InputOTP.tsx +2 -5
- package/Input/InputPhoneNumber.tsx +2 -5
- package/Input/InputSearch.tsx +2 -5
- package/Input/InputTextArea.tsx +1 -1
- package/Input/common.tsx +31 -24
- package/Layout/Card.tsx +1 -1
- package/Layout/FloatingButton.tsx +1 -1
- package/Layout/GridSystem.tsx +15 -14
- package/Layout/Item.tsx +1 -1
- package/Layout/Screen.tsx +5 -4
- package/Layout/Section.tsx +1 -1
- package/Layout/TrackingScope.tsx +3 -3
- package/Loader/DotLoader.tsx +7 -7
- package/Loader/ProgressBar.tsx +10 -9
- package/Loader/Spinner.tsx +7 -7
- package/Pagination/Dot.tsx +10 -7
- package/Pagination/PaginationDot.tsx +8 -8
- package/Pagination/PaginationScroll.tsx +12 -10
- package/Popup/PopupNotify.tsx +2 -2
- package/Popup/PopupPromotion.tsx +1 -1
- package/Radio/index.tsx +18 -18
- package/Skeleton/index.tsx +1 -1
- package/Switch/index.tsx +17 -12
- package/Text/index.tsx +1 -1
- package/Title/index.tsx +48 -29
- package/index.ts +1 -0
- package/package.json +1 -1
- package/Application/Components/index.ts +0 -7
|
@@ -3,9 +3,10 @@ import { Alert, InteractionManager } from 'react-native';
|
|
|
3
3
|
import { useHeaderHeight } from '@react-navigation/elements';
|
|
4
4
|
import { ScreenTrackingParams } from './types';
|
|
5
5
|
import Navigation from './Navigation';
|
|
6
|
-
import { ApplicationContext, MiniAppContext, ScreenContext } from '
|
|
6
|
+
import { ApplicationContext, MiniAppContext, ScreenContext } from '../Context';
|
|
7
7
|
import { GridSystem } from '../Layout';
|
|
8
8
|
import { version } from '../package.json';
|
|
9
|
+
import { useAppState } from './utils';
|
|
9
10
|
|
|
10
11
|
const runAfterInteractions = InteractionManager.runAfterInteractions;
|
|
11
12
|
|
|
@@ -48,6 +49,7 @@ const StackScreen: React.FC<any> = props => {
|
|
|
48
49
|
} = props.route.params;
|
|
49
50
|
const navigation = useRef(new Navigation(props.navigation, context)).current;
|
|
50
51
|
const heightHeader = useHeaderHeight();
|
|
52
|
+
const { isBackgroundToForeground } = useAppState();
|
|
51
53
|
|
|
52
54
|
const data = {
|
|
53
55
|
...initialParams,
|
|
@@ -140,29 +142,31 @@ const StackScreen: React.FC<any> = props => {
|
|
|
140
142
|
}, []);
|
|
141
143
|
|
|
142
144
|
const onScreenNavigated = (pre: string, current: string) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
if (!isBackgroundToForeground) {
|
|
146
|
+
const item: any = {
|
|
147
|
+
preScreenName: pre,
|
|
148
|
+
screenName: current,
|
|
149
|
+
componentName: 'Screen',
|
|
150
|
+
state: 'navigated',
|
|
151
|
+
action: tracking.current?.mounted ? 'back' : 'push',
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
context?.autoTracking?.({
|
|
155
|
+
...context,
|
|
156
|
+
...item,
|
|
157
|
+
});
|
|
150
158
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
appId: context.appId,
|
|
163
|
-
message: `${screenName} screen_navigated`,
|
|
164
|
-
type: 'ERROR',
|
|
165
|
-
});
|
|
159
|
+
tracking.current.mounted = true;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* debug toast
|
|
163
|
+
*/
|
|
164
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
165
|
+
appId: context.appId,
|
|
166
|
+
message: `${screenName} screen_navigated`,
|
|
167
|
+
type: 'ERROR',
|
|
168
|
+
});
|
|
169
|
+
}
|
|
166
170
|
};
|
|
167
171
|
|
|
168
172
|
/**
|
|
@@ -2,7 +2,7 @@ import React, { useContext, useRef, useState } from 'react';
|
|
|
2
2
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
3
3
|
import Navigator from './Navigator';
|
|
4
4
|
import { WidgetContainerProps } from './types';
|
|
5
|
-
import { ApplicationContext, MiniAppContext } from '
|
|
5
|
+
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
6
6
|
import Localize from './Localize';
|
|
7
7
|
import { defaultTheme } from '../Consts';
|
|
8
8
|
import {
|
package/Application/index.ts
CHANGED
|
@@ -1,48 +1,29 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import { createContext } from 'react';
|
|
3
1
|
import { NavigationContainer } from './NavigationContainer';
|
|
4
2
|
import { WidgetContainer } from './WidgetContainer';
|
|
5
3
|
import Localize from './Localize';
|
|
6
4
|
import BottomTab from './BottomTab';
|
|
7
|
-
import { defaultContext } from '../Consts';
|
|
8
|
-
import {
|
|
9
|
-
HeaderAnimated,
|
|
10
|
-
HeaderBackground,
|
|
11
|
-
HeaderTitle,
|
|
12
|
-
NavigationButton,
|
|
13
|
-
} from './Components';
|
|
14
|
-
import { setAutomationID, useComponentId, exportHeaderTitle } from './utils';
|
|
15
|
-
import Navigation from './Navigation';
|
|
16
|
-
import Navigator from './Navigator';
|
|
17
5
|
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
export * from './Components/BackgroundImageView';
|
|
7
|
+
export * from './Components/HeaderAnimated';
|
|
8
|
+
export * from './Components/HeaderBackground';
|
|
9
|
+
export * from './Components/HeaderExtendHeader';
|
|
10
|
+
export * from './Components/HeaderLeft';
|
|
11
|
+
export * from './Components/HeaderRight';
|
|
12
|
+
export * from './Components/HeaderTitle';
|
|
13
|
+
export * from './Components/NavigationButton';
|
|
14
|
+
export * from './Components/SearchHeader';
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const SkeletonContext = createContext({ loading: false });
|
|
25
|
-
const TrackingScopeContext = createContext<{ scopeName?: string }>({
|
|
26
|
-
scopeName: undefined,
|
|
27
|
-
});
|
|
16
|
+
import { exportHeaderTitle, setAutomationID, useComponentId } from './utils';
|
|
17
|
+
import Navigation from './Navigation';
|
|
18
|
+
import Navigator from './Navigator';
|
|
28
19
|
|
|
29
20
|
export {
|
|
30
|
-
ApplicationContext,
|
|
31
|
-
MiniAppContext,
|
|
32
|
-
ScreenContext,
|
|
33
|
-
ComponentContext,
|
|
34
|
-
SkeletonContext,
|
|
35
21
|
NavigationContainer,
|
|
36
22
|
WidgetContainer,
|
|
37
23
|
Localize,
|
|
38
|
-
HeaderTitle,
|
|
39
|
-
HeaderBackground,
|
|
40
|
-
NavigationButton,
|
|
41
24
|
BottomTab,
|
|
42
|
-
HeaderAnimated,
|
|
43
25
|
setAutomationID,
|
|
44
26
|
useComponentId,
|
|
45
|
-
TrackingScopeContext,
|
|
46
27
|
Navigation,
|
|
47
28
|
Navigator,
|
|
48
29
|
exportHeaderTitle,
|
package/Application/types.ts
CHANGED
|
@@ -8,11 +8,48 @@ import {
|
|
|
8
8
|
ViewStyle,
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import { PopupNotifyProps } from '../Popup/types';
|
|
11
|
-
import Localize from './Localize';
|
|
12
|
-
import Navigation from './Navigation';
|
|
13
|
-
import Navigator from './Navigator';
|
|
14
11
|
import { InputRef, InputSearchProps } from '../Input';
|
|
15
12
|
|
|
13
|
+
export type NavigationProps = {
|
|
14
|
+
context: any;
|
|
15
|
+
setOptions: (params: NavigationOptions) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type NavigatorProps = {
|
|
19
|
+
ref?: any;
|
|
20
|
+
isReady?: any;
|
|
21
|
+
isWidget?: any;
|
|
22
|
+
maxApi?: any;
|
|
23
|
+
dismissData?: any;
|
|
24
|
+
push: (params: ScreenParams) => void;
|
|
25
|
+
replace: (params: ScreenParams) => void;
|
|
26
|
+
pop: (count?: number) => void;
|
|
27
|
+
present: (params: ScreenParams) => void;
|
|
28
|
+
showModal: (params: ModalParams, onError?: (error: string) => void) => void;
|
|
29
|
+
showBottomSheet: (
|
|
30
|
+
params: BottomSheetParams,
|
|
31
|
+
onError?: (error: string) => void,
|
|
32
|
+
) => void;
|
|
33
|
+
popToTop: () => void;
|
|
34
|
+
navigate: (name: string) => void;
|
|
35
|
+
reset: (params: ScreenParams) => void;
|
|
36
|
+
setDismissData: (data: any) => void;
|
|
37
|
+
setCurrentContext: (context: {
|
|
38
|
+
code?: string;
|
|
39
|
+
name?: { vi: string; en: string };
|
|
40
|
+
description?: { vi: string; en: string };
|
|
41
|
+
icon?: string;
|
|
42
|
+
}) => void;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type LocalizeProps = {
|
|
46
|
+
getCurrentLanguage: 'en' | 'vi';
|
|
47
|
+
getAssets: LocalizationObject;
|
|
48
|
+
translate: (key: string) => string;
|
|
49
|
+
translateData: (data: { vi: string; en: string }) => string;
|
|
50
|
+
addTranslations: (translations: LocalizationObject) => void;
|
|
51
|
+
};
|
|
52
|
+
|
|
16
53
|
export type Theme = {
|
|
17
54
|
dark: boolean;
|
|
18
55
|
colors: {
|
|
@@ -72,7 +109,7 @@ export type Theme = {
|
|
|
72
109
|
export type Context = {
|
|
73
110
|
[key: string]: any;
|
|
74
111
|
theme: Theme;
|
|
75
|
-
navigator?:
|
|
112
|
+
navigator?: NavigatorProps;
|
|
76
113
|
showGrid?: boolean;
|
|
77
114
|
translate?: (data: string | { vi: string; en: string }) => string;
|
|
78
115
|
};
|
|
@@ -113,7 +150,7 @@ export type NavigationContainerProps = {
|
|
|
113
150
|
theme?: Theme;
|
|
114
151
|
maxApi: any;
|
|
115
152
|
initialParams?: any;
|
|
116
|
-
localize:
|
|
153
|
+
localize: LocalizeProps;
|
|
117
154
|
features: FeaturesFlag;
|
|
118
155
|
};
|
|
119
156
|
|
|
@@ -121,13 +158,13 @@ export type WidgetContainerProps = {
|
|
|
121
158
|
widget: React.ComponentType<any>;
|
|
122
159
|
theme?: Theme;
|
|
123
160
|
maxApi: any;
|
|
124
|
-
localize:
|
|
161
|
+
localize: LocalizeProps;
|
|
125
162
|
};
|
|
126
163
|
|
|
127
164
|
export type NavigationScreenProps = {
|
|
128
165
|
[key: string]: any;
|
|
129
166
|
options?: NavigationOptions;
|
|
130
|
-
navigation:
|
|
167
|
+
navigation: NavigationProps;
|
|
131
168
|
};
|
|
132
169
|
|
|
133
170
|
export type ScreenParams = {
|
|
@@ -274,7 +311,7 @@ export type BottomTabProps = {
|
|
|
274
311
|
nested?: boolean;
|
|
275
312
|
tabs: BottomTabItemProps[];
|
|
276
313
|
initialRouteName?: string;
|
|
277
|
-
navigation:
|
|
314
|
+
navigation: NavigationProps;
|
|
278
315
|
listeners?: {
|
|
279
316
|
tabPress?: (e: EventArg<'tabPress', true, undefined>) => void;
|
|
280
317
|
focus?: (e: EventArg<'focus', false, unknown>) => void;
|
package/Application/utils.tsx
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import React, { useContext, useMemo } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
StackNavigationOptions,
|
|
4
4
|
TransitionPresets,
|
|
5
5
|
} from '@react-navigation/stack';
|
|
6
|
-
import {
|
|
7
|
-
HeaderBackground,
|
|
8
|
-
HeaderLeft,
|
|
9
|
-
HeaderRight,
|
|
10
|
-
HeaderTitle,
|
|
11
|
-
TitleCustom,
|
|
12
|
-
} from './Components';
|
|
13
|
-
import { HeaderTitleProps, NavigationOptions } from './types';
|
|
6
|
+
import type { HeaderTitleProps, NavigationOptions } from './types';
|
|
14
7
|
import { Colors, Spacing } from '../Consts';
|
|
15
|
-
import { Animated, Platform } from 'react-native';
|
|
16
|
-
import {
|
|
8
|
+
import { Animated, AppState, Platform } from 'react-native';
|
|
9
|
+
import {
|
|
10
|
+
MiniAppContext,
|
|
11
|
+
ScreenContext,
|
|
12
|
+
TrackingScopeContext,
|
|
13
|
+
} from '../Context';
|
|
14
|
+
import { HeaderTitle, TitleCustom } from './Components/HeaderTitle';
|
|
15
|
+
import { HeaderBackground } from './Components/HeaderBackground';
|
|
16
|
+
import { HeaderLeft } from './Components/HeaderLeft';
|
|
17
|
+
import { HeaderRight } from './Components/HeaderRight';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* default options for stack screen
|
|
@@ -197,12 +198,34 @@ const useComponentId = (componentName: string, accessibilityLabel?: string) => {
|
|
|
197
198
|
return { componentId };
|
|
198
199
|
};
|
|
199
200
|
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
const useAppState = () => {
|
|
202
|
+
const isBackgroundToForeground = useRef(false);
|
|
203
|
+
const appState = useRef(AppState.currentState);
|
|
204
|
+
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
const subscription = AppState.addEventListener('change', nextAppState => {
|
|
207
|
+
isBackgroundToForeground.current = !!(
|
|
208
|
+
appState.current.match(/inactive|background/) &&
|
|
209
|
+
nextAppState === 'active'
|
|
210
|
+
);
|
|
211
|
+
appState.current = nextAppState;
|
|
212
|
+
|
|
213
|
+
if (isBackgroundToForeground.current) {
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
isBackgroundToForeground.current = false;
|
|
216
|
+
}, 100);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return () => {
|
|
221
|
+
subscription.remove();
|
|
222
|
+
};
|
|
223
|
+
}, []);
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
isBackgroundToForeground: isBackgroundToForeground.current,
|
|
227
|
+
appState: appState.current,
|
|
228
|
+
};
|
|
206
229
|
};
|
|
207
230
|
|
|
208
231
|
export {
|
|
@@ -212,4 +235,5 @@ export {
|
|
|
212
235
|
exportHeaderTitle,
|
|
213
236
|
setAutomationID,
|
|
214
237
|
useComponentId,
|
|
238
|
+
useAppState,
|
|
215
239
|
};
|
package/Badge/Badge.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React, {FC, useContext} from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
1
|
+
import React, { FC, useContext } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { useComponentId } from '../Application';
|
|
5
|
+
import { ApplicationContext } from '../Context';
|
|
6
|
+
import { BadgeProps } from './types';
|
|
6
7
|
import styles from './styles';
|
|
7
|
-
import {Colors} from '../Consts';
|
|
8
|
-
import {Text} from '../Text';
|
|
8
|
+
import { Colors } from '../Consts';
|
|
9
|
+
import { Text } from '../Text';
|
|
9
10
|
|
|
10
11
|
const Badge: FC<BadgeProps> = ({
|
|
11
12
|
label = 'Label',
|
|
@@ -13,8 +14,8 @@ const Badge: FC<BadgeProps> = ({
|
|
|
13
14
|
backgroundColor,
|
|
14
15
|
accessibilityLabel,
|
|
15
16
|
}) => {
|
|
16
|
-
const {theme} = useContext(ApplicationContext);
|
|
17
|
-
const {componentId} = useComponentId('Badge', accessibilityLabel);
|
|
17
|
+
const { theme } = useContext(ApplicationContext);
|
|
18
|
+
const { componentId } = useComponentId('Badge', accessibilityLabel);
|
|
18
19
|
|
|
19
20
|
const isValidatedColor = () => {
|
|
20
21
|
const colorKeys = Object.keys(Colors);
|
|
@@ -53,12 +54,14 @@ const Badge: FC<BadgeProps> = ({
|
|
|
53
54
|
return (
|
|
54
55
|
<View style={[style, styles.badgeContainer]}>
|
|
55
56
|
<View
|
|
56
|
-
style={[styles.badge, {backgroundColor: badgeColor}]}
|
|
57
|
-
accessibilityLabel={componentId}
|
|
57
|
+
style={[styles.badge, { backgroundColor: badgeColor }]}
|
|
58
|
+
accessibilityLabel={componentId}
|
|
59
|
+
>
|
|
58
60
|
<Text
|
|
59
61
|
color={Colors.black_01}
|
|
60
62
|
typography={'action_xxs_bold'}
|
|
61
|
-
accessibilityLabel={`${componentId}|text`}
|
|
63
|
+
accessibilityLabel={`${componentId}|text`}
|
|
64
|
+
>
|
|
62
65
|
{formatTitle()}
|
|
63
66
|
</Text>
|
|
64
67
|
</View>
|
package/Badge/BadgeRibbon.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { View } from 'react-native';
|
|
|
3
3
|
import { DownTail, UpTail } from './Shape';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import { BadgeRibbonProps } from './types';
|
|
6
|
-
import { ApplicationContext } from '../
|
|
6
|
+
import { ApplicationContext } from '../Context';
|
|
7
7
|
import { Text } from '../Text';
|
|
8
8
|
import { Colors } from '../Consts';
|
|
9
9
|
import { Image } from '../Image';
|
package/Button/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {FC, useContext} from 'react';
|
|
1
|
+
import React, { FC, useContext } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Animated,
|
|
4
4
|
StyleSheet,
|
|
@@ -7,19 +7,19 @@ import {
|
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
import LinearGradient from 'react-native-linear-gradient';
|
|
10
|
+
import { useComponentId } from '../Application';
|
|
10
11
|
import {
|
|
11
12
|
ApplicationContext,
|
|
12
13
|
ComponentContext,
|
|
13
14
|
SkeletonContext,
|
|
14
|
-
|
|
15
|
-
} from '../
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {Colors, Spacing} from '../Consts';
|
|
15
|
+
} from '../Context';
|
|
16
|
+
import { Text } from '../Text';
|
|
17
|
+
import { Typography } from '../Text/types';
|
|
18
|
+
import { Colors, Spacing } from '../Consts';
|
|
19
19
|
import styles from './styles';
|
|
20
|
-
import {Icon} from '../Icon';
|
|
21
|
-
import {Loader} from '../Loader';
|
|
22
|
-
import {Skeleton} from '../Skeleton';
|
|
20
|
+
import { Icon } from '../Icon';
|
|
21
|
+
import { Loader } from '../Loader';
|
|
22
|
+
import { Skeleton } from '../Skeleton';
|
|
23
23
|
|
|
24
24
|
const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
|
|
25
25
|
|
|
@@ -95,27 +95,27 @@ const Button: FC<ButtonProps> = ({
|
|
|
95
95
|
accessibilityState,
|
|
96
96
|
...rest
|
|
97
97
|
}) => {
|
|
98
|
-
const {theme, config} = useContext(ApplicationContext);
|
|
98
|
+
const { theme, config } = useContext(ApplicationContext);
|
|
99
99
|
const skeleton = useContext(SkeletonContext);
|
|
100
100
|
const componentName = 'Button';
|
|
101
101
|
|
|
102
|
-
const {componentId} = useComponentId(
|
|
102
|
+
const { componentId } = useComponentId(
|
|
103
103
|
`${componentName}/${title}`,
|
|
104
104
|
rest.accessibilityLabel,
|
|
105
105
|
);
|
|
106
|
-
const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
|
|
106
|
+
const { gradient, color } = config?.navigationBar?.buttonColors ?? {};
|
|
107
107
|
let gradientPros;
|
|
108
108
|
|
|
109
109
|
if (gradient?.length > 0 && type === 'primary') {
|
|
110
110
|
gradientPros = {
|
|
111
111
|
colors: gradient,
|
|
112
|
-
start: {x: 1, y: 0.5},
|
|
113
|
-
end: {x: 0, y: 0.5},
|
|
112
|
+
start: { x: 1, y: 0.5 },
|
|
113
|
+
end: { x: 0, y: 0.5 },
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
const getSizeStyle = () => {
|
|
118
|
-
const styleSheet: {[key: string]: any} = styles;
|
|
118
|
+
const styleSheet: { [key: string]: any } = styles;
|
|
119
119
|
return styleSheet[size ?? 'small'];
|
|
120
120
|
};
|
|
121
121
|
|
|
@@ -126,7 +126,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
126
126
|
backgroundColor: theme.colors.background.disable,
|
|
127
127
|
};
|
|
128
128
|
case 'primary':
|
|
129
|
-
return {backgroundColor: theme.colors.primary};
|
|
129
|
+
return { backgroundColor: theme.colors.primary };
|
|
130
130
|
case 'secondary':
|
|
131
131
|
return {
|
|
132
132
|
backgroundColor: theme.colors.background.surface,
|
|
@@ -150,7 +150,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
150
150
|
case 'text':
|
|
151
151
|
return {};
|
|
152
152
|
default:
|
|
153
|
-
return {backgroundColor: theme.colors.primary};
|
|
153
|
+
return { backgroundColor: theme.colors.primary };
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
156
|
|
|
@@ -256,7 +256,8 @@ const Button: FC<ButtonProps> = ({
|
|
|
256
256
|
marginRight,
|
|
257
257
|
borderRadius: Spacing.M,
|
|
258
258
|
},
|
|
259
|
-
]}
|
|
259
|
+
]}
|
|
260
|
+
>
|
|
260
261
|
<Loader type="spinner" color={getTextColor()} />
|
|
261
262
|
</View>
|
|
262
263
|
);
|
|
@@ -266,8 +267,9 @@ const Button: FC<ButtonProps> = ({
|
|
|
266
267
|
<View
|
|
267
268
|
style={[
|
|
268
269
|
styles.leading,
|
|
269
|
-
{width: iconSize, height: iconSize, marginRight},
|
|
270
|
-
]}
|
|
270
|
+
{ width: iconSize, height: iconSize, marginRight },
|
|
271
|
+
]}
|
|
272
|
+
>
|
|
271
273
|
<Icon color={textColor} source={iconLeft} size={iconSize} />
|
|
272
274
|
</View>
|
|
273
275
|
);
|
|
@@ -287,8 +289,9 @@ const Button: FC<ButtonProps> = ({
|
|
|
287
289
|
<View
|
|
288
290
|
style={[
|
|
289
291
|
styles.trailing,
|
|
290
|
-
{width: iconSize, height: iconSize, marginLeft},
|
|
291
|
-
]}
|
|
292
|
+
{ width: iconSize, height: iconSize, marginLeft },
|
|
293
|
+
]}
|
|
294
|
+
>
|
|
292
295
|
<Icon color={textColor} source={iconRight} size={iconSize} />
|
|
293
296
|
</View>
|
|
294
297
|
);
|
|
@@ -298,11 +301,11 @@ const Button: FC<ButtonProps> = ({
|
|
|
298
301
|
const buttonStyle = StyleSheet.flatten([
|
|
299
302
|
getSizeStyle(),
|
|
300
303
|
getTypeStyle(),
|
|
301
|
-
full && {width: '100%'},
|
|
304
|
+
full && { width: '100%' },
|
|
302
305
|
]);
|
|
303
306
|
|
|
304
307
|
if (skeleton?.loading) {
|
|
305
|
-
return <Skeleton style={[buttonStyle, {paddingHorizontal: 0}]} />;
|
|
308
|
+
return <Skeleton style={[buttonStyle, { paddingHorizontal: 0 }]} />;
|
|
306
309
|
}
|
|
307
310
|
|
|
308
311
|
return (
|
|
@@ -312,7 +315,8 @@ const Button: FC<ButtonProps> = ({
|
|
|
312
315
|
componentId,
|
|
313
316
|
params,
|
|
314
317
|
action: 'click',
|
|
315
|
-
}}
|
|
318
|
+
}}
|
|
319
|
+
>
|
|
316
320
|
<TouchableOpacity
|
|
317
321
|
{...rest}
|
|
318
322
|
accessibilityLabel={componentId}
|
|
@@ -324,7 +328,8 @@ const Button: FC<ButtonProps> = ({
|
|
|
324
328
|
}}
|
|
325
329
|
disabled={type === 'disabled'}
|
|
326
330
|
activeOpacity={0.5}
|
|
327
|
-
style={buttonStyle}
|
|
331
|
+
style={buttonStyle}
|
|
332
|
+
>
|
|
328
333
|
{renderLeading()}
|
|
329
334
|
{renderTitle()}
|
|
330
335
|
{renderTrailing()}
|
|
@@ -337,4 +342,4 @@ const Button: FC<ButtonProps> = ({
|
|
|
337
342
|
);
|
|
338
343
|
};
|
|
339
344
|
|
|
340
|
-
export {Button};
|
|
345
|
+
export { Button };
|
package/CheckBox/index.tsx
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import React, {FC, useContext} from 'react';
|
|
2
|
-
import {TouchableOpacity, View} from 'react-native';
|
|
3
|
-
import {CheckBoxProps} from './types';
|
|
1
|
+
import React, { FC, useContext } from 'react';
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { CheckBoxProps } from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from '../Application';
|
|
10
|
-
import {Text} from '../Text';
|
|
11
|
-
import {Icon} from '../Icon';
|
|
5
|
+
import { useComponentId } from '../Application';
|
|
6
|
+
import { ApplicationContext, ComponentContext } from '../Context';
|
|
7
|
+
import { Text } from '../Text';
|
|
8
|
+
import { Icon } from '../Icon';
|
|
12
9
|
|
|
13
10
|
const CheckBox: FC<CheckBoxProps> = ({
|
|
14
11
|
value,
|
|
@@ -21,15 +18,15 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
21
18
|
accessibilityState,
|
|
22
19
|
...props
|
|
23
20
|
}) => {
|
|
24
|
-
const {theme} = useContext(ApplicationContext);
|
|
21
|
+
const { theme } = useContext(ApplicationContext);
|
|
25
22
|
const haveValue = value || indeterminate;
|
|
26
23
|
const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
|
|
27
24
|
let borderColor = theme.colors.text.default;
|
|
28
25
|
let backgroundColor = 'transparent';
|
|
29
26
|
const componentName = 'CheckBox';
|
|
30
|
-
const {componentId} = useComponentId(
|
|
27
|
+
const { componentId } = useComponentId(
|
|
31
28
|
`${componentName}${label ? `/${label}` : ''}`,
|
|
32
|
-
props.accessibilityLabel
|
|
29
|
+
props.accessibilityLabel,
|
|
33
30
|
);
|
|
34
31
|
|
|
35
32
|
if (haveValue) {
|
|
@@ -54,7 +51,8 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
54
51
|
params,
|
|
55
52
|
state: disabled ? 'disabled' : 'filled',
|
|
56
53
|
action: 'click',
|
|
57
|
-
}}
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
58
56
|
<TouchableOpacity
|
|
59
57
|
{...props}
|
|
60
58
|
accessibilityLabel={componentId}
|
|
@@ -66,12 +64,14 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
66
64
|
disabled,
|
|
67
65
|
...accessibilityState,
|
|
68
66
|
}}
|
|
69
|
-
style={[style, styles.container]}
|
|
67
|
+
style={[style, styles.container]}
|
|
68
|
+
>
|
|
70
69
|
<View
|
|
71
70
|
style={[
|
|
72
|
-
{borderColor, backgroundColor, borderWidth: 1},
|
|
71
|
+
{ borderColor, backgroundColor, borderWidth: 1 },
|
|
73
72
|
styles.checkbox,
|
|
74
|
-
]}
|
|
73
|
+
]}
|
|
74
|
+
>
|
|
75
75
|
{haveValue && (
|
|
76
76
|
<Icon
|
|
77
77
|
color={theme.colors.background.surface}
|
|
@@ -80,10 +80,14 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
80
80
|
/>
|
|
81
81
|
)}
|
|
82
82
|
</View>
|
|
83
|
-
{!!label &&
|
|
83
|
+
{!!label && (
|
|
84
|
+
<Text typography={'body_default_regular'} style={styles.label}>
|
|
85
|
+
{label}
|
|
86
|
+
</Text>
|
|
87
|
+
)}
|
|
84
88
|
</TouchableOpacity>
|
|
85
89
|
</ComponentContext.Provider>
|
|
86
90
|
);
|
|
87
91
|
};
|
|
88
92
|
|
|
89
|
-
export {CheckBox};
|
|
93
|
+
export { CheckBox };
|
package/Context/index.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { createContext } from 'react';
|
|
3
|
+
import { defaultContext } from '../Consts';
|
|
4
|
+
|
|
5
|
+
const Context = createContext({});
|
|
6
|
+
const ApplicationContext = createContext(defaultContext);
|
|
7
|
+
|
|
8
|
+
const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
|
|
9
|
+
const ScreenContext = (Platform as any).ScreenContext ?? Context;
|
|
10
|
+
const ComponentContext = (Platform as any).ComponentContext ?? Context;
|
|
11
|
+
const SkeletonContext = createContext({ loading: false });
|
|
12
|
+
const TrackingScopeContext = createContext<{ scopeName?: string }>({
|
|
13
|
+
scopeName: undefined,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
ApplicationContext,
|
|
18
|
+
MiniAppContext,
|
|
19
|
+
ScreenContext,
|
|
20
|
+
ComponentContext,
|
|
21
|
+
SkeletonContext,
|
|
22
|
+
TrackingScopeContext,
|
|
23
|
+
};
|
package/Divider/DashDivider.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, {useContext} from 'react';
|
|
2
|
-
import {View, ViewStyle} from 'react-native';
|
|
3
|
-
import {ApplicationContext} from '../
|
|
4
|
-
import {Spacing} from '../Consts';
|
|
5
|
-
import Svg, {Line} from 'react-native-svg';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { View, ViewStyle } from 'react-native';
|
|
3
|
+
import { ApplicationContext } from '../Context';
|
|
4
|
+
import { Spacing } from '../Consts';
|
|
5
|
+
import Svg, { Line } from 'react-native-svg';
|
|
6
6
|
|
|
7
7
|
export interface DashDividerProps {
|
|
8
8
|
/**
|
|
@@ -11,8 +11,8 @@ export interface DashDividerProps {
|
|
|
11
11
|
style?: ViewStyle;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const DashDivider: React.FC<DashDividerProps> = ({style}) => {
|
|
15
|
-
const {theme} = useContext(ApplicationContext);
|
|
14
|
+
const DashDivider: React.FC<DashDividerProps> = ({ style }) => {
|
|
15
|
+
const { theme } = useContext(ApplicationContext);
|
|
16
16
|
const borderColor = theme.colors.border.default;
|
|
17
17
|
|
|
18
18
|
return (
|
|
@@ -24,7 +24,8 @@ const DashDivider: React.FC<DashDividerProps> = ({style}) => {
|
|
|
24
24
|
marginVertical: Spacing.XS,
|
|
25
25
|
},
|
|
26
26
|
style,
|
|
27
|
-
]}
|
|
27
|
+
]}
|
|
28
|
+
>
|
|
28
29
|
<Svg height="1" width="100%">
|
|
29
30
|
<Line
|
|
30
31
|
x1="0"
|
|
@@ -42,4 +43,4 @@ const DashDivider: React.FC<DashDividerProps> = ({style}) => {
|
|
|
42
43
|
);
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
export {DashDivider};
|
|
46
|
+
export { DashDivider };
|