@momo-kits/foundation 0.161.1-beta.1 → 0.161.2-beta.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 (52) hide show
  1. package/Application/BottomSheet.tsx +3 -3
  2. package/Application/BottomTab/BottomTabBar.tsx +17 -17
  3. package/Application/BottomTab/CustomBottomTabItem.tsx +1 -1
  4. package/Application/BottomTab/index.tsx +31 -55
  5. package/Application/Components/BackgroundImageView.tsx +22 -6
  6. package/Application/Components/HeaderAnimated.tsx +32 -29
  7. package/Application/Components/HeaderBackground.tsx +21 -27
  8. package/Application/Components/HeaderExtendHeader.tsx +114 -94
  9. package/Application/Components/HeaderTitle.tsx +40 -11
  10. package/Application/Components/SearchHeader.tsx +17 -22
  11. package/Application/NavigationContainer.tsx +21 -21
  12. package/Application/ScaleSizeProvider.tsx +16 -0
  13. package/Application/WidgetContainer.tsx +7 -15
  14. package/Application/index.ts +2 -0
  15. package/Application/types.ts +10 -4
  16. package/Application/utils.tsx +4 -3
  17. package/Badge/Badge.tsx +3 -9
  18. package/Badge/BadgeDot.tsx +1 -1
  19. package/Badge/BadgeDotAnimation.tsx +53 -71
  20. package/Badge/BadgeRibbon.tsx +1 -1
  21. package/Button/index.tsx +3 -6
  22. package/CheckBox/index.tsx +1 -1
  23. package/Context/index.ts +4 -0
  24. package/Icon/index.tsx +1 -1
  25. package/IconButton/index.tsx +1 -1
  26. package/Image/index.tsx +13 -3
  27. package/Input/Input.tsx +1 -1
  28. package/Input/InputDropDown.tsx +1 -1
  29. package/Input/InputMoney.tsx +1 -1
  30. package/Input/InputOTP.tsx +39 -24
  31. package/Input/InputPhoneNumber.tsx +1 -1
  32. package/Input/InputSearch.tsx +1 -1
  33. package/Input/InputTextArea.tsx +10 -4
  34. package/Layout/FloatingButton.tsx +59 -59
  35. package/Layout/Item.tsx +1 -1
  36. package/Layout/Screen.tsx +61 -57
  37. package/Loader/ProgressBar.tsx +20 -18
  38. package/Pagination/Dot.tsx +2 -2
  39. package/Pagination/PaginationDot.tsx +1 -1
  40. package/Pagination/PaginationNumber.tsx +1 -1
  41. package/Pagination/PaginationScroll.tsx +32 -28
  42. package/Pagination/PaginationWhiteDot.tsx +1 -1
  43. package/Popup/PopupNotify.tsx +1 -1
  44. package/Popup/PopupPromotion.tsx +1 -1
  45. package/Radio/index.tsx +1 -1
  46. package/Skeleton/index.tsx +32 -24
  47. package/Switch/index.tsx +1 -1
  48. package/Tag/index.tsx +1 -1
  49. package/Text/index.tsx +1 -1
  50. package/Text/utils.ts +41 -18
  51. package/Title/index.tsx +1 -1
  52. package/package.json +34 -34
@@ -1,13 +1,20 @@
1
- import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
1
+ import React, { useContext, useEffect, useState } from 'react';
2
2
  import {
3
- Animated,
4
- Easing,
5
3
  LayoutAnimation,
6
4
  Platform,
7
5
  StyleSheet,
8
6
  UIManager,
9
7
  View,
10
8
  } from 'react-native';
9
+ import Animated, {
10
+ cancelAnimation,
11
+ Easing,
12
+ interpolate,
13
+ useAnimatedStyle,
14
+ useSharedValue,
15
+ withRepeat,
16
+ withTiming,
17
+ } from 'react-native-reanimated';
11
18
  import LinearGradient from 'react-native-linear-gradient';
12
19
  import { SkeletonTypes } from './types';
13
20
  import { Colors, Styles } from '../Consts';
@@ -20,32 +27,31 @@ const Skeleton: React.FC<SkeletonTypes> = ({ style }) => {
20
27
  const PRIMARY_COLOR = Colors.black_05;
21
28
  const HIGHLIGHT_COLOR1 = Colors.black_05;
22
29
  const HIGHLIGHT_COLOR2 = Colors.black_03;
23
- const beginShimmerPosition = useRef(new Animated.Value(0)).current;
30
+ const progress = useSharedValue(0);
24
31
 
25
32
  const shimmerColors = [HIGHLIGHT_COLOR1, HIGHLIGHT_COLOR2, HIGHLIGHT_COLOR1];
26
- const linearTranslate = beginShimmerPosition.interpolate({
27
- inputRange: [0, 1],
28
- outputRange: [-width, width],
29
- });
30
- const animatedValue = useMemo(() => {
31
- return Animated.loop(
32
- Animated.timing(beginShimmerPosition, {
33
- toValue: 1,
33
+
34
+ useEffect(() => {
35
+ progress.value = 0;
36
+ progress.value = withRepeat(
37
+ withTiming(1, {
34
38
  duration: 1000,
35
39
  easing: Easing.linear,
36
- useNativeDriver: Platform.OS !== 'web',
37
40
  }),
41
+ -1,
42
+ false,
38
43
  );
39
- }, [beginShimmerPosition]);
40
-
41
- useEffect(() => {
42
- animatedValue.start();
43
44
  screen?.onLoading?.(true);
44
45
  return () => {
45
- animatedValue.stop();
46
+ cancelAnimation(progress);
46
47
  screen?.onLoading?.(false);
47
48
  };
48
- }, [animatedValue, screen]);
49
+ }, [progress, screen]);
50
+
51
+ const shimmerStyle = useAnimatedStyle(() => {
52
+ const translateX = interpolate(progress.value, [0, 1], [-width, width]);
53
+ return { transform: [{ translateX }] };
54
+ });
49
55
 
50
56
  const onLayout = (newWidth: number) => {
51
57
  if (newWidth !== width) {
@@ -60,11 +66,13 @@ const Skeleton: React.FC<SkeletonTypes> = ({ style }) => {
60
66
  style={[Styles.flex, { backgroundColor: PRIMARY_COLOR }]}
61
67
  >
62
68
  <Animated.View
63
- style={{
64
- transform: [{ translateX: linearTranslate }],
65
- width: '60%',
66
- height: '100%',
67
- }}
69
+ style={[
70
+ {
71
+ width: '60%',
72
+ height: '100%',
73
+ },
74
+ shimmerStyle,
75
+ ]}
68
76
  >
69
77
  <LinearGradient
70
78
  style={[StyleSheet.absoluteFill]}
package/Switch/index.tsx CHANGED
@@ -22,7 +22,7 @@ const Switch: FC<SwitchProps> = ({
22
22
 
23
23
  const { componentId } = useComponentId(componentName, accessibilityLabel);
24
24
 
25
- const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
25
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
26
26
 
27
27
  let backgroundColor = value ? Colors.green_03 : Colors.black_07;
28
28
  if (disabled) {
package/Tag/index.tsx CHANGED
@@ -38,7 +38,7 @@ const Tag: FC<TagProps> = ({
38
38
  const scaledHeight24 = useScaleSize(24);
39
39
  const scaledHeight18 = useScaleSize(18);
40
40
 
41
- const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
41
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
42
42
 
43
43
  const styles = StyleSheet.create({
44
44
  container: {
package/Text/index.tsx CHANGED
@@ -158,7 +158,7 @@ const Text: React.FC<TextProps> = ({
158
158
  );
159
159
  }
160
160
 
161
- const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
161
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
162
162
 
163
163
  if (skeleton.loading) {
164
164
  return (
package/Text/utils.ts CHANGED
@@ -1,39 +1,62 @@
1
1
  import { Dimensions, PixelRatio, useWindowDimensions } from 'react-native';
2
2
  import { useContext } from 'react';
3
- import { MiniAppContext } from '../Context';
3
+ import { ScaleSizeContext } from '../Context';
4
4
 
5
5
  const deviceWidth = Dimensions.get('window').width;
6
6
  const DEFAULT_SCREEN_SIZE = 375;
7
- const MAX_FONT_SCALE = 1.2;
7
+ const MAX_FONT_SCALE = 1.5;
8
+ const MAX_DEVICE_SCALE = 5;
8
9
 
9
- const useScaleSize = (size: number) => {
10
+ const useScaleSize = (size: number, scaleRate?: number) => {
11
+ const { scaleSizeMaxRate = MAX_FONT_SCALE } = useContext(ScaleSizeContext);
12
+ const fontScale = PixelRatio.getFontScale();
10
13
  const { width } = useWindowDimensions();
11
- const context = useContext<any>(MiniAppContext);
12
- const allowFontScale = context?.designSystemConfig?.allowFontScale ?? true;
14
+ const deviceScale = width / DEFAULT_SCREEN_SIZE;
15
+
16
+ const maxScaleRate = scaleRate ?? scaleSizeMaxRate;
13
17
 
14
- if (allowFontScale) {
15
- const deviceScale = width / DEFAULT_SCREEN_SIZE;
16
- const fontScale = PixelRatio.getFontScale();
18
+ let fontSizeDeviceScale = size;
19
+ let fontSizeOSScale = size;
17
20
 
18
- const maxSize = size * MAX_FONT_SCALE;
19
- const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
20
- const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
21
+ if (deviceScale > 1) {
22
+ fontSizeDeviceScale = Math.min(
23
+ fontSizeDeviceScale * deviceScale,
24
+ fontSizeDeviceScale + MAX_DEVICE_SCALE,
25
+ );
26
+ }
21
27
 
22
- return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
28
+ if (fontScale > 1) {
29
+ fontSizeOSScale = Math.min(
30
+ fontSizeOSScale * fontScale,
31
+ fontSizeOSScale * maxScaleRate,
32
+ );
23
33
  }
24
34
 
25
- return size;
35
+ return Math.max(fontSizeDeviceScale, fontSizeOSScale);
26
36
  };
27
37
 
28
38
  const scaleSize = (size: number) => {
29
- const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
30
39
  const fontScale = PixelRatio.getFontScale();
40
+ const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
31
41
 
32
- const maxSize = size * MAX_FONT_SCALE;
33
- const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
34
- const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
42
+ let fontSizeDeviceScale = size;
43
+ let fontSizeOSScale = size;
44
+
45
+ if (deviceScale > 1) {
46
+ fontSizeDeviceScale = Math.min(
47
+ fontSizeDeviceScale * deviceScale,
48
+ fontSizeDeviceScale + MAX_DEVICE_SCALE,
49
+ );
50
+ }
51
+
52
+ if (fontScale > 1) {
53
+ fontSizeOSScale = Math.min(
54
+ fontSizeOSScale * fontScale,
55
+ fontSizeOSScale * MAX_FONT_SCALE,
56
+ );
57
+ }
35
58
 
36
- return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
59
+ return Math.max(fontSizeDeviceScale, fontSizeOSScale);
37
60
  };
38
61
 
39
62
  export { scaleSize, useScaleSize };
package/Title/index.tsx CHANGED
@@ -39,7 +39,7 @@ const Title: FC<TitleProps> = ({
39
39
  const [badgeWidth, setBadgeWidth] = useState(0);
40
40
  const [contentWidth, setContentWidth] = useState(0);
41
41
 
42
- const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
42
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
43
43
 
44
44
  const size18 = useScaleSize(18);
45
45
  const size22 = useScaleSize(22);
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
- "name": "@momo-kits/foundation",
3
- "version": "0.161.1-beta.1",
4
- "description": "React Native Component Kits",
5
- "main": "index.ts",
6
- "scripts": {},
7
- "keywords": [
8
- "@momo-kits/foundation"
9
- ],
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
- "@react-navigation/bottom-tabs": "7.4.2",
13
- "@react-navigation/core": "7.12.1",
14
- "@react-navigation/elements": "2.5.2",
15
- "@react-navigation/native": "7.1.14",
16
- "@react-navigation/routers": "7.4.1",
17
- "@react-navigation/stack": "7.4.2",
18
- "react-native-gesture-handler": "2.27.1",
19
- "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
20
- "react-native-reanimated": "4.1.0",
21
- "react-native-safe-area-context": "5.5.2",
22
- "@shopify/flash-list": "2.1.0",
23
- "lottie-react-native": "7.2.4"
24
- },
25
- "peerDependencies": {
26
- "react-native": "*"
27
- },
28
- "devDependencies": {
29
- "@types/color": "3.0.6"
30
- },
31
- "publishConfig": {
32
- "registry": "https://registry.npmjs.org/"
33
- },
34
- "license": "MoMo"
35
- }
2
+ "name": "@momo-kits/foundation",
3
+ "version": "0.161.2-beta.1",
4
+ "description": "React Native Component Kits",
5
+ "main": "index.ts",
6
+ "scripts": {},
7
+ "keywords": [
8
+ "@momo-kits/foundation"
9
+ ],
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
+ "@react-navigation/bottom-tabs": "7.4.2",
13
+ "@react-navigation/core": "7.12.1",
14
+ "@react-navigation/elements": "2.5.2",
15
+ "@react-navigation/native": "7.1.14",
16
+ "@react-navigation/routers": "7.4.1",
17
+ "@react-navigation/stack": "7.4.2",
18
+ "react-native-gesture-handler": "2.27.1",
19
+ "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
20
+ "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"
24
+ },
25
+ "peerDependencies": {
26
+ "react-native": "*"
27
+ },
28
+ "devDependencies": {
29
+ "@types/color": "3.0.6"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/"
33
+ },
34
+ "license": "MoMo"
35
+ }