@momo-kits/foundation 0.165.2-beta.3 → 0.167.1-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/HeaderTitle.tsx +24 -10
- package/Application/NavigationContainer.tsx +14 -7
- package/Application/WidgetContainer.tsx +9 -7
- package/Application/utils.tsx +4 -0
- package/Consts/index.ts +0 -1
- package/Consts/theme.ts +2 -2
- package/Text/index.tsx +2 -11
- package/package.json +1 -1
- package/Consts/designSystemFont.ts +0 -38
|
@@ -16,7 +16,16 @@ import {
|
|
|
16
16
|
import { Image } from '../../Image';
|
|
17
17
|
import { Icon } from '../../Icon';
|
|
18
18
|
import { Skeleton } from '../../Skeleton';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
AnimatedCompatValue,
|
|
21
|
+
isWhiteListDesignSystem,
|
|
22
|
+
useNormalizedSharedValue,
|
|
23
|
+
} from '../utils';
|
|
24
|
+
|
|
25
|
+
const useHeaderFontFamily = (): string => {
|
|
26
|
+
const context = useContext<any>(MiniAppContext);
|
|
27
|
+
return isWhiteListDesignSystem(context) ? 'MoMoTrustDisplay' : 'SFProText';
|
|
28
|
+
};
|
|
20
29
|
|
|
21
30
|
type HeaderTitleInterpolate = {
|
|
22
31
|
inputRange: number[];
|
|
@@ -37,6 +46,7 @@ const HeaderTitle: React.FC<
|
|
|
37
46
|
HeaderTitleExtraProps & { [key: string]: any }
|
|
38
47
|
> = props => {
|
|
39
48
|
const context = useContext<any>(MiniAppContext);
|
|
49
|
+
const headerFontFamily = useHeaderFontFamily();
|
|
40
50
|
|
|
41
51
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
42
52
|
|
|
@@ -85,7 +95,7 @@ const HeaderTitle: React.FC<
|
|
|
85
95
|
fontFamily: exportFontFamily(
|
|
86
96
|
'bold',
|
|
87
97
|
'action_xs_bold',
|
|
88
|
-
|
|
98
|
+
headerFontFamily,
|
|
89
99
|
),
|
|
90
100
|
color: props.tintColor,
|
|
91
101
|
},
|
|
@@ -130,6 +140,7 @@ const TitleUser: React.FC<TitleUserProps> = ({
|
|
|
130
140
|
isLoading,
|
|
131
141
|
}) => {
|
|
132
142
|
const { theme } = useContext(ApplicationContext);
|
|
143
|
+
const headerFontFamily = useHeaderFontFamily();
|
|
133
144
|
const maxWidth = Dimensions.get('window').width - 172;
|
|
134
145
|
const getShortName = (name: string) => {
|
|
135
146
|
const words = name.split(' ');
|
|
@@ -378,7 +389,7 @@ const TitleUser: React.FC<TitleUserProps> = ({
|
|
|
378
389
|
<View style={Styles.row}>
|
|
379
390
|
<Text
|
|
380
391
|
typography="action_xs_bold"
|
|
381
|
-
fontFamily=
|
|
392
|
+
fontFamily={headerFontFamily}
|
|
382
393
|
color={tintColor}
|
|
383
394
|
numberOfLines={1}
|
|
384
395
|
>
|
|
@@ -412,6 +423,7 @@ const TitleLocation: React.FC<TitleLocationProps> = ({
|
|
|
412
423
|
onPress,
|
|
413
424
|
isLoading,
|
|
414
425
|
}) => {
|
|
426
|
+
const headerFontFamily = useHeaderFontFamily();
|
|
415
427
|
const maxWidth = Dimensions.get('window').width - 172;
|
|
416
428
|
const renderShimmer = () => {
|
|
417
429
|
return (
|
|
@@ -448,9 +460,12 @@ const TitleLocation: React.FC<TitleLocationProps> = ({
|
|
|
448
460
|
</Text>
|
|
449
461
|
)}
|
|
450
462
|
<View style={Styles.row}>
|
|
451
|
-
<Text
|
|
452
|
-
|
|
453
|
-
|
|
463
|
+
<Text
|
|
464
|
+
typography="action_xs_bold"
|
|
465
|
+
fontFamily={headerFontFamily}
|
|
466
|
+
color={tintColor}
|
|
467
|
+
numberOfLines={1}
|
|
468
|
+
>
|
|
454
469
|
{location}
|
|
455
470
|
</Text>
|
|
456
471
|
<Icon
|
|
@@ -477,6 +492,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
|
|
|
477
492
|
onPress,
|
|
478
493
|
isLoading,
|
|
479
494
|
}) => {
|
|
495
|
+
const headerFontFamily = useHeaderFontFamily();
|
|
480
496
|
const { width } = Dimensions.get('screen');
|
|
481
497
|
const maxWidth = Dimensions.get('window').width - 172;
|
|
482
498
|
const startWidth = width * 0.25;
|
|
@@ -512,8 +528,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
|
|
|
512
528
|
style={{ maxWidth: startWidth }}
|
|
513
529
|
color={tintColor}
|
|
514
530
|
numberOfLines={1}
|
|
515
|
-
|
|
516
|
-
|
|
531
|
+
fontFamily={headerFontFamily}
|
|
517
532
|
>
|
|
518
533
|
{start}
|
|
519
534
|
</Text>
|
|
@@ -529,8 +544,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
|
|
|
529
544
|
typography="action_xs_bold"
|
|
530
545
|
color={tintColor}
|
|
531
546
|
numberOfLines={1}
|
|
532
|
-
|
|
533
|
-
|
|
547
|
+
fontFamily={headerFontFamily}
|
|
534
548
|
>
|
|
535
549
|
{end}
|
|
536
550
|
</Text>
|
|
@@ -17,10 +17,14 @@ import { DeviceEventEmitter } from 'react-native';
|
|
|
17
17
|
import StackScreen from './StackScreen';
|
|
18
18
|
import ModalScreen from './ModalScreen';
|
|
19
19
|
import Navigator from './Navigator';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
getModalOptions,
|
|
22
|
+
getStackOptions,
|
|
23
|
+
isWhiteListDesignSystem,
|
|
24
|
+
useNativeCanGoBack,
|
|
25
|
+
} from './utils';
|
|
21
26
|
import { NavigationContainerProps } from './types';
|
|
22
27
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
23
|
-
import { useDefaultRegularFontFamily } from '../Consts/designSystemFont';
|
|
24
28
|
import Localize from './Localize';
|
|
25
29
|
import { Colors, defaultTheme } from '../Consts';
|
|
26
30
|
import { HeaderLeft } from './Components/HeaderLeft';
|
|
@@ -103,8 +107,10 @@ const Navigation: React.FC<any> = ({
|
|
|
103
107
|
const navigator = useRef(new Navigator(navigationRef, isReady));
|
|
104
108
|
const [showGrid, setShowGrid] = useState(false);
|
|
105
109
|
const insets = useSafeAreaInsets();
|
|
106
|
-
const defaultRegularFontFamily = useDefaultRegularFontFamily();
|
|
107
110
|
const syncCanGoBack = useNativeCanGoBack();
|
|
111
|
+
const isWhiteList = isWhiteListDesignSystem(context);
|
|
112
|
+
const fontFamily = isWhiteList ? 'MomoTrustSans' : 'SFProText';
|
|
113
|
+
const navigationFontFamily = isWhiteList ? 'MomoTrustSans-Regular' : 'SFProText';
|
|
108
114
|
let headerBackground = context?.designSystemConfig?.config?.headerBar;
|
|
109
115
|
let headerGradient = theme.colors?.gradient;
|
|
110
116
|
|
|
@@ -156,6 +162,7 @@ const Navigation: React.FC<any> = ({
|
|
|
156
162
|
navigator: navigator.current,
|
|
157
163
|
theme: {
|
|
158
164
|
...theme,
|
|
165
|
+
font: fontFamily,
|
|
159
166
|
colors: {
|
|
160
167
|
...theme.colors,
|
|
161
168
|
gradient: headerGradient,
|
|
@@ -183,19 +190,19 @@ const Navigation: React.FC<any> = ({
|
|
|
183
190
|
},
|
|
184
191
|
fonts: {
|
|
185
192
|
regular: {
|
|
186
|
-
fontFamily:
|
|
193
|
+
fontFamily: navigationFontFamily,
|
|
187
194
|
fontWeight: '400',
|
|
188
195
|
},
|
|
189
196
|
medium: {
|
|
190
|
-
fontFamily:
|
|
197
|
+
fontFamily: navigationFontFamily,
|
|
191
198
|
fontWeight: '400',
|
|
192
199
|
},
|
|
193
200
|
bold: {
|
|
194
|
-
fontFamily:
|
|
201
|
+
fontFamily: navigationFontFamily,
|
|
195
202
|
fontWeight: '400',
|
|
196
203
|
},
|
|
197
204
|
heavy: {
|
|
198
|
-
fontFamily:
|
|
205
|
+
fontFamily: navigationFontFamily,
|
|
199
206
|
fontWeight: '400',
|
|
200
207
|
},
|
|
201
208
|
},
|
|
@@ -3,7 +3,6 @@ import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
|
3
3
|
import Navigator from './Navigator';
|
|
4
4
|
import { WidgetContainerProps } from './types';
|
|
5
5
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
6
|
-
import { useDefaultRegularFontFamily } from '../Consts/designSystemFont';
|
|
7
6
|
import Localize from './Localize';
|
|
8
7
|
import { defaultTheme } from '../Consts';
|
|
9
8
|
import {
|
|
@@ -11,7 +10,7 @@ import {
|
|
|
11
10
|
NavigationContainerRef,
|
|
12
11
|
NavigationIndependentTree,
|
|
13
12
|
} from '@react-navigation/native';
|
|
14
|
-
import { getModalOptions } from './utils';
|
|
13
|
+
import { getModalOptions, isWhiteListDesignSystem } from './utils';
|
|
15
14
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
16
15
|
import ModalScreen from './ModalScreen';
|
|
17
16
|
import { View } from 'react-native';
|
|
@@ -43,7 +42,6 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
43
42
|
const isReady = useRef(false);
|
|
44
43
|
const navigator = useRef(new Navigator(navigationRef, isReady, true));
|
|
45
44
|
const [currentContext, setCurrentContext] = useState({});
|
|
46
|
-
const defaultRegularFontFamily = useDefaultRegularFontFamily();
|
|
47
45
|
|
|
48
46
|
useEffect(() => {
|
|
49
47
|
const sub = maxApi?.observer?.('font_scale_config', (data: any) => {
|
|
@@ -80,6 +78,9 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
80
78
|
...context,
|
|
81
79
|
...currentContext,
|
|
82
80
|
};
|
|
81
|
+
const isWhiteList = isWhiteListDesignSystem(mergedContext);
|
|
82
|
+
const fontFamily = isWhiteList ? 'MomoTrustSans' : 'SFProText';
|
|
83
|
+
const navigationFontFamily = isWhiteList ? 'MomoTrustSans-Regular' : 'SFProText';
|
|
83
84
|
|
|
84
85
|
return (
|
|
85
86
|
<View style={{ height: height ?? '100%', minHeight: 1 }}>
|
|
@@ -90,6 +91,7 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
90
91
|
navigator: navigator.current,
|
|
91
92
|
theme: {
|
|
92
93
|
...theme,
|
|
94
|
+
font: fontFamily,
|
|
93
95
|
colors: {
|
|
94
96
|
...theme.colors,
|
|
95
97
|
gradient: headerGradient,
|
|
@@ -116,19 +118,19 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
116
118
|
},
|
|
117
119
|
fonts: {
|
|
118
120
|
regular: {
|
|
119
|
-
fontFamily:
|
|
121
|
+
fontFamily: navigationFontFamily,
|
|
120
122
|
fontWeight: '400',
|
|
121
123
|
},
|
|
122
124
|
medium: {
|
|
123
|
-
fontFamily:
|
|
125
|
+
fontFamily: navigationFontFamily,
|
|
124
126
|
fontWeight: '400',
|
|
125
127
|
},
|
|
126
128
|
bold: {
|
|
127
|
-
fontFamily:
|
|
129
|
+
fontFamily: navigationFontFamily,
|
|
128
130
|
fontWeight: '400',
|
|
129
131
|
},
|
|
130
132
|
heavy: {
|
|
131
|
-
fontFamily:
|
|
133
|
+
fontFamily: navigationFontFamily,
|
|
132
134
|
fontWeight: '400',
|
|
133
135
|
},
|
|
134
136
|
},
|
package/Application/utils.tsx
CHANGED
|
@@ -475,6 +475,9 @@ const SwipeBackHaptic = () => {
|
|
|
475
475
|
return null;
|
|
476
476
|
};
|
|
477
477
|
|
|
478
|
+
const isWhiteListDesignSystem = (context: any): boolean =>
|
|
479
|
+
context?.designSystemConfig?.isWhiteListDesignSystem === true;
|
|
480
|
+
|
|
478
481
|
export {
|
|
479
482
|
getStackOptions,
|
|
480
483
|
getModalOptions,
|
|
@@ -487,4 +490,5 @@ export {
|
|
|
487
490
|
useNativeCanGoBack,
|
|
488
491
|
useNormalizedSharedValue,
|
|
489
492
|
SwipeBackHaptic,
|
|
493
|
+
isWhiteListDesignSystem,
|
|
490
494
|
};
|
package/Consts/index.ts
CHANGED
package/Consts/theme.ts
CHANGED
|
@@ -51,7 +51,7 @@ const defaultTheme: Theme = {
|
|
|
51
51
|
container: Colors.blue_08,
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
|
-
font: '
|
|
54
|
+
font: 'SFProText',
|
|
55
55
|
assets: {},
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -105,7 +105,7 @@ const defaultDarkTheme: Theme = {
|
|
|
105
105
|
container: Colors.blue_08,
|
|
106
106
|
},
|
|
107
107
|
},
|
|
108
|
-
font: '
|
|
108
|
+
font: 'SFProText',
|
|
109
109
|
assets: {},
|
|
110
110
|
};
|
|
111
111
|
|
package/Text/index.tsx
CHANGED
|
@@ -7,10 +7,6 @@ import {
|
|
|
7
7
|
MiniAppContext,
|
|
8
8
|
SkeletonContext,
|
|
9
9
|
} from '../Context';
|
|
10
|
-
import {
|
|
11
|
-
NEW_DEFAULT_FONT_FAMILY,
|
|
12
|
-
useResolvedFontFamily,
|
|
13
|
-
} from '../Consts/designSystemFont';
|
|
14
10
|
import { scaleSize, useScaleSize } from './utils';
|
|
15
11
|
import { Skeleton } from '../Skeleton';
|
|
16
12
|
|
|
@@ -118,8 +114,7 @@ const TypoStyles = (typo: Typography, newFontFamily?: string) => {
|
|
|
118
114
|
const typoStyle = styleSheet[typo] ?? styleSheet.paragraph_default;
|
|
119
115
|
const { fontWeight, fontSize, fontStyle, lineHeight } = typoStyle;
|
|
120
116
|
const style = FontStyle[fontStyle ?? 'normal'];
|
|
121
|
-
const font =
|
|
122
|
-
const resolvedDefaultFamily = useResolvedFontFamily(NEW_DEFAULT_FONT_FAMILY);
|
|
117
|
+
const font = newFontFamily ?? theme.font;
|
|
123
118
|
let fontFamily: string;
|
|
124
119
|
|
|
125
120
|
switch (font) {
|
|
@@ -148,11 +143,7 @@ const TypoStyles = (typo: Typography, newFontFamily?: string) => {
|
|
|
148
143
|
break;
|
|
149
144
|
}
|
|
150
145
|
default: {
|
|
151
|
-
fontFamily = `${
|
|
152
|
-
resolvedDefaultFamily === NEW_DEFAULT_FONT_FAMILY
|
|
153
|
-
? MomoTrustSans[fontWeight]
|
|
154
|
-
: SFProText[fontWeight]
|
|
155
|
-
}`;
|
|
146
|
+
fontFamily = `${font}-${SFProText[fontWeight]}${style}`;
|
|
156
147
|
}
|
|
157
148
|
}
|
|
158
149
|
|
package/package.json
CHANGED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { MiniAppContext } from '../Context';
|
|
3
|
-
|
|
4
|
-
export const NEW_DEFAULT_FONT_FAMILY = 'MomoTrustSans';
|
|
5
|
-
export const LEGACY_DEFAULT_FONT_FAMILY = 'SFProText';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Font thuoc bo design system moi. Ngoai whitelist thi ha het ve font cu:
|
|
9
|
-
* MoMoTrustDisplay chi duoc dung tu commit header title 5bfde6251 (DS-791),
|
|
10
|
-
* truoc do header lay font theo theme.
|
|
11
|
-
*/
|
|
12
|
-
const NEW_FONT_FAMILIES = [NEW_DEFAULT_FONT_FAMILY, 'MoMoTrustDisplay'];
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Cờ whitelist design system, host đẩy xuống qua `decorateProps`
|
|
16
|
-
* (`designSystemConfig.isWhiteListDesignSystem`). Ngoài whitelist thì kit giữ
|
|
17
|
-
* nguyên font cũ.
|
|
18
|
-
*/
|
|
19
|
-
export const useIsDesignSystemWhiteList = (): boolean => {
|
|
20
|
-
const context = useContext<any>(MiniAppContext);
|
|
21
|
-
return context?.designSystemConfig?.isWhiteListDesignSystem === true;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Hạ font mặc định mới về font cũ khi user không nằm trong whitelist.
|
|
26
|
-
* Font do caller chỉ định tường minh (MoMoSignature, AlegreyaSans...) giữ nguyên.
|
|
27
|
-
*/
|
|
28
|
-
export const useResolvedFontFamily = (font: string): string => {
|
|
29
|
-
const isWhiteList = useIsDesignSystemWhiteList();
|
|
30
|
-
if (NEW_FONT_FAMILIES.includes(font) && !isWhiteList) {
|
|
31
|
-
return LEGACY_DEFAULT_FONT_FAMILY;
|
|
32
|
-
}
|
|
33
|
-
return font;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/** Tên file font Regular tương ứng với nhánh whitelist đang áp dụng. */
|
|
37
|
-
export const useDefaultRegularFontFamily = (): string =>
|
|
38
|
-
`${useResolvedFontFamily(NEW_DEFAULT_FONT_FAMILY)}-Regular`;
|