@zhenryx/react-native-components 0.1.0 → 0.1.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/README.md +30 -9
- package/dist/Header/Header.d.ts +3 -0
- package/dist/Header/Header.d.ts.map +1 -1
- package/dist/Header/Header.js +8 -9
- package/package.json +6 -8
package/README.md
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
|
-
# @zhenryx/react-native-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
# @zhenryx/react-native-components
|
|
2
|
+
|
|
3
|
+
一个 React Native UI 组件库。
|
|
4
|
+
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @zhenryx/react-native-
|
|
8
|
+
npm install @zhenryx/react-native-components
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## 要求
|
|
12
|
-
- React >= 18.1.0
|
|
13
|
-
- React Native >= 0.70.0
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
- React >= 16.8.0
|
|
14
|
+
- React Native >= 0.60.0
|
|
15
|
+
- react-native-safe-area-context >= 3.0.0
|
|
16
|
+
|
|
17
|
+
## 快速开始
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install react-native-safe-area-context
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { ThemeProvider } from '@zhenryx/react-native-components';
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<ThemeProvider>
|
|
29
|
+
<YourApp />
|
|
30
|
+
</ThemeProvider>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 文档
|
|
36
|
+
|
|
37
|
+
详细的组件文档请查看 [src/docs](./src/docs) 目录。
|
package/dist/Header/Header.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ export interface HeaderProps {
|
|
|
4
4
|
title?: string;
|
|
5
5
|
backGroundColor?: string;
|
|
6
6
|
leftComponent?: ReactNode;
|
|
7
|
+
leftComponentStyle?: StyleProp<ViewStyle>;
|
|
7
8
|
centerComponent?: ReactNode;
|
|
9
|
+
centerComponentStyle?: StyleProp<ViewStyle>;
|
|
8
10
|
rightComponent?: ReactNode;
|
|
11
|
+
rightComponentStyle?: StyleProp<ViewStyle>;
|
|
9
12
|
containerStyle?: StyleProp<ViewStyle>;
|
|
10
13
|
titleStyle?: StyleProp<TextStyle>;
|
|
11
14
|
showBack?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/components/Header/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAW,SAAS,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAQ,SAAS,EAAE,SAAS,EAAE,SAAS,EAAgC,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/components/Header/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAW,SAAS,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAQ,SAAS,EAAE,SAAS,EAAE,SAAS,EAAgC,MAAM,cAAc,CAAA;AAIlG,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,kBAAkB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,oBAAoB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5C,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,mBAAmB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC3C,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAyDxC,CAAA"}
|
package/dist/Header/Header.js
CHANGED
|
@@ -26,21 +26,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.Header = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
|
-
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
30
29
|
const Text_1 = require("../Text/Text");
|
|
31
30
|
const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
|
|
32
|
-
const Header = ({ title = '自定义头部导航', backGroundColor, leftComponent, centerComponent, rightComponent, containerStyle, titleStyle: customTitleStyle, showBack = true, onBack }) => {
|
|
31
|
+
const Header = ({ title = '自定义头部导航', backGroundColor, leftComponent, leftComponentStyle, centerComponent, centerComponentStyle, rightComponent, rightComponentStyle, containerStyle, titleStyle: customTitleStyle, showBack = true, onBack }) => {
|
|
33
32
|
const { theme } = (0, ThemeConfig_1.useTheme)();
|
|
34
|
-
const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
35
33
|
const headerStyle = (0, react_1.useMemo)(() => ({
|
|
36
|
-
|
|
37
|
-
paddingTop: insets.top,
|
|
34
|
+
minHeight: theme['$header-height'] || 44,
|
|
38
35
|
backgroundColor: backGroundColor || theme['$header-background'] || 'transparent',
|
|
39
36
|
flexDirection: 'row',
|
|
40
37
|
justifyContent: 'space-between',
|
|
41
38
|
alignItems: 'center',
|
|
42
39
|
paddingHorizontal: theme['$header-spacing'] || 15,
|
|
43
|
-
}), [theme, backGroundColor
|
|
40
|
+
}), [theme, backGroundColor]);
|
|
44
41
|
const defaultTitleStyle = (0, react_1.useMemo)(() => ({
|
|
45
42
|
fontSize: theme['$header-title-fontsize'] || 18,
|
|
46
43
|
fontWeight: theme['$header-title-fontweight'] || '500'
|
|
@@ -60,13 +57,13 @@ const Header = ({ title = '自定义头部导航', backGroundColor, leftComponen
|
|
|
60
57
|
return <Text_1.Text style={[defaultTitleStyle, customTitleStyle]}>{title}</Text_1.Text>;
|
|
61
58
|
};
|
|
62
59
|
return (<react_native_1.View style={[headerStyle, containerStyle]}>
|
|
63
|
-
<react_native_1.View style={styles.leftContainer}>
|
|
60
|
+
<react_native_1.View style={[styles.leftContainer, leftComponentStyle]}>
|
|
64
61
|
{renderLeft()}
|
|
65
62
|
</react_native_1.View>
|
|
66
|
-
<react_native_1.View style={styles.centerContainer}>
|
|
63
|
+
<react_native_1.View style={[styles.centerContainer, centerComponentStyle]}>
|
|
67
64
|
{renderCenter()}
|
|
68
65
|
</react_native_1.View>
|
|
69
|
-
<react_native_1.View style={styles.rightContainer}>
|
|
66
|
+
<react_native_1.View style={[styles.rightContainer, rightComponentStyle]}>
|
|
70
67
|
{rightComponent}
|
|
71
68
|
</react_native_1.View>
|
|
72
69
|
</react_native_1.View>);
|
|
@@ -83,6 +80,8 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
83
80
|
},
|
|
84
81
|
rightContainer: {
|
|
85
82
|
flex: 1,
|
|
83
|
+
justifyContent: 'flex-end',
|
|
84
|
+
flexDirection: 'row',
|
|
86
85
|
},
|
|
87
86
|
icon_return: {
|
|
88
87
|
width: 18,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhenryx/react-native-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -25,14 +25,12 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/react": "18.
|
|
29
|
-
"@types/react-native": "0.
|
|
30
|
-
"typescript": "
|
|
31
|
-
"react-native-safe-area-context": "^4.8.0"
|
|
28
|
+
"@types/react": "^18.0.0",
|
|
29
|
+
"@types/react-native": "^0.60.0",
|
|
30
|
+
"typescript": "^4.0.0"
|
|
32
31
|
},
|
|
33
32
|
"peerDependencies": {
|
|
34
|
-
"react": ">=
|
|
35
|
-
"react-native": ">=0.
|
|
36
|
-
"react-native-safe-area-context": ">=4.0.0"
|
|
33
|
+
"react": ">=16.8.0",
|
|
34
|
+
"react-native": ">=0.60.0"
|
|
37
35
|
}
|
|
38
36
|
}
|