@zhenryx/react-native-components 0.0.1 → 0.0.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,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { TextStyle } from 'react-native';
3
3
  export interface DialogProps {
4
- useModal?: boolean;
5
4
  visible: boolean;
6
5
  type?: 'alert' | 'confirm';
7
6
  title?: string;
@@ -1 +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"}
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,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,CAkDxC,CAAC"}
@@ -9,7 +9,7 @@ const react_native_1 = require("react-native");
9
9
  const Text_1 = require("../Text/Text");
10
10
  const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
11
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 }) => {
12
+ const Dialog = ({ visible = false, type = "alert", title = "提示", content, titleStyle, contentStyle, closeOnOverlayPress = false, round = false, confirmText = "确认", cancelText = '取消', onConfirm = () => null, onCancel = () => null, children }) => {
13
13
  const { theme } = (0, ThemeConfig_1.useTheme)();
14
14
  const confirmTextColor = theme['$primary-color'] || '#e25829ff';
15
15
  const paddingHorizontal = theme['$dialog-padding-horizontal'] || 20;
@@ -32,7 +32,7 @@ const Dialog = ({ useModal = true, visible = false, type = "alert", title = "提
32
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
33
  </react_native_1.View>
34
34
  </react_native_1.View>);
35
- return (<Popup_1.Popup useModal={useModal} visible={visible} closeable={false} closeOnOverlayPress={closeOnOverlayPress} onClose={handleClose} round={round}>
35
+ return (<Popup_1.Popup visible={visible} closeable={false} closeOnOverlayPress={closeOnOverlayPress} onClose={handleClose} round={round}>
36
36
  {renderDialog()}
37
37
  </Popup_1.Popup>);
38
38
  };
@@ -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;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"}
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;AAKlG,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,CAwDxC,CAAA"}
@@ -26,18 +26,21 @@ 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");
29
30
  const Text_1 = require("../Text/Text");
30
31
  const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
31
32
  const Header = ({ title = '自定义头部导航', backGroundColor, leftComponent, centerComponent, rightComponent, containerStyle, titleStyle: customTitleStyle, showBack = true, onBack }) => {
32
33
  const { theme } = (0, ThemeConfig_1.useTheme)();
34
+ const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
33
35
  const headerStyle = (0, react_1.useMemo)(() => ({
34
- height: theme['$header-height'] || 44,
36
+ height: (theme['$header-height'] || 44) + insets.top,
37
+ paddingTop: insets.top,
35
38
  backgroundColor: backGroundColor || theme['$header-background'] || 'transparent',
36
39
  flexDirection: 'row',
37
40
  justifyContent: 'space-between',
38
41
  alignItems: 'center',
39
42
  paddingHorizontal: theme['$header-spacing'] || 15,
40
- }), [theme, backGroundColor]);
43
+ }), [theme, backGroundColor, insets.top]);
41
44
  const defaultTitleStyle = (0, react_1.useMemo)(() => ({
42
45
  fontSize: theme['$header-title-fontsize'] || 18,
43
46
  fontWeight: theme['$header-title-fontweight'] || '500'
@@ -1,11 +1,10 @@
1
- import React from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
3
  export interface OverLayProps {
4
- useModal?: boolean;
5
4
  children?: React.ReactNode;
6
5
  visible: boolean;
7
6
  overlayStyle?: StyleProp<ViewStyle>;
8
- onOverlayPress?(): void;
7
+ onOverlayPress?: () => void;
9
8
  }
10
9
  export declare const OverLay: React.FC<OverLayProps>;
11
10
  //# sourceMappingURL=Overlay.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"Overlay.d.ts","sourceRoot":"","sources":["../../src/components/Overlay/Overlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAKL,SAAS,EACT,SAAS,EAEV,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AACD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA8C1C,CAAC"}
@@ -25,68 +25,47 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.OverLay = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
- const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
29
28
  const react_native_1 = require("react-native");
30
- const OverLay = ({ useModal = true, children, visible = false, overlayStyle, onOverlayPress, }) => {
29
+ const ThemeConfig_1 = require("../ThemeConfig/ThemeConfig");
30
+ const OverLay = ({ children, visible, overlayStyle, onOverlayPress, }) => {
31
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);
32
+ const [mounted, setMounted] = (0, react_1.useState)(visible);
33
+ const opacity = (0, react_1.useRef)(new react_native_1.Animated.Value(visible ? 1 : 0)).current;
35
34
  (0, react_1.useEffect)(() => {
36
35
  if (visible) {
37
- setRealVisible(true);
38
- }
39
- if (fadeInstance.current) {
40
- fadeInstance.current.stop();
36
+ setMounted(true);
41
37
  }
42
- fadeInstance.current = react_native_1.Animated.timing(opacityAnim, {
38
+ react_native_1.Animated.timing(opacity, {
43
39
  toValue: visible ? 1 : 0,
44
40
  duration: 250,
41
+ easing: react_native_1.Easing.out(react_native_1.Easing.cubic),
45
42
  useNativeDriver: true,
46
- });
47
- fadeInstance.current.start(({ finished }) => {
48
- if (finished && fadeInstance.current) {
49
- fadeInstance.current = null;
50
- if (!visible) {
51
- setRealVisible(false);
52
- }
43
+ }).start(({ finished }) => {
44
+ if (finished && !visible) {
45
+ setMounted(false);
53
46
  }
54
47
  });
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}>
48
+ }, [visible, opacity]);
49
+ if (!mounted)
50
+ return null;
51
+ return (<react_native_1.Animated.View style={[
52
+ react_native_1.StyleSheet.absoluteFill,
53
+ { backgroundColor: theme['$overlay-bg-color'] ?? 'rgba(0,0,0,0.35)' },
54
+ { opacity },
55
+ overlayStyle,
56
+ ]}>
69
57
  {onOverlayPress && (<react_native_1.Pressable style={react_native_1.StyleSheet.absoluteFill} onPress={onOverlayPress}/>)}
70
58
  <react_native_1.View style={styles.content} pointerEvents="box-none">
71
59
  {children}
72
60
  </react_native_1.View>
73
61
  </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
62
  };
81
63
  exports.OverLay = OverLay;
64
+ exports.OverLay.displayName = 'OverLay';
82
65
  const styles = react_native_1.StyleSheet.create({
83
- container: {
84
- ...react_native_1.StyleSheet.absoluteFillObject,
85
- },
86
66
  content: {
87
67
  flex: 1,
88
68
  alignItems: 'center',
89
69
  justifyContent: 'center',
90
- }
70
+ },
91
71
  });
92
- exports.OverLay.displayName = 'OverLay';
@@ -1,7 +1,6 @@
1
- import React from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
3
  export interface PopupProps {
4
- useModal?: boolean;
5
4
  visible?: boolean;
6
5
  position?: 'bottom' | 'center' | 'top';
7
6
  height?: number;
@@ -1 +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"}
1
+ {"version":3,"file":"Popup.d.ts","sourceRoot":"","sources":["../../src/components/Popup/Popup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAGL,SAAS,EACT,SAAS,EAGV,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,UAAU;IACzB,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;AAED,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAuHtC,CAAC"}
@@ -25,125 +25,95 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Popup = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
- const Overlay_1 = require("../Overlay/Overlay");
29
28
  const react_native_1 = require("react-native");
29
+ const Overlay_1 = require("../Overlay/Overlay");
30
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;
31
+ const DURATION = 250;
32
+ const Popup = ({ visible = false, position = 'center', height, width, round = false, closeable = false, closeOnOverlayPress = false, overlayStyle, style, children, onClose, }) => {
34
33
  const { theme } = (0, ThemeConfig_1.useTheme)();
35
34
  const radius = theme['$popup-border-radius'] ?? 10;
36
35
  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);
36
+ const centerRadius = theme['$popup-center-border-radius'] ?? 10;
37
+ const closeIconSize = {
38
+ width: theme['$popup-closeicon-width'] ?? 12,
39
+ height: theme['$popup-closeicon-height'] ?? 12,
40
+ };
41
+ const progress = (0, react_1.useRef)(new react_native_1.Animated.Value(visible ? 1 : 0)).current;
42
+ const [mounted, setMounted] = (0, react_1.useState)(visible);
43
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, {
44
+ if (visible)
45
+ setMounted(true);
46
+ react_native_1.Animated.timing(progress, {
51
47
  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),
48
+ duration: DURATION,
49
+ easing: visible
50
+ ? react_native_1.Easing.out(react_native_1.Easing.cubic)
51
+ : react_native_1.Easing.in(react_native_1.Easing.cubic),
54
52
  useNativeDriver: true,
55
- });
56
- fadeInstance.current.start(({ finished }) => {
57
- if (finished && fadeInstance.current) {
58
- fadeInstance.current = null;
59
- if (!visible) {
60
- setRealVisible(false);
61
- }
53
+ }).start(({ finished }) => {
54
+ if (finished && !visible) {
55
+ setMounted(false);
62
56
  }
63
57
  });
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
- }
58
+ }, [visible, progress]);
59
+ if (!mounted)
60
+ return null;
61
+ const baseStyle = {
62
+ backgroundColor: '#fff',
63
+ ...(height ? { height } : { minHeight }),
64
+ width: position === 'center'
65
+ ? (width ?? 300)
66
+ : '100%',
67
+ };
68
+ if (position !== 'center') {
69
+ //上弹出层or下弹出层
70
+ Object.assign(baseStyle, {
71
+ position: 'absolute',
72
+ left: 0,
73
+ right: 0,
74
+ ...(position === 'bottom' ? { bottom: 0 } : { top: 0 }),
75
+ });
76
+ }
77
+ if (round) {
78
+ if (position === 'center') {
79
+ baseStyle.borderRadius = centerRadius;
87
80
  }
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
- }
81
+ else if (position === 'bottom') {
82
+ baseStyle.borderTopLeftRadius = radius;
83
+ baseStyle.borderTopRightRadius = radius;
100
84
  }
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
- };
85
+ else {
86
+ baseStyle.borderBottomLeftRadius = radius;
87
+ baseStyle.borderBottomRightRadius = radius;
116
88
  }
117
- const distance = height || minHeight;
118
- return {
89
+ }
90
+ const animatedStyle = position === 'center'
91
+ ? { opacity: progress }
92
+ : {
119
93
  transform: [
120
94
  {
121
- translateY: animatedValue.interpolate({
95
+ translateY: progress.interpolate({
122
96
  inputRange: [0, 1],
123
- outputRange: position === 'bottom' ? [distance, 0] : [-distance, 0],
97
+ outputRange: [
98
+ position === 'bottom'
99
+ ? height ?? minHeight
100
+ : -(height ?? minHeight),
101
+ 0,
102
+ ],
124
103
  }),
125
104
  },
126
105
  ],
127
106
  };
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}>
107
+ return (<Overlay_1.OverLay visible={mounted} overlayStyle={overlayStyle} onOverlayPress={closeOnOverlayPress ? onClose : undefined}>
143
108
  <react_native_1.Animated.View style={[baseStyle, animatedStyle, style]}>
144
109
  {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}/>
110
+
111
+ {closeable && (<react_native_1.Pressable hitSlop={15} onPress={onClose} style={{
112
+ position: 'absolute',
113
+ right: 10,
114
+ [position === 'top' ? 'bottom' : 'top']: 10,
115
+ }}>
116
+ <react_native_1.Image source={require('./assets/icon-close.png')} style={closeIconSize}/>
147
117
  </react_native_1.Pressable>)}
148
118
  </react_native_1.Animated.View>
149
119
  </Overlay_1.OverLay>);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenryx/react-native-components",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -27,10 +27,12 @@
27
27
  "devDependencies": {
28
28
  "@types/react": "18.2.0",
29
29
  "@types/react-native": "0.70.0",
30
- "typescript": "5.0.4"
30
+ "typescript": "5.0.4",
31
+ "react-native-safe-area-context": "^4.8.0"
31
32
  },
32
33
  "peerDependencies": {
33
34
  "react": ">=18.1.0",
34
- "react-native": ">=0.70.0"
35
+ "react-native": ">=0.70.0",
36
+ "react-native-safe-area-context": ">=4.0.0"
35
37
  }
36
38
  }