@momo-kits/foundation 0.167.1-beta.5 → 0.167.1-beta.7

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.
@@ -7,7 +7,13 @@ import Animated, {
7
7
  } from 'react-native-reanimated';
8
8
  import { ApplicationContext, MiniAppContext } from '../../Context';
9
9
  import { exportFontFamily, Text, useScaleSize } from '../../Text';
10
- import { Colors, Radius, Spacing, Styles } from '../../Consts';
10
+ import {
11
+ Colors,
12
+ Radius,
13
+ Spacing,
14
+ Styles,
15
+ useHeaderFontFamily,
16
+ } from '../../Consts';
11
17
  import {
12
18
  TitleJourneyProps,
13
19
  TitleLocationProps,
@@ -37,6 +43,7 @@ const HeaderTitle: React.FC<
37
43
  HeaderTitleExtraProps & { [key: string]: any }
38
44
  > = props => {
39
45
  const context = useContext<any>(MiniAppContext);
46
+ const headerFontFamily = useHeaderFontFamily();
40
47
 
41
48
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
42
49
 
@@ -85,7 +92,7 @@ const HeaderTitle: React.FC<
85
92
  fontFamily: exportFontFamily(
86
93
  'bold',
87
94
  'action_xs_bold',
88
- 'MoMoTrustDisplay',
95
+ headerFontFamily,
89
96
  ),
90
97
  color: props.tintColor,
91
98
  },
@@ -130,6 +137,7 @@ const TitleUser: React.FC<TitleUserProps> = ({
130
137
  isLoading,
131
138
  }) => {
132
139
  const { theme } = useContext(ApplicationContext);
140
+ const headerFontFamily = useHeaderFontFamily();
133
141
  const maxWidth = Dimensions.get('window').width - 172;
134
142
  const getShortName = (name: string) => {
135
143
  const words = name.split(' ');
@@ -378,7 +386,7 @@ const TitleUser: React.FC<TitleUserProps> = ({
378
386
  <View style={Styles.row}>
379
387
  <Text
380
388
  typography="action_xs_bold"
381
- fontFamily='MoMoTrustDisplay'
389
+ fontFamily={headerFontFamily}
382
390
  color={tintColor}
383
391
  numberOfLines={1}
384
392
  >
@@ -412,6 +420,7 @@ const TitleLocation: React.FC<TitleLocationProps> = ({
412
420
  onPress,
413
421
  isLoading,
414
422
  }) => {
423
+ const headerFontFamily = useHeaderFontFamily();
415
424
  const maxWidth = Dimensions.get('window').width - 172;
416
425
  const renderShimmer = () => {
417
426
  return (
@@ -449,7 +458,7 @@ const TitleLocation: React.FC<TitleLocationProps> = ({
449
458
  )}
450
459
  <View style={Styles.row}>
451
460
  <Text typography="action_xs_bold"
452
- fontFamily='MoMoTrustDisplay'
461
+ fontFamily={headerFontFamily}
453
462
  color={tintColor} numberOfLines={1}>
454
463
  {location}
455
464
  </Text>
@@ -477,6 +486,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
477
486
  onPress,
478
487
  isLoading,
479
488
  }) => {
489
+ const headerFontFamily = useHeaderFontFamily();
480
490
  const { width } = Dimensions.get('screen');
481
491
  const maxWidth = Dimensions.get('window').width - 172;
482
492
  const startWidth = width * 0.25;
@@ -512,7 +522,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
512
522
  style={{ maxWidth: startWidth }}
513
523
  color={tintColor}
514
524
  numberOfLines={1}
515
- fontFamily='MoMoTrustDisplay'
525
+ fontFamily={headerFontFamily}
516
526
 
517
527
  >
518
528
  {start}
@@ -529,7 +539,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
529
539
  typography="action_xs_bold"
530
540
  color={tintColor}
531
541
  numberOfLines={1}
532
- fontFamily='MoMoTrustDisplay'
542
+ fontFamily={headerFontFamily}
533
543
 
534
544
  >
535
545
  {end}
@@ -20,7 +20,10 @@ import Navigator from './Navigator';
20
20
  import { getModalOptions, getStackOptions, useNativeCanGoBack } from './utils';
21
21
  import { NavigationContainerProps } from './types';
22
22
  import { ApplicationContext, MiniAppContext } from '../Context';
23
- import { useDefaultRegularFontFamily } from '../Consts/designSystemFont';
23
+ import {
24
+ useDefaultRegularFontFamily,
25
+ useResolvedFontFamily,
26
+ } from '../Consts/designSystemFont';
24
27
  import Localize from './Localize';
25
28
  import { Colors, defaultTheme } from '../Consts';
26
29
  import { HeaderLeft } from './Components/HeaderLeft';
@@ -104,6 +107,7 @@ const Navigation: React.FC<any> = ({
104
107
  const [showGrid, setShowGrid] = useState(false);
105
108
  const insets = useSafeAreaInsets();
106
109
  const defaultRegularFontFamily = useDefaultRegularFontFamily();
110
+ const themeFont = useResolvedFontFamily(theme.font);
107
111
  const syncCanGoBack = useNativeCanGoBack();
108
112
  let headerBackground = context?.designSystemConfig?.config?.headerBar;
109
113
  let headerGradient = theme.colors?.gradient;
@@ -156,6 +160,7 @@ const Navigation: React.FC<any> = ({
156
160
  navigator: navigator.current,
157
161
  theme: {
158
162
  ...theme,
163
+ font: themeFont,
159
164
  colors: {
160
165
  ...theme.colors,
161
166
  gradient: headerGradient,
@@ -3,7 +3,10 @@ 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';
6
+ import {
7
+ resolveFontFamily,
8
+ useDefaultRegularFontFamily,
9
+ } from '../Consts/designSystemFont';
7
10
  import Localize from './Localize';
8
11
  import { defaultTheme } from '../Consts';
9
12
  import {
@@ -90,6 +93,11 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
90
93
  navigator: navigator.current,
91
94
  theme: {
92
95
  ...theme,
96
+ font: resolveFontFamily(
97
+ theme.font,
98
+ mergedContext?.designSystemConfig?.isWhiteListDesignSystem ===
99
+ true,
100
+ ),
93
101
  colors: {
94
102
  ...theme.colors,
95
103
  gradient: headerGradient,
@@ -3,36 +3,23 @@ import { MiniAppContext } from '../Context';
3
3
 
4
4
  export const NEW_DEFAULT_FONT_FAMILY = 'MomoTrustSans';
5
5
  export const LEGACY_DEFAULT_FONT_FAMILY = 'SFProText';
6
+ const HEADER_FONT_FAMILY = 'MoMoTrustDisplay';
6
7
 
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
8
  export const useIsDesignSystemWhiteList = (): boolean => {
20
9
  const context = useContext<any>(MiniAppContext);
21
10
  return context?.designSystemConfig?.isWhiteListDesignSystem === true;
22
11
  };
23
12
 
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
- };
13
+ export const resolveFontFamily = (font: string, isWhiteList: boolean): string =>
14
+ isWhiteList ? NEW_DEFAULT_FONT_FAMILY : font;
15
+
16
+ export const useResolvedFontFamily = (font: string): string =>
17
+ resolveFontFamily(font, useIsDesignSystemWhiteList());
35
18
 
36
- /** Tên file font Regular tương ứng với nhánh whitelist đang áp dụng. */
37
19
  export const useDefaultRegularFontFamily = (): string =>
38
- `${useResolvedFontFamily(NEW_DEFAULT_FONT_FAMILY)}-Regular`;
20
+ `${useResolvedFontFamily(LEGACY_DEFAULT_FONT_FAMILY)}-Regular`;
21
+
22
+ export const useHeaderFontFamily = (): string =>
23
+ useIsDesignSystemWhiteList()
24
+ ? HEADER_FONT_FAMILY
25
+ : LEGACY_DEFAULT_FONT_FAMILY;
package/Consts/theme.ts CHANGED
@@ -51,7 +51,7 @@ const defaultTheme: Theme = {
51
51
  container: Colors.blue_08,
52
52
  },
53
53
  },
54
- font: 'MomoTrustSans',
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: 'MomoTrustSans',
108
+ font: 'SFProText',
109
109
  assets: {},
110
110
  };
111
111
 
package/Text/index.tsx CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  SkeletonContext,
9
9
  } from '../Context';
10
10
  import {
11
+ LEGACY_DEFAULT_FONT_FAMILY,
11
12
  NEW_DEFAULT_FONT_FAMILY,
12
13
  useResolvedFontFamily,
13
14
  } from '../Consts/designSystemFont';
@@ -118,8 +119,11 @@ const TypoStyles = (typo: Typography, newFontFamily?: string) => {
118
119
  const typoStyle = styleSheet[typo] ?? styleSheet.paragraph_default;
119
120
  const { fontWeight, fontSize, fontStyle, lineHeight } = typoStyle;
120
121
  const style = FontStyle[fontStyle ?? 'normal'];
121
- const font = useResolvedFontFamily(newFontFamily ?? theme.font);
122
- const resolvedDefaultFamily = useResolvedFontFamily(NEW_DEFAULT_FONT_FAMILY);
122
+ const defaultFontFamily = useResolvedFontFamily(theme.font);
123
+ const font = newFontFamily ?? defaultFontFamily;
124
+ const resolvedDefaultFamily = useResolvedFontFamily(
125
+ LEGACY_DEFAULT_FONT_FAMILY,
126
+ );
123
127
  let fontFamily: string;
124
128
 
125
129
  switch (font) {
@@ -162,9 +166,6 @@ const TypoStyles = (typo: Typography, newFontFamily?: string) => {
162
166
  fontSize: useScaleSize(fontSize),
163
167
  lineHeight: useScaleSize(lineHeight),
164
168
  fontStyle,
165
- // fontFamily da mang san weight. Tren Android, ReactFontManager doi
166
- // `fonts/<family>_bold.ttf` khi fontWeight >= 700; file do khong ton tai nen
167
- // font se roi ve font he thong. Bo fontWeight de Android dung dung file.
168
169
  fontWeight: undefined,
169
170
  };
170
171
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.167.1-beta.5",
3
+ "version": "0.167.1-beta.7",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},