related-ui-components 1.2.3 → 1.2.5

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,4 +1,4 @@
1
- import React, { useCallback, useRef, useState } from "react";
1
+ import React, { useCallback, useEffect, useRef, useState } from "react";
2
2
  import {
3
3
  View,
4
4
  Text,
@@ -8,6 +8,7 @@ import {
8
8
  ViewStyle,
9
9
  ImageRequireSource,
10
10
  I18nManager,
11
+ TouchableWithoutFeedback,
11
12
  } from "react-native";
12
13
  import { GestureHandlerRootView } from "react-native-gesture-handler";
13
14
  import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet";
@@ -82,6 +83,9 @@ interface FiltersProps {
82
83
  snapPoints?: string[];
83
84
  handleIndicatorStyle?: ViewStyle;
84
85
  applyButtonText?: string;
86
+ overlayColor?: string;
87
+ onClose?: () => void;
88
+ visible?: boolean;
85
89
  }
86
90
 
87
91
  const Filters: React.FC<FiltersProps> = ({
@@ -134,15 +138,31 @@ const Filters: React.FC<FiltersProps> = ({
134
138
  applyButtonText = "Apply Filter",
135
139
  headerResetText = "Reset All",
136
140
  headerTitleText = "Filter",
141
+ overlayColor = "rgba(0, 0, 0, 0.5)",
142
+ onClose,
143
+ visible = true,
137
144
  }) => {
138
145
  const {theme, isRTL : rtl} = useTheme();
139
- isRTL = rtl
146
+ isRTL = rtl || isRTL;
140
147
  const bottomSheetRef = useRef<BottomSheet>(null);
141
148
  const styles = createStyles(theme, isRTL);
142
149
  const checkboxColor = checkboxColorProp ?? theme.primary;
150
+ const [isVisible, setIsVisible] = useState(visible);
151
+
152
+ // Sync the internal isVisible state with the visible prop
153
+ useEffect(() => {
154
+ setIsVisible(visible);
155
+ if (visible && bottomSheetRef.current) {
156
+ bottomSheetRef.current.snapToIndex(0);
157
+ }
158
+ }, [visible]);
143
159
 
144
160
  const handleSheetChanges = useCallback((index: number) => {
145
161
  console.log("handleSheetChanges", index);
162
+ // If the sheet is closed (index -1), handle visibility
163
+ if (index === -1) {
164
+ setIsVisible(false);
165
+ }
146
166
  }, []);
147
167
 
148
168
  const [resetCounter, setResetCounter] = useState(0);
@@ -195,6 +215,7 @@ const Filters: React.FC<FiltersProps> = ({
195
215
  };
196
216
 
197
217
  onActionButtonPress(filterResult);
218
+ closeBottomSheet(); // Close the filter after applying
198
219
  }
199
220
  };
200
221
 
@@ -215,16 +236,42 @@ const Filters: React.FC<FiltersProps> = ({
215
236
  setResetCounter((prev) => prev + 1);
216
237
  };
217
238
 
239
+ const closeBottomSheet = useCallback(() => {
240
+ if (bottomSheetRef.current) {
241
+ bottomSheetRef.current.close();
242
+ }
243
+ setIsVisible(false);
244
+ if (onClose) {
245
+ onClose();
246
+ }
247
+ }, [onClose]);
248
+
249
+ // If not visible, don't render anything
250
+ if (!isVisible) {
251
+ return null;
252
+ }
253
+
218
254
  return (
219
- <GestureHandlerRootView style={{ flex: 1 }}>
255
+ <GestureHandlerRootView style={styles.overlayContainer}>
256
+ {/* Semi-transparent overlay */}
257
+ <TouchableWithoutFeedback onPress={closeBottomSheet}>
258
+ <View style={[styles.overlay, { backgroundColor: overlayColor }]} />
259
+ </TouchableWithoutFeedback>
260
+
220
261
  <BottomSheet
221
262
  ref={bottomSheetRef}
222
263
  index={bottomSheetIndex}
223
264
  handleComponent={() => null}
224
265
  onChange={handleSheetChanges}
225
266
  style={bottomSheetStyle}
226
- backgroundStyle={{ backgroundColor: theme.surface }} // Use surface for BS background
267
+ backgroundStyle={{ backgroundColor: theme.surface }}
227
268
  handleIndicatorStyle={[styles.handleIndicator, handleIndicatorStyle]}
269
+ // snapPoints={snapPoints}
270
+ enablePanDownToClose={true}
271
+ // onClose={() => {
272
+ // setIsVisible(false);
273
+ // if (onClose) onClose();
274
+ // }}
228
275
  >
229
276
  <View style={[styles.container, containerStyle]}>
230
277
  <View style={[styles.header, headerStyle]}>
@@ -321,7 +368,7 @@ const Filters: React.FC<FiltersProps> = ({
321
368
  brandActiveIcon || (
322
369
  <Ionicons
323
370
  name="checkmark-outline"
324
- color={theme.onPrimary} // Use primary for checkmark color
371
+ color={theme.onPrimary}
325
372
  />
326
373
  )
327
374
  }
@@ -349,17 +396,30 @@ const Filters: React.FC<FiltersProps> = ({
349
396
 
350
397
  const createStyles = (theme: ThemeType, isRTL: boolean) =>
351
398
  StyleSheet.create({
399
+ overlayContainer: {
400
+ flex: 1,
401
+ position: 'absolute',
402
+ top: 0,
403
+ left: 0,
404
+ right: 0,
405
+ bottom: 0,
406
+ zIndex: 1000,
407
+ },
408
+ overlay: {
409
+ ...StyleSheet.absoluteFillObject,
410
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
411
+ },
352
412
  container: {
353
413
  flex: 1,
354
414
  paddingHorizontal: 25,
355
- backgroundColor: theme.surface, // Use surface for container inside BS
415
+ backgroundColor: theme.surface,
356
416
  },
357
417
  handleIndicator: {
358
418
  width: 40,
359
419
  height: 4,
360
420
  backgroundColor: theme.border,
361
421
  alignSelf: "center",
362
- marginTop: 8, // Add some margin if handle is visible
422
+ marginTop: 8,
363
423
  borderRadius: 2,
364
424
  },
365
425
  header: {
@@ -402,7 +462,7 @@ const createStyles = (theme: ThemeType, isRTL: boolean) =>
402
462
  fontSize: 15,
403
463
  color: theme.text,
404
464
  textAlign: isRTL ? "right" : "left",
405
- marginLeft: isRTL ? 0 : 8, // Add spacing between checkbox and text
465
+ marginLeft: isRTL ? 0 : 8,
406
466
  marginRight: isRTL ? 8 : 0,
407
467
  },
408
468
  brandsGrid: {
@@ -419,10 +479,10 @@ const createStyles = (theme: ThemeType, isRTL: boolean) =>
419
479
  marginTop: 30,
420
480
  },
421
481
  applyButtonText: {
422
- color: theme.onPrimary, // Use onPrimary for text on primary button
482
+ color: theme.onPrimary,
423
483
  fontSize: 16,
424
484
  fontWeight: "bold",
425
485
  },
426
486
  });
427
487
 
428
- export default Filters;
488
+ export default Filters;
@@ -71,7 +71,7 @@ const PointsRangeSelector: React.FC<PointsRangeSelectorProps> = ({
71
71
  multiSliderProps = {},
72
72
  }) => {
73
73
  const {theme, isRTL: rtl} = useTheme();
74
- isRTL = rtl;
74
+ isRTL = rtl || isRTL;
75
75
  const styles = createStyles(theme, isRTL);
76
76
 
77
77
  const [values, setValues] = useState([initialMin, initialMax]);
@@ -236,7 +236,7 @@ const PointsRangeSelector: React.FC<PointsRangeSelectorProps> = ({
236
236
  sliderLength={containerWidth} // Use measured width for slider length
237
237
  customMarker={CustomMarker}
238
238
  // For RTL support with MultiSlider
239
- enabledOne={true}
239
+ enabledsOne={true}
240
240
  enabledTwo={true}
241
241
  isRTL={isRTL}
242
242
  {...multiSliderProps}
@@ -268,7 +268,7 @@ const createStyles = (theme: ThemeType, isRTL: boolean) =>
268
268
  alignItems: "center",
269
269
  width: "100%",
270
270
  // Apply any RTL specific styling if needed
271
- transform: isRTL ? [{ scaleX: -1 }] : [],
271
+ // transform: isRTL ? [{ scaleX: -1 }] : [],
272
272
  },
273
273
  sliderContainerStyle: {
274
274
  height: 30,