@momo-kits/foundation 0.168.1-rn862.1 → 0.169.2
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.hooks.ts +195 -0
- package/Application/BottomSheet.parts.tsx +147 -0
- package/Application/BottomSheet.styles.ts +43 -0
- package/Application/BottomSheet.tsx +76 -279
- package/Application/BottomTab/ActiveIndicator.tsx +90 -0
- package/Application/BottomTab/BottomTabBar.styles.ts +65 -0
- package/Application/BottomTab/BottomTabBar.tsx +229 -276
- package/Application/BottomTab/BottomTabInset.tsx +14 -0
- package/Application/BottomTab/CurvedContainer.tsx +153 -0
- package/Application/BottomTab/CustomBottomTabItem.tsx +132 -108
- package/Application/BottomTab/DuoBarCompression.tsx +4 -12
- package/Application/BottomTab/DuoRailTabBar.tsx +227 -0
- package/Application/BottomTab/DuoTabBar.styles.ts +81 -0
- package/Application/BottomTab/DuoTabBar.tsx +29 -495
- package/Application/BottomTab/TabBarIcon.tsx +160 -72
- package/Application/BottomTab/TabScreen.tsx +164 -0
- package/Application/BottomTab/index.tsx +84 -351
- package/Application/BottomTab/metrics.ts +164 -0
- package/Application/BottomTab/tabItems.ts +46 -0
- package/Application/BottomTab/usePressLift.ts +32 -0
- package/Application/Components/DuoGlassBackground.tsx +7 -9
- package/Application/Components/HeaderAnimated.tsx +1 -1
- package/Application/Components/HeaderBackground.tsx +1 -1
- package/Application/Components/HeaderExtendHeader.tsx +17 -11
- package/Application/Components/HeaderRight.styles.ts +144 -0
- package/Application/Components/HeaderRight.tsx +6 -528
- package/Application/Components/HeaderTitle.shared.ts +43 -0
- package/Application/Components/HeaderTitle.styles.ts +125 -0
- package/Application/Components/HeaderTitle.tsx +12 -576
- package/Application/Components/HeaderToolkitAction.tsx +208 -0
- package/Application/Components/NavigationButton.tsx +9 -6
- package/Application/Components/SearchHeader.tsx +1 -1
- package/Application/Components/SwipeBackHaptic.tsx +95 -0
- package/Application/Components/TitleJourney.tsx +110 -0
- package/Application/Components/TitleLocation.tsx +73 -0
- package/Application/Components/TitleUser.tsx +304 -0
- package/Application/Components/useToolkitActions.tsx +233 -0
- package/Application/ModalIconButton.tsx +66 -0
- package/Application/ModalScreen.tsx +39 -18
- package/Application/Navigation.ts +1 -1
- package/Application/NavigationContainer.tsx +7 -8
- package/Application/StackScreen.tracking.ts +158 -0
- package/Application/StackScreen.tsx +10 -137
- package/Application/WidgetContainer.tsx +10 -3
- package/Application/__tests__/modalLayout.test.ts +128 -0
- package/Application/hooks.ts +137 -0
- package/Application/index.ts +13 -1
- package/Application/modalLayout.ts +177 -0
- package/Application/navigationOptions.tsx +217 -0
- package/Application/types.header.ts +116 -0
- package/Application/types.tabs.ts +48 -0
- package/Application/types.theme.ts +87 -0
- package/Application/types.ts +12 -244
- package/Application/utils.ts +107 -0
- package/Badge/BadgeRibbon.tsx +3 -3
- package/Badge/styles.ts +2 -0
- package/Button/index.tsx +16 -136
- package/Button/styles.ts +1 -1
- package/Button/utils.ts +139 -0
- package/CheckBox/index.tsx +1 -6
- package/Divider/DashDivider.tsx +10 -11
- package/Divider/index.tsx +18 -8
- package/Image/index.tsx +1 -46
- package/Input/Input.tsx +7 -8
- package/Input/InputDropDown.tsx +3 -4
- package/Input/InputMoney.tsx +38 -164
- package/Input/InputMoneyView.tsx +187 -0
- package/Input/InputOTP.tsx +1 -1
- package/Input/InputPhoneNumber.tsx +5 -1
- package/Input/InputSearch.tsx +2 -108
- package/Input/InputTextArea.tsx +1 -5
- package/Input/SearchTextTyping.tsx +104 -0
- package/Input/common.tsx +4 -4
- package/Input/moneyUtils.ts +17 -0
- package/Input/styles.ts +26 -2
- package/Layout/FloatingButton.tsx +22 -21
- package/Layout/ReservedRegions.tsx +21 -4
- package/Layout/Screen.tsx +74 -670
- package/Layout/Section.tsx +1 -2
- package/Layout/index.ts +10 -4
- package/Layout/layoutMetrics.ts +58 -0
- package/Layout/layoutTypes.ts +86 -0
- package/Layout/screenContent.tsx +90 -0
- package/Layout/screenFooter.tsx +53 -0
- package/Layout/screenHeader.tsx +315 -0
- package/Layout/screenQuickReturn.tsx +67 -0
- package/Layout/screenScroll.ts +110 -0
- package/Layout/screenTypes.ts +134 -0
- package/Layout/styles.ts +2 -0
- package/Layout/utils.ts +10 -144
- package/Loader/DotLoader.tsx +7 -3
- package/Loader/ProgressBar.tsx +2 -6
- package/Loader/Spinner.tsx +7 -3
- package/Loader/styles.ts +4 -0
- package/Popup/PopupNotify.tsx +70 -64
- package/Popup/PopupPromotion.tsx +5 -4
- package/Popup/types.ts +7 -0
- package/Popup/utils.ts +46 -24
- package/Radio/index.tsx +2 -10
- package/Radio/styles.ts +6 -0
- package/Skeleton/index.tsx +1 -9
- package/Skeleton/styles.ts +1 -0
- package/Tag/index.tsx +3 -3
- package/Text/index.tsx +11 -2
- package/Title/index.tsx +2 -9
- package/Title/styles.ts +6 -0
- package/package.json +21 -22
- package/Application/device.ts +0 -29
- package/Application/utils.tsx +0 -497
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { EventArg } from '@react-navigation/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type {
|
|
4
|
+
NavigationOptions,
|
|
5
|
+
NavigationProps,
|
|
6
|
+
NavigationScreenProps,
|
|
7
|
+
} from './types';
|
|
8
|
+
|
|
9
|
+
export type BottomTabItemProps = {
|
|
10
|
+
name: string;
|
|
11
|
+
label: string;
|
|
12
|
+
icon: string;
|
|
13
|
+
showDot?: boolean;
|
|
14
|
+
badgeLabel?: string | number;
|
|
15
|
+
screen: React.ComponentType<NavigationScreenProps>;
|
|
16
|
+
options: NavigationOptions;
|
|
17
|
+
initialParams?: any;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type BottomTabProps = {
|
|
21
|
+
nested?: boolean;
|
|
22
|
+
tabs: BottomTabItemProps[];
|
|
23
|
+
initialRouteName?: string;
|
|
24
|
+
navigation: NavigationProps;
|
|
25
|
+
listeners?: {
|
|
26
|
+
tabPress?: (e: EventArg<'tabPress', true, undefined>) => void;
|
|
27
|
+
focus?: (e: EventArg<'focus', false, unknown>) => void;
|
|
28
|
+
blur?: (e: EventArg<'blur', false, unknown>) => void;
|
|
29
|
+
};
|
|
30
|
+
floatingButton?: FloatingButtonProps;
|
|
31
|
+
/**
|
|
32
|
+
* iPhone Duo: when the side bar can't hold both bars, which one starts compressed;
|
|
33
|
+
* tapping the compressed one swaps them. Defaults to 'toolbar'
|
|
34
|
+
*/
|
|
35
|
+
compressionBehavior?: 'toolbar' | 'tabBar';
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type FloatingButtonProps = {
|
|
39
|
+
container?: React.ReactNode;
|
|
40
|
+
icon: string | React.ReactNode;
|
|
41
|
+
label: string;
|
|
42
|
+
onPress: () => void;
|
|
43
|
+
/**
|
|
44
|
+
* Drawn over the label text, which stays, e.g. a Lottie of the label; centered on the
|
|
45
|
+
* label and unclipped. `icon` takes the button part (inside the 48 button)
|
|
46
|
+
*/
|
|
47
|
+
labelContent?: React.ReactNode;
|
|
48
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ViewProps } from 'react-native';
|
|
2
|
+
import type { NavigatorProps } from './types';
|
|
3
|
+
|
|
4
|
+
export type LocalizeProps = {
|
|
5
|
+
getCurrentLanguage: 'en' | 'vi';
|
|
6
|
+
getAssets: LocalizationObject;
|
|
7
|
+
translate: (key: string) => string;
|
|
8
|
+
translateData: (data: { vi: string; en: string }) => string;
|
|
9
|
+
addTranslations: (translations: LocalizationObject) => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Theme = {
|
|
13
|
+
dark: boolean;
|
|
14
|
+
colors: {
|
|
15
|
+
primary: string;
|
|
16
|
+
secondary: string;
|
|
17
|
+
gradient: string;
|
|
18
|
+
background: {
|
|
19
|
+
default: string;
|
|
20
|
+
surface: string;
|
|
21
|
+
tonal: string;
|
|
22
|
+
pressed: string;
|
|
23
|
+
selected: string;
|
|
24
|
+
disable: string;
|
|
25
|
+
};
|
|
26
|
+
text: {
|
|
27
|
+
default: string;
|
|
28
|
+
secondary: string;
|
|
29
|
+
hint: string;
|
|
30
|
+
disable: string;
|
|
31
|
+
};
|
|
32
|
+
border: {
|
|
33
|
+
default: string;
|
|
34
|
+
disable: string;
|
|
35
|
+
};
|
|
36
|
+
success: {
|
|
37
|
+
primary: string;
|
|
38
|
+
secondary: string;
|
|
39
|
+
container: string;
|
|
40
|
+
};
|
|
41
|
+
warning: {
|
|
42
|
+
primary: string;
|
|
43
|
+
secondary: string;
|
|
44
|
+
container: string;
|
|
45
|
+
};
|
|
46
|
+
error: {
|
|
47
|
+
primary: string;
|
|
48
|
+
secondary: string;
|
|
49
|
+
container: string;
|
|
50
|
+
};
|
|
51
|
+
highlight: {
|
|
52
|
+
primary: string;
|
|
53
|
+
secondary: string;
|
|
54
|
+
container: string;
|
|
55
|
+
};
|
|
56
|
+
interactive: {
|
|
57
|
+
primary: string;
|
|
58
|
+
secondary: string;
|
|
59
|
+
container: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
font: string;
|
|
63
|
+
assets?: {
|
|
64
|
+
headerBackground?: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type ScaleSizeProviderProps = {
|
|
69
|
+
scaleSizeMaxRate?: number;
|
|
70
|
+
children: ViewProps['children'];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type Context = {
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
theme: Theme;
|
|
76
|
+
navigator?: NavigatorProps;
|
|
77
|
+
translate?: (data: string | { vi: string; en: string }) => string;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type LocalizationObject = {
|
|
81
|
+
vi: {
|
|
82
|
+
[key: string]: string;
|
|
83
|
+
};
|
|
84
|
+
en: {
|
|
85
|
+
[key: string]: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
package/Application/types.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { EventArg } from '@react-navigation/core';
|
|
2
1
|
import { StackNavigationOptions } from '@react-navigation/stack';
|
|
3
|
-
import React
|
|
4
|
-
import {
|
|
5
|
-
Animated,
|
|
6
|
-
TouchableOpacityProps,
|
|
7
|
-
ViewProps,
|
|
8
|
-
ViewStyle,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
import type { SharedValue } from 'react-native-reanimated';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ViewStyle } from 'react-native';
|
|
11
4
|
import { PopupNotifyProps } from '../Popup/types';
|
|
12
|
-
import { InputRef, InputSearchProps } from '../Input';
|
|
13
5
|
import Navigation from './Navigation';
|
|
6
|
+
import type {
|
|
7
|
+
HeaderRightToolkit,
|
|
8
|
+
HeaderTitleProps,
|
|
9
|
+
OnBoarding,
|
|
10
|
+
} from './types.header';
|
|
11
|
+
import type { LocalizeProps, Theme } from './types.theme';
|
|
12
|
+
|
|
13
|
+
export * from './types.theme';
|
|
14
|
+
export * from './types.header';
|
|
15
|
+
export * from './types.tabs';
|
|
14
16
|
|
|
15
17
|
export type NavigationProps = {
|
|
16
18
|
context: any;
|
|
@@ -44,105 +46,6 @@ export type NavigatorProps = {
|
|
|
44
46
|
}) => void;
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
export type LocalizeProps = {
|
|
48
|
-
getCurrentLanguage: 'en' | 'vi';
|
|
49
|
-
getAssets: LocalizationObject;
|
|
50
|
-
translate: (key: string) => string;
|
|
51
|
-
translateData: (data: { vi: string; en: string }) => string;
|
|
52
|
-
addTranslations: (translations: LocalizationObject) => void;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export type Theme = {
|
|
56
|
-
dark: boolean;
|
|
57
|
-
colors: {
|
|
58
|
-
primary: string;
|
|
59
|
-
secondary: string;
|
|
60
|
-
gradient: string;
|
|
61
|
-
background: {
|
|
62
|
-
default: string;
|
|
63
|
-
surface: string;
|
|
64
|
-
tonal: string;
|
|
65
|
-
pressed: string;
|
|
66
|
-
selected: string;
|
|
67
|
-
disable: string;
|
|
68
|
-
};
|
|
69
|
-
text: {
|
|
70
|
-
default: string;
|
|
71
|
-
secondary: string;
|
|
72
|
-
hint: string;
|
|
73
|
-
disable: string;
|
|
74
|
-
};
|
|
75
|
-
border: {
|
|
76
|
-
default: string;
|
|
77
|
-
disable: string;
|
|
78
|
-
};
|
|
79
|
-
success: {
|
|
80
|
-
primary: string;
|
|
81
|
-
secondary: string;
|
|
82
|
-
container: string;
|
|
83
|
-
};
|
|
84
|
-
warning: {
|
|
85
|
-
primary: string;
|
|
86
|
-
secondary: string;
|
|
87
|
-
container: string;
|
|
88
|
-
};
|
|
89
|
-
error: {
|
|
90
|
-
primary: string;
|
|
91
|
-
secondary: string;
|
|
92
|
-
container: string;
|
|
93
|
-
};
|
|
94
|
-
highlight: {
|
|
95
|
-
primary: string;
|
|
96
|
-
secondary: string;
|
|
97
|
-
container: string;
|
|
98
|
-
};
|
|
99
|
-
interactive: {
|
|
100
|
-
primary: string;
|
|
101
|
-
secondary: string;
|
|
102
|
-
container: string;
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
font: string;
|
|
106
|
-
assets?: {
|
|
107
|
-
headerBackground?: string;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export type ScaleSizeProviderProps = {
|
|
112
|
-
scaleSizeMaxRate?: number;
|
|
113
|
-
children: ViewProps['children'];
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export type Context = {
|
|
117
|
-
[key: string]: any;
|
|
118
|
-
theme: Theme;
|
|
119
|
-
navigator?: NavigatorProps;
|
|
120
|
-
translate?: (data: string | { vi: string; en: string }) => string;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export type LocalizationObject = {
|
|
124
|
-
vi: {
|
|
125
|
-
[key: string]: string;
|
|
126
|
-
};
|
|
127
|
-
en: {
|
|
128
|
-
[key: string]: string;
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export type ToolGroup = {
|
|
133
|
-
title: { vi: string; en: string };
|
|
134
|
-
items: Tool[];
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export type Tool = {
|
|
138
|
-
icon: string;
|
|
139
|
-
name: { vi: string; en: string };
|
|
140
|
-
key: string;
|
|
141
|
-
showBadge?: boolean;
|
|
142
|
-
showRightIcon?: boolean;
|
|
143
|
-
onPress: () => void;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
49
|
export type FeatureFlags = {
|
|
147
50
|
enableFoundationList?: boolean;
|
|
148
51
|
enableBottomTabAnimation?: boolean;
|
|
@@ -217,19 +120,6 @@ export type BottomSheetParams = {
|
|
|
217
120
|
};
|
|
218
121
|
};
|
|
219
122
|
|
|
220
|
-
export interface NavigationButtonProps extends TouchableOpacityProps {
|
|
221
|
-
icon: string;
|
|
222
|
-
tintColor?: string;
|
|
223
|
-
showBadge?: boolean;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export type HeaderTitleProps = {
|
|
227
|
-
type: 'default' | 'user' | 'location' | 'journey';
|
|
228
|
-
data: TitleUserProps | TitleLocationProps | TitleJourneyProps;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
export type HeaderType = 'default' | 'extended' | 'none';
|
|
232
|
-
|
|
233
123
|
export interface NavigationOptions
|
|
234
124
|
extends Omit<StackNavigationOptions, 'headerRight' | 'headerTitle'> {
|
|
235
125
|
preventBack?: PopupNotifyProps;
|
|
@@ -239,125 +129,3 @@ export interface NavigationOptions
|
|
|
239
129
|
headerTitle?: HeaderTitleProps | string;
|
|
240
130
|
headerRight?: OnBoarding | HeaderRightToolkit | any;
|
|
241
131
|
}
|
|
242
|
-
|
|
243
|
-
export type OnBoarding = {
|
|
244
|
-
useOnBoarding?: boolean;
|
|
245
|
-
onPress?: () => void;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
export type HeaderRightToolkit = {
|
|
249
|
-
useShortcut?: boolean;
|
|
250
|
-
tools?: ToolGroup[];
|
|
251
|
-
preventClose?: PopupNotifyProps;
|
|
252
|
-
useMore?: boolean;
|
|
253
|
-
useCloseIcon?: boolean;
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
export interface HeaderBackProps extends NavigationButtonProps {
|
|
257
|
-
preventBack?: PopupNotifyProps;
|
|
258
|
-
onPressLeftHeader?: () => void;
|
|
259
|
-
onBackHandler?: (goBack: () => void) => void;
|
|
260
|
-
/**
|
|
261
|
-
* Optional. If `true`, the button floats into the iPhone Duo side bar while the
|
|
262
|
-
* device shows one. Set when the button is rendered by the navigation header.
|
|
263
|
-
*/
|
|
264
|
-
floating?: boolean;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export type HeaderBackgroundProps = {
|
|
268
|
-
animatedValue?: Animated.Value | SharedValue<number>;
|
|
269
|
-
useGradient?: boolean;
|
|
270
|
-
useShadowHeader?: boolean;
|
|
271
|
-
backgroundColor?: string;
|
|
272
|
-
gradientColor?: string;
|
|
273
|
-
headerBackground?: string;
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
export type TitleUserProps = {
|
|
277
|
-
title: string;
|
|
278
|
-
subTitle?: string;
|
|
279
|
-
image?: string[] | string;
|
|
280
|
-
dotColor?: string;
|
|
281
|
-
verify?: boolean;
|
|
282
|
-
tintColor?: string;
|
|
283
|
-
onPress?: () => void;
|
|
284
|
-
icons?: string[];
|
|
285
|
-
isLoading?: boolean;
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
export type TitleLocationProps = {
|
|
289
|
-
description?: string;
|
|
290
|
-
location: string;
|
|
291
|
-
tintColor?: string;
|
|
292
|
-
onPress?: () => void;
|
|
293
|
-
isLoading?: boolean;
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
export type TitleJourneyProps = {
|
|
297
|
-
start: string;
|
|
298
|
-
end?: string;
|
|
299
|
-
description?: string;
|
|
300
|
-
icon: string;
|
|
301
|
-
iconColor?: string;
|
|
302
|
-
tintColor?: string;
|
|
303
|
-
onPress?: () => void;
|
|
304
|
-
isLoading?: boolean;
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
export interface HeaderAnimatedProps extends ViewProps {
|
|
308
|
-
animatedValue: Animated.Value | SharedValue<number>;
|
|
309
|
-
image: string;
|
|
310
|
-
useScale?: boolean;
|
|
311
|
-
aspectRatio?: '16/9' | '3/2' | '1/1';
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
export type BottomTabItemProps = {
|
|
315
|
-
name: string;
|
|
316
|
-
label: string;
|
|
317
|
-
icon: string;
|
|
318
|
-
showDot?: boolean;
|
|
319
|
-
badgeLabel?: string | number;
|
|
320
|
-
screen: React.ComponentType<NavigationScreenProps>;
|
|
321
|
-
options: NavigationOptions;
|
|
322
|
-
initialParams?: any;
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
export type BottomTabProps = {
|
|
326
|
-
nested?: boolean;
|
|
327
|
-
tabs: BottomTabItemProps[];
|
|
328
|
-
initialRouteName?: string;
|
|
329
|
-
navigation: NavigationProps;
|
|
330
|
-
listeners?: {
|
|
331
|
-
tabPress?: (e: EventArg<'tabPress', true, undefined>) => void;
|
|
332
|
-
focus?: (e: EventArg<'focus', false, unknown>) => void;
|
|
333
|
-
blur?: (e: EventArg<'blur', false, unknown>) => void;
|
|
334
|
-
};
|
|
335
|
-
floatingButton?: FloatingButtonProps;
|
|
336
|
-
/**
|
|
337
|
-
* iPhone Duo: when the side bar can't hold both bars, which one starts compressed;
|
|
338
|
-
* tapping the compressed one swaps them. Defaults to 'toolbar'
|
|
339
|
-
*/
|
|
340
|
-
compressionBehavior?: 'toolbar' | 'tabBar';
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
export type FloatingButtonProps = {
|
|
344
|
-
container?: React.ReactNode;
|
|
345
|
-
icon: string | React.ReactNode;
|
|
346
|
-
label: string;
|
|
347
|
-
onPress: () => void;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
export type AnimatedHeader = {
|
|
351
|
-
headerTintColor?: string;
|
|
352
|
-
component?: (props?: any) => React.ReactElement;
|
|
353
|
-
headerTitle?: HeaderTitleProps | string;
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
export interface SearchHeaderProps extends InputSearchProps {
|
|
357
|
-
ref?: React.RefObject<InputRef>;
|
|
358
|
-
animatedValue?: Animated.Value | SharedValue<number>;
|
|
359
|
-
headerRightWidth?: 0 | 74 | 110 | number;
|
|
360
|
-
leftPosition?: 12 | 48 | number;
|
|
361
|
-
renderButtons?: () => ReactNode;
|
|
362
|
-
hiddenBack?: boolean;
|
|
363
|
-
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Animated, Dimensions, Platform, ScaledSize } from 'react-native';
|
|
2
|
+
import type { NavigationState, PartialState } from '@react-navigation/native';
|
|
3
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
const IPHONE_MAX_SHORT_SIDE = 440;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Animation runtimes an internal header component may receive. Public Screen
|
|
9
|
+
* props still accept RN Animated.Value only.
|
|
10
|
+
*/
|
|
11
|
+
type AnimatedCompatValue = Animated.Value | SharedValue<number>;
|
|
12
|
+
|
|
13
|
+
type NavigationTreeState = NavigationState | PartialState<NavigationState>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* True when `value` has a callable property `name`. Safe on null and primitives.
|
|
17
|
+
*/
|
|
18
|
+
const hasMethod = (value: unknown, name: string) => {
|
|
19
|
+
return typeof (value as Record<string, unknown>)?.[name] === 'function';
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* True for a React Native `Animated.Value`.
|
|
24
|
+
*/
|
|
25
|
+
const isRNAnimatedValue = (value: unknown): value is Animated.Value => {
|
|
26
|
+
return hasMethod(value, 'setValue') && hasMethod(value, 'interpolate');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* True for a reanimated shared value: has `.value`, not an `Animated.Value`.
|
|
31
|
+
*/
|
|
32
|
+
const isSharedValue = (value: unknown): value is SharedValue<number> => {
|
|
33
|
+
if (!value || isRNAnimatedValue(value)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return 'value' in (value as object);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Props carrying the QA automation id: `testID` on iOS (label cleared so it
|
|
41
|
+
* doesn't override it), `accessibilityLabel` on Android.
|
|
42
|
+
*/
|
|
43
|
+
const setAutomationID = (accessibilityLabel = '') => {
|
|
44
|
+
if (Platform.OS === 'ios') {
|
|
45
|
+
return {
|
|
46
|
+
accessible: true,
|
|
47
|
+
testID: accessibilityLabel,
|
|
48
|
+
accessibilityLabel: undefined,
|
|
49
|
+
};
|
|
50
|
+
} else {
|
|
51
|
+
return {
|
|
52
|
+
accessibilityLabel,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Screens the focused navigation branch can still pop. Only stack navigators
|
|
59
|
+
* count, switching bottom tab is not a back step.
|
|
60
|
+
*/
|
|
61
|
+
const getStackDepth = (state?: NavigationTreeState): number => {
|
|
62
|
+
const routes = state?.routes;
|
|
63
|
+
if (!routes?.length) {
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const index = state?.index ?? routes.length - 1;
|
|
68
|
+
const depth = state?.type === 'stack' ? index : 0;
|
|
69
|
+
|
|
70
|
+
return depth + getStackDepth(routes[index]?.state);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* True when the mini app context opts into the whitelisted design system.
|
|
75
|
+
*/
|
|
76
|
+
const isWhiteListDesignSystem = (context: any): boolean => {
|
|
77
|
+
return context?.designSystemConfig?.isWhiteListDesignSystem === true;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Shorter edge of a screen or window size.
|
|
82
|
+
*/
|
|
83
|
+
const getShortSide = (size: ScaledSize) => Math.min(size.width, size.height);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* True on iPhone Duo. Duo reports idiom "phone" and `screen` stays on the
|
|
87
|
+
* outer display, so this still matches when Split View narrows the window.
|
|
88
|
+
*/
|
|
89
|
+
const isIPhoneDuo = () => {
|
|
90
|
+
if (Platform.OS !== 'ios' || Platform.isPad) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const screenSide = getShortSide(Dimensions.get('screen'));
|
|
94
|
+
const windowSide = getShortSide(Dimensions.get('window'));
|
|
95
|
+
return Math.max(screenSide, windowSide) > IPHONE_MAX_SHORT_SIDE;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type { AnimatedCompatValue, NavigationTreeState };
|
|
99
|
+
export {
|
|
100
|
+
hasMethod,
|
|
101
|
+
isRNAnimatedValue,
|
|
102
|
+
isSharedValue,
|
|
103
|
+
setAutomationID,
|
|
104
|
+
getStackDepth,
|
|
105
|
+
isWhiteListDesignSystem,
|
|
106
|
+
isIPhoneDuo,
|
|
107
|
+
};
|
package/Badge/BadgeRibbon.tsx
CHANGED
|
@@ -46,7 +46,7 @@ const BadgeRibbon: FC<BadgeRibbonProps> = ({
|
|
|
46
46
|
>
|
|
47
47
|
<View
|
|
48
48
|
collapsable={false}
|
|
49
|
-
style={{ transform: textTransform
|
|
49
|
+
style={[styles.ribbonLabelWrapper, { transform: textTransform }]}
|
|
50
50
|
>
|
|
51
51
|
<Text
|
|
52
52
|
style={styles.ribbonLabel}
|
|
@@ -60,7 +60,7 @@ const BadgeRibbon: FC<BadgeRibbonProps> = ({
|
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
const renderSkewContent = () => (
|
|
63
|
-
<View style={{
|
|
63
|
+
<View style={[styles.ribbonSkewRow, { marginTop: skewMargin }]}>
|
|
64
64
|
<View
|
|
65
65
|
collapsable={false}
|
|
66
66
|
style={[
|
|
@@ -70,7 +70,7 @@ const BadgeRibbon: FC<BadgeRibbonProps> = ({
|
|
|
70
70
|
>
|
|
71
71
|
<View
|
|
72
72
|
collapsable={false}
|
|
73
|
-
style={{ transform: textTransform
|
|
73
|
+
style={[styles.ribbonLabelWrapper, { transform: textTransform }]}
|
|
74
74
|
>
|
|
75
75
|
<Text
|
|
76
76
|
style={styles.ribbonLabel}
|
package/Badge/styles.ts
CHANGED
|
@@ -118,6 +118,8 @@ export default StyleSheet.create({
|
|
|
118
118
|
ribbonLabel: {
|
|
119
119
|
color: Colors.black_01,
|
|
120
120
|
},
|
|
121
|
+
ribbonLabelWrapper: {marginVertical: -2},
|
|
122
|
+
ribbonSkewRow: {flexDirection: 'row'},
|
|
121
123
|
skew: {width: 8, height: 16},
|
|
122
124
|
tail: {width: 5, height: 20},
|
|
123
125
|
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|