ripal-ui 1.0.0 → 1.0.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 ADDED
File without changes
@@ -0,0 +1,197 @@
1
+ import React, { useEffect, useRef, useState, ReactNode } from 'react';
2
+ import {
3
+ Animated,
4
+ View,
5
+ TouchableOpacity,
6
+ StyleSheet,
7
+ Dimensions,
8
+ PanResponder,
9
+ TouchableWithoutFeedback,
10
+ ScrollView,
11
+ Keyboard,
12
+ } from 'react-native';
13
+ import { Separator, Text } from '../elements';
14
+ import config from '../config';
15
+
16
+ const { height: screenHeight } = Dimensions.get('window');
17
+
18
+ // Define props interface
19
+ interface BottomSheetProps {
20
+ isVisible: boolean;
21
+ onClose: () => void;
22
+ children: ReactNode;
23
+ height?: number | string;
24
+ scroll?: boolean;
25
+ style?: object;
26
+ contentContainerStyle?: object;
27
+ }
28
+
29
+ const BottomSheet: React.FC<BottomSheetProps> = ({
30
+ isVisible,
31
+ onClose,
32
+ children,
33
+ height = 'auto',
34
+ scroll = false,
35
+ style,
36
+ contentContainerStyle,
37
+ }) => {
38
+ const [visible, setVisible] = useState(isVisible);
39
+ const translateY = useRef(new Animated.Value(screenHeight)).current;
40
+ const scrollOffset = useRef(0); // Keep track of ScrollView offset
41
+ const keyboardHeight = useRef(new Animated.Value(0)).current; // Use Animated.Value for keyboard height
42
+
43
+ // Create a PanResponder to handle the dragging gesture
44
+ const panResponder = useRef(
45
+ PanResponder.create({
46
+ onMoveShouldSetPanResponder: (evt, gestureState) => {
47
+ return Math.abs(gestureState.dy) > 5;
48
+ },
49
+ onPanResponderMove: (evt, gestureState) => {
50
+ translateY.setValue(Math.max(gestureState.dy, 0));
51
+ },
52
+ onPanResponderRelease: (evt, gestureState) => {
53
+ const isClosing = gestureState.dy > 100;
54
+ if (isClosing) {
55
+ Animated.timing(translateY, {
56
+ toValue: screenHeight,
57
+ duration: 300,
58
+ useNativeDriver: false,
59
+ }).start(() => setVisible(false));
60
+ onClose();
61
+ } else {
62
+ Animated.timing(translateY, {
63
+ toValue: 0,
64
+ duration: 300,
65
+ useNativeDriver: false,
66
+ }).start();
67
+ }
68
+ },
69
+ })
70
+ ).current;
71
+
72
+ useEffect(() => {
73
+ if (isVisible) {
74
+ setVisible(true);
75
+ Animated.timing(translateY, {
76
+ toValue: 0,
77
+ duration: 300,
78
+ useNativeDriver: false,
79
+ }).start();
80
+ } else {
81
+ Animated.timing(translateY, {
82
+ toValue: screenHeight,
83
+ duration: 300,
84
+ useNativeDriver: false,
85
+ }).start(() => setVisible(false));
86
+ }
87
+ }, [isVisible]);
88
+
89
+ useEffect(() => {
90
+ // Handle keyboard show and hide
91
+ const keyboardDidShowListener = Keyboard.addListener(
92
+ 'keyboardDidShow',
93
+ (event) => {
94
+ Animated.timing(keyboardHeight, {
95
+ toValue: event.endCoordinates.height,
96
+ duration: 300,
97
+ useNativeDriver: false, // Layout animation
98
+ }).start();
99
+ }
100
+ );
101
+ const keyboardDidHideListener = Keyboard.addListener(
102
+ 'keyboardDidHide',
103
+ () => {
104
+ Animated.timing(keyboardHeight, {
105
+ toValue: 0,
106
+ duration: 300,
107
+ useNativeDriver: false, // Layout animation
108
+ }).start();
109
+ }
110
+ );
111
+
112
+ // Cleanup listeners on component unmount
113
+ return () => {
114
+ keyboardDidShowListener.remove();
115
+ keyboardDidHideListener.remove();
116
+ };
117
+ }, []);
118
+
119
+ if (!visible) return null;
120
+
121
+ return (
122
+ <View style={StyleSheet.absoluteFill}>
123
+ {/* Background Overlay */}
124
+ <TouchableWithoutFeedback onPress={onClose}>
125
+ <View style={styles.overlay} />
126
+ </TouchableWithoutFeedback>
127
+
128
+ {/* Bottom Sheet */}
129
+ <Animated.View
130
+ {...panResponder.panHandlers}
131
+ style={[
132
+ styles.sheet,
133
+ { height: height, ...style },
134
+ {
135
+ transform: [
136
+ { translateY },
137
+ { translateY: keyboardHeight.interpolate({
138
+ inputRange: [0, 1],
139
+ outputRange: [0, -1], // Interpolate for smoother transition
140
+ }) }
141
+ ]
142
+ },
143
+ ]}
144
+ >
145
+ {/* Children */}
146
+ <View style={styles.dragIndicatorContainer}>
147
+ <TouchableWithoutFeedback {...panResponder.panHandlers}>
148
+ <Separator height={6} style={{ borderRadius: 99 }} width='12%' color={config.colors.slate[300]} />
149
+ </TouchableWithoutFeedback>
150
+ </View>
151
+
152
+ <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
153
+ <View>
154
+ {scroll ? (
155
+ <ScrollView
156
+ onScroll={(e) => (scrollOffset.current = e.nativeEvent.contentOffset.y)} // Update scrollOffset correctly
157
+ scrollEventThrottle={16}
158
+ showsVerticalScrollIndicator={false}
159
+ contentContainerStyle={contentContainerStyle}
160
+ >
161
+ {children}
162
+ </ScrollView>
163
+ ) : (
164
+ children
165
+ )}
166
+ </View>
167
+ </TouchableWithoutFeedback>
168
+ </Animated.View>
169
+ </View>
170
+ );
171
+ };
172
+
173
+ const styles = StyleSheet.create({
174
+ overlay: {
175
+ ...StyleSheet.absoluteFillObject,
176
+ backgroundColor: 'rgba(0, 0, 0, 0.7)', // Semi-transparent black
177
+ },
178
+ sheet: {
179
+ position: 'absolute',
180
+ bottom: 0,
181
+ left: 0,
182
+ right: 0,
183
+ paddingHorizontal: 20,
184
+ paddingBottom: 20,
185
+ backgroundColor: '#fff',
186
+ borderTopLeftRadius: 20,
187
+ borderTopRightRadius: 20,
188
+ elevation: 5,
189
+ },
190
+ dragIndicatorContainer: {
191
+ width: '100%',
192
+ alignItems: 'center',
193
+ paddingVertical: 10,
194
+ },
195
+ });
196
+
197
+ export default BottomSheet;
@@ -0,0 +1,61 @@
1
+ import React from "react";
2
+ import { Dimensions, Pressable, ScrollView, StyleSheet, View, ViewStyle } from "react-native";
3
+ import { Text } from "../elements";
4
+
5
+ // Define types for the CarouselItem props
6
+ interface CarouselItemProps {
7
+ children: React.ReactNode;
8
+ itemWidth: number;
9
+ onPress?: () => void;
10
+ style?: ViewStyle;
11
+ }
12
+
13
+ // Define the CarouselItem component
14
+ const CarouselItem: React.FC<CarouselItemProps> = ({ children, itemWidth, onPress, style }) => {
15
+ return (
16
+ <Pressable style={{ width: itemWidth, ...style }} onPress={onPress}>
17
+ {children}
18
+ </Pressable>
19
+ );
20
+ };
21
+
22
+ // Define types for the Carousel props
23
+ interface CarouselProps {
24
+ children: React.ReactNode;
25
+ itemWidth?: number;
26
+ showIndicator?: boolean;
27
+ }
28
+
29
+ // Define the Carousel component
30
+ const Carousel: React.FC<CarouselProps> = ({
31
+ children,
32
+ itemWidth = 0.6 * Dimensions.get('window').width,
33
+ showIndicator = false,
34
+ }) => {
35
+ return (
36
+ <ScrollView
37
+ horizontal
38
+ showsHorizontalScrollIndicator={showIndicator}
39
+ contentContainerStyle={styles.container}
40
+ >
41
+ <View></View>
42
+ {React.Children.map(children, (child) =>
43
+ React.cloneElement(child as React.ReactElement<any>, { itemWidth })
44
+ )}
45
+ <View></View>
46
+ </ScrollView>
47
+ );
48
+ };
49
+
50
+ // Define styles
51
+ const styles = StyleSheet.create({
52
+ area: {
53
+ // Add any specific styles if needed
54
+ },
55
+ container: {
56
+ gap: 20,
57
+ },
58
+ });
59
+
60
+ // Export components
61
+ export { Carousel, CarouselItem };
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import { Pressable, StyleSheet, PressableProps, ViewStyle } from "react-native";
3
+ import config from "../config";
4
+
5
+ interface CircleProps extends PressableProps {
6
+ size?: number; // Optional size for the circle
7
+ color?: string; // Optional color for the circle
8
+ rounded?: number; // Optional rounded value for the border radius
9
+ children?: React.ReactNode; // Allows for any valid React node
10
+ onPress?: () => void; // Optional onPress function
11
+ }
12
+
13
+ const Circle: React.FC<CircleProps> = ({
14
+ size = 24,
15
+ color = config.colors.primary,
16
+ children,
17
+ onPress,
18
+ rounded = 999,
19
+ }) => {
20
+ return (
21
+ <Pressable
22
+ onPress={onPress}
23
+ style={{
24
+ ...styles.area,
25
+ backgroundColor: color,
26
+ height: size,
27
+ width: size, // Added width to maintain aspect ratio
28
+ borderRadius: rounded,
29
+ }}
30
+ >
31
+ {children}
32
+ </Pressable>
33
+ );
34
+ };
35
+
36
+ const styles = StyleSheet.create({
37
+ area: {
38
+ aspectRatio: 1,
39
+ alignItems: 'center',
40
+ justifyContent: 'center',
41
+ },
42
+ });
43
+
44
+ export default Circle;
@@ -0,0 +1,90 @@
1
+ import React, { useState, ReactNode } from "react";
2
+ import { Pressable, ScrollView, StyleSheet, View } from "react-native";
3
+ import Text from "../elements/Text";
4
+ import Inline from "../elements/Inline";
5
+ import config from "../config";
6
+
7
+ // Define the props for the TabScreen component
8
+ interface TabScreenProps {
9
+ children: ReactNode;
10
+ }
11
+
12
+ // TabScreen component
13
+ const TabScreen: React.FC<TabScreenProps> = ({ children }) => {
14
+ return <>{children}</>;
15
+ };
16
+
17
+ // Define the props for the Tab component
18
+ interface TabProps {
19
+ children: React.ReactElement<{ title: string }>[];
20
+ }
21
+
22
+ // Tab component
23
+ const Tab: React.FC<TabProps> = ({ children }) => {
24
+ const [index, setIndex] = useState(0);
25
+
26
+ return (
27
+ <View>
28
+ {
29
+ children.length > 3 ? (
30
+ <ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.tab_area}>
31
+ {children.map((child, c) => {
32
+ const isActive = c === index;
33
+ return (
34
+ <Pressable
35
+ key={c}
36
+ style={{
37
+ ...styles.tab_item,
38
+ borderBottomColor: isActive ? config.colors.primary : config.colors.slate[200],
39
+ }}
40
+ onPress={() => setIndex(c)}
41
+ >
42
+ <Text
43
+ color={isActive ? config.colors.primary : config.colors.slate[500]}
44
+ weight={isActive ? "600SemiBold" : "400Regular"}
45
+ >
46
+ {child.props.title}
47
+ </Text>
48
+ </Pressable>
49
+ );
50
+ })}
51
+ </ScrollView>
52
+ ) : (
53
+ <Inline style={styles.tab_area} gap={0}>
54
+ {children.map((child, c) => {
55
+ const isActive = c === index;
56
+ return (
57
+ <Inline justifyContent="center" key={c} style={{
58
+ ...styles.tab_item,
59
+ borderBottomColor: isActive ? config.colors.primary : config.colors.slate[200],
60
+ }} onPress={() => setIndex(c)}>
61
+ <Text
62
+ color={isActive ? config.colors.primary : config.colors.slate[500]}
63
+ weight={isActive ? "600SemiBold" : "400Regular"}
64
+ >
65
+ {child.props.title}
66
+ </Text>
67
+ </Inline>
68
+ );
69
+ })}
70
+ </Inline>
71
+ )
72
+ }
73
+ {children[index]}
74
+ </View>
75
+ );
76
+ };
77
+
78
+ const styles = StyleSheet.create({
79
+ tab_area: {
80
+ marginBottom: 10,
81
+ },
82
+ tab_item: {
83
+ paddingHorizontal: 20,
84
+ paddingVertical: 12,
85
+ flexGrow: 1,
86
+ borderBottomWidth: 1,
87
+ }
88
+ });
89
+
90
+ export { Tab, TabScreen };
@@ -1,10 +1,18 @@
1
1
  import React from 'react';
2
- import { View, ScrollView, StyleSheet } from 'react-native';
2
+ import { View, ScrollView, StyleSheet, ViewStyle } from 'react-native';
3
3
  import Text from '../elements/Text';
4
4
  import config from '../config';
5
5
 
6
+ // Define the types for the Cell component props
7
+ interface CellProps {
8
+ children: React.ReactNode;
9
+ isHeader?: boolean;
10
+ width?: number;
11
+ flexible?: boolean;
12
+ }
13
+
6
14
  // Cell component
7
- const Cell = ({ children, isHeader, width, flexible }) => {
15
+ const Cell: React.FC<CellProps> = ({ children, isHeader = false, width, flexible = false }) => {
8
16
  return (
9
17
  <View style={[styles.cell, { width: flexible ? 'auto' : width, flex: flexible ? 1 : undefined }]}>
10
18
  <Text weight={isHeader ? '600SemiBold' : '400Regular'}>
@@ -14,37 +22,51 @@ const Cell = ({ children, isHeader, width, flexible }) => {
14
22
  );
15
23
  };
16
24
 
25
+ // Define the types for the Row component props
26
+ interface RowProps {
27
+ children: React.ReactNode;
28
+ isHeader?: boolean;
29
+ cellWidth?: number;
30
+ flexible?: boolean;
31
+ }
32
+
17
33
  // Row component
18
- const Row = ({ children, isHeader, cellWidth, flexible }) => {
34
+ const Row: React.FC<RowProps> = ({ children, isHeader = false, cellWidth, flexible = false }) => {
19
35
  return (
20
36
  <View style={styles.row}>
21
37
  {React.Children.map(children, (child) =>
22
- React.cloneElement(child, { isHeader, width: cellWidth, flexible })
38
+ React.cloneElement(child as React.ReactElement, { isHeader, width: cellWidth, flexible })
23
39
  )}
24
40
  </View>
25
41
  );
26
42
  };
27
43
 
44
+ // Define the types for the Table component props
45
+ interface TableProps {
46
+ children: React.ReactNode;
47
+ cellWidth?: number;
48
+ }
49
+
28
50
  // Table component with dynamic width adjustment and scroll if more than 3 cells
29
- const Table = ({ children, cellWidth = 100 }) => {
51
+ const Table: React.FC<TableProps> = ({ children, cellWidth = 100 }) => {
30
52
  // Determine if any row has more than 3 cells
31
53
  const hasManyCells = React.Children.toArray(children).some(child => {
32
- return React.Children.count(child.props.children) > 3;
54
+ return React.Children.count((child as React.ReactElement).props.children) > 3;
33
55
  });
34
56
 
35
57
  return hasManyCells ? (
36
58
  <ScrollView horizontal>
37
- <View style={styles.table}>
59
+ <View>
38
60
  {React.Children.map(children, (child, index) => (
39
61
  // Automatically pass `isHeader` for the first row (index 0)
40
- React.cloneElement(child, { isHeader: index === 0, cellWidth, flexible: false })
62
+ React.cloneElement(child as React.ReactElement, { isHeader: index === 0, cellWidth, flexible: false })
41
63
  ))}
42
64
  </View>
43
65
  </ScrollView>
44
66
  ) : (
45
- <View style={styles.table}>
67
+ <View>
46
68
  {React.Children.map(children, (child, index) => (
47
- React.cloneElement(child, { isHeader: index === 0, cellWidth, flexible: true })
69
+ React.cloneElement(child as React.ReactElement, { isHeader: index === 0, cellWidth, flexible: true })
48
70
  ))}
49
71
  </View>
50
72
  );
@@ -0,0 +1,5 @@
1
+ export { default as Circle } from './Circle';
2
+ export { default as BottomSheet } from './BottomSheet';
3
+ export { Carousel, CarouselItem } from "./Carousel";
4
+ export { Table, Cell, Row } from './Table';
5
+ export { Tab, TabScreen } from "./Tab";
package/config.js ADDED
@@ -0,0 +1,4 @@
1
+ // import config from "../../ripal-ui.config.js"
2
+ import config from "../ripal-ui.config.js"
3
+
4
+ export default config
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactNative = require("react-native");
10
+ var _elements = require("../elements");
11
+ var _config = _interopRequireDefault(require("../config"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
20
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
22
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
24
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
25
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
26
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
27
+ var _Dimensions$get = _reactNative.Dimensions.get('window'),
28
+ screenHeight = _Dimensions$get.height;
29
+ var BottomSheet = function BottomSheet(_ref) {
30
+ var isVisible = _ref.isVisible,
31
+ onClose = _ref.onClose,
32
+ children = _ref.children,
33
+ _ref$height = _ref.height,
34
+ height = _ref$height === void 0 ? 'auto' : _ref$height,
35
+ _ref$scroll = _ref.scroll,
36
+ scroll = _ref$scroll === void 0 ? false : _ref$scroll,
37
+ style = _ref.style,
38
+ contentContainerStyle = _ref.contentContainerStyle;
39
+ var _useState = (0, _react.useState)(isVisible),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ visible = _useState2[0],
42
+ setVisible = _useState2[1];
43
+ var translateY = (0, _react.useRef)(new _reactNative.Animated.Value(screenHeight)).current;
44
+ var scrollOffset = (0, _react.useRef)(0); // Keep track of ScrollView offset
45
+ var keyboardHeight = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current; // Use Animated.Value for keyboard height
46
+
47
+ // Create a PanResponder to handle the dragging gesture
48
+ var panResponder = (0, _react.useRef)(_reactNative.PanResponder.create({
49
+ onMoveShouldSetPanResponder: function onMoveShouldSetPanResponder(evt, gestureState) {
50
+ return Math.abs(gestureState.dy) > 5;
51
+ },
52
+ onPanResponderMove: function onPanResponderMove(evt, gestureState) {
53
+ translateY.setValue(Math.max(gestureState.dy, 0));
54
+ },
55
+ onPanResponderRelease: function onPanResponderRelease(evt, gestureState) {
56
+ var isClosing = gestureState.dy > 100;
57
+ if (isClosing) {
58
+ _reactNative.Animated.timing(translateY, {
59
+ toValue: screenHeight,
60
+ duration: 300,
61
+ useNativeDriver: false
62
+ }).start(function () {
63
+ return setVisible(false);
64
+ });
65
+ onClose();
66
+ } else {
67
+ _reactNative.Animated.timing(translateY, {
68
+ toValue: 0,
69
+ duration: 300,
70
+ useNativeDriver: false
71
+ }).start();
72
+ }
73
+ }
74
+ })).current;
75
+ (0, _react.useEffect)(function () {
76
+ if (isVisible) {
77
+ setVisible(true);
78
+ _reactNative.Animated.timing(translateY, {
79
+ toValue: 0,
80
+ duration: 300,
81
+ useNativeDriver: false
82
+ }).start();
83
+ } else {
84
+ _reactNative.Animated.timing(translateY, {
85
+ toValue: screenHeight,
86
+ duration: 300,
87
+ useNativeDriver: false
88
+ }).start(function () {
89
+ return setVisible(false);
90
+ });
91
+ }
92
+ }, [isVisible]);
93
+ (0, _react.useEffect)(function () {
94
+ // Handle keyboard show and hide
95
+ var keyboardDidShowListener = _reactNative.Keyboard.addListener('keyboardDidShow', function (event) {
96
+ _reactNative.Animated.timing(keyboardHeight, {
97
+ toValue: event.endCoordinates.height,
98
+ duration: 300,
99
+ useNativeDriver: false // Layout animation
100
+ }).start();
101
+ });
102
+ var keyboardDidHideListener = _reactNative.Keyboard.addListener('keyboardDidHide', function () {
103
+ _reactNative.Animated.timing(keyboardHeight, {
104
+ toValue: 0,
105
+ duration: 300,
106
+ useNativeDriver: false // Layout animation
107
+ }).start();
108
+ });
109
+
110
+ // Cleanup listeners on component unmount
111
+ return function () {
112
+ keyboardDidShowListener.remove();
113
+ keyboardDidHideListener.remove();
114
+ };
115
+ }, []);
116
+ if (!visible) return null;
117
+ return /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
118
+ style: _reactNative.StyleSheet.absoluteFill
119
+ }, /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableWithoutFeedback, {
120
+ onPress: function onPress() {
121
+ return onClose();
122
+ }
123
+ }, /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
124
+ style: styles.overlay
125
+ })), /*#__PURE__*/_react["default"].createElement(_reactNative.Animated.View, _extends({}, panResponder.panHandlers, {
126
+ style: [styles.sheet, _objectSpread({
127
+ height: height
128
+ }, style), {
129
+ transform: [{
130
+ translateY: translateY
131
+ }, {
132
+ translateY: keyboardHeight.interpolate({
133
+ inputRange: [0, 1],
134
+ outputRange: [0, -1] // Interpolate for smoother transition
135
+ })
136
+ }]
137
+ }]
138
+ }), /*#__PURE__*/_react["default"].createElement(_reactNative.View, {
139
+ style: styles.dragIndicatorContainer
140
+ }, /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableWithoutFeedback, panResponder.panHandlers, /*#__PURE__*/_react["default"].createElement(_elements.Separator, {
141
+ height: 6,
142
+ style: {
143
+ borderRadius: 99
144
+ },
145
+ width: "12%",
146
+ color: _config["default"].colors.slate[300]
147
+ }))), /*#__PURE__*/_react["default"].createElement(_reactNative.TouchableWithoutFeedback, {
148
+ onPress: _reactNative.Keyboard.dismiss
149
+ }, /*#__PURE__*/_react["default"].createElement(_reactNative.View, null, scroll ? /*#__PURE__*/_react["default"].createElement(_reactNative.ScrollView, {
150
+ onScroll: function onScroll(e) {
151
+ return scrollOffset.current = e.nativeEvent.contentOffset.y;
152
+ } // Update scrollOffset correctly
153
+ ,
154
+ scrollEventThrottle: 16,
155
+ showsVerticalScrollIndicator: false,
156
+ contentContainerStyle: contentContainerStyle
157
+ }, children) : children))));
158
+ };
159
+ var styles = _reactNative.StyleSheet.create({
160
+ overlay: _objectSpread(_objectSpread({}, _reactNative.StyleSheet.absoluteFillObject), {}, {
161
+ backgroundColor: 'rgba(0, 0, 0, 0.7)' // Semi-transparent black
162
+ }),
163
+ sheet: {
164
+ position: 'absolute',
165
+ bottom: 0,
166
+ left: 0,
167
+ right: 0,
168
+ paddingHorizontal: 20,
169
+ paddingBottom: 20,
170
+ backgroundColor: '#fff',
171
+ borderTopLeftRadius: 20,
172
+ borderTopRightRadius: 20,
173
+ elevation: 5
174
+ },
175
+ content: {
176
+ flex: 1,
177
+ justifyContent: 'center',
178
+ alignItems: 'center'
179
+ },
180
+ dragIndicatorContainer: {
181
+ width: '100%',
182
+ alignItems: 'center',
183
+ paddingVertical: 10
184
+ }
185
+ });
186
+ var _default = exports["default"] = BottomSheet;