@momo-kits/foundation 0.163.1-beta.1 → 0.163.1-beta.2
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/NavigationContainer.tsx +12 -16
- package/Application/ScaleSizeProvider.tsx +0 -1
- package/Application/WidgetContainer.tsx +6 -9
- package/Context/index.ts +0 -1
- package/IconButton/index.tsx +6 -28
- package/IconButton/styles.ts +7 -15
- package/Layout/Screen.tsx +1 -19
- package/Text/utils.ts +3 -6
- package/package.json +3 -3
|
@@ -16,6 +16,7 @@ import { DeviceEventEmitter } from 'react-native';
|
|
|
16
16
|
import StackScreen from './StackScreen';
|
|
17
17
|
import ModalScreen from './ModalScreen';
|
|
18
18
|
import Navigator from './Navigator';
|
|
19
|
+
import ScaleSizeProvider from './ScaleSizeProvider';
|
|
19
20
|
import { getModalOptions, getStackOptions } from './utils';
|
|
20
21
|
import { NavigationContainerProps } from './types';
|
|
21
22
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
@@ -45,13 +46,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
45
46
|
const context = useContext<any>(MiniAppContext);
|
|
46
47
|
const [currentContext, setCurrentContext] = useState<any>({});
|
|
47
48
|
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
const sub = maxApi?.observer?.('font_scale_config', (data: any) => {
|
|
50
|
-
setCurrentContext((prev: any) => ({ ...prev, fontScale: data }));
|
|
51
|
-
});
|
|
52
|
-
return () => sub?.remove?.();
|
|
53
|
-
}, [maxApi]);
|
|
54
|
-
|
|
55
49
|
const mergedContext = {
|
|
56
50
|
...context,
|
|
57
51
|
...currentContext,
|
|
@@ -64,15 +58,17 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
64
58
|
return (
|
|
65
59
|
<SafeAreaProvider>
|
|
66
60
|
<MiniAppContext.Provider value={mergedContext}>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
<ScaleSizeProvider scaleSizeMaxRate={mergedContext?.scaleSizeMaxRate}>
|
|
62
|
+
<Navigation
|
|
63
|
+
screen={screen}
|
|
64
|
+
theme={theme}
|
|
65
|
+
options={options}
|
|
66
|
+
maxApi={maxApi}
|
|
67
|
+
setCurrentContext={setCurrentContext}
|
|
68
|
+
initialParams={initialParams}
|
|
69
|
+
localize={localize}
|
|
70
|
+
/>
|
|
71
|
+
</ScaleSizeProvider>
|
|
76
72
|
</MiniAppContext.Provider>
|
|
77
73
|
</SafeAreaProvider>
|
|
78
74
|
);
|
|
@@ -2,7 +2,6 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { ScaleSizeContext } from '../Context';
|
|
3
3
|
import { ScaleSizeProviderProps } from './types';
|
|
4
4
|
|
|
5
|
-
/** @deprecated Max font scale is fixed at 1.5; this provider no longer affects scaling. */
|
|
6
5
|
const ScaleSizeProvider: FC<ScaleSizeProviderProps> = ({
|
|
7
6
|
scaleSizeMaxRate,
|
|
8
7
|
children,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext,
|
|
1
|
+
import React, { useContext, useRef, useState } from 'react';
|
|
2
2
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
3
3
|
import Navigator from './Navigator';
|
|
4
4
|
import ScaleSizeProvider from './ScaleSizeProvider';
|
|
@@ -44,13 +44,6 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
44
44
|
const navigator = useRef(new Navigator(navigationRef, isReady, true));
|
|
45
45
|
const [currentContext, setCurrentContext] = useState({});
|
|
46
46
|
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
const sub = maxApi?.observer?.('font_scale_config', (data: any) => {
|
|
49
|
-
setCurrentContext((prev: any) => ({ ...prev, fontScale: data }));
|
|
50
|
-
});
|
|
51
|
-
return () => sub?.remove?.();
|
|
52
|
-
}, [maxApi]);
|
|
53
|
-
|
|
54
47
|
let headerBackground = context?.designConfig?.headerBar;
|
|
55
48
|
let headerGradient = theme.colors?.gradient;
|
|
56
49
|
|
|
@@ -81,9 +74,12 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
81
74
|
};
|
|
82
75
|
|
|
83
76
|
return (
|
|
84
|
-
<View style={{ height: height ?? '100%', minHeight:
|
|
77
|
+
<View style={{ height: height ?? '100%', minHeight:1 }}>
|
|
85
78
|
<SafeAreaProvider>
|
|
86
79
|
<MiniAppContext.Provider value={mergedContext}>
|
|
80
|
+
<ScaleSizeProvider
|
|
81
|
+
scaleSizeMaxRate={mergedContext?.scaleSizeMaxRate}
|
|
82
|
+
>
|
|
87
83
|
<ApplicationContext.Provider
|
|
88
84
|
value={{
|
|
89
85
|
navigator: navigator.current,
|
|
@@ -161,6 +157,7 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
161
157
|
</ReactNavigationContainer>
|
|
162
158
|
</NavigationIndependentTree>
|
|
163
159
|
</ApplicationContext.Provider>
|
|
160
|
+
</ScaleSizeProvider>
|
|
164
161
|
</MiniAppContext.Provider>
|
|
165
162
|
</SafeAreaProvider>
|
|
166
163
|
</View>
|
package/Context/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
|
|
|
9
9
|
const ScreenContext = (Platform as any).ScreenContext ?? Context;
|
|
10
10
|
const ComponentContext = (Platform as any).ComponentContext ?? Context;
|
|
11
11
|
const SkeletonContext = createContext({ loading: false });
|
|
12
|
-
/** @deprecated Max font scale is fixed at 1.5; this context is no longer read. */
|
|
13
12
|
const ScaleSizeContext = createContext<{ scaleSizeMaxRate?: number }>({
|
|
14
13
|
scaleSizeMaxRate: undefined,
|
|
15
14
|
});
|
package/IconButton/index.tsx
CHANGED
|
@@ -28,12 +28,7 @@ export interface IconButtonProps extends TouchableOpacityProps {
|
|
|
28
28
|
/**
|
|
29
29
|
* Optional. Defines the size of the IconButton.
|
|
30
30
|
*/
|
|
31
|
-
size?: 'large' | '
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Optional. Defines the shape of the IconButton.
|
|
35
|
-
*/
|
|
36
|
-
shape?: 'circle' | 'square';
|
|
31
|
+
size?: 'large' | 'small';
|
|
37
32
|
|
|
38
33
|
/**
|
|
39
34
|
* Optional. Params auto tracking component.
|
|
@@ -45,7 +40,6 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
45
40
|
type = 'primary',
|
|
46
41
|
icon,
|
|
47
42
|
size,
|
|
48
|
-
shape = 'circle',
|
|
49
43
|
params,
|
|
50
44
|
...rest
|
|
51
45
|
}) => {
|
|
@@ -58,21 +52,10 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
58
52
|
* get size icon button
|
|
59
53
|
*/
|
|
60
54
|
const getSizeStyle = () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return styles.small;
|
|
64
|
-
case 'medium':
|
|
65
|
-
return styles.medium;
|
|
66
|
-
default:
|
|
67
|
-
return styles.large;
|
|
55
|
+
if (size === 'small') {
|
|
56
|
+
return styles.small;
|
|
68
57
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* get shape icon button
|
|
73
|
-
*/
|
|
74
|
-
const getShapeStyle = () => {
|
|
75
|
-
return shape === 'square' ? styles.square : styles.circle;
|
|
58
|
+
return styles.large;
|
|
76
59
|
};
|
|
77
60
|
|
|
78
61
|
/**
|
|
@@ -134,13 +117,8 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
134
117
|
};
|
|
135
118
|
|
|
136
119
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
137
|
-
const buttonStyle = StyleSheet.flatten([
|
|
138
|
-
|
|
139
|
-
styles.base,
|
|
140
|
-
getSizeStyle(),
|
|
141
|
-
getShapeStyle(),
|
|
142
|
-
]);
|
|
143
|
-
const iconSize = size === 'small' || size === 'medium' ? 16 : 24;
|
|
120
|
+
const buttonStyle = StyleSheet.flatten([getTypeStyle(), getSizeStyle()]);
|
|
121
|
+
const iconSize = size === 'small' ? 16 : 24;
|
|
144
122
|
|
|
145
123
|
return (
|
|
146
124
|
<ComponentContext.Provider
|
package/IconButton/styles.ts
CHANGED
|
@@ -2,27 +2,19 @@ import { StyleSheet } from 'react-native';
|
|
|
2
2
|
import { Radius, Colors } from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
|
-
base: {
|
|
6
|
-
justifyContent: 'center',
|
|
7
|
-
alignItems: 'center',
|
|
8
|
-
},
|
|
9
5
|
large: {
|
|
10
6
|
width: 48,
|
|
11
7
|
height: 48,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
height: 36,
|
|
8
|
+
borderRadius: Radius.XL,
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alignItems: 'center',
|
|
16
11
|
},
|
|
17
12
|
small: {
|
|
18
|
-
width:
|
|
19
|
-
height:
|
|
20
|
-
},
|
|
21
|
-
circle: {
|
|
13
|
+
width: 40,
|
|
14
|
+
height: 40,
|
|
22
15
|
borderRadius: Radius.XL,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
borderRadius: Radius.S,
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
alignItems: 'center',
|
|
26
18
|
},
|
|
27
19
|
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
28
20
|
});
|
package/Layout/Screen.tsx
CHANGED
|
@@ -166,13 +166,6 @@ export interface ScreenProps extends ViewProps {
|
|
|
166
166
|
trackingParams?: ScreenTrackingParams;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
/**
|
|
170
|
-
* Scroll distance (px) over which the animated search header collapses from its
|
|
171
|
-
* expanded to its docked state — the input range consumed by `HeaderExtendHeader`
|
|
172
|
-
* and the settle threshold in `handleScrollEnd`.
|
|
173
|
-
*/
|
|
174
|
-
const SEARCH_HEADER_COLLAPSE_DISTANCE = 100;
|
|
175
|
-
|
|
176
169
|
const Screen = forwardRef(
|
|
177
170
|
(
|
|
178
171
|
{
|
|
@@ -202,7 +195,7 @@ const Screen = forwardRef(
|
|
|
202
195
|
ref: any,
|
|
203
196
|
) => {
|
|
204
197
|
const screenRef = useRef<View | ScrollView>(null);
|
|
205
|
-
const { width: widthDevice
|
|
198
|
+
const { width: widthDevice } = useWindowDimensions();
|
|
206
199
|
const { theme } = useContext(ApplicationContext);
|
|
207
200
|
const screen: any = useContext(ScreenContext);
|
|
208
201
|
const insets = useSafeAreaInsets();
|
|
@@ -663,17 +656,6 @@ const Screen = forwardRef(
|
|
|
663
656
|
]}
|
|
664
657
|
contentContainerStyle={[
|
|
665
658
|
scrollable && !Footer && !isTab && { paddingBottom: bottomInset },
|
|
666
|
-
// The animated search header collapses as the body scrolls. When the
|
|
667
|
-
// body is short (e.g. no search history) the ScrollView is barely
|
|
668
|
-
// scrollable, so overscroll bounce feeds the scroll-driven animation
|
|
669
|
-
// and the input jitters on its way up to the header. A ScrollView
|
|
670
|
-
// frame can never exceed the window, so forcing the content to be at
|
|
671
|
-
// least one screen plus the collapse distance guarantees the animation
|
|
672
|
-
// always has room to complete smoothly, independent of body content.
|
|
673
|
-
scrollable &&
|
|
674
|
-
inputSearchProps && {
|
|
675
|
-
minHeight: heightDevice + SEARCH_HEADER_COLLAPSE_DISTANCE,
|
|
676
|
-
},
|
|
677
659
|
scrollViewProps?.contentContainerStyle,
|
|
678
660
|
]}
|
|
679
661
|
>
|
package/Text/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dimensions, PixelRatio, useWindowDimensions } from 'react-native';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { ScaleSizeContext } from '../Context';
|
|
4
4
|
|
|
5
5
|
const deviceWidth = Dimensions.get('window').width;
|
|
6
6
|
const DEFAULT_SCREEN_SIZE = 375;
|
|
@@ -8,15 +8,12 @@ const MAX_FONT_SCALE = 1.5;
|
|
|
8
8
|
const MAX_DEVICE_SCALE = 5;
|
|
9
9
|
|
|
10
10
|
const useScaleSize = (size: number, scaleRate?: number) => {
|
|
11
|
-
const
|
|
12
|
-
if (context?.fontScale?.useOSScaleRate === false) {
|
|
13
|
-
return size * (context.fontScale.userScaleRate ?? 1);
|
|
14
|
-
}
|
|
11
|
+
const { scaleSizeMaxRate = MAX_FONT_SCALE } = useContext(ScaleSizeContext);
|
|
15
12
|
const fontScale = PixelRatio.getFontScale();
|
|
16
13
|
const { width } = useWindowDimensions();
|
|
17
14
|
const deviceScale = width / DEFAULT_SCREEN_SIZE;
|
|
18
15
|
|
|
19
|
-
const maxScaleRate = scaleRate ??
|
|
16
|
+
const maxScaleRate = scaleRate ?? scaleSizeMaxRate;
|
|
20
17
|
|
|
21
18
|
let fontSizeDeviceScale = size;
|
|
22
19
|
let fontSizeOSScale = size;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.163.1-beta.
|
|
3
|
+
"version": "0.163.1-beta.2",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {},
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"@momo-kits/foundation"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"react-native-fast-image": "git+https://oauth2:
|
|
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
12
|
"@react-navigation/bottom-tabs": "7.4.2",
|
|
13
13
|
"@react-navigation/core": "7.12.1",
|
|
14
14
|
"@react-navigation/elements": "2.5.2",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@react-navigation/routers": "7.4.1",
|
|
17
17
|
"@react-navigation/stack": "7.4.2",
|
|
18
18
|
"react-native-gesture-handler": "2.27.1",
|
|
19
|
-
"react-native-linear-gradient": "git+https://oauth2:
|
|
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
20
|
"react-native-reanimated": "4.2.2",
|
|
21
21
|
"react-native-safe-area-context": "5.5.2",
|
|
22
22
|
"@shopify/flash-list": "2.1.0",
|