@momo-kits/foundation 0.158.1-beta.4 → 0.159.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.
@@ -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';
@@ -43,29 +44,31 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
43
44
  },
44
45
  }) => {
45
46
  const context = useContext<any>(MiniAppContext);
46
- const [currentContext, setCurrentContext] = useState({});
47
+ const [currentContext, setCurrentContext] = useState<any>({});
48
+
49
+ const mergedContext = {
50
+ ...context,
51
+ ...currentContext,
52
+ features: {
53
+ ...context?.features,
54
+ ...features,
55
+ },
56
+ };
47
57
 
48
58
  return (
49
59
  <SafeAreaProvider>
50
- <MiniAppContext.Provider
51
- value={{
52
- ...context,
53
- ...currentContext,
54
- features: {
55
- ...context?.features,
56
- ...features,
57
- },
58
- }}
59
- >
60
- <Navigation
61
- screen={screen}
62
- theme={theme}
63
- options={options}
64
- maxApi={maxApi}
65
- setCurrentContext={setCurrentContext}
66
- initialParams={initialParams}
67
- localize={localize}
68
- />
60
+ <MiniAppContext.Provider value={mergedContext}>
61
+ <ScaleSizeProvider scaleSizeMaxRate={1.0}>
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>
69
72
  </MiniAppContext.Provider>
70
73
  </SafeAreaProvider>
71
74
  );
@@ -1,6 +1,7 @@
1
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
+ import ScaleSizeProvider from './ScaleSizeProvider';
4
5
  import { WidgetContainerProps } from './types';
5
6
  import { ApplicationContext, MiniAppContext } from '../Context';
6
7
  import Localize from './Localize';
@@ -67,15 +68,18 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
67
68
 
68
69
  navigator.current.setCurrentContext = setCurrentContext;
69
70
 
71
+ const mergedContext = {
72
+ ...context,
73
+ ...currentContext,
74
+ };
75
+
70
76
  return (
71
77
  <View style={{ height: height ?? '100%', minHeight:1 }}>
72
78
  <SafeAreaProvider>
73
- <MiniAppContext.Provider
74
- value={{
75
- ...context,
76
- ...currentContext,
77
- }}
78
- >
79
+ <MiniAppContext.Provider value={mergedContext}>
80
+ <ScaleSizeProvider
81
+ scaleSizeMaxRate={mergedContext?.scaleSizeMaxRate}
82
+ >
79
83
  <ApplicationContext.Provider
80
84
  value={{
81
85
  navigator: navigator.current,
@@ -153,6 +157,7 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
153
157
  </ReactNavigationContainer>
154
158
  </NavigationIndependentTree>
155
159
  </ApplicationContext.Provider>
160
+ </ScaleSizeProvider>
156
161
  </MiniAppContext.Provider>
157
162
  </SafeAreaProvider>
158
163
  </View>
package/Badge/styles.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import {StyleSheet} from 'react-native';
2
2
  import {Colors, Radius, Spacing} from '../Consts';
3
- import {scaleSize} from '../Text';
4
3
 
5
4
  const DOT_SIZE = 16;
6
5
 
@@ -12,8 +11,8 @@ export default StyleSheet.create({
12
11
  borderRadius: Radius.M,
13
12
  justifyContent: 'center',
14
13
  alignItems: 'center',
15
- height: scaleSize(16) - 2,
16
- minWidth: scaleSize(16) - 2,
14
+ height: DOT_SIZE - 2,
15
+ minWidth: DOT_SIZE - 2,
17
16
  flexDirection: 'row',
18
17
  alignSelf: 'baseline',
19
18
  },
@@ -21,8 +20,8 @@ export default StyleSheet.create({
21
20
  borderRadius: Radius.M,
22
21
  justifyContent: 'center',
23
22
  alignItems: 'center',
24
- height: scaleSize(16),
25
- minWidth: scaleSize(16),
23
+ height: DOT_SIZE,
24
+ minWidth: DOT_SIZE,
26
25
  flexDirection: 'row',
27
26
  borderWidth: 1,
28
27
  borderColor: Colors.black_01,
@@ -35,6 +35,7 @@ const TextTyping: FC<any> = ({
35
35
  timeDelayNextChar = 20,
36
36
  }) => {
37
37
  const textRef = useRef<TextInput>(null);
38
+ const scaledFontSize = useScaleSize(12);
38
39
 
39
40
  const currentIndex = useRef<number>(0);
40
41
  const currentCharIndex = useRef<number>(0);
@@ -107,7 +108,7 @@ const TextTyping: FC<any> = ({
107
108
 
108
109
  return (
109
110
  <TextInput
110
- style={styles.inputStyle}
111
+ style={[styles.inputStyle, { fontSize: scaledFontSize }]}
111
112
  ref={textRef}
112
113
  editable={false}
113
114
  autoCorrect={false}
package/Input/styles.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  import { Platform, StyleSheet } from 'react-native';
2
2
  import { Colors, Radius, Spacing } from '../Consts';
3
- import { scaleSize } from '../Text';
4
3
 
5
4
  export default StyleSheet.create({
6
5
  //input style
7
6
  input: {
8
7
  flex: 1,
9
8
  paddingLeft: Spacing.M,
10
- fontSize: scaleSize(14),
11
9
  height: '100%',
12
10
  },
13
11
  wrapper: {
@@ -76,7 +74,6 @@ export default StyleSheet.create({
76
74
  flex: 1,
77
75
  paddingRight: Spacing.XS,
78
76
  paddingVertical: Spacing.XS,
79
- fontSize: scaleSize(14),
80
77
  },
81
78
  textAreaWrapper: {
82
79
  borderWidth: 1,
@@ -129,13 +126,11 @@ export default StyleSheet.create({
129
126
  width: '100%',
130
127
  paddingLeft: Spacing.M,
131
128
  height: '100%',
132
- fontSize: scaleSize(20),
133
129
  paddingVertical: Spacing.S,
134
130
  fontWeight: 'bold',
135
131
  },
136
132
  inputStyle: {
137
133
  color: Colors.black_12,
138
- fontSize: scaleSize(12),
139
134
  height: Platform.select({
140
135
  android: 60,
141
136
  ios: 36,
@@ -217,7 +212,7 @@ export default StyleSheet.create({
217
212
  borderRadius: Radius.XS,
218
213
  overflow: 'hidden',
219
214
  },
220
- currency: { fontSize: scaleSize(20), fontWeight: 'bold' },
215
+ currency: { fontWeight: 'bold' },
221
216
  phoneNumberDivider: {
222
217
  width: 1,
223
218
  marginLeft: Spacing.M,
@@ -14,6 +14,7 @@ import {
14
14
  } from 'react-native';
15
15
  import { ApplicationContext } from '../Context';
16
16
  import { Icon } from '../Icon';
17
+ import { useScaleSize } from '../Text';
17
18
 
18
19
  export interface FloatingButtonProps {
19
20
  label?: string;
@@ -39,6 +40,8 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
39
40
  bottom = 12,
40
41
  }: FloatingButtonProps) => {
41
42
  const { theme } = useContext(ApplicationContext);
43
+ const scaledFontSize = useScaleSize(16);
44
+ const scaledLineHeight = useScaleSize(22);
42
45
  const maxWidth = useRef(0);
43
46
  const minWidth = size === 'small' ? 36 : 48;
44
47
  const [opacityAnimated] = useState(new Animated.Value(0)); // Initial opacity set to 0
@@ -148,7 +151,15 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
148
151
  {showText && !!label && (
149
152
  <Animated.Text
150
153
  allowFontScaling={false}
151
- style={[styles.label, { opacity: opacityAnimated, color: 'white' }]}
154
+ style={[
155
+ styles.label,
156
+ {
157
+ fontSize: scaledFontSize,
158
+ lineHeight: scaledLineHeight,
159
+ opacity: opacityAnimated,
160
+ color: 'white',
161
+ },
162
+ ]}
152
163
  numberOfLines={1}
153
164
  >
154
165
  {label}
@@ -172,8 +183,6 @@ const styles = StyleSheet.create({
172
183
  },
173
184
  label: {
174
185
  marginLeft: 8,
175
- fontSize: 16,
176
- lineHeight: 22,
177
186
  fontWeight: '700',
178
187
  },
179
188
  });
package/Text/utils.ts CHANGED
@@ -8,13 +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 scaleSizeContext = useContext<any>(ScaleSizeContext);
11
+ const { scaleSizeMaxRate = MAX_FONT_SCALE } = useContext(ScaleSizeContext);
12
12
  const fontScale = PixelRatio.getFontScale();
13
- const windowSize = useWindowDimensions();
14
- const deviceScale = windowSize.width / DEFAULT_SCREEN_SIZE;
13
+ const { width } = useWindowDimensions();
14
+ const deviceScale = width / DEFAULT_SCREEN_SIZE;
15
15
 
16
- const maxScaleRate =
17
- scaleRate || scaleSizeContext?.scaleSizeMaxRate || MAX_FONT_SCALE;
16
+ const maxScaleRate = scaleRate ?? scaleSizeMaxRate;
18
17
 
19
18
  let fontSizeDeviceScale = size;
20
19
  let fontSizeOSScale = size;
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
- "name": "@momo-kits/foundation",
3
- "version": "0.158.1-beta.4",
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.159.1-beta.2",
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
+ }