@momo-kits/foundation 0.153.2-beta.2 → 0.153.2-beta.3

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.
@@ -1,4 +1,4 @@
1
- import {useTheme} from '@react-navigation/native';
1
+ import { useTheme } from '@react-navigation/native';
2
2
  import color from 'color';
3
3
  import * as React from 'react';
4
4
  import {
@@ -41,7 +41,7 @@ export function Badge({
41
41
  const [opacity] = React.useState(() => new Animated.Value(visible ? 1 : 0));
42
42
  const [rendered, setRendered] = React.useState(visible);
43
43
 
44
- const {colors, fonts} = useTheme();
44
+ const { colors, fonts } = useTheme();
45
45
 
46
46
  React.useEffect(() => {
47
47
  if (!rendered) {
@@ -52,7 +52,7 @@ export function Badge({
52
52
  toValue: visible ? 1 : 0,
53
53
  duration: 150,
54
54
  useNativeDriver,
55
- }).start(({finished}) => {
55
+ }).start(({ finished }) => {
56
56
  if (finished && !visible) {
57
57
  setRendered(false);
58
58
  }
@@ -70,7 +70,7 @@ export function Badge({
70
70
  }
71
71
 
72
72
  // @ts-expect-error: backgroundColor definitely exists
73
- const {backgroundColor = colors.notification, ...restStyle} =
73
+ const { backgroundColor = colors.notification, ...restStyle } =
74
74
  StyleSheet.flatten(style) || {};
75
75
  const textColor = color(backgroundColor).isLight() ? 'black' : 'white';
76
76
 
@@ -91,6 +91,7 @@ export function Badge({
91
91
 
92
92
  return (
93
93
  <Animated.Text
94
+ allowFontScaling={false}
94
95
  numberOfLines={1}
95
96
  style={[
96
97
  {
@@ -8,13 +8,13 @@ import {
8
8
  type ViewStyle,
9
9
  } from 'react-native';
10
10
 
11
- import { Badge } from './Badge';
12
11
  import { Colors } from '../../Consts';
12
+ import { Badge, BadgeDot } from '../../Badge';
13
13
 
14
14
  type Props = {
15
15
  route: Route<string>;
16
16
  badge?: string | number;
17
- badgeStyle?: StyleProp<TextStyle>;
17
+ badgeStyle?: StyleProp<TextStyle> | any;
18
18
  activeOpacity: number;
19
19
  inactiveOpacity: number;
20
20
  activeTintColor?: string;
@@ -43,11 +43,20 @@ export function TabBarIcon({
43
43
  activeTintColor,
44
44
  inactiveTintColor,
45
45
  renderIcon,
46
- allowFontScaling,
47
46
  style,
48
47
  }: Props) {
49
48
  const iconSize = 25;
50
49
 
50
+ const renderBadge = () => {
51
+ if (badge == null) {
52
+ return;
53
+ }
54
+ if (badge === '') {
55
+ return <BadgeDot size={'small'} style={[styles.badge, badgeStyle]} />;
56
+ }
57
+ return <Badge style={[styles.badge, badgeStyle]} label={badge} />;
58
+ };
59
+
51
60
  // We render the icon twice at the same position on top of each other:
52
61
  // active and inactive one, so we can fade between them.
53
62
  return (
@@ -75,14 +84,7 @@ export function TabBarIcon({
75
84
  color: inactiveTintColor ?? Colors.black_04,
76
85
  })}
77
86
  </View>
78
- <Badge
79
- visible={badge != null}
80
- size={badge === '' ? 12 : iconSize * 0.75}
81
- allowFontScaling={allowFontScaling}
82
- style={[styles.badge, badgeStyle]}
83
- >
84
- {badge}
85
- </Badge>
87
+ {renderBadge()}
86
88
  </View>
87
89
  );
88
90
  }
@@ -12,7 +12,7 @@ import { Colors, Spacing, Styles } from '../../Consts';
12
12
  import { PopupNotify } from '../../Popup';
13
13
  import { Tool, ToolGroup } from '../types';
14
14
  import { Icon } from '../../Icon';
15
- import { scaleSize, Text } from '../../Text';
15
+ import { useScaleSize, Text } from '../../Text';
16
16
 
17
17
  const DID_SYNC_NEW_HOME = 'did_sync_new_home';
18
18
 
@@ -388,11 +388,6 @@ const styles = StyleSheet.create({
388
388
  headerLeft: {
389
389
  marginLeft: 12,
390
390
  },
391
- title: {
392
- fontSize: scaleSize(15),
393
- lineHeight: scaleSize(22),
394
- fontWeight: 'bold',
395
- },
396
391
  badge: {
397
392
  position: 'absolute',
398
393
  top: -Spacing.S,
@@ -7,7 +7,7 @@ import {
7
7
  View,
8
8
  } from 'react-native';
9
9
  import { ApplicationContext, MiniAppContext } from '../../Context';
10
- import { exportFontFamily, scaleSize, Text } from '../../Text';
10
+ import { exportFontFamily, useScaleSize, Text } from '../../Text';
11
11
  import { Colors, Radius, Spacing, Styles } from '../../Consts';
12
12
  import {
13
13
  TitleJourneyProps,
@@ -31,12 +31,23 @@ const HeaderTitle: React.FC<any> = props => {
31
31
  );
32
32
 
33
33
  return (
34
- <View pointerEvents={'none'} style={styles.headerTitleContainer}>
34
+ <View
35
+ pointerEvents={'none'}
36
+ style={{
37
+ justifyContent: 'center',
38
+ maxWidth: Dimensions.get('window').width - 172,
39
+ }}
40
+ >
35
41
  <Animated.Text
36
42
  {...props}
43
+ allowFontScaling={false}
37
44
  accessibilityLabel={'title_navigation_header'}
38
45
  style={[
39
- styles.title,
46
+ {
47
+ fontSize: useScaleSize(15),
48
+ lineHeight: useScaleSize(22),
49
+ fontWeight: 'bold',
50
+ },
40
51
  {
41
52
  fontFamily: exportFontFamily('bold', 'action_xs_bold'),
42
53
  opacity,
@@ -83,7 +94,7 @@ const TitleUser: React.FC<TitleUserProps> = ({
83
94
  isLoading,
84
95
  }) => {
85
96
  const { theme } = useContext(ApplicationContext);
86
- const maxWidth = Dimensions.get('window').width - scaleSize(172);
97
+ const maxWidth = Dimensions.get('window').width - 172;
87
98
  const getShortName = (name: string) => {
88
99
  const words = name.split(' ');
89
100
  const lastTwoWords = words.slice(-2);
@@ -311,7 +322,10 @@ const TitleUser: React.FC<TitleUserProps> = ({
311
322
 
312
323
  return (
313
324
  <TouchableOpacity
314
- style={styles.headerTitleContainer}
325
+ style={{
326
+ justifyContent: 'center',
327
+ maxWidth: maxWidth - (icons?.length ?? 0) * 16,
328
+ }}
315
329
  onPress={onPress}
316
330
  disabled={onPress === undefined}
317
331
  >
@@ -362,6 +376,7 @@ const TitleLocation: React.FC<TitleLocationProps> = ({
362
376
  onPress,
363
377
  isLoading,
364
378
  }) => {
379
+ const maxWidth = Dimensions.get('window').width - 172;
365
380
  const renderShimmer = () => {
366
381
  return (
367
382
  <View style={Styles.flex}>
@@ -380,7 +395,11 @@ const TitleLocation: React.FC<TitleLocationProps> = ({
380
395
  }
381
396
  return (
382
397
  <TouchableOpacity
383
- style={[styles.headerTitleContainer, { alignItems: 'flex-start' }]}
398
+ style={{
399
+ justifyContent: 'center',
400
+ maxWidth: maxWidth,
401
+ alignItems: 'flex-start',
402
+ }}
384
403
  onPress={onPress}
385
404
  >
386
405
  {!!description && (
@@ -422,6 +441,7 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
422
441
  isLoading,
423
442
  }) => {
424
443
  const { width } = Dimensions.get('screen');
444
+ const maxWidth = Dimensions.get('window').width - 172;
425
445
  const startWidth = width * 0.25;
426
446
  const endWidth = width * 0.75 - 212;
427
447
  const renderShimmer = () => {
@@ -441,7 +461,13 @@ const TitleJourney: React.FC<TitleJourneyProps> = ({
441
461
  return renderShimmer();
442
462
  }
443
463
  return (
444
- <TouchableOpacity style={styles.headerTitleContainer} onPress={onPress}>
464
+ <TouchableOpacity
465
+ style={{
466
+ justifyContent: 'center',
467
+ maxWidth: maxWidth,
468
+ }}
469
+ onPress={onPress}
470
+ >
445
471
  <View style={styles.rowJourney}>
446
472
  <View style={Styles.row}>
447
473
  <Text
@@ -501,11 +527,6 @@ const Verified: React.FC<any> = () => {
501
527
  };
502
528
 
503
529
  const styles = StyleSheet.create({
504
- title: {
505
- fontSize: scaleSize(15),
506
- lineHeight: scaleSize(22),
507
- fontWeight: 'bold',
508
- },
509
530
  rowJourney: { flexDirection: 'row', width: '100%', alignItems: 'flex-start' },
510
531
  verifiedDot: {
511
532
  width: 4,
@@ -515,10 +536,6 @@ const styles = StyleSheet.create({
515
536
  position: 'absolute',
516
537
  alignSelf: 'center',
517
538
  },
518
- headerTitleContainer: {
519
- justifyContent: 'center',
520
- maxWidth: Dimensions.get('window').width - scaleSize(172),
521
- },
522
539
  circle: {
523
540
  width: 32,
524
541
  height: 32,
package/Badge/Badge.tsx CHANGED
@@ -1,21 +1,46 @@
1
1
  import React, { FC, useContext } from 'react';
2
- import { View } from 'react-native';
2
+ import { View, StyleSheet } from 'react-native';
3
3
 
4
4
  import { useComponentId } from '../Application';
5
5
  import { ApplicationContext } from '../Context';
6
6
  import { BadgeProps } from './types';
7
- import styles from './styles';
8
- import { Colors } from '../Consts';
9
- import { Text } from '../Text';
7
+ import { Colors, Radius, Spacing } from '../Consts';
8
+ import { Text, useScaleSize } from '../Text';
10
9
 
11
10
  const Badge: FC<BadgeProps> = ({
12
- label = 'Label',
11
+ label = '',
13
12
  style,
14
13
  backgroundColor,
15
14
  accessibilityLabel,
16
15
  }) => {
17
16
  const { theme } = useContext(ApplicationContext);
18
17
  const { componentId } = useComponentId('Badge', accessibilityLabel);
18
+ const scaledSize = useScaleSize(16);
19
+
20
+ const styles = StyleSheet.create({
21
+ badge: {
22
+ paddingHorizontal: Spacing.XS,
23
+ borderRadius: Radius.M,
24
+ justifyContent: 'center',
25
+ alignItems: 'center',
26
+ height: scaledSize - 2,
27
+ minWidth: scaledSize - 2,
28
+ flexDirection: 'row',
29
+ alignSelf: 'baseline',
30
+ },
31
+ badgeContainer: {
32
+ borderRadius: Radius.M,
33
+ justifyContent: 'center',
34
+ alignItems: 'center',
35
+ height: scaledSize,
36
+ minWidth: scaledSize,
37
+ flexDirection: 'row',
38
+ borderWidth: 1,
39
+ borderColor: Colors.black_01,
40
+ backgroundColor: 'transparent',
41
+ alignSelf: 'baseline',
42
+ },
43
+ });
19
44
 
20
45
  const isValidatedColor = () => {
21
46
  const colorKeys = Object.keys(Colors);
@@ -41,7 +41,10 @@ const BadgeRibbon: FC<BadgeRibbonProps> = ({
41
41
  },
42
42
  ]}
43
43
  >
44
- <View collapsable={false} style={{ transform: textTransform }}>
44
+ <View
45
+ collapsable={false}
46
+ style={{ transform: textTransform, marginVertical: -2 }}
47
+ >
45
48
  <Text
46
49
  style={styles.ribbonLabel}
47
50
  color={Colors.black_01}
@@ -62,7 +65,10 @@ const BadgeRibbon: FC<BadgeRibbonProps> = ({
62
65
  { backgroundColor: theme.colors.warning.primary },
63
66
  ]}
64
67
  >
65
- <View collapsable={false} style={{ transform: textTransform }}>
68
+ <View
69
+ collapsable={false}
70
+ style={{ transform: textTransform, marginVertical: -2 }}
71
+ >
66
72
  <Text
67
73
  style={styles.ribbonLabel}
68
74
  color={Colors.black_01}
package/Input/Input.tsx CHANGED
@@ -14,7 +14,8 @@ import {
14
14
  } from 'react-native';
15
15
  import { useComponentId } from '../Application';
16
16
  import { Icon } from '../Icon';
17
- import { exportFontFamily } from '../Text';
17
+ import { exportFontFamily, useScaleSize } from '../Text';
18
+ import { Spacing } from '../Consts';
18
19
  import {
19
20
  ErrorView,
20
21
  FloatingView,
@@ -68,6 +69,7 @@ const Input = forwardRef(
68
69
  ref,
69
70
  ) => {
70
71
  const { theme } = useContext(ApplicationContext);
72
+ const scaledFontSize = useScaleSize(14);
71
73
  const [focused, setFocused] = useState(false);
72
74
  const haveValue = !!value || !!defaultValue;
73
75
  // TODO: CHECK THIS
@@ -176,7 +178,12 @@ const Input = forwardRef(
176
178
  ...props.accessibilityState,
177
179
  }}
178
180
  style={[
179
- styles.input,
181
+ {
182
+ flex: 1,
183
+ paddingLeft: Spacing.M,
184
+ fontSize: scaledFontSize,
185
+ height: '100%',
186
+ },
180
187
  {
181
188
  color: textColor,
182
189
  fontFamily: exportFontFamily(fontWeight ?? 'regular'),
@@ -17,6 +17,8 @@ import {
17
17
  import { useComponentId } from '../Application';
18
18
  import { ApplicationContext, ComponentContext } from '../Context';
19
19
  import { Icon } from '../Icon';
20
+ import { useScaleSize } from '../Text';
21
+ import { Spacing } from '../Consts';
20
22
  import {
21
23
  ErrorView,
22
24
  FloatingView,
@@ -60,6 +62,7 @@ const InputMoney = forwardRef(
60
62
  ref,
61
63
  ) => {
62
64
  const { theme } = useContext(ApplicationContext);
65
+ const scaledFontSize = useScaleSize(20);
63
66
  const [focused, setFocused] = useState(false);
64
67
  const [displayValue, setDisplayValue] = useState('');
65
68
  const [numericValue, setNumericValue] = useState('');
@@ -219,7 +222,14 @@ const InputMoney = forwardRef(
219
222
  ...props.accessibilityState,
220
223
  }}
221
224
  style={[
222
- styles.moneyInput,
225
+ {
226
+ width: '100%',
227
+ paddingLeft: Spacing.M,
228
+ height: '100%',
229
+ fontSize: scaledFontSize,
230
+ paddingVertical: Spacing.S,
231
+ fontWeight: 'bold',
232
+ },
223
233
  {
224
234
  color: textColor,
225
235
  },
@@ -16,7 +16,7 @@ import {
16
16
  } from 'react-native';
17
17
  import { useComponentId } from '../Application';
18
18
  import { Spacing, Styles } from '../Consts';
19
- import { scaleSize, Text } from '../Text';
19
+ import { useScaleSize, Text } from '../Text';
20
20
  import { ErrorView, getBorderColor } from './common';
21
21
  import { CaretProps, InputOTPProps } from './index';
22
22
  import styles from './styles';
@@ -53,7 +53,7 @@ const OTPCaret: FC<CaretProps> = ({ index, length }) => {
53
53
  <View style={[Styles.rowCenter, spacingStyle]}>
54
54
  <Animated.View
55
55
  style={{
56
- height: scaleSize(12),
56
+ height: useScaleSize(12),
57
57
  width: 1,
58
58
  backgroundColor: theme.colors.primary,
59
59
  opacity,
@@ -17,7 +17,7 @@ import { useComponentId } from '../Application';
17
17
  import { ApplicationContext, ComponentContext } from '../Context';
18
18
  import { Colors, Spacing, Styles } from '../Consts';
19
19
  import { Icon } from '../Icon';
20
- import { scaleSize, Text } from '../Text';
20
+ import { useScaleSize, Text } from '../Text';
21
21
  import {
22
22
  ErrorView,
23
23
  getBorderColor,
@@ -109,11 +109,11 @@ const InputPhoneNumber = forwardRef(
109
109
  let dividerHeight = 24;
110
110
  let typography: Typography;
111
111
  if (size === 'small') {
112
- inputTextStyles = { fontSize: scaleSize(14), fontWeight: '600' };
112
+ inputTextStyles = { fontSize: useScaleSize(14), fontWeight: '600' };
113
113
  dividerHeight = 24;
114
114
  typography = 'header_s_semibold';
115
115
  } else {
116
- inputTextStyles = { fontSize: scaleSize(18), fontWeight: '700' };
116
+ inputTextStyles = { fontSize: useScaleSize(18), fontWeight: '700' };
117
117
  dividerHeight = 32;
118
118
  typography = 'header_m_bold';
119
119
  }
@@ -19,10 +19,10 @@ import {
19
19
  import { useComponentId } from '../Application';
20
20
  import { ApplicationContext, ComponentContext } from '../Context';
21
21
  import { Icon } from '../Icon';
22
- import { Text } from '../Text';
22
+ import { Text, useScaleSize } from '../Text';
23
23
  import { InputRef, InputSearchProps } from './index';
24
24
  import styles from './styles';
25
- import { Styles } from '../Consts';
25
+ import { Styles, Spacing } from '../Consts';
26
26
  import SystemTextInput from './SystemTextInput';
27
27
 
28
28
  const TextTyping: FC<any> = ({
@@ -138,6 +138,8 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
138
138
  ref,
139
139
  ) => {
140
140
  const { theme } = useContext(ApplicationContext);
141
+ const scaledFontSize = useScaleSize(14);
142
+
141
143
  const [focused, setFocused] = useState(false);
142
144
  const [internalText, setInternalText] = useState(defaultValue || '');
143
145
  const currentValue = value !== undefined ? value : internalText;
@@ -196,7 +198,13 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
196
198
  return (
197
199
  <TouchableOpacity
198
200
  style={[
199
- styles.searchInput,
201
+ {
202
+ height: 36,
203
+ marginLeft: Spacing.S,
204
+ flex: 1,
205
+ fontSize: scaledFontSize,
206
+ paddingVertical: Spacing.XS,
207
+ },
200
208
  {
201
209
  justifyContent: 'center',
202
210
  },
@@ -217,7 +225,13 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
217
225
  allowFontScaling={false}
218
226
  ref={inputRef}
219
227
  style={[
220
- styles.searchInput,
228
+ {
229
+ height: 36,
230
+ marginLeft: Spacing.S,
231
+ flex: 1,
232
+ fontSize: scaledFontSize,
233
+ paddingVertical: Spacing.XS,
234
+ },
221
235
  {
222
236
  color: theme.colors.text.default,
223
237
  },
@@ -15,9 +15,9 @@ import {
15
15
  } from 'react-native';
16
16
  import { ApplicationContext } from '../Context';
17
17
  import { Icon } from '../Icon';
18
- import { Text } from '../Text';
18
+ import { Text, useScaleSize } from '../Text';
19
+ import { Spacing } from '../Consts';
19
20
  import {
20
- DEFAULT_HEIGHT,
21
21
  ErrorView,
22
22
  FloatingView,
23
23
  getBorderColor,
@@ -61,6 +61,8 @@ const InputTextArea = forwardRef(
61
61
  props.accessibilityLabel,
62
62
  );
63
63
  const { theme } = useContext(ApplicationContext);
64
+ const DEFAULT_HEIGHT = useScaleSize(104);
65
+ const scaledFontSize = useScaleSize(14);
64
66
  const [focused, setFocused] = useState(false);
65
67
  const [inputValue, setInputValue] = useState(defaultValue ?? '');
66
68
  const inputRef = useRef<TextInput | null>(null);
@@ -154,7 +156,13 @@ const InputTextArea = forwardRef(
154
156
  textAlignVertical="top"
155
157
  allowFontScaling={false}
156
158
  style={[
157
- styles.textArea,
159
+ {
160
+ width: '100%',
161
+ flex: 1,
162
+ paddingRight: Spacing.XS,
163
+ paddingVertical: Spacing.XS,
164
+ fontSize: scaledFontSize,
165
+ },
158
166
  {
159
167
  color: textColor,
160
168
  },
@@ -2,7 +2,7 @@
2
2
  import React, { FC, memo, useEffect, useRef } from 'react';
3
3
  import { Platform, StyleSheet, TextInput, TextStyle } from 'react-native';
4
4
  import { Colors } from '../Consts';
5
- import { scaleSize } from '../Text';
5
+ import { useScaleSize } from '../Text';
6
6
 
7
7
  export interface TextTypingProps {
8
8
  data: string[];
@@ -18,6 +18,7 @@ const TextTyping: FC<TextTypingProps> = ({
18
18
  inputStyle = {},
19
19
  }) => {
20
20
  const textRef = useRef<TextInput>(null);
21
+ const scaledFontSize = useScaleSize(12);
21
22
 
22
23
  const currentIndex = useRef<number>(0);
23
24
  const currentCharIndex = useRef<number>(0);
@@ -90,7 +91,14 @@ const TextTyping: FC<TextTypingProps> = ({
90
91
 
91
92
  return (
92
93
  <TextInput
93
- style={[styles.inputStyle, inputStyle]}
94
+ style={[{
95
+ color: Colors.black_12,
96
+ fontSize: scaledFontSize,
97
+ height: Platform.select({
98
+ android: 60,
99
+ ios: 36,
100
+ }),
101
+ }, inputStyle]}
94
102
  ref={textRef}
95
103
  editable={false}
96
104
  autoCorrect={false}
@@ -102,14 +110,3 @@ const TextTyping: FC<TextTypingProps> = ({
102
110
  };
103
111
 
104
112
  export default memo(TextTyping);
105
-
106
- const styles = StyleSheet.create({
107
- inputStyle: {
108
- color: Colors.black_12,
109
- fontSize: scaleSize(12),
110
- height: Platform.select({
111
- android: 60,
112
- ios: 36,
113
- }),
114
- },
115
- });
package/Input/common.tsx CHANGED
@@ -9,7 +9,7 @@ import { ApplicationContext } from '../Context';
9
9
  import { Theme } from '../Application/types';
10
10
  import { Styles } from '../Consts';
11
11
  import { Icon } from '../Icon';
12
- import { scaleSize, Text } from '../Text';
12
+ import { useScaleSize, Text } from '../Text';
13
13
  import styles from './styles';
14
14
  import { Loader } from '../Loader';
15
15
  import IconSources from '../Assets/icon.json';
@@ -33,7 +33,6 @@ type TrailingProps = {
33
33
  onPressIcon?: () => void;
34
34
  };
35
35
 
36
- export const DEFAULT_HEIGHT = scaleSize(104);
37
36
  export const MAX_LENGTH = 300;
38
37
 
39
38
  export const getBorderColor = (
@@ -142,6 +141,7 @@ export const FloatingView: FC<FloatingViewProps> = ({
142
141
  {
143
142
  backgroundColor: theme.colors.background.surface,
144
143
  zIndex: 10,
144
+ top: -useScaleSize(10),
145
145
  },
146
146
  style,
147
147
  ]}
package/Input/styles.ts CHANGED
@@ -1,15 +1,8 @@
1
- import { Platform, StyleSheet } from 'react-native';
2
- import { Colors, Radius, Spacing } from '../Consts';
3
- import { scaleSize } from '../Text';
1
+ import { StyleSheet } from 'react-native';
2
+ import { Radius, Spacing } from '../Consts';
4
3
 
5
4
  export default StyleSheet.create({
6
5
  //input style
7
- input: {
8
- flex: 1,
9
- paddingLeft: Spacing.M,
10
- fontSize: scaleSize(14),
11
- height: '100%',
12
- },
13
6
  wrapper: {
14
7
  width: '100%',
15
8
  },
@@ -71,13 +64,6 @@ export default StyleSheet.create({
71
64
  textAreaView: {
72
65
  flex: 1,
73
66
  },
74
- textArea: {
75
- width: '100%',
76
- flex: 1,
77
- paddingRight: Spacing.XS,
78
- paddingVertical: Spacing.XS,
79
- fontSize: scaleSize(14),
80
- },
81
67
  textAreaWrapper: {
82
68
  borderWidth: 1,
83
69
  borderRadius: Radius.S,
@@ -105,13 +91,6 @@ export default StyleSheet.create({
105
91
  alignItems: 'center',
106
92
  flex: 1,
107
93
  },
108
- searchInput: {
109
- height: 36,
110
- marginLeft: Spacing.S,
111
- flex: 1,
112
- fontSize: scaleSize(14),
113
- paddingVertical: Spacing.XS,
114
- },
115
94
  searchInputView: {
116
95
  flexDirection: 'row',
117
96
  alignItems: 'center',
@@ -126,22 +105,6 @@ export default StyleSheet.create({
126
105
  height: 20,
127
106
  marginLeft: Spacing.XS,
128
107
  },
129
- moneyInput: {
130
- width: '100%',
131
- paddingLeft: Spacing.M,
132
- height: '100%',
133
- fontSize: scaleSize(20),
134
- paddingVertical: Spacing.S,
135
- fontWeight: 'bold',
136
- },
137
- inputStyle: {
138
- color: Colors.black_12,
139
- fontSize: scaleSize(12),
140
- height: Platform.select({
141
- android: 60,
142
- ios: 36,
143
- }),
144
- },
145
108
  //OTP
146
109
  otpWrapper: {
147
110
  width: '100%',
@@ -205,7 +168,7 @@ export default StyleSheet.create({
205
168
  },
206
169
  textViewDropDown: {
207
170
  flex: 1,
208
- marginVertical: Spacing.M,
171
+ marginVertical: Spacing.S,
209
172
  marginRight: Spacing.S,
210
173
  justifyContent: 'center',
211
174
  },
@@ -217,9 +180,9 @@ export default StyleSheet.create({
217
180
  borderRadius: Radius.XS,
218
181
  overflow: 'hidden',
219
182
  },
220
- currency: { fontSize: scaleSize(20), fontWeight: 'bold' },
221
183
  phoneNumberDivider: {
222
184
  width: 1,
223
- marginLeft: Spacing.M
185
+ marginLeft: Spacing.M,
186
+ marginRight: Spacing.M,
224
187
  },
225
188
  });
@@ -147,6 +147,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
147
147
  />
148
148
  {showText && !!label && (
149
149
  <Animated.Text
150
+ allowFontScaling={false}
150
151
  style={[styles.label, { opacity: opacityAnimated, color: 'white' }]}
151
152
  numberOfLines={1}
152
153
  >
@@ -11,7 +11,7 @@ import { Button } from '../Button';
11
11
  import { Radius, Spacing, Styles } from '../Consts';
12
12
  import { Icon } from '../Icon';
13
13
  import { Image } from '../Image';
14
- import { scaleSize, Text } from '../Text';
14
+ import { useScaleSize, Text } from '../Text';
15
15
  import { PopupNotifyProps } from './types';
16
16
  import { runOnJS } from 'react-native-reanimated';
17
17
 
@@ -31,13 +31,14 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
31
31
  const { theme, navigator, translate } = useContext(ApplicationContext);
32
32
  const [scrollContent, setScrollContent] = useState(false);
33
33
  const { width: widthDevice } = Dimensions.get('window');
34
+ const scaledMaxHeight = useScaleSize(172);
34
35
 
35
36
  const closeAction = useRef('touch_outside');
36
37
  let descriptionStyle = {};
37
38
  let Description: any = View;
38
39
  if (scrollContent) {
39
40
  Description = ScrollView;
40
- descriptionStyle = { maxHeight: scaleSize(172) };
41
+ descriptionStyle = { maxHeight: scaledMaxHeight };
41
42
  }
42
43
  /**
43
44
  * tracking
package/Tag/index.tsx CHANGED
@@ -1,10 +1,9 @@
1
1
  import React, {FC} from 'react';
2
- import {View} from 'react-native';
2
+ import {View, StyleSheet} from 'react-native';
3
3
  import {TagProps} from './types';
4
- import styles from './styles';
5
- import {Colors} from '../Consts';
4
+ import {Colors, Radius, Spacing} from '../Consts';
6
5
  import {Icon} from '../Icon';
7
- import {Text} from '../Text';
6
+ import {Text, useScaleSize} from '../Text';
8
7
  import {useComponentId} from '../Application';
9
8
 
10
9
  const backgroundColor = {
@@ -34,6 +33,31 @@ const Tag: FC<TagProps> = ({
34
33
  customColor,
35
34
  accessibilityLabel,
36
35
  }) => {
36
+ const scaledHeight24 = useScaleSize(24);
37
+ const scaledHeight18 = useScaleSize(18);
38
+
39
+ const styles = StyleSheet.create({
40
+ container: {
41
+ paddingHorizontal: Spacing.S,
42
+ borderRadius: Radius.S,
43
+ flexDirection: 'row',
44
+ height: scaledHeight24,
45
+ alignItems: 'center',
46
+ justifyContent: 'center',
47
+ },
48
+ mediumContainer: {
49
+ paddingHorizontal: Spacing.S,
50
+ borderRadius: Radius.S,
51
+ height: scaledHeight18,
52
+ alignItems: 'center',
53
+ flexDirection: 'row',
54
+ justifyContent: 'center',
55
+ },
56
+ icon: {
57
+ marginRight: Spacing.XS,
58
+ },
59
+ });
60
+
37
61
  let labelColor = textColor[color];
38
62
  let tagColor = backgroundColor[color];
39
63
  let sizeStyle = styles.mediumContainer;
package/Text/index.tsx CHANGED
@@ -3,8 +3,9 @@ import { Text as RNText, TextProps as RNTextProps, View } from 'react-native';
3
3
  import styles from './styles';
4
4
  import { Typography, TypographyWeight } from './types';
5
5
  import { ApplicationContext, SkeletonContext } from '../Context';
6
- import { scaleSize } from './utils';
6
+ import { scaleSize, useScaleSize } from './utils';
7
7
  import { Skeleton } from '../Skeleton';
8
+ import { Colors } from '../Consts';
8
9
 
9
10
  const SFProText: TypographyWeight = {
10
11
  100: 'Thin',
@@ -164,6 +165,8 @@ const Text: React.FC<TextProps> = ({
164
165
  textStyle,
165
166
  {
166
167
  color: color ?? theme.colors.text.default,
168
+ borderWidth: 1,
169
+ borderColor: Colors.green_06,
167
170
  },
168
171
  ]}
169
172
  >
@@ -201,4 +204,4 @@ const exportFontFamily = (
201
204
  return newFontFamily;
202
205
  };
203
206
 
204
- export { Text, scaleSize, exportFontFamily };
207
+ export { Text, scaleSize, useScaleSize, exportFontFamily };
package/Text/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Dimensions, PixelRatio } from 'react-native';
1
+ import { Dimensions, PixelRatio, useWindowDimensions } from 'react-native';
2
2
  import { useContext } from 'react';
3
3
  import { MiniAppContext, ScaleSizeContext } from '../Context';
4
4
 
@@ -11,7 +11,9 @@ const useScaleSize = (size: number) => {
11
11
  const context = useContext<any>(MiniAppContext);
12
12
  const scaleSizeContext = useContext<any>(ScaleSizeContext);
13
13
  const fontScale = PixelRatio.getFontScale();
14
- const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
14
+ const windowSize = useWindowDimensions();
15
+ const deviceScale = windowSize.width / DEFAULT_SCREEN_SIZE;
16
+
15
17
  const maxScaleRate =
16
18
  scaleSizeContext?.scaleSizeMaxRate ||
17
19
  context?.features?.scaleSizeMaxRate ||
@@ -23,7 +25,7 @@ const useScaleSize = (size: number) => {
23
25
  if (deviceScale > 1) {
24
26
  fontSizeDeviceScale = Math.min(
25
27
  fontSizeDeviceScale * deviceScale,
26
- fontSizeDeviceScale + maxScaleRate,
28
+ fontSizeDeviceScale + MAX_DEVICE_SCALE,
27
29
  );
28
30
  }
29
31
 
package/Title/index.tsx CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  ViewStyle,
7
7
  } from 'react-native';
8
8
  import { Icon } from '../Icon';
9
- import { scaleSize, Text } from '../Text';
9
+ import { useScaleSize, Text } from '../Text';
10
10
  import { useComponentId } from '../Application';
11
11
  import { ApplicationContext } from '../Context';
12
12
  import { Badge } from '../Badge';
@@ -37,9 +37,38 @@ const Title: FC<TitleProps> = ({
37
37
  const { theme } = useContext(ApplicationContext);
38
38
  const [badgeWidth, setBadgeWidth] = useState(0);
39
39
  const [contentWidth, setContentWidth] = useState(0);
40
+
41
+ // Dynamic styles using useScaleSize hook
42
+ const dynamicStyles = {
43
+ card_small: {
44
+ fontSize: useScaleSize(14),
45
+ lineHeight: useScaleSize(20),
46
+ },
47
+ card_medium: {
48
+ fontSize: useScaleSize(16),
49
+ lineHeight: useScaleSize(22),
50
+ },
51
+ card_large: {
52
+ fontSize: useScaleSize(18),
53
+ lineHeight: useScaleSize(26),
54
+ },
55
+ section_medium: {
56
+ fontSize: useScaleSize(20),
57
+ lineHeight: useScaleSize(28),
58
+ },
59
+ section_small: {
60
+ fontSize: useScaleSize(16),
61
+ lineHeight: useScaleSize(22),
62
+ },
63
+ section_large: {
64
+ fontSize: useScaleSize(24),
65
+ lineHeight: useScaleSize(34),
66
+ },
67
+ };
68
+
40
69
  const styleSheet: {
41
70
  [key: string]: any;
42
- } = styles;
71
+ } = { ...styles, ...dynamicStyles };
43
72
  const typography = `${type}_${size}`;
44
73
  const isSection = type === 'section';
45
74
  const numberOfLines = showTrailingAction || !!badgeLabel ? 1 : 2;
@@ -90,6 +119,7 @@ const Title: FC<TitleProps> = ({
90
119
  style={[styles.iconLeftView, flexStyle]}
91
120
  >
92
121
  <RNText
122
+ allowFontScaling={false}
93
123
  accessibilityLabel={componentId + '|title-text'}
94
124
  numberOfLines={numberOfLines}
95
125
  style={[
@@ -158,7 +188,7 @@ const Title: FC<TitleProps> = ({
158
188
  >
159
189
  <Icon
160
190
  source={'arrow_chevron_right_small'}
161
- size={scaleSize(18)}
191
+ size={useScaleSize(18)}
162
192
  color={theme.colors.text.default}
163
193
  />
164
194
  </View>
@@ -192,7 +222,7 @@ const Title: FC<TitleProps> = ({
192
222
  >
193
223
  <Icon
194
224
  source={'arrow_chevron_right_small'}
195
- size={scaleSize(22)}
225
+ size={useScaleSize(22)}
196
226
  color={theme.colors.primary}
197
227
  />
198
228
  </TouchableOpacity>
package/Title/styles.ts CHANGED
@@ -1,32 +1,7 @@
1
1
  import {StyleSheet} from 'react-native';
2
- import {scaleSize} from '../Text';
3
2
  import {Colors, Radius, Spacing} from '../Consts';
4
3
 
5
4
  export default StyleSheet.create({
6
- card_small: {
7
- fontSize: scaleSize(14),
8
- lineHeight: scaleSize(20),
9
- },
10
- card_medium: {
11
- fontSize: scaleSize(16),
12
- lineHeight: scaleSize(22),
13
- },
14
- card_large: {
15
- fontSize: scaleSize(18),
16
- lineHeight: scaleSize(26),
17
- },
18
- section_medium: {
19
- fontSize: scaleSize(20),
20
- lineHeight: scaleSize(28),
21
- },
22
- section_small: {
23
- fontSize: scaleSize(16),
24
- lineHeight: scaleSize(22),
25
- },
26
- section_large: {
27
- fontSize: scaleSize(24),
28
- lineHeight: scaleSize(34),
29
- },
30
5
  actionIcon: {
31
6
  borderRadius: Radius.M,
32
7
  alignItems: 'center',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.153.2-beta.2",
3
+ "version": "0.153.2-beta.3",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},