@momo-kits/foundation 0.75.1-beta.19 → 0.75.1-beta.21
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/Layout/Card.tsx +3 -3
- package/Layout/GridSystem.tsx +3 -3
- package/Layout/Section.tsx +3 -3
- package/Layout/utils.ts +11 -14
- package/Navigation/Components.tsx +8 -3
- package/Text/index.tsx +4 -3
- package/Text/utils.ts +14 -0
- package/package.json +1 -1
package/Layout/Card.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
2
|
+
import {Dimensions, View} from 'react-native';
|
|
3
3
|
import {useGridSystem, validateChildren} from './utils';
|
|
4
4
|
import {CardProps, GridContextProps} from './types';
|
|
5
5
|
import {GridContext} from './index';
|
|
@@ -7,12 +7,12 @@ import {GRIDVIEW} from '../Consts';
|
|
|
7
7
|
import Item from './Item';
|
|
8
8
|
|
|
9
9
|
const Card: React.FC<CardProps> = ({children, style}) => {
|
|
10
|
-
const {numberOfColumns
|
|
10
|
+
const {numberOfColumns} = useGridSystem();
|
|
11
11
|
|
|
12
12
|
const gutterSize = 8;
|
|
13
13
|
const margin = 12;
|
|
14
14
|
|
|
15
|
-
const widthSection = window.width - margin * 2;
|
|
15
|
+
const widthSection = Dimensions.get('window').width - margin * 2;
|
|
16
16
|
const totalGutterSize = gutterSize * (numberOfColumns - 1);
|
|
17
17
|
const sizePerSpan = (widthSection - totalGutterSize - 24) / numberOfColumns;
|
|
18
18
|
|
package/Layout/GridSystem.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
2
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
3
|
-
import {StyleSheet, View} from 'react-native';
|
|
3
|
+
import {Dimensions, StyleSheet, View} from 'react-native';
|
|
4
4
|
import {ApplicationContext} from '../Navigation';
|
|
5
5
|
import {Colors, Spacing} from '../Consts';
|
|
6
6
|
import {GridContextProps} from './types';
|
|
@@ -8,11 +8,11 @@ import {useGridSystem} from './utils';
|
|
|
8
8
|
|
|
9
9
|
const GridSystem: React.FC = () => {
|
|
10
10
|
const {theme} = useContext(ApplicationContext);
|
|
11
|
-
const {numberOfColumns
|
|
11
|
+
const {numberOfColumns} = useGridSystem();
|
|
12
12
|
|
|
13
13
|
const gutterSize = 12;
|
|
14
14
|
const margin = 12;
|
|
15
|
-
const widthSection = window.width - margin * 2;
|
|
15
|
+
const widthSection = Dimensions.get('window').width - margin * 2;
|
|
16
16
|
const totalGutterSize = gutterSize * (numberOfColumns - 1);
|
|
17
17
|
const sizePerSpan = (widthSection - totalGutterSize) / numberOfColumns;
|
|
18
18
|
|
package/Layout/Section.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
2
|
+
import {Dimensions, View} from 'react-native';
|
|
3
3
|
import {useGridSystem, validateChildren} from './utils';
|
|
4
4
|
import {GridContextProps, SectionProps} from './types';
|
|
5
5
|
import {GridContext} from './index';
|
|
@@ -11,14 +11,14 @@ const Section: React.FC<SectionProps> = ({
|
|
|
11
11
|
useMargin = true,
|
|
12
12
|
backgroundColor,
|
|
13
13
|
}) => {
|
|
14
|
-
const {numberOfColumns
|
|
14
|
+
const {numberOfColumns} = useGridSystem();
|
|
15
15
|
|
|
16
16
|
const gutterSize = 12;
|
|
17
17
|
let margin = 0;
|
|
18
18
|
if (useMargin) {
|
|
19
19
|
margin = 12;
|
|
20
20
|
}
|
|
21
|
-
let widthSection = window.width;
|
|
21
|
+
let widthSection = Dimensions.get('window').width;
|
|
22
22
|
if (useMargin) widthSection = widthSection - margin * 2;
|
|
23
23
|
const totalGutterSize = gutterSize * (numberOfColumns - 1);
|
|
24
24
|
const sizePerSpan = (widthSection - totalGutterSize) / numberOfColumns;
|
package/Layout/utils.ts
CHANGED
|
@@ -62,22 +62,19 @@ const useGridSystem = () => {
|
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
useEffect(() => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// },
|
|
76
|
-
// );
|
|
77
|
-
// return () => subscription?.remove();
|
|
65
|
+
const subscription: any = Dimensions.addEventListener(
|
|
66
|
+
'change',
|
|
67
|
+
({window}: any) => {
|
|
68
|
+
const newColumns = Dimensions.get('window').width > 600 ? 24 : 12;
|
|
69
|
+
if (newColumns != numberOfColumns){
|
|
70
|
+
setNumberOfColumns(newColumns);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
return () => subscription?.remove();
|
|
78
75
|
}, []);
|
|
79
76
|
|
|
80
|
-
return {numberOfColumns
|
|
77
|
+
return {numberOfColumns};
|
|
81
78
|
};
|
|
82
79
|
|
|
83
80
|
export {validateChildren, useGridSystem};
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
HeaderToolkitProps,
|
|
17
17
|
TitleCustomProps,
|
|
18
18
|
} from './types';
|
|
19
|
-
import {Text} from '../Text';
|
|
19
|
+
import {scaleSize, Text} from '../Text';
|
|
20
20
|
import {Icon} from '../Icon';
|
|
21
21
|
import {PopupNotify} from '../Popup';
|
|
22
22
|
|
|
@@ -70,7 +70,11 @@ const styles = StyleSheet.create({
|
|
|
70
70
|
headerLeft: {
|
|
71
71
|
marginLeft: 12,
|
|
72
72
|
},
|
|
73
|
-
title: {
|
|
73
|
+
title: {
|
|
74
|
+
fontSize: scaleSize(15),
|
|
75
|
+
lineHeight: scaleSize(22),
|
|
76
|
+
fontWeight: 'bold',
|
|
77
|
+
},
|
|
74
78
|
});
|
|
75
79
|
|
|
76
80
|
const HeaderTitle: React.FC<any> = props => {
|
|
@@ -80,6 +84,7 @@ const HeaderTitle: React.FC<any> = props => {
|
|
|
80
84
|
outputRange: [0, 1],
|
|
81
85
|
extrapolate: 'clamp',
|
|
82
86
|
});
|
|
87
|
+
|
|
83
88
|
return (
|
|
84
89
|
<Animated.Text
|
|
85
90
|
{...props}
|
|
@@ -314,7 +319,7 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
314
319
|
};
|
|
315
320
|
|
|
316
321
|
const renderUtilityTool = () => {
|
|
317
|
-
if (
|
|
322
|
+
if (hidden === false) {
|
|
318
323
|
return (
|
|
319
324
|
<NavigationButton
|
|
320
325
|
icon={type as string}
|
package/Text/index.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import styles from './styles';
|
|
|
4
4
|
import {Typography, TypographyWeight} from './types';
|
|
5
5
|
import {ApplicationContext} from '../Navigation';
|
|
6
6
|
import {GridContext} from '../Layout';
|
|
7
|
+
import {scaleSize} from './utils';
|
|
7
8
|
|
|
8
9
|
const SFProText: TypographyWeight = {
|
|
9
10
|
100: 'Thin',
|
|
@@ -93,8 +94,8 @@ const Text: React.FC<TextProps> = ({
|
|
|
93
94
|
|
|
94
95
|
return {
|
|
95
96
|
fontFamily,
|
|
96
|
-
fontSize,
|
|
97
|
-
lineHeight,
|
|
97
|
+
fontSize: scaleSize(fontSize),
|
|
98
|
+
lineHeight: scaleSize(lineHeight),
|
|
98
99
|
fontStyle,
|
|
99
100
|
};
|
|
100
101
|
};
|
|
@@ -120,4 +121,4 @@ Text.defaultProps = {
|
|
|
120
121
|
typography: 'paragraph_default',
|
|
121
122
|
};
|
|
122
123
|
|
|
123
|
-
export {Text};
|
|
124
|
+
export {Text, scaleSize};
|
package/Text/utils.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {Dimensions} from 'react-native';
|
|
2
|
+
|
|
3
|
+
const deviceWidth = Dimensions.get('window').width;
|
|
4
|
+
const DEFAULT_SCREEN_SIZE = 375;
|
|
5
|
+
const scaleSize = (size: number) => {
|
|
6
|
+
const scaleRate = deviceWidth / DEFAULT_SCREEN_SIZE;
|
|
7
|
+
|
|
8
|
+
if (scaleRate > 1) {
|
|
9
|
+
return Math.min(Math.round(size * scaleRate), size + 5);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return size;
|
|
13
|
+
};
|
|
14
|
+
export {scaleSize};
|