@momo-kits/foundation 0.162.2-sp.2 → 0.162.2-test.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/BottomSheet.tsx +2 -2
- package/Application/BottomTab/BottomTabBar.tsx +15 -15
- package/Application/BottomTab/index.tsx +55 -31
- package/Application/Components/BackgroundImageView.tsx +6 -22
- package/Application/Components/HeaderAnimated.tsx +29 -29
- package/Application/Components/HeaderBackground.tsx +26 -20
- package/Application/Components/HeaderExtendHeader.tsx +94 -115
- package/Application/Components/HeaderTitle.tsx +10 -43
- package/Application/Components/SearchHeader.tsx +21 -13
- package/Application/NavigationContainer.tsx +27 -2
- package/Application/ScaleSizeProvider.tsx +5 -3
- package/Application/WidgetContainer.tsx +1 -1
- package/Application/types.ts +5 -5
- package/Application/utils.tsx +2 -42
- package/Badge/BadgeDotAnimation.tsx +71 -53
- package/Button/index.tsx +4 -1
- package/Context/index.ts +6 -3
- package/Input/InputOTP.tsx +23 -38
- package/Layout/FloatingButton.tsx +59 -64
- package/Layout/Screen.tsx +20 -66
- package/Loader/ProgressBar.tsx +18 -20
- package/Pagination/Dot.tsx +2 -2
- package/Pagination/PaginationScroll.tsx +27 -31
- package/Skeleton/index.tsx +24 -32
- package/Text/utils.ts +15 -5
- package/package.json +1 -1
package/Loader/ProgressBar.tsx
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import React, { FC, useContext, useEffect } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import Animated, {
|
|
4
|
-
useAnimatedStyle,
|
|
5
|
-
useSharedValue,
|
|
6
|
-
withTiming,
|
|
7
|
-
} from 'react-native-reanimated';
|
|
1
|
+
import React, { FC, useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, View } from 'react-native';
|
|
8
3
|
import styles from './styles';
|
|
9
4
|
import { ProgressBarProps } from './types';
|
|
10
5
|
import { ApplicationContext } from '../Context';
|
|
@@ -12,15 +7,20 @@ import { Radius } from '../Consts';
|
|
|
12
7
|
|
|
13
8
|
const ProgressBar: FC<ProgressBarProps> = ({ percent = 0, style }) => {
|
|
14
9
|
const { theme } = useContext(ApplicationContext);
|
|
15
|
-
const animation =
|
|
10
|
+
const animation = useRef(new Animated.Value(0)).current;
|
|
16
11
|
|
|
17
12
|
useEffect(() => {
|
|
18
|
-
|
|
13
|
+
Animated.timing(animation, {
|
|
14
|
+
toValue: percent,
|
|
15
|
+
duration: 200,
|
|
16
|
+
useNativeDriver: false,
|
|
17
|
+
}).start();
|
|
19
18
|
}, [percent, animation]);
|
|
20
19
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const width = animation.interpolate({
|
|
21
|
+
inputRange: [0, 100],
|
|
22
|
+
outputRange: ['0%', '100%'],
|
|
23
|
+
});
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<View
|
|
@@ -31,14 +31,12 @@ const ProgressBar: FC<ProgressBarProps> = ({ percent = 0, style }) => {
|
|
|
31
31
|
]}
|
|
32
32
|
>
|
|
33
33
|
<Animated.View
|
|
34
|
-
style={
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
animatedStyle,
|
|
41
|
-
]}
|
|
34
|
+
style={{
|
|
35
|
+
height: 4,
|
|
36
|
+
borderRadius: Radius.XXS,
|
|
37
|
+
width,
|
|
38
|
+
backgroundColor: theme.colors.primary,
|
|
39
|
+
}}
|
|
42
40
|
/>
|
|
43
41
|
</View>
|
|
44
42
|
);
|
package/Pagination/Dot.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, useContext } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
3
|
import styles from './styles';
|
|
4
4
|
import { DotProps } from './types';
|
|
5
5
|
import { ApplicationContext } from '../Context';
|
|
@@ -13,7 +13,7 @@ const Dot: FC<DotProps> = ({ active, style }) => {
|
|
|
13
13
|
{ backgroundColor: theme.colors.background.pressed },
|
|
14
14
|
];
|
|
15
15
|
|
|
16
|
-
return <View style={[style, dotStyle]} />;
|
|
16
|
+
return <Animated.View style={[style, dotStyle]} />;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export default Dot;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import React, { FC, useContext, useState } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import Animated, {
|
|
4
|
-
Extrapolation,
|
|
5
|
-
interpolate,
|
|
6
|
-
useAnimatedScrollHandler,
|
|
7
|
-
useAnimatedStyle,
|
|
8
|
-
useSharedValue,
|
|
9
|
-
} from 'react-native-reanimated';
|
|
1
|
+
import React, { FC, useContext, useRef, useState } from 'react';
|
|
2
|
+
import { Animated, View } from 'react-native';
|
|
10
3
|
import { ScrollIndicatorProps } from './types';
|
|
11
4
|
import styles from './styles';
|
|
12
5
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
@@ -20,37 +13,40 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
|
|
|
20
13
|
}) => {
|
|
21
14
|
const { theme } = useContext(ApplicationContext);
|
|
22
15
|
const context = useContext<any>(MiniAppContext);
|
|
23
|
-
const left =
|
|
16
|
+
const left = useRef(new Animated.Value(0)).current;
|
|
24
17
|
const [scrollViewWidth, setScrollViewWidth] = useState(0);
|
|
25
18
|
const [scrollContentWidth, setScrollContentWidth] = useState(0);
|
|
26
19
|
|
|
27
20
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
28
21
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return {};
|
|
22
|
+
const translateX = () => {
|
|
23
|
+
if (scrollViewWidth && scrollContentWidth) {
|
|
24
|
+
const value = left.interpolate({
|
|
25
|
+
inputRange: [0, scrollContentWidth - scrollViewWidth],
|
|
26
|
+
outputRange: [0, INDICATOR_CONTAINER_WIDTH - INDICATOR_WIDTH],
|
|
27
|
+
extrapolate: 'clamp',
|
|
28
|
+
});
|
|
29
|
+
return { transform: [{ translateX: value }] };
|
|
38
30
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
[0, scrollContentWidth - scrollViewWidth],
|
|
42
|
-
[0, INDICATOR_CONTAINER_WIDTH - INDICATOR_WIDTH],
|
|
43
|
-
Extrapolation.CLAMP,
|
|
44
|
-
);
|
|
45
|
-
return { transform: [{ translateX: value }] };
|
|
46
|
-
});
|
|
31
|
+
return {};
|
|
32
|
+
};
|
|
47
33
|
|
|
48
34
|
const renderScrollView = () => {
|
|
49
35
|
return (
|
|
50
36
|
<Animated.ScrollView
|
|
51
|
-
ref={scrollViewRef
|
|
52
|
-
onScroll={
|
|
53
|
-
|
|
37
|
+
ref={scrollViewRef}
|
|
38
|
+
onScroll={Animated.event(
|
|
39
|
+
[
|
|
40
|
+
{
|
|
41
|
+
nativeEvent: {
|
|
42
|
+
contentOffset: {
|
|
43
|
+
x: left,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
{ useNativeDriver: true },
|
|
49
|
+
)}
|
|
54
50
|
alwaysBounceHorizontal={false}
|
|
55
51
|
showsHorizontalScrollIndicator={false}
|
|
56
52
|
horizontal
|
|
@@ -80,7 +76,7 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
|
|
|
80
76
|
{
|
|
81
77
|
backgroundColor: theme.colors.primary,
|
|
82
78
|
},
|
|
83
|
-
|
|
79
|
+
translateX(),
|
|
84
80
|
]}
|
|
85
81
|
/>
|
|
86
82
|
</View>
|
package/Skeleton/index.tsx
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
Animated,
|
|
4
|
+
Easing,
|
|
3
5
|
LayoutAnimation,
|
|
4
6
|
Platform,
|
|
5
7
|
StyleSheet,
|
|
6
8
|
UIManager,
|
|
7
9
|
View,
|
|
8
10
|
} 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';
|
|
18
11
|
import LinearGradient from 'react-native-linear-gradient';
|
|
19
12
|
import { SkeletonTypes } from './types';
|
|
20
13
|
import { Colors, Styles } from '../Consts';
|
|
@@ -27,31 +20,32 @@ const Skeleton: React.FC<SkeletonTypes> = ({ style }) => {
|
|
|
27
20
|
const PRIMARY_COLOR = Colors.black_05;
|
|
28
21
|
const HIGHLIGHT_COLOR1 = Colors.black_05;
|
|
29
22
|
const HIGHLIGHT_COLOR2 = Colors.black_03;
|
|
30
|
-
const
|
|
23
|
+
const beginShimmerPosition = useRef(new Animated.Value(0)).current;
|
|
31
24
|
|
|
32
25
|
const shimmerColors = [HIGHLIGHT_COLOR1, HIGHLIGHT_COLOR2, HIGHLIGHT_COLOR1];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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,
|
|
38
34
|
duration: 1000,
|
|
39
35
|
easing: Easing.linear,
|
|
36
|
+
useNativeDriver: Platform.OS !== 'web',
|
|
40
37
|
}),
|
|
41
|
-
-1,
|
|
42
|
-
false,
|
|
43
38
|
);
|
|
39
|
+
}, [beginShimmerPosition]);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
animatedValue.start();
|
|
44
43
|
screen?.onLoading?.(true);
|
|
45
44
|
return () => {
|
|
46
|
-
|
|
45
|
+
animatedValue.stop();
|
|
47
46
|
screen?.onLoading?.(false);
|
|
48
47
|
};
|
|
49
|
-
}, [
|
|
50
|
-
|
|
51
|
-
const shimmerStyle = useAnimatedStyle(() => {
|
|
52
|
-
const translateX = interpolate(progress.value, [0, 1], [-width, width]);
|
|
53
|
-
return { transform: [{ translateX }] };
|
|
54
|
-
});
|
|
48
|
+
}, [animatedValue, screen]);
|
|
55
49
|
|
|
56
50
|
const onLayout = (newWidth: number) => {
|
|
57
51
|
if (newWidth !== width) {
|
|
@@ -66,13 +60,11 @@ const Skeleton: React.FC<SkeletonTypes> = ({ style }) => {
|
|
|
66
60
|
style={[Styles.flex, { backgroundColor: PRIMARY_COLOR }]}
|
|
67
61
|
>
|
|
68
62
|
<Animated.View
|
|
69
|
-
style={
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
shimmerStyle,
|
|
75
|
-
]}
|
|
63
|
+
style={{
|
|
64
|
+
transform: [{ translateX: linearTranslate }],
|
|
65
|
+
width: '60%',
|
|
66
|
+
height: '100%',
|
|
67
|
+
}}
|
|
76
68
|
>
|
|
77
69
|
<LinearGradient
|
|
78
70
|
style={[StyleSheet.absoluteFill]}
|
package/Text/utils.ts
CHANGED
|
@@ -7,14 +7,24 @@ const DEFAULT_SCREEN_SIZE = 375;
|
|
|
7
7
|
const MAX_FONT_SCALE = 1.5;
|
|
8
8
|
const MAX_DEVICE_SCALE = 5;
|
|
9
9
|
|
|
10
|
-
const useScaleSize = (size: number,
|
|
11
|
-
const {
|
|
10
|
+
const useScaleSize = (size: number, userScaleRate?: number) => {
|
|
11
|
+
const { useOSFontScale = true, userScaleRate: ctxRate } =
|
|
12
|
+
useContext(ScaleSizeContext);
|
|
12
13
|
const fontScale = PixelRatio.getFontScale();
|
|
13
14
|
const { width } = useWindowDimensions();
|
|
14
15
|
const deviceScale = width / DEFAULT_SCREEN_SIZE;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
// rate precedence: per-call param override > host config (ctxRate) > 1 (no scaling)
|
|
18
|
+
const customRate = userScaleRate ?? ctxRate ?? 1;
|
|
17
19
|
|
|
20
|
+
// useOSFontScale off -> the user has full control via customRate; skip device-width scaling
|
|
21
|
+
// entirely and apply only the custom rate (capped at MAX_FONT_SCALE).
|
|
22
|
+
if (!useOSFontScale) {
|
|
23
|
+
// custom rate is uncapped (full user control); only the OS-follow path below caps at MAX_FONT_SCALE.
|
|
24
|
+
return customRate > 1 ? customRate * size : size;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// useOSFontScale on -> device-width scale + OS font scale, take the larger.
|
|
18
28
|
let fontSizeDeviceScale = size;
|
|
19
29
|
let fontSizeOSScale = size;
|
|
20
30
|
|
|
@@ -27,8 +37,8 @@ const useScaleSize = (size: number, scaleRate?: number) => {
|
|
|
27
37
|
|
|
28
38
|
if (fontScale > 1) {
|
|
29
39
|
fontSizeOSScale = Math.min(
|
|
30
|
-
|
|
31
|
-
fontSizeOSScale *
|
|
40
|
+
fontScale * fontSizeOSScale,
|
|
41
|
+
fontSizeOSScale * MAX_FONT_SCALE,
|
|
32
42
|
);
|
|
33
43
|
}
|
|
34
44
|
|