@zhenryx/react-native-components 0.0.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/CHANGELOG.md +12 -0
- package/README.md +16 -0
- package/dist/Button/Button.d.ts +24 -0
- package/dist/Button/Button.d.ts.map +1 -0
- package/dist/Button/Button.js +73 -0
- package/dist/Dialog/Dialog.d.ts +20 -0
- package/dist/Dialog/Dialog.d.ts.map +1 -0
- package/dist/Dialog/Dialog.js +92 -0
- package/dist/Empty/Empty.d.ts +13 -0
- package/dist/Empty/Empty.d.ts.map +1 -0
- package/dist/Empty/Empty.js +36 -0
- package/dist/Empty/assets/icon-empty.png +0 -0
- package/dist/Header/Header.d.ts +15 -0
- package/dist/Header/Header.d.ts.map +1 -0
- package/dist/Header/Header.js +90 -0
- package/dist/Header/assets/icon-return.png +0 -0
- package/dist/Overlay/Overlay.d.ts +11 -0
- package/dist/Overlay/Overlay.d.ts.map +1 -0
- package/dist/Overlay/Overlay.js +92 -0
- package/dist/Popup/Popup.d.ts +18 -0
- package/dist/Popup/Popup.d.ts.map +1 -0
- package/dist/Popup/Popup.js +152 -0
- package/dist/Popup/assets/icon-close.png +0 -0
- package/dist/Text/Text.d.ts +9 -0
- package/dist/Text/Text.d.ts.map +1 -0
- package/dist/Text/Text.js +25 -0
- package/dist/ThemeConfig/ThemeConfig.d.ts +13 -0
- package/dist/ThemeConfig/ThemeConfig.d.ts.map +1 -0
- package/dist/ThemeConfig/ThemeConfig.js +55 -0
- package/dist/ThemeConfig/styles/defaultTheme.d.ts +20 -0
- package/dist/ThemeConfig/styles/defaultTheme.d.ts.map +1 -0
- package/dist/ThemeConfig/styles/defaultTheme.js +35 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/package.json +36 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { ComponentType } from "react";
|
|
2
|
+
import { ImageSourcePropType, ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
|
+
type ButtonFill = 'solid' | 'outline';
|
|
4
|
+
export interface ButtonProps {
|
|
5
|
+
title: string;
|
|
6
|
+
InnerComponent?: ComponentType<any>;
|
|
7
|
+
linearGradientProps?: Record<string, any>;
|
|
8
|
+
fill?: ButtonFill;
|
|
9
|
+
width?: ViewStyle['width'];
|
|
10
|
+
fullWidth?: boolean;
|
|
11
|
+
height?: number;
|
|
12
|
+
onPress?: () => void;
|
|
13
|
+
color?: string;
|
|
14
|
+
feedbackEffect?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
icon?: ImageSourcePropType;
|
|
17
|
+
iconStyle?: StyleProp<ImageStyle>;
|
|
18
|
+
iconPosition?: 'left' | 'right';
|
|
19
|
+
buttonStyle?: StyleProp<ViewStyle>;
|
|
20
|
+
textStyle?: StyleProp<TextStyle>;
|
|
21
|
+
}
|
|
22
|
+
export declare const Button: React.FC<ButtonProps>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAW,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAa,SAAS,EAAE,SAAS,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAGxH,KAAK,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AACtC,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACnC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAClC;AACD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA4ExC,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Button = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const react_native_1 = require("react-native");
|
|
29
|
+
const Text_1 = require("../Text/Text");
|
|
30
|
+
const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
|
|
31
|
+
exports.Button = react_1.default.memo(({ InnerComponent = react_native_1.View, linearGradientProps, title, fill = 'solid', width = 120, fullWidth = false, height = 36, onPress = () => { }, color, disabled = false, feedbackEffect = true, icon, iconStyle, iconPosition = "right", buttonStyle, textStyle }) => {
|
|
32
|
+
const { theme } = (0, ThemeConfig_1.useTheme)();
|
|
33
|
+
const defaultColor = theme['$primary-color'] || '#e25829ff';
|
|
34
|
+
const actualColor = color || defaultColor;
|
|
35
|
+
const baseViewStyle = (0, react_1.useMemo)(() => {
|
|
36
|
+
const isOutline = fill === 'outline';
|
|
37
|
+
const isGradient = InnerComponent &&
|
|
38
|
+
(InnerComponent.displayName === 'LinearGradient' ||
|
|
39
|
+
InnerComponent.name === 'LinearGradient');
|
|
40
|
+
return {
|
|
41
|
+
borderRadius: theme['$button-border-radius'],
|
|
42
|
+
borderWidth: isOutline ? 1 : 0,
|
|
43
|
+
borderColor: isOutline ? actualColor : 'transparent',
|
|
44
|
+
backgroundColor: isGradient ? 'transparent' : (isOutline ? 'transparent' : actualColor),
|
|
45
|
+
width: fullWidth ? '100%' : width,
|
|
46
|
+
height: height,
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
justifyContent: 'center',
|
|
49
|
+
overflow: 'hidden',
|
|
50
|
+
flexDirection: iconPosition === 'right' ? 'row' : 'row-reverse',
|
|
51
|
+
};
|
|
52
|
+
}, [width, height, fill, actualColor, fullWidth, iconPosition, theme, InnerComponent]);
|
|
53
|
+
const textColor = fill === 'outline' ? actualColor : '#fff';
|
|
54
|
+
const defaultIconSize = height * 0.5;
|
|
55
|
+
const iconMargin = iconPosition === 'right'
|
|
56
|
+
? { marginLeft: 5 }
|
|
57
|
+
: { marginRight: 5 };
|
|
58
|
+
const pressableStyle = ({ pressed }) => [
|
|
59
|
+
{ opacity: disabled ? 0.5 : 1 },
|
|
60
|
+
pressed && feedbackEffect && !disabled && { opacity: 0.85 },
|
|
61
|
+
];
|
|
62
|
+
const InnerComponentStyle = [baseViewStyle, buttonStyle];
|
|
63
|
+
const content = (<>
|
|
64
|
+
<Text_1.Text style={[{ color: textColor }, textStyle]}>{title}</Text_1.Text>
|
|
65
|
+
{icon && (<react_native_1.Image source={icon} style={[{ width: defaultIconSize, height: defaultIconSize, ...iconMargin }, iconStyle]}/>)}
|
|
66
|
+
</>);
|
|
67
|
+
return (<react_native_1.Pressable style={pressableStyle} onPress={disabled ? undefined : onPress} disabled={disabled}>
|
|
68
|
+
<InnerComponent {...linearGradientProps} style={InnerComponentStyle}>
|
|
69
|
+
{content}
|
|
70
|
+
</InnerComponent>
|
|
71
|
+
</react_native_1.Pressable>);
|
|
72
|
+
});
|
|
73
|
+
exports.Button.displayName = 'Button';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextStyle } from 'react-native';
|
|
3
|
+
export interface DialogProps {
|
|
4
|
+
useModal?: boolean;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
type?: 'alert' | 'confirm';
|
|
7
|
+
title?: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
titleStyle?: TextStyle;
|
|
10
|
+
contentStyle?: TextStyle;
|
|
11
|
+
closeOnOverlayPress?: boolean;
|
|
12
|
+
round?: boolean;
|
|
13
|
+
confirmText?: string;
|
|
14
|
+
cancelText?: string;
|
|
15
|
+
onConfirm?: () => void;
|
|
16
|
+
onCancel?: () => void;
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare const Dialog: React.FC<DialogProps>;
|
|
20
|
+
//# sourceMappingURL=Dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA+B,SAAS,EAAE,MAAM,cAAc,CAAC;AAItE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AACD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAoDxC,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Dialog = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const Text_1 = require("../Text/Text");
|
|
10
|
+
const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
|
|
11
|
+
const Popup_1 = require("../Popup/Popup");
|
|
12
|
+
const Dialog = ({ useModal = true, visible = false, type = "alert", title = "提示", content, titleStyle, contentStyle, closeOnOverlayPress = false, round = false, confirmText = "确认", cancelText = '取消', onConfirm = () => null, onCancel = () => null, children }) => {
|
|
13
|
+
const { theme } = (0, ThemeConfig_1.useTheme)();
|
|
14
|
+
const confirmTextColor = theme['$primary-color'] || '#e25829ff';
|
|
15
|
+
const paddingHorizontal = theme['$dialog-padding-horizontal'] || 20;
|
|
16
|
+
const paddingTop = theme['$dialog-padding-top'] || 24;
|
|
17
|
+
const contentMarginVertical = theme['$dialog-content-margin-vertical'] || 10;
|
|
18
|
+
const handleConfirm = () => {
|
|
19
|
+
onConfirm();
|
|
20
|
+
};
|
|
21
|
+
const handleClose = () => {
|
|
22
|
+
onCancel();
|
|
23
|
+
};
|
|
24
|
+
const renderDialog = () => (<react_native_1.View style={styles.dialog_content_wrapper}>
|
|
25
|
+
<react_native_1.View style={[styles.dialog_text, { paddingHorizontal, paddingTop }]}>
|
|
26
|
+
{title && <Text_1.Text style={[styles.dialog_title, titleStyle]}>{title}</Text_1.Text>}
|
|
27
|
+
{content && <Text_1.Text style={[styles.dialog_content, { marginVertical: contentMarginVertical }, contentStyle]}>{content}</Text_1.Text>}
|
|
28
|
+
</react_native_1.View>
|
|
29
|
+
{children && <react_native_1.View style={styles.dialog_children}>{children}</react_native_1.View>}
|
|
30
|
+
<react_native_1.View style={styles.dialog_footer_button}>
|
|
31
|
+
{type === 'confirm' && <react_native_1.Pressable style={styles.dialog_footer_button_cancel} onPress={handleClose}><Text_1.Text style={styles.dialog_footer_button_cancel_text}>{cancelText}</Text_1.Text></react_native_1.Pressable>}
|
|
32
|
+
<react_native_1.Pressable style={styles.dialog_footer_button_confirm} onPress={handleConfirm}><Text_1.Text style={[styles.dialog_footer_button_confirm_text, { color: confirmTextColor }]}>{confirmText}</Text_1.Text></react_native_1.Pressable>
|
|
33
|
+
</react_native_1.View>
|
|
34
|
+
</react_native_1.View>);
|
|
35
|
+
return (<Popup_1.Popup useModal={useModal} visible={visible} closeable={false} closeOnOverlayPress={closeOnOverlayPress} onClose={handleClose} round={round}>
|
|
36
|
+
{renderDialog()}
|
|
37
|
+
</Popup_1.Popup>);
|
|
38
|
+
};
|
|
39
|
+
exports.Dialog = Dialog;
|
|
40
|
+
const styles = react_native_1.StyleSheet.create({
|
|
41
|
+
dialog_content_wrapper: {
|
|
42
|
+
width: '100%',
|
|
43
|
+
minHeight: 100,
|
|
44
|
+
},
|
|
45
|
+
dialog_text: {
|
|
46
|
+
width: '100%',
|
|
47
|
+
},
|
|
48
|
+
dialog_title: {
|
|
49
|
+
fontSize: 16,
|
|
50
|
+
fontWeight: '600',
|
|
51
|
+
color: '#222',
|
|
52
|
+
textAlign: 'center'
|
|
53
|
+
},
|
|
54
|
+
dialog_content: {
|
|
55
|
+
color: '#555',
|
|
56
|
+
fontSize: 14,
|
|
57
|
+
textAlign: 'center',
|
|
58
|
+
},
|
|
59
|
+
dialog_children: {
|
|
60
|
+
width: '100%',
|
|
61
|
+
},
|
|
62
|
+
dialog_footer_button: {
|
|
63
|
+
minHeight: 50,
|
|
64
|
+
flexDirection: 'row',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
borderTopWidth: react_native_1.StyleSheet.hairlineWidth,
|
|
67
|
+
borderTopColor: '#EEE',
|
|
68
|
+
width: '100%',
|
|
69
|
+
},
|
|
70
|
+
dialog_footer_button_cancel: {
|
|
71
|
+
flex: 1,
|
|
72
|
+
minHeight: 50,
|
|
73
|
+
justifyContent: 'center',
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
borderRightWidth: react_native_1.StyleSheet.hairlineWidth,
|
|
76
|
+
borderRightColor: '#F0F0F0',
|
|
77
|
+
},
|
|
78
|
+
dialog_footer_button_confirm: {
|
|
79
|
+
flex: 1,
|
|
80
|
+
minHeight: 50,
|
|
81
|
+
justifyContent: 'center',
|
|
82
|
+
alignItems: 'center',
|
|
83
|
+
},
|
|
84
|
+
dialog_footer_button_cancel_text: {
|
|
85
|
+
color: '#999',
|
|
86
|
+
fontSize: 16,
|
|
87
|
+
},
|
|
88
|
+
dialog_footer_button_confirm_text: {
|
|
89
|
+
fontSize: 16,
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
exports.Dialog.displayName = 'Dialog';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ImageSourcePropType, ViewStyle, StyleProp, TextStyle } from "react-native";
|
|
3
|
+
export interface EmptyProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
img?: ImageSourcePropType;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
desc?: string;
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
textStyle?: TextStyle;
|
|
11
|
+
}
|
|
12
|
+
export declare const Empty: React.FC<EmptyProps>;
|
|
13
|
+
//# sourceMappingURL=Empty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Empty.d.ts","sourceRoot":"","sources":["../../src/components/Empty/Empty.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA2B,mBAAmB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE7G,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,GAAG,CAAC,EAAE,mBAAmB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAID,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAmBtC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Empty = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const Text_1 = require("../Text/Text");
|
|
10
|
+
const defaultImage = require('./assets/icon-empty.png');
|
|
11
|
+
const Empty = ({ children, img, width = 120, height = 100, desc = "数据消失了~", style, textStyle, }) => {
|
|
12
|
+
return (<react_native_1.View style={[styles.empty_view, style]}>
|
|
13
|
+
<react_native_1.Image source={img || defaultImage} style={[styles.empty_icon, { width, height }]}/>
|
|
14
|
+
<Text_1.Text style={[styles.empty_text, textStyle]}>{desc}</Text_1.Text>
|
|
15
|
+
{children}
|
|
16
|
+
</react_native_1.View>);
|
|
17
|
+
};
|
|
18
|
+
exports.Empty = Empty;
|
|
19
|
+
exports.Empty.displayName = 'Empty';
|
|
20
|
+
const styles = react_native_1.StyleSheet.create({
|
|
21
|
+
empty_view: {
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
justifyContent: "center",
|
|
24
|
+
paddingVertical: 40,
|
|
25
|
+
paddingHorizontal: 20,
|
|
26
|
+
},
|
|
27
|
+
empty_icon: {
|
|
28
|
+
resizeMode: "contain",
|
|
29
|
+
},
|
|
30
|
+
empty_text: {
|
|
31
|
+
color: '#999',
|
|
32
|
+
fontSize: 14,
|
|
33
|
+
marginVertical: 15,
|
|
34
|
+
textAlign: "center",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { StyleProp, ViewStyle, TextStyle } from "react-native";
|
|
3
|
+
export interface HeaderProps {
|
|
4
|
+
title?: string;
|
|
5
|
+
backGroundColor?: string;
|
|
6
|
+
leftComponent?: ReactNode;
|
|
7
|
+
centerComponent?: ReactNode;
|
|
8
|
+
rightComponent?: ReactNode;
|
|
9
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
10
|
+
titleStyle?: StyleProp<TextStyle>;
|
|
11
|
+
showBack?: boolean;
|
|
12
|
+
onBack?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const Header: React.FC<HeaderProps>;
|
|
15
|
+
//# sourceMappingURL=Header.d.ts.map
|
|
@@ -0,0 +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;AAIlG,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,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,CAsDxC,CAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Header = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const react_native_1 = require("react-native");
|
|
29
|
+
const Text_1 = require("../Text/Text");
|
|
30
|
+
const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
|
|
31
|
+
const Header = ({ title = '自定义头部导航', backGroundColor, leftComponent, centerComponent, rightComponent, containerStyle, titleStyle: customTitleStyle, showBack = true, onBack }) => {
|
|
32
|
+
const { theme } = (0, ThemeConfig_1.useTheme)();
|
|
33
|
+
const headerStyle = (0, react_1.useMemo)(() => ({
|
|
34
|
+
height: theme['$header-height'] || 44,
|
|
35
|
+
backgroundColor: backGroundColor || theme['$header-background'] || 'transparent',
|
|
36
|
+
flexDirection: 'row',
|
|
37
|
+
justifyContent: 'space-between',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
paddingHorizontal: theme['$header-spacing'] || 15,
|
|
40
|
+
}), [theme, backGroundColor]);
|
|
41
|
+
const defaultTitleStyle = (0, react_1.useMemo)(() => ({
|
|
42
|
+
fontSize: theme['$header-title-fontsize'] || 18,
|
|
43
|
+
fontWeight: theme['$header-title-fontweight'] || '500'
|
|
44
|
+
}), [theme]);
|
|
45
|
+
const renderLeft = () => {
|
|
46
|
+
if (leftComponent)
|
|
47
|
+
return leftComponent;
|
|
48
|
+
if (!showBack || !onBack)
|
|
49
|
+
return null;
|
|
50
|
+
return (<react_native_1.Pressable onPress={onBack} hitSlop={10}>
|
|
51
|
+
<react_native_1.Image source={require('./assets/icon-return.png')} style={styles.icon_return}/>
|
|
52
|
+
</react_native_1.Pressable>);
|
|
53
|
+
};
|
|
54
|
+
const renderCenter = () => {
|
|
55
|
+
if (centerComponent)
|
|
56
|
+
return centerComponent;
|
|
57
|
+
return <Text_1.Text style={[defaultTitleStyle, customTitleStyle]}>{title}</Text_1.Text>;
|
|
58
|
+
};
|
|
59
|
+
return (<react_native_1.View style={[headerStyle, containerStyle]}>
|
|
60
|
+
<react_native_1.View style={styles.leftContainer}>
|
|
61
|
+
{renderLeft()}
|
|
62
|
+
</react_native_1.View>
|
|
63
|
+
<react_native_1.View style={styles.centerContainer}>
|
|
64
|
+
{renderCenter()}
|
|
65
|
+
</react_native_1.View>
|
|
66
|
+
<react_native_1.View style={styles.rightContainer}>
|
|
67
|
+
{rightComponent}
|
|
68
|
+
</react_native_1.View>
|
|
69
|
+
</react_native_1.View>);
|
|
70
|
+
};
|
|
71
|
+
exports.Header = Header;
|
|
72
|
+
const styles = react_native_1.StyleSheet.create({
|
|
73
|
+
leftContainer: {
|
|
74
|
+
flex: 1,
|
|
75
|
+
},
|
|
76
|
+
centerContainer: {
|
|
77
|
+
flex: 2,
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
justifyContent: 'center',
|
|
80
|
+
},
|
|
81
|
+
rightContainer: {
|
|
82
|
+
flex: 1,
|
|
83
|
+
},
|
|
84
|
+
icon_return: {
|
|
85
|
+
width: 18,
|
|
86
|
+
height: 22,
|
|
87
|
+
resizeMode: 'contain'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
exports.Header.displayName = 'Header';
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
export interface OverLayProps {
|
|
4
|
+
useModal?: boolean;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
visible: boolean;
|
|
7
|
+
overlayStyle?: StyleProp<ViewStyle>;
|
|
8
|
+
onOverlayPress?(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare const OverLay: React.FC<OverLayProps>;
|
|
11
|
+
//# sourceMappingURL=Overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Overlay.d.ts","sourceRoot":"","sources":["../../src/components/Overlay/Overlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAEpE,OAAO,EAGL,SAAS,EACT,SAAS,EAIV,MAAM,cAAc,CAAC;AACtB,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,cAAc,CAAC,IAAI,IAAI,CAAC;CACzB;AAGD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAgF1C,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.OverLay = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
|
|
29
|
+
const react_native_1 = require("react-native");
|
|
30
|
+
const OverLay = ({ useModal = true, children, visible = false, overlayStyle, onOverlayPress, }) => {
|
|
31
|
+
const { theme } = (0, ThemeConfig_1.useTheme)();
|
|
32
|
+
const [realVisible, setRealVisible] = (0, react_1.useState)(visible);
|
|
33
|
+
const opacityAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(visible ? 1 : 0)).current;
|
|
34
|
+
const fadeInstance = (0, react_1.useRef)(null);
|
|
35
|
+
(0, react_1.useEffect)(() => {
|
|
36
|
+
if (visible) {
|
|
37
|
+
setRealVisible(true);
|
|
38
|
+
}
|
|
39
|
+
if (fadeInstance.current) {
|
|
40
|
+
fadeInstance.current.stop();
|
|
41
|
+
}
|
|
42
|
+
fadeInstance.current = react_native_1.Animated.timing(opacityAnim, {
|
|
43
|
+
toValue: visible ? 1 : 0,
|
|
44
|
+
duration: 250,
|
|
45
|
+
useNativeDriver: true,
|
|
46
|
+
});
|
|
47
|
+
fadeInstance.current.start(({ finished }) => {
|
|
48
|
+
if (finished && fadeInstance.current) {
|
|
49
|
+
fadeInstance.current = null;
|
|
50
|
+
if (!visible) {
|
|
51
|
+
setRealVisible(false);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return () => {
|
|
56
|
+
if (fadeInstance.current) {
|
|
57
|
+
fadeInstance.current.stop();
|
|
58
|
+
fadeInstance.current = null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}, [visible]);
|
|
62
|
+
const dynamicBg = theme['$overlay-bg-color'] || 'rgba(0, 0, 0, 0.35)';
|
|
63
|
+
const containerStyle = (0, react_1.useMemo)(() => [
|
|
64
|
+
styles.container,
|
|
65
|
+
{ backgroundColor: dynamicBg, opacity: opacityAnim },
|
|
66
|
+
overlayStyle,
|
|
67
|
+
], [dynamicBg, opacityAnim, overlayStyle]);
|
|
68
|
+
const renderContent = () => (<react_native_1.Animated.View style={containerStyle}>
|
|
69
|
+
{onOverlayPress && (<react_native_1.Pressable style={react_native_1.StyleSheet.absoluteFill} onPress={onOverlayPress}/>)}
|
|
70
|
+
<react_native_1.View style={styles.content} pointerEvents="box-none">
|
|
71
|
+
{children}
|
|
72
|
+
</react_native_1.View>
|
|
73
|
+
</react_native_1.Animated.View>);
|
|
74
|
+
if (useModal) {
|
|
75
|
+
return (<react_native_1.Modal visible={realVisible} transparent animationType='none' statusBarTranslucent onRequestClose={onOverlayPress}>
|
|
76
|
+
{renderContent()}
|
|
77
|
+
</react_native_1.Modal>);
|
|
78
|
+
}
|
|
79
|
+
return realVisible ? renderContent() : null;
|
|
80
|
+
};
|
|
81
|
+
exports.OverLay = OverLay;
|
|
82
|
+
const styles = react_native_1.StyleSheet.create({
|
|
83
|
+
container: {
|
|
84
|
+
...react_native_1.StyleSheet.absoluteFillObject,
|
|
85
|
+
},
|
|
86
|
+
content: {
|
|
87
|
+
flex: 1,
|
|
88
|
+
alignItems: 'center',
|
|
89
|
+
justifyContent: 'center',
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
exports.OverLay.displayName = 'OverLay';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
export interface PopupProps {
|
|
4
|
+
useModal?: boolean;
|
|
5
|
+
visible?: boolean;
|
|
6
|
+
position?: 'bottom' | 'center' | 'top';
|
|
7
|
+
height?: number;
|
|
8
|
+
width?: number | string;
|
|
9
|
+
round?: boolean;
|
|
10
|
+
closeable?: boolean;
|
|
11
|
+
closeOnOverlayPress?: boolean;
|
|
12
|
+
overlayStyle?: StyleProp<ViewStyle>;
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const Popup: React.FC<PopupProps>;
|
|
18
|
+
//# sourceMappingURL=Popup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popup.d.ts","sourceRoot":"","sources":["../../src/components/Popup/Popup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;AAEf,OAAO,EAGL,SAAS,EACT,SAAS,EAGV,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAID,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAmKtC,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Popup = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const Overlay_1 = require("../Overlay/Overlay");
|
|
29
|
+
const react_native_1 = require("react-native");
|
|
30
|
+
const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
|
|
31
|
+
const ANIMATION_DURATION = 250;
|
|
32
|
+
const Popup = (props) => {
|
|
33
|
+
const { useModal = true, visible = false, position = 'center', height, width, round = false, closeable = false, closeOnOverlayPress = false, overlayStyle, style, children, onClose, } = props;
|
|
34
|
+
const { theme } = (0, ThemeConfig_1.useTheme)();
|
|
35
|
+
const radius = theme['$popup-border-radius'] ?? 10;
|
|
36
|
+
const minHeight = theme['$popup-height'] ?? 100;
|
|
37
|
+
const closeIconWidth = theme['$popup-closeicon-width'] ?? 12;
|
|
38
|
+
const closeIconHeight = theme['$popup-closeicon-height'] ?? 12;
|
|
39
|
+
const centerPopRadius = theme['$popup-center-border-radius'] || 10;
|
|
40
|
+
const animatedValue = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
41
|
+
const fadeInstance = (0, react_1.useRef)(null);
|
|
42
|
+
const [realVisible, setRealVisible] = (0, react_1.useState)(visible);
|
|
43
|
+
(0, react_1.useEffect)(() => {
|
|
44
|
+
if (visible) {
|
|
45
|
+
setRealVisible(true);
|
|
46
|
+
}
|
|
47
|
+
if (fadeInstance.current) {
|
|
48
|
+
fadeInstance.current.stop();
|
|
49
|
+
}
|
|
50
|
+
fadeInstance.current = react_native_1.Animated.timing(animatedValue, {
|
|
51
|
+
toValue: visible ? 1 : 0,
|
|
52
|
+
duration: ANIMATION_DURATION,
|
|
53
|
+
easing: visible ? react_native_1.Easing.out(react_native_1.Easing.cubic) : react_native_1.Easing.in(react_native_1.Easing.cubic),
|
|
54
|
+
useNativeDriver: true,
|
|
55
|
+
});
|
|
56
|
+
fadeInstance.current.start(({ finished }) => {
|
|
57
|
+
if (finished && fadeInstance.current) {
|
|
58
|
+
fadeInstance.current = null;
|
|
59
|
+
if (!visible) {
|
|
60
|
+
setRealVisible(false);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return () => {
|
|
65
|
+
if (fadeInstance.current) {
|
|
66
|
+
fadeInstance.current.stop();
|
|
67
|
+
fadeInstance.current = null;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}, [visible]);
|
|
71
|
+
const baseStyle = (0, react_1.useMemo)(() => {
|
|
72
|
+
const base = {
|
|
73
|
+
backgroundColor: '#fff',
|
|
74
|
+
...(height ? { height } : { minHeight }),
|
|
75
|
+
width: position === 'center' ? width ?? 300 : '100%',
|
|
76
|
+
};
|
|
77
|
+
if (position !== 'center') {
|
|
78
|
+
base.position = 'absolute';
|
|
79
|
+
base.left = 0;
|
|
80
|
+
base.right = 0;
|
|
81
|
+
if (position === 'bottom') {
|
|
82
|
+
base.bottom = 0;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
base.top = 0;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (round) {
|
|
89
|
+
if (position === 'center') {
|
|
90
|
+
base.borderRadius = centerPopRadius;
|
|
91
|
+
}
|
|
92
|
+
else if (position === 'bottom') {
|
|
93
|
+
base.borderTopLeftRadius = radius;
|
|
94
|
+
base.borderTopRightRadius = radius;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
base.borderBottomLeftRadius = radius;
|
|
98
|
+
base.borderBottomRightRadius = radius;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return base;
|
|
102
|
+
}, [position, width, height, minHeight, round, radius, centerPopRadius]);
|
|
103
|
+
const animatedStyle = (0, react_1.useMemo)(() => {
|
|
104
|
+
if (position === 'center') {
|
|
105
|
+
return {
|
|
106
|
+
opacity: animatedValue,
|
|
107
|
+
transform: [
|
|
108
|
+
{
|
|
109
|
+
scale: animatedValue.interpolate({
|
|
110
|
+
inputRange: [0, 1],
|
|
111
|
+
outputRange: [0.9, 1],
|
|
112
|
+
}),
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const distance = height || minHeight;
|
|
118
|
+
return {
|
|
119
|
+
transform: [
|
|
120
|
+
{
|
|
121
|
+
translateY: animatedValue.interpolate({
|
|
122
|
+
inputRange: [0, 1],
|
|
123
|
+
outputRange: position === 'bottom' ? [distance, 0] : [-distance, 0],
|
|
124
|
+
}),
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
}, [position, animatedValue, height, minHeight]);
|
|
129
|
+
const closeIconStyle = (0, react_1.useMemo)(() => ({
|
|
130
|
+
width: closeIconWidth,
|
|
131
|
+
height: closeIconHeight,
|
|
132
|
+
}), [closeIconWidth, closeIconHeight]);
|
|
133
|
+
const closeButtonPressableStyle = (0, react_1.useMemo)(() => ({
|
|
134
|
+
position: 'absolute',
|
|
135
|
+
right: 10,
|
|
136
|
+
[position === 'top' ? 'bottom' : 'top']: 10,
|
|
137
|
+
zIndex: 999,
|
|
138
|
+
}), [position]);
|
|
139
|
+
if (!realVisible) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return (<Overlay_1.OverLay useModal={useModal} visible={realVisible} overlayStyle={overlayStyle} onOverlayPress={closeOnOverlayPress ? onClose : undefined}>
|
|
143
|
+
<react_native_1.Animated.View style={[baseStyle, animatedStyle, style]}>
|
|
144
|
+
{children}
|
|
145
|
+
{closeable && (<react_native_1.Pressable hitSlop={15} onPress={onClose} style={closeButtonPressableStyle}>
|
|
146
|
+
<react_native_1.Image source={require('./assets/icon-close.png')} style={closeIconStyle}/>
|
|
147
|
+
</react_native_1.Pressable>)}
|
|
148
|
+
</react_native_1.Animated.View>
|
|
149
|
+
</Overlay_1.OverLay>);
|
|
150
|
+
};
|
|
151
|
+
exports.Popup = Popup;
|
|
152
|
+
exports.Popup.displayName = 'Popup';
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/components/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAkB,SAAS,EAAwB,MAAM,cAAc,CAAC;AAC/E;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAUpC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Text = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* 自定义 Text 组件
|
|
11
|
+
* 自动修复老安卓机型字体宽度测量不准确导致文本被截断的问题(该问题出现很多年,官方没有修复)
|
|
12
|
+
* 找了几种解决办法,目前这样简便易懂
|
|
13
|
+
*/
|
|
14
|
+
const Text = ({ style, ...props }) => {
|
|
15
|
+
const mergedStyle = react_native_1.StyleSheet.flatten([
|
|
16
|
+
react_native_1.Platform.select({
|
|
17
|
+
android: {
|
|
18
|
+
fontFamily: 'Roboto', //这里随便什么都可以
|
|
19
|
+
},
|
|
20
|
+
}),
|
|
21
|
+
style,
|
|
22
|
+
]);
|
|
23
|
+
return <react_native_1.Text style={mergedStyle} {...props}/>;
|
|
24
|
+
};
|
|
25
|
+
exports.Text = Text;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import defaultTheme from "./styles/defaultTheme";
|
|
3
|
+
export type Theme = typeof defaultTheme;
|
|
4
|
+
interface ThemeContextValue {
|
|
5
|
+
theme: Theme;
|
|
6
|
+
setTheme: (theme: Theme) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const ThemeProvider: React.FC<{
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const useTheme: () => ThemeContextValue;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=ThemeConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeConfig.d.ts","sourceRoot":"","sources":["../../src/components/ThemeConfig/ThemeConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,SAAS,EAAwB,MAAM,OAAO,CAAC;AAC9E,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,MAAM,MAAM,KAAK,GAAG,OAAO,YAAY,CAAC;AACxC,UAAU,iBAAiB;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAWD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,CAO3D,CAAA;AACD,eAAO,MAAM,QAAQ,yBAIpB,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.useTheme = exports.ThemeProvider = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const defaultTheme_1 = __importDefault(require("./styles/defaultTheme"));
|
|
32
|
+
const warnNoProvider = () => {
|
|
33
|
+
if (__DEV__) {
|
|
34
|
+
console.warn('ThemeProvider没有应用~');
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const defaultContextValue = {
|
|
38
|
+
theme: defaultTheme_1.default,
|
|
39
|
+
setTheme: warnNoProvider,
|
|
40
|
+
};
|
|
41
|
+
const ThemeContext = (0, react_1.createContext)(null);
|
|
42
|
+
const ThemeProvider = ({ children }) => {
|
|
43
|
+
const [theme, setTheme] = (0, react_1.useState)(defaultTheme_1.default);
|
|
44
|
+
return (<ThemeContext.Provider value={{ theme, setTheme }}>
|
|
45
|
+
{children}
|
|
46
|
+
</ThemeContext.Provider>);
|
|
47
|
+
};
|
|
48
|
+
exports.ThemeProvider = ThemeProvider;
|
|
49
|
+
const useTheme = () => {
|
|
50
|
+
const context = (0, react_1.useContext)(ThemeContext);
|
|
51
|
+
if (!context)
|
|
52
|
+
return defaultContextValue;
|
|
53
|
+
return context;
|
|
54
|
+
};
|
|
55
|
+
exports.useTheme = useTheme;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const defaultTheme: {
|
|
2
|
+
'$header-height': number;
|
|
3
|
+
'$header-background': string;
|
|
4
|
+
'$header-title-fontsize': number;
|
|
5
|
+
'$header-title-fontweight': string;
|
|
6
|
+
'$header-spacing': number;
|
|
7
|
+
'$button-border-radius': number;
|
|
8
|
+
'$overlay-bg-color': string;
|
|
9
|
+
'$popup-closeicon-width': number;
|
|
10
|
+
'$popup-closeicon-height': number;
|
|
11
|
+
'$popup-height': number;
|
|
12
|
+
'$popup-center-border-radius': number;
|
|
13
|
+
'$popup-border-radius': number;
|
|
14
|
+
'$dialog-padding-horizontal': number;
|
|
15
|
+
'$dialog-padding-top': number;
|
|
16
|
+
'$dialog-content-margin-vertical': number;
|
|
17
|
+
'$primary-color': string;
|
|
18
|
+
};
|
|
19
|
+
export default defaultTheme;
|
|
20
|
+
//# sourceMappingURL=defaultTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultTheme.d.ts","sourceRoot":"","sources":["../../../src/components/ThemeConfig/styles/defaultTheme.ts"],"names":[],"mappings":"AA+BA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;CAAgB,CAAA;AAClC,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commonStyles = {
|
|
4
|
+
'$primary-color': '#e25829ff',
|
|
5
|
+
};
|
|
6
|
+
const componentsStyles = {
|
|
7
|
+
//Header
|
|
8
|
+
'$header-height': 44,
|
|
9
|
+
'$header-background': 'transparent',
|
|
10
|
+
'$header-title-fontsize': 18,
|
|
11
|
+
'$header-title-fontweight': "500",
|
|
12
|
+
'$header-spacing': 15,
|
|
13
|
+
//Button
|
|
14
|
+
'$button-border-radius': 18,
|
|
15
|
+
//OverLay
|
|
16
|
+
'$overlay-bg-color': 'rgba(0, 0, 0, 0.35)',
|
|
17
|
+
//Popup
|
|
18
|
+
'$popup-closeicon-width': 12,
|
|
19
|
+
'$popup-closeicon-height': 12,
|
|
20
|
+
'$popup-height': 100,
|
|
21
|
+
'$popup-center-border-radius': 10,
|
|
22
|
+
'$popup-border-radius': 10,
|
|
23
|
+
//Dialog
|
|
24
|
+
'$dialog-padding-horizontal': 20,
|
|
25
|
+
'$dialog-padding-top': 24,
|
|
26
|
+
'$dialog-content-margin-vertical': 15,
|
|
27
|
+
};
|
|
28
|
+
const createTheme = () => {
|
|
29
|
+
return {
|
|
30
|
+
...commonStyles,
|
|
31
|
+
...componentsStyles
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const defaultTheme = createTheme();
|
|
35
|
+
exports.default = defaultTheme;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { Button } from './Button/Button';
|
|
2
|
+
export type { ButtonProps } from './Button/Button';
|
|
3
|
+
export { Dialog } from './Dialog/Dialog';
|
|
4
|
+
export type { DialogProps } from './Dialog/Dialog';
|
|
5
|
+
export { Empty } from './Empty/Empty';
|
|
6
|
+
export type { EmptyProps } from './Empty/Empty';
|
|
7
|
+
export { Header } from './Header/Header';
|
|
8
|
+
export type { HeaderProps } from './Header/Header';
|
|
9
|
+
export { OverLay } from './Overlay/Overlay';
|
|
10
|
+
export type { OverLayProps } from './Overlay/Overlay';
|
|
11
|
+
export { Popup } from './Popup/Popup';
|
|
12
|
+
export type { PopupProps } from './Popup/Popup';
|
|
13
|
+
export { Text } from './Text/Text';
|
|
14
|
+
export { ThemeProvider, useTheme } from './ThemeConfig/ThemeConfig';
|
|
15
|
+
export type { Theme } from './ThemeConfig/ThemeConfig';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTheme = exports.ThemeProvider = exports.Text = exports.Popup = exports.OverLay = exports.Header = exports.Empty = exports.Dialog = exports.Button = void 0;
|
|
4
|
+
var Button_1 = require("./Button/Button");
|
|
5
|
+
Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return Button_1.Button; } });
|
|
6
|
+
var Dialog_1 = require("./Dialog/Dialog");
|
|
7
|
+
Object.defineProperty(exports, "Dialog", { enumerable: true, get: function () { return Dialog_1.Dialog; } });
|
|
8
|
+
var Empty_1 = require("./Empty/Empty");
|
|
9
|
+
Object.defineProperty(exports, "Empty", { enumerable: true, get: function () { return Empty_1.Empty; } });
|
|
10
|
+
var Header_1 = require("./Header/Header");
|
|
11
|
+
Object.defineProperty(exports, "Header", { enumerable: true, get: function () { return Header_1.Header; } });
|
|
12
|
+
var Overlay_1 = require("./Overlay/Overlay");
|
|
13
|
+
Object.defineProperty(exports, "OverLay", { enumerable: true, get: function () { return Overlay_1.OverLay; } });
|
|
14
|
+
var Popup_1 = require("./Popup/Popup");
|
|
15
|
+
Object.defineProperty(exports, "Popup", { enumerable: true, get: function () { return Popup_1.Popup; } });
|
|
16
|
+
var Text_1 = require("./Text/Text");
|
|
17
|
+
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return Text_1.Text; } });
|
|
18
|
+
var ThemeConfig_1 = require("./ThemeConfig/ThemeConfig");
|
|
19
|
+
Object.defineProperty(exports, "ThemeProvider", { enumerable: true, get: function () { return ThemeConfig_1.ThemeProvider; } });
|
|
20
|
+
Object.defineProperty(exports, "useTheme", { enumerable: true, get: function () { return ThemeConfig_1.useTheme; } });
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zhenryx/react-native-components",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build": "tsc && node src/scripts/copy-assets.mjs",
|
|
9
|
+
"prepare": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"react-native",
|
|
13
|
+
"ui",
|
|
14
|
+
"components"
|
|
15
|
+
],
|
|
16
|
+
"author": "zhenryx",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"description": "A React Native UI component library",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"CHANGELOG.md"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/react": "18.2.0",
|
|
29
|
+
"@types/react-native": "0.70.0",
|
|
30
|
+
"typescript": "5.0.4"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": ">=18.1.0",
|
|
34
|
+
"react-native": ">=0.70.0"
|
|
35
|
+
}
|
|
36
|
+
}
|