@momo-kits/foundation 0.167.1-beta.11 → 0.167.1-beta.13

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.
@@ -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 { AnimatedCompatValue, useNormalizedSharedValue } from '../utils';
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
 
@@ -80,12 +90,13 @@ const HeaderTitle: React.FC<
80
90
  {
81
91
  fontSize: useScaleSize(15),
82
92
  lineHeight: useScaleSize(22),
93
+ fontWeight: 'bold',
83
94
  },
84
95
  {
85
96
  fontFamily: exportFontFamily(
86
97
  'bold',
87
98
  'action_xs_bold',
88
- 'MoMoTrustDisplay',
99
+ headerFontFamily,
89
100
  ),
90
101
  color: props.tintColor,
91
102
  },
@@ -130,6 +141,7 @@ const TitleUser: React.FC<TitleUserProps> = ({
130
141
  isLoading,
131
142
  }) => {
132
143
  const { theme } = useContext(ApplicationContext);
144
+ const headerFontFamily = useHeaderFontFamily();
133
145
  const maxWidth = Dimensions.get('window').width - 172;
134
146
  const getShortName = (name: string) => {
135
147
  const words = name.split(' ');
@@ -378,7 +390,7 @@ const TitleUser: React.FC<TitleUserProps> = ({
378
390
  <View style={Styles.row}>
379
391
  <Text
380
392
  typography="action_xs_bold"
381
- fontFamily='MoMoTrustDisplay'
393
+ fontFamily={headerFontFamily}
382
394
  color={tintColor}
383
395
  numberOfLines={1}
384
396
  >
@@ -412,6 +424,7 @@ const TitleLocation: React.FC<TitleLocationProps> = ({
412
424
  onPress,
413
425
  isLoading,
414
426
  }) => {
427
+ const headerFontFamily = useHeaderFontFamily();
415
428
  const maxWidth = Dimensions.get('window').width - 172;
416
429
  const renderShimmer = () => {
417
430
  return (
@@ -448,9 +461,12 @@ const TitleLocation: React.FC<TitleLocationProps> = ({
448
461
  </Text>
449
462
  )}
450
463
  <View style={Styles.row}>
451
- <Text typography="action_xs_bold"
452
- fontFamily='MoMoTrustDisplay'
453
- color={tintColor} numberOfLines={1}>
464
+ <Text
465
+ typography="action_xs_bold"
466
+ fontFamily={headerFontFamily}
467
+ color={tintColor}
468
+ numberOfLines={1}
469
+ >
454
470
  {location}
455
471
  </Text>
456
472
  <Icon
@@ -477,6 +493,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
477
493
  onPress,
478
494
  isLoading,
479
495
  }) => {
496
+ const headerFontFamily = useHeaderFontFamily();
480
497
  const { width } = Dimensions.get('screen');
481
498
  const maxWidth = Dimensions.get('window').width - 172;
482
499
  const startWidth = width * 0.25;
@@ -512,8 +529,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
512
529
  style={{ maxWidth: startWidth }}
513
530
  color={tintColor}
514
531
  numberOfLines={1}
515
- fontFamily='MoMoTrustDisplay'
516
-
532
+ fontFamily={headerFontFamily}
517
533
  >
518
534
  {start}
519
535
  </Text>
@@ -529,8 +545,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
529
545
  typography="action_xs_bold"
530
546
  color={tintColor}
531
547
  numberOfLines={1}
532
- fontFamily='MoMoTrustDisplay'
533
-
548
+ fontFamily={headerFontFamily}
534
549
  >
535
550
  {end}
536
551
  </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 { getModalOptions, getStackOptions, useNativeCanGoBack } from './utils';
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: defaultRegularFontFamily,
193
+ fontFamily: navigationFontFamily,
187
194
  fontWeight: '400',
188
195
  },
189
196
  medium: {
190
- fontFamily: defaultRegularFontFamily,
197
+ fontFamily: navigationFontFamily,
191
198
  fontWeight: '400',
192
199
  },
193
200
  bold: {
194
- fontFamily: defaultRegularFontFamily,
201
+ fontFamily: navigationFontFamily,
195
202
  fontWeight: '400',
196
203
  },
197
204
  heavy: {
198
- fontFamily: defaultRegularFontFamily,
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: defaultRegularFontFamily,
121
+ fontFamily: navigationFontFamily,
120
122
  fontWeight: '400',
121
123
  },
122
124
  medium: {
123
- fontFamily: defaultRegularFontFamily,
125
+ fontFamily: navigationFontFamily,
124
126
  fontWeight: '400',
125
127
  },
126
128
  bold: {
127
- fontFamily: defaultRegularFontFamily,
129
+ fontFamily: navigationFontFamily,
128
130
  fontWeight: '400',
129
131
  },
130
132
  heavy: {
131
- fontFamily: defaultRegularFontFamily,
133
+ fontFamily: navigationFontFamily,
132
134
  fontWeight: '400',
133
135
  },
134
136
  },
@@ -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
@@ -2,4 +2,3 @@ export * from './colors+spacing+radius';
2
2
  export * from './theme';
3
3
  export * from './styles';
4
4
  export const GRIDVIEW = false;
5
- export * from './designSystemFont';
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
 
@@ -361,6 +361,7 @@ const InputMoney = forwardRef(
361
361
  height: '100%',
362
362
  fontSize: scaledFontSize,
363
363
  paddingVertical: Spacing.S,
364
+ fontWeight: 'bold',
364
365
  fontFamily: inputFontFamily,
365
366
  },
366
367
  {
@@ -134,6 +134,7 @@ const InputPhoneNumber = forwardRef(
134
134
  if (size === 'small') {
135
135
  inputTextStyles = {
136
136
  fontSize: size14,
137
+ fontWeight: '600',
137
138
  fontFamily: semiboldFontFamily,
138
139
  };
139
140
  dividerHeight = 24;
@@ -141,6 +142,7 @@ const InputPhoneNumber = forwardRef(
141
142
  } else {
142
143
  inputTextStyles = {
143
144
  fontSize: size18,
145
+ fontWeight: '700',
144
146
  fontFamily: boldFontFamily,
145
147
  };
146
148
  dividerHeight = 32;
@@ -213,6 +215,7 @@ const InputPhoneNumber = forwardRef(
213
215
  styles.input,
214
216
  {
215
217
  color: textColor,
218
+ fontFamily: exportFontFamily('regular'),
216
219
  },
217
220
  inputTextStyles,
218
221
  secure && haveValue && { fontSize: size === 'small' ? 18 : 22 },
@@ -190,5 +190,6 @@ const styles = StyleSheet.create({
190
190
  },
191
191
  label: {
192
192
  marginLeft: 8,
193
+ fontWeight: '700',
193
194
  },
194
195
  });
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 = useResolvedFontFamily(newFontFamily ?? theme.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 = `${resolvedDefaultFamily}-${
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
 
@@ -162,10 +153,6 @@ const TypoStyles = (typo: Typography, newFontFamily?: string) => {
162
153
  fontSize: useScaleSize(fontSize),
163
154
  lineHeight: useScaleSize(lineHeight),
164
155
  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
- fontWeight: undefined,
169
156
  };
170
157
  };
171
158
 
package/Title/styles.ts CHANGED
@@ -42,6 +42,7 @@ export default StyleSheet.create({
42
42
  },
43
43
  contentView: { marginRight: Spacing.S, flex: 1 },
44
44
  title: {
45
+ fontWeight: 'bold',
45
46
  color: Colors.black_17,
46
47
  },
47
48
  badge: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.167.1-beta.11",
3
+ "version": "0.167.1-beta.13",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
@@ -8,19 +8,19 @@
8
8
  "@momo-kits/foundation"
9
9
  ],
10
10
  "dependencies": {
11
- "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
12
11
  "@react-navigation/bottom-tabs": "7.4.2",
13
12
  "@react-navigation/core": "7.12.1",
14
13
  "@react-navigation/elements": "2.5.2",
15
14
  "@react-navigation/native": "7.1.14",
16
15
  "@react-navigation/routers": "7.4.1",
17
16
  "@react-navigation/stack": "7.4.2",
17
+ "@shopify/flash-list": "2.1.0",
18
+ "lottie-react-native": "7.2.4",
19
+ "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
18
20
  "react-native-gesture-handler": "2.27.1",
19
21
  "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
20
22
  "react-native-reanimated": "4.2.2",
21
- "react-native-safe-area-context": "5.5.2",
22
- "@shopify/flash-list": "2.1.0",
23
- "lottie-react-native": "7.2.4"
23
+ "react-native-safe-area-context": "5.5.2"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react-native": "*"
@@ -32,4 +32,4 @@
32
32
  "registry": "https://registry.npmjs.org/"
33
33
  },
34
34
  "license": "MoMo"
35
- }
35
+ }
@@ -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`;