@momo-kits/foundation 0.75.1-beta.8 → 0.76.1-beta.1
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/{Navigation → Application}/BottomTab.tsx +19 -6
- package/{Navigation → Application}/Components.tsx +24 -15
- package/{Navigation → Application}/ModalScreen.tsx +17 -13
- package/{Navigation → Application}/Navigation.ts +5 -5
- package/{Navigation → Application}/NavigationContainer.tsx +3 -3
- package/{Navigation → Application}/StackScreen.tsx +7 -7
- package/{Navigation → Application}/index.ts +7 -3
- package/{Navigation → Application}/types.ts +23 -5
- package/{Navigation → Application}/utils.tsx +4 -6
- package/Assets/icon.json +6 -0
- package/Button/index.tsx +1 -1
- package/CheckBox/index.tsx +1 -1
- package/Consts/theme.ts +1 -1
- package/Divider/index.tsx +1 -1
- package/Icon/index.tsx +2 -2
- package/IconButton/index.tsx +1 -1
- package/Image/index.tsx +4 -2
- package/Input/Input.tsx +2 -1
- package/Input/InputMoney.tsx +2 -1
- package/Input/InputSearch.tsx +4 -2
- package/Input/InputTextArea.tsx +20 -19
- package/Input/common.tsx +1 -1
- package/Input/index.tsx +2 -0
- package/Layout/Card.tsx +108 -54
- package/Layout/GridSystem.tsx +4 -2
- package/Layout/Item.tsx +60 -0
- package/Layout/Screen.tsx +188 -0
- package/Layout/Section.tsx +12 -9
- package/Layout/index.ts +2 -1
- package/Layout/types.ts +7 -7
- package/Layout/utils.ts +46 -16
- package/Pagination/Dot.tsx +1 -1
- package/Pagination/PaginationDot.tsx +1 -1
- package/Pagination/PaginationNumber.tsx +1 -2
- package/Pagination/PaginationScroll.tsx +2 -1
- package/Pagination/PaginationWhiteDot.tsx +1 -1
- package/Popup/PopupNotify.tsx +1 -1
- package/Popup/PopupPromotion.tsx +1 -1
- package/Radio/index.tsx +1 -1
- package/Switch/index.tsx +1 -1
- package/Tag/index.tsx +3 -1
- package/Text/index.tsx +5 -4
- package/Text/utils.ts +14 -0
- package/index.ts +9 -2
- package/package.json +40 -40
- package/publish.sh +2 -5
- package/Layout/ScreenContainer.tsx +0 -122
- package/Navigation/Observer.ts +0 -79
- /package/{Navigation → Application}/NavigationButton.tsx +0 -0
- /package/{Navigation → Application}/Navigator.ts +0 -0
package/Layout/utils.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {Alert} from 'react-native';
|
|
2
|
-
import React, {
|
|
1
|
+
import {Alert, Dimensions} from 'react-native';
|
|
2
|
+
import React, {useEffect, useState} from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* validate children type
|
|
6
6
|
* @param children
|
|
7
|
-
* @param
|
|
7
|
+
* @param childrenTypes
|
|
8
8
|
*/
|
|
9
9
|
const validateChildren = (
|
|
10
10
|
children:
|
|
@@ -17,34 +17,64 @@ const validateChildren = (
|
|
|
17
17
|
| null
|
|
18
18
|
| undefined
|
|
19
19
|
| boolean,
|
|
20
|
-
|
|
20
|
+
childrenTypes: Array<React.FC<any>>,
|
|
21
21
|
) => {
|
|
22
22
|
if (!__DEV__) return children;
|
|
23
|
+
|
|
23
24
|
let results: React.ReactElement[] = [];
|
|
25
|
+
const validateType = (child: React.ReactElement) => {
|
|
26
|
+
return childrenTypes.some(childrenType => child?.type === childrenType);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const alertWrongType = () => {
|
|
30
|
+
Alert.alert(
|
|
31
|
+
'Component Kits',
|
|
32
|
+
`Wrong children type for this component, expected are ${childrenTypes
|
|
33
|
+
.map(type => type.displayName)
|
|
34
|
+
.join(', ')}.`,
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
24
38
|
if (Array.isArray(children)) {
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
const flattenChildren = children.flat();
|
|
40
|
+
results = flattenChildren.filter((child: React.ReactElement) => {
|
|
41
|
+
if (validateType(child)) {
|
|
27
42
|
return child;
|
|
28
43
|
} else {
|
|
29
|
-
|
|
30
|
-
'Component Kits',
|
|
31
|
-
`Wrong children type for this component, expected is ${childrenType.displayName}.`,
|
|
32
|
-
);
|
|
44
|
+
alertWrongType();
|
|
33
45
|
}
|
|
34
46
|
});
|
|
35
47
|
} else {
|
|
36
48
|
const singleChild: any = children;
|
|
37
|
-
if (singleChild
|
|
49
|
+
if (validateType(singleChild)) {
|
|
38
50
|
results = [singleChild];
|
|
39
51
|
} else {
|
|
40
|
-
|
|
41
|
-
'Component Kits',
|
|
42
|
-
`Wrong children type for this component, expected is ${childrenType.displayName}.`,
|
|
43
|
-
);
|
|
52
|
+
alertWrongType();
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
return results;
|
|
48
57
|
};
|
|
49
58
|
|
|
50
|
-
|
|
59
|
+
const useGridSystem = () => {
|
|
60
|
+
const [numberOfColumns, setNumberOfColumns] = useState(
|
|
61
|
+
Dimensions.get('window').width > 600 ? 24 : 12,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
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();
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
return {numberOfColumns};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export {validateChildren, useGridSystem};
|
package/Pagination/Dot.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React, {FC, useContext} from 'react';
|
|
|
2
2
|
import {Animated} from 'react-native';
|
|
3
3
|
import styles from './styles';
|
|
4
4
|
import {DotProps} from './types';
|
|
5
|
-
import {ApplicationContext} from '../
|
|
5
|
+
import {ApplicationContext} from '../Application';
|
|
6
6
|
|
|
7
7
|
const Dot: FC<DotProps> = ({active, style}) => {
|
|
8
8
|
const {theme} = useContext(ApplicationContext);
|
|
@@ -4,7 +4,7 @@ import {ChildPaginationProps} from './types';
|
|
|
4
4
|
import Dot from './Dot';
|
|
5
5
|
import styles from './styles';
|
|
6
6
|
import {Spacing} from '../Consts';
|
|
7
|
-
import {ApplicationContext} from '../
|
|
7
|
+
import {ApplicationContext} from '../Application';
|
|
8
8
|
|
|
9
9
|
const PaginationDot: FC<ChildPaginationProps> = ({
|
|
10
10
|
dataLength = 2,
|
|
@@ -3,14 +3,13 @@ import {View} from 'react-native';
|
|
|
3
3
|
import {ChildPaginationProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import {Text} from '../Text';
|
|
6
|
-
import {ApplicationContext} from '../
|
|
6
|
+
import {ApplicationContext} from '../Application';
|
|
7
7
|
import {Colors} from '../Consts';
|
|
8
8
|
|
|
9
9
|
const PaginationNumber: FC<ChildPaginationProps> = ({
|
|
10
10
|
activeIndex = 0,
|
|
11
11
|
dataLength = 2,
|
|
12
12
|
}) => {
|
|
13
|
-
const {theme} = useContext(ApplicationContext);
|
|
14
13
|
return (
|
|
15
14
|
<View style={[styles.paginationNumberContainer]}>
|
|
16
15
|
<Text color={Colors.black_01} typography={'label_default'}>{`${
|
|
@@ -2,7 +2,7 @@ import React, {FC, useContext, useRef, useState} from 'react';
|
|
|
2
2
|
import {Animated, View} from 'react-native';
|
|
3
3
|
import {ScrollIndicatorProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {ApplicationContext} from '../
|
|
5
|
+
import {ApplicationContext} from '../Application';
|
|
6
6
|
|
|
7
7
|
const INDICATOR_WIDTH = 24;
|
|
8
8
|
const INDICATOR_CONTAINER_WIDTH = 72;
|
|
@@ -31,6 +31,7 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
|
|
|
31
31
|
const renderScrollView = () => {
|
|
32
32
|
return (
|
|
33
33
|
<Animated.ScrollView
|
|
34
|
+
accessibilityLabel={'PaginationScroll'}
|
|
34
35
|
ref={scrollViewRef}
|
|
35
36
|
onScroll={Animated.event(
|
|
36
37
|
[
|
|
@@ -4,7 +4,7 @@ import {ChildPaginationProps} from './types';
|
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import Dot from './Dot';
|
|
6
6
|
import {Colors, Spacing} from '../Consts';
|
|
7
|
-
import {ApplicationContext} from '../
|
|
7
|
+
import {ApplicationContext} from '../Application';
|
|
8
8
|
|
|
9
9
|
const PaginationWhiteDot: FC<ChildPaginationProps> = ({
|
|
10
10
|
dataLength = 2,
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {PopupNotifyProps} from './types';
|
|
|
4
4
|
import {Radius, Spacing, Styles} from '../Consts';
|
|
5
5
|
import {Image} from '../Image';
|
|
6
6
|
import {Text} from '../Text';
|
|
7
|
-
import {ApplicationContext} from '../
|
|
7
|
+
import {ApplicationContext} from '../Application';
|
|
8
8
|
import {Button} from '../Button';
|
|
9
9
|
import {Icon} from '../Icon';
|
|
10
10
|
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
2
|
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {PopupPromotionProps} from './types';
|
|
4
|
-
import {ApplicationContext} from '../
|
|
4
|
+
import {ApplicationContext} from '../Application';
|
|
5
5
|
import {Image} from '../Image';
|
|
6
6
|
import {Radius, Spacing} from '../Consts';
|
|
7
7
|
import {Icon} from '../Icon';
|
package/Radio/index.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {TouchableOpacity, View} from 'react-native';
|
|
|
4
4
|
import {RadioProps} from './types';
|
|
5
5
|
import {Text} from '../Text';
|
|
6
6
|
import styles from './styles';
|
|
7
|
-
import {ApplicationContext} from '../
|
|
7
|
+
import {ApplicationContext} from '../Application';
|
|
8
8
|
import {Spacing} from '../Consts';
|
|
9
9
|
|
|
10
10
|
const Radio: FC<RadioProps> = ({
|
package/Switch/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React, {FC, useContext} from 'react';
|
|
|
2
2
|
import {TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {SwitchProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {ApplicationContext} from '../
|
|
5
|
+
import {ApplicationContext} from '../Application';
|
|
6
6
|
import {Colors} from '../Consts';
|
|
7
7
|
|
|
8
8
|
const Switch: FC<SwitchProps> = props => {
|
package/Tag/index.tsx
CHANGED
|
@@ -60,7 +60,9 @@ const Tag: FC<TagProps> = ({
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return (
|
|
63
|
-
<View
|
|
63
|
+
<View
|
|
64
|
+
style={[style, sizeStyle, {backgroundColor: tagColor}]}
|
|
65
|
+
accessibilityLabel={`Tag/${label}`}>
|
|
64
66
|
{!!icon && (
|
|
65
67
|
<Icon
|
|
66
68
|
style={styles.icon}
|
package/Text/index.tsx
CHANGED
|
@@ -2,8 +2,9 @@ import React, {useContext} from 'react';
|
|
|
2
2
|
import {Text as RNText, TextProps as RNTextProps} from 'react-native';
|
|
3
3
|
import styles from './styles';
|
|
4
4
|
import {Typography, TypographyWeight} from './types';
|
|
5
|
-
import {ApplicationContext} from '../
|
|
5
|
+
import {ApplicationContext} from '../Application';
|
|
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};
|
package/index.ts
CHANGED
|
@@ -5,8 +5,15 @@ import {
|
|
|
5
5
|
} from 'react-native-safe-area-context';
|
|
6
6
|
import LinearGradient from 'react-native-linear-gradient';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* native export
|
|
10
|
+
*/
|
|
8
11
|
export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient};
|
|
9
12
|
|
|
13
|
+
/**
|
|
14
|
+
* foundation component
|
|
15
|
+
*/
|
|
16
|
+
|
|
10
17
|
export * from './Consts';
|
|
11
18
|
export * from './Layout';
|
|
12
19
|
export * from './Layout/types';
|
|
@@ -15,8 +22,8 @@ export * from './Popup/types';
|
|
|
15
22
|
export * from './Text';
|
|
16
23
|
export * from './Text/types';
|
|
17
24
|
export * from './Button';
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
25
|
+
export * from './Application';
|
|
26
|
+
export * from './Application/types';
|
|
20
27
|
export * from './Icon';
|
|
21
28
|
export * from './Icon/types';
|
|
22
29
|
export * from './IconButton';
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
2
|
+
"name": "@momo-kits/foundation",
|
|
3
|
+
"version": "0.76.1-beta.1",
|
|
4
|
+
"description": "React Native Component Kits",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"@momo-kits/foundation"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"react-native-safe-area-context": "3.1.4",
|
|
14
|
+
"react-native-linear-gradient": "2.5.6",
|
|
15
|
+
"@react-navigation/bottom-tabs": "git+https://gitlab.com/dung.huynh1/react-navigation-bottom-tabs.git#main",
|
|
16
|
+
"@react-navigation/core": "5.16.1",
|
|
17
|
+
"@react-navigation/native": "5.9.8",
|
|
18
|
+
"@react-navigation/routers": "5.7.4",
|
|
19
|
+
"@react-navigation/stack": "git+https://gitlab.com/dung.huynh1/react-navigation-stack.git#main",
|
|
20
|
+
"@gorhom/bottom-sheet": "2.4.1"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"react-native": "*"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/core": "^7.12.9",
|
|
27
|
+
"@babel/runtime": "^7.12.5",
|
|
28
|
+
"@react-native-community/eslint-config": "^2.0.0",
|
|
29
|
+
"@types/jest": "26.0.23",
|
|
30
|
+
"@types/react-native": "0.64.4",
|
|
31
|
+
"@types/react-test-renderer": "16.9.2",
|
|
32
|
+
"babel-jest": "^26.6.3",
|
|
33
|
+
"eslint": "^7.14.0",
|
|
34
|
+
"jest": "^26.6.3",
|
|
35
|
+
"metro-react-native-babel-preset": "^0.64.0",
|
|
36
|
+
"react-test-renderer": "17.0.1",
|
|
37
|
+
"typescript": "^4.0.3"
|
|
38
|
+
},
|
|
39
|
+
"author": "@momo-kits/foundation",
|
|
40
|
+
"license": "ISC"
|
|
41
|
+
}
|
package/publish.sh
CHANGED
|
@@ -12,15 +12,12 @@ echo VERSION: $VERSION
|
|
|
12
12
|
|
|
13
13
|
rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
|
|
14
14
|
|
|
15
|
-
#babel component to dist
|
|
16
|
-
#babel ./dist -d dist --copy-files
|
|
17
|
-
|
|
18
15
|
cd dist
|
|
19
|
-
npm publish --tag
|
|
16
|
+
npm publish --tag latest --access=public
|
|
20
17
|
|
|
21
18
|
#clear dist and package json
|
|
22
19
|
cd ..
|
|
23
20
|
rm -rf dist
|
|
24
21
|
|
|
25
22
|
|
|
26
|
-
#curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/core new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/
|
|
23
|
+
#curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/core new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/foundation"}'
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import {Animated, KeyboardAvoidingView, Platform, View} from 'react-native';
|
|
2
|
-
import {useHeaderHeight} from '@react-navigation/stack';
|
|
3
|
-
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
4
|
-
import React, {useContext} from 'react';
|
|
5
|
-
import {ScreenContainerProps} from '../Navigation/types';
|
|
6
|
-
import {Spacing, Styles} from '../Consts';
|
|
7
|
-
import {Section, validateChildren} from './index';
|
|
8
|
-
|
|
9
|
-
import {ApplicationContext} from '../Navigation';
|
|
10
|
-
|
|
11
|
-
const ScreenContainer: React.FC<ScreenContainerProps> = ({
|
|
12
|
-
children,
|
|
13
|
-
enableKeyboardAvoidingView,
|
|
14
|
-
scrollable,
|
|
15
|
-
scrollY,
|
|
16
|
-
headerBackground,
|
|
17
|
-
scrollViewProps,
|
|
18
|
-
footerComponent: Footer,
|
|
19
|
-
}) => {
|
|
20
|
-
const {theme} = useContext(ApplicationContext);
|
|
21
|
-
const insets = useSafeAreaInsets();
|
|
22
|
-
let marginHeader = 0;
|
|
23
|
-
let handleScroll;
|
|
24
|
-
let imageAnimatedStyle = {};
|
|
25
|
-
let Component: any = View;
|
|
26
|
-
if (scrollable) {
|
|
27
|
-
Component = Animated.ScrollView;
|
|
28
|
-
}
|
|
29
|
-
if (scrollY) {
|
|
30
|
-
marginHeader = useHeaderHeight();
|
|
31
|
-
imageAnimatedStyle = {
|
|
32
|
-
transform: [
|
|
33
|
-
{
|
|
34
|
-
scale: scrollY.interpolate?.({
|
|
35
|
-
inputRange: [-300, 0, 1],
|
|
36
|
-
outputRange: [1.75, 1, 1],
|
|
37
|
-
extrapolate: 'clamp',
|
|
38
|
-
}),
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
handleScroll = Animated.event(
|
|
43
|
-
[{nativeEvent: {contentOffset: {y: scrollY}}}],
|
|
44
|
-
{useNativeDriver: true},
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* build content for screen
|
|
50
|
-
*/
|
|
51
|
-
const renderContent = () => {
|
|
52
|
-
const results = validateChildren(children, Section);
|
|
53
|
-
if (Array.isArray(results)) {
|
|
54
|
-
return results.map((item, index) => {
|
|
55
|
-
return (
|
|
56
|
-
<View
|
|
57
|
-
key={`Section${index}`}
|
|
58
|
-
style={{
|
|
59
|
-
marginTop: item.props?.useMargin ? Spacing.M : 0,
|
|
60
|
-
flex: item.props?.expanded ? 1 : undefined,
|
|
61
|
-
}}>
|
|
62
|
-
{item}
|
|
63
|
-
</View>
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return results;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<View style={Styles.flex} accessibilityLabel={`ScreenContainer`}>
|
|
72
|
-
<View
|
|
73
|
-
style={{
|
|
74
|
-
position: 'absolute',
|
|
75
|
-
height: 300,
|
|
76
|
-
width: '100%',
|
|
77
|
-
}}>
|
|
78
|
-
{!!headerBackground && (
|
|
79
|
-
<Animated.Image
|
|
80
|
-
source={{
|
|
81
|
-
uri: headerBackground,
|
|
82
|
-
}}
|
|
83
|
-
style={{
|
|
84
|
-
aspectRatio: 1.3,
|
|
85
|
-
...imageAnimatedStyle,
|
|
86
|
-
}}
|
|
87
|
-
/>
|
|
88
|
-
)}
|
|
89
|
-
</View>
|
|
90
|
-
<KeyboardAvoidingView
|
|
91
|
-
style={Styles.flex}
|
|
92
|
-
enabled={enableKeyboardAvoidingView}
|
|
93
|
-
behavior={Platform.select({
|
|
94
|
-
ios: 'padding',
|
|
95
|
-
android: undefined,
|
|
96
|
-
})}>
|
|
97
|
-
<Component
|
|
98
|
-
{...scrollViewProps}
|
|
99
|
-
onScroll={handleScroll}
|
|
100
|
-
style={[Styles.flex, {marginTop: marginHeader}]}>
|
|
101
|
-
{renderContent()}
|
|
102
|
-
</Component>
|
|
103
|
-
{Footer && (
|
|
104
|
-
<View
|
|
105
|
-
style={{
|
|
106
|
-
paddingTop: Spacing.S,
|
|
107
|
-
paddingBottom: insets.bottom,
|
|
108
|
-
backgroundColor: theme.colors.background.surface,
|
|
109
|
-
}}>
|
|
110
|
-
<Section>{Footer}</Section>
|
|
111
|
-
</View>
|
|
112
|
-
)}
|
|
113
|
-
</KeyboardAvoidingView>
|
|
114
|
-
</View>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
ScreenContainer.defaultProps = {
|
|
119
|
-
enableKeyboardAvoidingView: false,
|
|
120
|
-
scrollable: false,
|
|
121
|
-
};
|
|
122
|
-
export default ScreenContainer;
|
package/Navigation/Observer.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
class Subject {
|
|
2
|
-
private observers: any[];
|
|
3
|
-
constructor() {
|
|
4
|
-
this.observers = [];
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
attach(observer: any) {
|
|
8
|
-
observer && this.observers.push(observer);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
detach(observer: any) {
|
|
12
|
-
this.observers = this.observers.filter(item => item !== observer);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
notify(newState: any) {
|
|
16
|
-
this.observers.forEach(observer => {
|
|
17
|
-
if (typeof observer === 'function') {
|
|
18
|
-
observer(newState);
|
|
19
|
-
} else {
|
|
20
|
-
observer.updateData && observer.updateData(newState);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
class ObserverInstance {
|
|
27
|
-
private readonly props: any;
|
|
28
|
-
constructor(props: any) {
|
|
29
|
-
this.props = props;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
remove() {
|
|
33
|
-
const {detach, observer} = this.props;
|
|
34
|
-
detach && detach(observer);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default class Observer {
|
|
39
|
-
static SCHEMA = 'Observer';
|
|
40
|
-
|
|
41
|
-
static instances: any = {};
|
|
42
|
-
private schema: any;
|
|
43
|
-
private subject: Subject;
|
|
44
|
-
private data: null;
|
|
45
|
-
private loaded: boolean;
|
|
46
|
-
|
|
47
|
-
constructor(props: any) {
|
|
48
|
-
this.schema = props.schema;
|
|
49
|
-
this.subject = new Subject();
|
|
50
|
-
this.data = null;
|
|
51
|
-
this.loaded = false;
|
|
52
|
-
this.initilize();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static getInstance(schema: string, Class = Observer) {
|
|
56
|
-
schema = schema || Class.SCHEMA;
|
|
57
|
-
let instance = Observer.instances[schema];
|
|
58
|
-
if (!instance) {
|
|
59
|
-
instance = new Class({schema});
|
|
60
|
-
Observer.instances[schema] = instance;
|
|
61
|
-
}
|
|
62
|
-
return instance;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
initilize = () => {};
|
|
66
|
-
|
|
67
|
-
notify = (state: any) => {
|
|
68
|
-
this.subject.notify(state);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
attach = (observer: any) => {
|
|
72
|
-
this.subject.attach(observer);
|
|
73
|
-
return new ObserverInstance({observer, detach: this.detach});
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
detach = (observer: any) => {
|
|
77
|
-
this.subject.detach(observer);
|
|
78
|
-
};
|
|
79
|
-
}
|
|
File without changes
|
|
File without changes
|