@momo-kits/foundation 0.167.1-beta.5 → 0.167.1-duo-test.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.
Files changed (47) hide show
  1. package/Application/BottomSheet.tsx +115 -14
  2. package/Application/BottomTab/BottomTabBar.tsx +6 -3
  3. package/Application/BottomTab/DuoBarCompression.tsx +135 -0
  4. package/Application/BottomTab/DuoTabBar.tsx +462 -0
  5. package/Application/BottomTab/index.tsx +150 -134
  6. package/Application/Components/DuoGlassBackground.tsx +179 -0
  7. package/Application/Components/DuoQuickReturnHeader.tsx +42 -0
  8. package/Application/Components/HeaderExtendHeader.tsx +75 -28
  9. package/Application/Components/HeaderLeft.tsx +38 -0
  10. package/Application/Components/HeaderRight.tsx +142 -9
  11. package/Application/Components/HeaderTitle.tsx +67 -17
  12. package/Application/Components/OptionalGlassView.ts +11 -0
  13. package/Application/Components/OptionalScrollObserver.ts +12 -0
  14. package/Application/Components/SearchHeader.tsx +22 -15
  15. package/Application/Components/SideBarButton.tsx +139 -0
  16. package/Application/ModalScreen.tsx +16 -2
  17. package/Application/NavigationContainer.tsx +36 -45
  18. package/Application/Navigator.ts +1 -3
  19. package/Application/StackScreen.tsx +63 -9
  20. package/Application/WidgetContainer.tsx +9 -7
  21. package/Application/device.ts +29 -0
  22. package/Application/types.ts +27 -1
  23. package/Application/utils.tsx +255 -7
  24. package/Consts/index.ts +0 -1
  25. package/Consts/theme.ts +5 -6
  26. package/Input/Input.tsx +3 -4
  27. package/Input/InputMoney.tsx +31 -51
  28. package/Input/InputPhoneNumber.tsx +3 -4
  29. package/Input/InputSearch.tsx +3 -4
  30. package/Input/InputTextArea.tsx +3 -4
  31. package/Layout/Card.tsx +8 -26
  32. package/Layout/FloatingButton.tsx +3 -3
  33. package/Layout/Item.tsx +1 -10
  34. package/Layout/ReservedRegions.tsx +47 -0
  35. package/Layout/Screen.tsx +199 -52
  36. package/Layout/Section.tsx +5 -18
  37. package/Layout/index.ts +4 -4
  38. package/Layout/styles.ts +5 -0
  39. package/Layout/utils.ts +465 -5
  40. package/Popup/PopupNotify.tsx +33 -22
  41. package/Popup/PopupPromotion.tsx +20 -8
  42. package/Popup/utils.ts +32 -0
  43. package/Text/index.tsx +2 -11
  44. package/Text/utils.ts +1 -2
  45. package/package.json +3 -2
  46. package/Consts/designSystemFont.ts +0 -38
  47. package/Layout/GridSystem.tsx +0 -137
package/Popup/utils.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { Dimensions, useWindowDimensions } from 'react-native';
2
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
3
+ import { Spacing } from '../Consts';
4
+ import { getDuoTopInset, isIPhoneDuo } from '../Application/device';
5
+
6
+ // width of a system alert on the iPhone Duo inner display, in both orientations
7
+ const DUO_POPUP_MAX_WIDTH = 440;
8
+
9
+ const usePopupWidth = () => {
10
+ const windowSize = useWindowDimensions();
11
+ if (!isIPhoneDuo()) {
12
+ return Dimensions.get('window').width - Spacing.XL * 2;
13
+ }
14
+ return Math.min(windowSize.width - Spacing.XL * 2, DUO_POPUP_MAX_WIDTH);
15
+ };
16
+
17
+ // room left for a popup on iPhone Duo, where landscape is too short for it
18
+ const usePopupMaxHeight = () => {
19
+ const insets = useSafeAreaInsets();
20
+ const { width, height } = useWindowDimensions();
21
+ if (!isIPhoneDuo()) {
22
+ return undefined;
23
+ }
24
+ return (
25
+ height -
26
+ getDuoTopInset(insets, width, height) -
27
+ insets.bottom -
28
+ Spacing.XL * 2
29
+ );
30
+ };
31
+
32
+ export { usePopupWidth, usePopupMaxHeight };
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
 
package/Text/utils.ts CHANGED
@@ -2,7 +2,6 @@ import { Dimensions, PixelRatio, useWindowDimensions } from 'react-native';
2
2
  import { useContext } from 'react';
3
3
  import { MiniAppContext } from '../Context';
4
4
 
5
- const deviceWidth = Dimensions.get('window').width;
6
5
  const DEFAULT_SCREEN_SIZE = 375;
7
6
  const MAX_FONT_SCALE = 1.5;
8
7
  const MAX_DEVICE_SCALE = 5;
@@ -40,7 +39,7 @@ const useScaleSize = (size: number, scaleRate?: number) => {
40
39
 
41
40
  const scaleSize = (size: number) => {
42
41
  const fontScale = PixelRatio.getFontScale();
43
- const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
42
+ const deviceScale = Dimensions.get('window').width / DEFAULT_SCREEN_SIZE;
44
43
 
45
44
  let fontSizeDeviceScale = size;
46
45
  let fontSizeOSScale = size;
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-duo-test.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
@@ -23,7 +23,8 @@
23
23
  "lottie-react-native": "7.2.4"
24
24
  },
25
25
  "peerDependencies": {
26
- "react-native": "*"
26
+ "react-native": "*",
27
+ "react-native-worklets": ">=0.5.0"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@types/color": "3.0.6"
@@ -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`;
@@ -1,137 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
3
- import { Dimensions, StyleSheet, View } from 'react-native';
4
- import { ApplicationContext } from '../Context';
5
- import { Colors, Spacing } from '../Consts';
6
- import { GridContextProps } from './types';
7
- import { useGridSystem } from './utils';
8
-
9
- const GridSystem: React.FC<any> = ({
10
- width = Dimensions.get('window').width,
11
- useMargin = true,
12
- gutterSize = Spacing.M,
13
- screenGrid = true,
14
- gridColor = Colors.blue_07,
15
- }) => {
16
- const { theme } = useContext(ApplicationContext);
17
- const { numberOfColumns } = useGridSystem();
18
-
19
- const margin = useMargin ? Spacing.M : 0;
20
- const widthSection = width - margin * 2;
21
- const totalGutterSize = gutterSize * (numberOfColumns - 1);
22
- const sizePerSpan = (widthSection - totalGutterSize) / numberOfColumns;
23
-
24
- const grid: GridContextProps = {
25
- numberOfColumns,
26
- gutterSize,
27
- sizePerSpan,
28
- getSizeSpan: span => {
29
- return span * sizePerSpan + (span - 1) * gutterSize;
30
- },
31
- };
32
- const insets = useSafeAreaInsets();
33
-
34
- const list: number[] = [];
35
- for (let i = 1; i <= grid.numberOfColumns; i++) {
36
- list.push(i);
37
- }
38
-
39
- return (
40
- <>
41
- <View
42
- pointerEvents="none"
43
- style={[
44
- styles.gridContainer,
45
- screenGrid && insets,
46
- {
47
- borderColor: theme.colors.error.primary,
48
- marginHorizontal: margin,
49
- top: Spacing.M,
50
- bottom: Spacing.M,
51
- },
52
- ]}
53
- >
54
- {list.map((_, index) => {
55
- return (
56
- <View style={{ flexDirection: 'row' }} key={index.toString()}>
57
- {index !== 0 && <View style={{ width: grid.gutterSize }} />}
58
- <View
59
- key={`Grid${index.toString()}`}
60
- pointerEvents="none"
61
- style={[
62
- styles.gridColumn,
63
- {
64
- width: grid.sizePerSpan,
65
- backgroundColor: gridColor,
66
- },
67
- ]}
68
- />
69
- </View>
70
- );
71
- })}
72
- </View>
73
- {screenGrid && (
74
- <>
75
- <View pointerEvents="none" style={styles.dangerLeftContainer} />
76
- <View pointerEvents="none" style={styles.dangerRightContainer} />
77
- <View
78
- pointerEvents="none"
79
- style={[styles.dangerTopContainer, { height: Spacing.M }]}
80
- />
81
- <View
82
- pointerEvents="none"
83
- style={[styles.dangerBottomContainer, { height: insets.bottom }]}
84
- />
85
- </>
86
- )}
87
- </>
88
- );
89
- };
90
-
91
- const styles = StyleSheet.create({
92
- gridContainer: {
93
- position: 'absolute',
94
- top: 0,
95
- bottom: 0,
96
- left: 0,
97
- right: 0,
98
- flexDirection: 'row',
99
- borderWidth: 1,
100
- },
101
- gridColumn: {
102
- height: '100%',
103
- opacity: 0.2,
104
- },
105
- dangerTopContainer: {
106
- opacity: 0.2,
107
- backgroundColor: Colors.red_03,
108
- width: '100%',
109
- top: 0,
110
- position: 'absolute',
111
- },
112
- dangerBottomContainer: {
113
- opacity: 0.2,
114
- backgroundColor: Colors.red_03,
115
- width: '100%',
116
- bottom: 0,
117
- position: 'absolute',
118
- },
119
- dangerLeftContainer: {
120
- opacity: 0.2,
121
- backgroundColor: Colors.red_03,
122
- width: Spacing.M,
123
- height: '100%',
124
- left: 0,
125
- position: 'absolute',
126
- },
127
- dangerRightContainer: {
128
- opacity: 0.2,
129
- backgroundColor: Colors.red_03,
130
- width: Spacing.M,
131
- height: '100%',
132
- right: 0,
133
- position: 'absolute',
134
- },
135
- });
136
-
137
- export default GridSystem;