related-ui-components 1.6.5 → 1.6.6
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/lib/commonjs/components/Filters/Filters.js +46 -52
- package/lib/commonjs/components/Filters/Filters.js.map +1 -1
- package/lib/module/components/Filters/Filters.js +52 -54
- package/lib/module/components/Filters/Filters.js.map +1 -1
- package/lib/typescript/commonjs/components/Filters/Filters.d.ts.map +1 -1
- package/lib/typescript/module/components/Filters/Filters.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Filters/Filters.tsx +462 -449
|
@@ -1,479 +1,492 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
TextStyle,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
ImageSourcePropType,
|
|
10
|
+
I18nManager,
|
|
11
|
+
// Remove TouchableWithoutFeedback as it's no longer needed for the overlay
|
|
12
|
+
} from "react-native";
|
|
13
|
+
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
14
|
+
import BottomSheet, {
|
|
15
|
+
BottomSheetView,
|
|
16
|
+
BottomSheetBackdrop, // Import BottomSheetBackdrop
|
|
17
|
+
BottomSheetBackdropProps, // Import props type for type safety
|
|
18
|
+
} from "@gorhom/bottom-sheet";
|
|
19
|
+
import PointsRangeSelector from "./PointsRangeSelector";
|
|
20
|
+
import { BrandIcon } from "../BrandIcon";
|
|
21
|
+
import { Ionicons } from "@expo/vector-icons";
|
|
22
|
+
import Checkbox from "expo-checkbox";
|
|
23
|
+
import { useTheme, ThemeType } from "../../theme"; // Import ThemeType
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
isRTL?: boolean;
|
|
40
|
-
sortOptions?: SortOption[];
|
|
41
|
-
sortSectionTitle?: string;
|
|
42
|
-
sectionTitleStyle?: TextStyle;
|
|
43
|
-
sortSectionStyle?: ViewStyle;
|
|
44
|
-
rangeMinLimit?: number;
|
|
45
|
-
rangeMaxLimit?: number;
|
|
46
|
-
rangeInitialMin?: number;
|
|
47
|
-
rangeInitialMax?: number;
|
|
48
|
-
showPointsRange?: boolean;
|
|
49
|
-
pointsRangeSectionTitle?: string;
|
|
50
|
-
pointsRangeContainerStyle?: ViewStyle;
|
|
51
|
-
pointsRangeInputsContainerStyle?: ViewStyle;
|
|
52
|
-
pointsRangeCustomInputContainerStyle?: ViewStyle;
|
|
53
|
-
pointsRangeCustomInputFieldStyle?: ViewStyle;
|
|
54
|
-
pointsRangeSliderContainerStyle?: ViewStyle;
|
|
55
|
-
pointsRangeMultiSliderContainerStyle?: ViewStyle;
|
|
56
|
-
pointsRangeTrackStyle?: ViewStyle;
|
|
57
|
-
pointsRangeSelectedTrackStyle?: ViewStyle;
|
|
58
|
-
pointsRangeUnselectedTrackStyle?: ViewStyle;
|
|
59
|
-
pointsRangeMarkerStyle?: ViewStyle;
|
|
60
|
-
pointsRangeMarkerEnabledStyle?: ViewStyle;
|
|
61
|
-
pointsRangeMarkerDisabledStyle?: ViewStyle;
|
|
62
|
-
pointsRangeMarkerDotStyle?: ViewStyle;
|
|
63
|
-
pointsRangeInputProps?: any;
|
|
64
|
-
pointsRangeMultiSliderProps?: any;
|
|
65
|
-
brands?: Brand[];
|
|
66
|
-
brandContainerStyle?: ViewStyle;
|
|
67
|
-
brandActiveIcon?: React.ReactNode;
|
|
68
|
-
brandActiveIconStyle?: ViewStyle;
|
|
69
|
-
brandSectionTile?: string;
|
|
70
|
-
onActionButtonPress?: (result: FilterResult) => void;
|
|
71
|
-
containerStyle?: ViewStyle;
|
|
72
|
-
headerStyle?: ViewStyle;
|
|
73
|
-
titleStyle?: TextStyle;
|
|
74
|
-
resetTextStyle?: TextStyle;
|
|
75
|
-
sectionStyle?: ViewStyle;
|
|
76
|
-
optionRowStyle?: ViewStyle;
|
|
77
|
-
optionTextStyle?: TextStyle;
|
|
78
|
-
checkboxColor?: string;
|
|
79
|
-
applyButtonStyle?: ViewStyle;
|
|
80
|
-
applyButtonTextStyle?: TextStyle;
|
|
81
|
-
bottomSheetStyle?: ViewStyle;
|
|
82
|
-
headerTitleText?: string;
|
|
83
|
-
headerResetText?: string;
|
|
84
|
-
bottomSheetIndex?: number;
|
|
85
|
-
snapPoints?: string[];
|
|
86
|
-
handleIndicatorStyle?: ViewStyle;
|
|
87
|
-
applyButtonText?: string;
|
|
88
|
-
overlayColor?: string;
|
|
89
|
-
onClose?: () => void;
|
|
90
|
-
visible?: boolean;
|
|
91
|
-
}
|
|
25
|
+
// ... (Keep existing type definitions: SortOption, Brand, FilterResult) ...
|
|
26
|
+
type SortOption = {
|
|
27
|
+
name: string;
|
|
28
|
+
value: string;
|
|
29
|
+
id: number;
|
|
30
|
+
checked?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type Brand = {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
logo: ImageSourcePropType;
|
|
36
|
+
checked?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type FilterResult = {
|
|
39
|
+
sort: SortOption | undefined;
|
|
40
|
+
pointsRange: { min: number; max: number };
|
|
41
|
+
selectedBrands: Brand[];
|
|
42
|
+
};
|
|
92
43
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const {theme, isRTL : rtl} = useTheme();
|
|
148
|
-
isRTL = rtl || isRTL;
|
|
149
|
-
const bottomSheetRef = useRef<BottomSheet>(null);
|
|
150
|
-
const styles = createStyles(theme, isRTL);
|
|
151
|
-
const checkboxColor = checkboxColorProp ?? theme.primary;
|
|
152
|
-
const [isVisible, setIsVisible] = useState(visible);
|
|
44
|
+
interface FiltersProps {
|
|
45
|
+
isRTL?: boolean;
|
|
46
|
+
sortOptions?: SortOption[];
|
|
47
|
+
sortSectionTitle?: string;
|
|
48
|
+
sectionTitleStyle?: TextStyle;
|
|
49
|
+
sortSectionStyle?: ViewStyle;
|
|
50
|
+
rangeMinLimit?: number;
|
|
51
|
+
rangeMaxLimit?: number;
|
|
52
|
+
rangeInitialMin?: number;
|
|
53
|
+
rangeInitialMax?: number;
|
|
54
|
+
showPointsRange?: boolean;
|
|
55
|
+
pointsRangeSectionTitle?: string;
|
|
56
|
+
pointsRangeContainerStyle?: ViewStyle;
|
|
57
|
+
pointsRangeInputsContainerStyle?: ViewStyle;
|
|
58
|
+
pointsRangeCustomInputContainerStyle?: ViewStyle;
|
|
59
|
+
pointsRangeCustomInputFieldStyle?: ViewStyle;
|
|
60
|
+
pointsRangeSliderContainerStyle?: ViewStyle;
|
|
61
|
+
pointsRangeMultiSliderContainerStyle?: ViewStyle;
|
|
62
|
+
pointsRangeTrackStyle?: ViewStyle;
|
|
63
|
+
pointsRangeSelectedTrackStyle?: ViewStyle;
|
|
64
|
+
pointsRangeUnselectedTrackStyle?: ViewStyle;
|
|
65
|
+
pointsRangeMarkerStyle?: ViewStyle;
|
|
66
|
+
pointsRangeMarkerEnabledStyle?: ViewStyle;
|
|
67
|
+
pointsRangeMarkerDisabledStyle?: ViewStyle;
|
|
68
|
+
pointsRangeMarkerDotStyle?: ViewStyle;
|
|
69
|
+
pointsRangeInputProps?: any;
|
|
70
|
+
pointsRangeMultiSliderProps?: any;
|
|
71
|
+
brands?: Brand[];
|
|
72
|
+
brandContainerStyle?: ViewStyle;
|
|
73
|
+
brandActiveIcon?: React.ReactNode;
|
|
74
|
+
brandActiveIconStyle?: ViewStyle;
|
|
75
|
+
brandSectionTile?: string;
|
|
76
|
+
onActionButtonPress?: (result: FilterResult) => void;
|
|
77
|
+
containerStyle?: ViewStyle;
|
|
78
|
+
headerStyle?: ViewStyle;
|
|
79
|
+
titleStyle?: TextStyle;
|
|
80
|
+
resetTextStyle?: TextStyle;
|
|
81
|
+
sectionStyle?: ViewStyle;
|
|
82
|
+
optionRowStyle?: ViewStyle;
|
|
83
|
+
optionTextStyle?: TextStyle;
|
|
84
|
+
checkboxColor?: string;
|
|
85
|
+
applyButtonStyle?: ViewStyle;
|
|
86
|
+
applyButtonTextStyle?: TextStyle;
|
|
87
|
+
bottomSheetStyle?: ViewStyle;
|
|
88
|
+
headerTitleText?: string;
|
|
89
|
+
headerResetText?: string;
|
|
90
|
+
bottomSheetIndex?: number;
|
|
91
|
+
snapPoints?: string[];
|
|
92
|
+
handleIndicatorStyle?: ViewStyle;
|
|
93
|
+
applyButtonText?: string;
|
|
94
|
+
overlayColor?: string;
|
|
95
|
+
onClose?: () => void;
|
|
96
|
+
visible?: boolean;
|
|
97
|
+
}
|
|
153
98
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
99
|
+
const Filters: React.FC<FiltersProps> = ({
|
|
100
|
+
isRTL: isRTLProp,
|
|
101
|
+
sortOptions = [],
|
|
102
|
+
sortSectionTitle = "Sort",
|
|
103
|
+
sectionTitleStyle,
|
|
104
|
+
sortSectionStyle,
|
|
105
|
+
onActionButtonPress,
|
|
106
|
+
rangeInitialMax = 1000,
|
|
107
|
+
rangeInitialMin = 0,
|
|
108
|
+
rangeMaxLimit = 1000,
|
|
109
|
+
rangeMinLimit = 0,
|
|
110
|
+
pointsRangeContainerStyle,
|
|
111
|
+
pointsRangeInputsContainerStyle,
|
|
112
|
+
pointsRangeCustomInputContainerStyle,
|
|
113
|
+
pointsRangeCustomInputFieldStyle,
|
|
114
|
+
pointsRangeSliderContainerStyle,
|
|
115
|
+
pointsRangeMultiSliderContainerStyle,
|
|
116
|
+
pointsRangeTrackStyle,
|
|
117
|
+
pointsRangeSelectedTrackStyle,
|
|
118
|
+
pointsRangeUnselectedTrackStyle,
|
|
119
|
+
pointsRangeMarkerStyle,
|
|
120
|
+
pointsRangeMarkerEnabledStyle,
|
|
121
|
+
pointsRangeMarkerDisabledStyle,
|
|
122
|
+
pointsRangeMarkerDotStyle,
|
|
123
|
+
pointsRangeInputProps,
|
|
124
|
+
pointsRangeMultiSliderProps,
|
|
125
|
+
containerStyle,
|
|
126
|
+
headerStyle,
|
|
127
|
+
titleStyle,
|
|
128
|
+
resetTextStyle,
|
|
129
|
+
sectionStyle,
|
|
130
|
+
optionRowStyle,
|
|
131
|
+
optionTextStyle,
|
|
132
|
+
checkboxColor: checkboxColorProp,
|
|
133
|
+
applyButtonStyle,
|
|
134
|
+
applyButtonTextStyle,
|
|
135
|
+
bottomSheetStyle,
|
|
136
|
+
bottomSheetIndex = 0,
|
|
137
|
+
snapPoints = ["50%", "90%"],
|
|
138
|
+
handleIndicatorStyle,
|
|
139
|
+
brands = [],
|
|
140
|
+
brandContainerStyle,
|
|
141
|
+
brandActiveIcon,
|
|
142
|
+
showPointsRange = true,
|
|
143
|
+
pointsRangeSectionTitle = "Points range",
|
|
144
|
+
brandActiveIconStyle,
|
|
145
|
+
brandSectionTile = "Brands",
|
|
146
|
+
applyButtonText = "Apply Filter",
|
|
147
|
+
headerResetText = "Reset All",
|
|
148
|
+
headerTitleText = "Filter",
|
|
149
|
+
onClose,
|
|
150
|
+
visible = true,
|
|
151
|
+
}) => {
|
|
152
|
+
const { theme, isRTL: themeIsRTL } = useTheme();
|
|
153
|
+
const isRTL = isRTLProp ?? themeIsRTL ?? I18nManager.isRTL;
|
|
154
|
+
const bottomSheetRef = useRef<BottomSheet>(null);
|
|
155
|
+
const styles = createStyles(theme, isRTL);
|
|
156
|
+
const checkboxColor = checkboxColorProp ?? theme.primary;
|
|
157
|
+
const [isVisible, setIsVisible] = useState(visible);
|
|
158
|
+
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (visible) {
|
|
161
|
+
setIsVisible(true);
|
|
162
|
+
setTimeout(() => bottomSheetRef.current?.snapToIndex(bottomSheetIndex), 0);
|
|
163
|
+
} else {
|
|
164
|
+
bottomSheetRef.current?.close();
|
|
165
|
+
setIsVisible(false);
|
|
166
|
+
}
|
|
167
|
+
}, [visible, bottomSheetIndex]);
|
|
161
168
|
|
|
162
|
-
|
|
169
|
+
const handleSheetChanges = useCallback(
|
|
170
|
+
(index: number) => {
|
|
163
171
|
if (index === -1) {
|
|
164
172
|
setIsVisible(false);
|
|
173
|
+
if (onClose) {
|
|
174
|
+
onClose();
|
|
175
|
+
}
|
|
165
176
|
}
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
},
|
|
178
|
+
[onClose]
|
|
179
|
+
);
|
|
169
180
|
|
|
181
|
+
const [resetCounter, setResetCounter] = useState(0);
|
|
170
182
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
const [checkedItem, setCheckedItem] = useState<number | null>(
|
|
184
|
+
sortOptions.find((option) => option.checked)?.id || null
|
|
185
|
+
);
|
|
174
186
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
const [selectedBrands, setSelectedBrands] = useState<
|
|
188
|
+
Record<string, boolean>
|
|
189
|
+
>(
|
|
190
|
+
brands.reduce((acc, option) => {
|
|
191
|
+
acc[option.id] = option.checked || false;
|
|
192
|
+
return acc;
|
|
193
|
+
}, {} as Record<string, boolean>)
|
|
194
|
+
);
|
|
195
|
+
const [pointsRange, setPointsRange] = useState<{ min: number; max: number }>(
|
|
196
|
+
{
|
|
182
197
|
min: rangeInitialMin,
|
|
183
198
|
max: rangeInitialMax,
|
|
184
|
-
}
|
|
199
|
+
}
|
|
200
|
+
);
|
|
185
201
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
202
|
+
const handleCheckboxChange = (id: number) => {
|
|
203
|
+
setCheckedItem(id);
|
|
204
|
+
};
|
|
189
205
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
206
|
+
const handleBrandSelect = (id: string) => {
|
|
207
|
+
setSelectedBrands((prevState) => ({
|
|
208
|
+
...prevState,
|
|
209
|
+
[id]: !prevState[id],
|
|
210
|
+
}));
|
|
211
|
+
};
|
|
196
212
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
(option) => option.id == checkedItem
|
|
201
|
-
);
|
|
213
|
+
const closeBottomSheet = useCallback(() => {
|
|
214
|
+
bottomSheetRef.current?.close();
|
|
215
|
+
}, [/* onClose */]);
|
|
202
216
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
217
|
+
const handleApplyFilter = () => {
|
|
218
|
+
if (onActionButtonPress) {
|
|
219
|
+
const selectedSortOption = sortOptions.find(
|
|
220
|
+
(option) => option.id == checkedItem
|
|
221
|
+
);
|
|
206
222
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
selectedBrands: selectedBrandsList,
|
|
211
|
-
};
|
|
223
|
+
const selectedBrandsList = brands.filter(
|
|
224
|
+
(brand) => selectedBrands[brand.id]
|
|
225
|
+
);
|
|
212
226
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
227
|
+
const filterResult: FilterResult = {
|
|
228
|
+
sort: selectedSortOption,
|
|
229
|
+
pointsRange: pointsRange,
|
|
230
|
+
selectedBrands: selectedBrandsList,
|
|
231
|
+
};
|
|
217
232
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}, {} as Record<string, boolean>);
|
|
233
|
+
onActionButtonPress(filterResult);
|
|
234
|
+
}
|
|
235
|
+
closeBottomSheet();
|
|
236
|
+
};
|
|
223
237
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
};
|
|
238
|
+
const handleResetAll = () => {
|
|
239
|
+
const resetBrands = brands.reduce((acc, option) => {
|
|
240
|
+
acc[option.id] = false;
|
|
241
|
+
return acc;
|
|
242
|
+
}, {} as Record<string, boolean>);
|
|
229
243
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (onClose) {
|
|
236
|
-
onClose();
|
|
237
|
-
}
|
|
238
|
-
}, [onClose]);
|
|
244
|
+
setCheckedItem(null);
|
|
245
|
+
setSelectedBrands(resetBrands);
|
|
246
|
+
setPointsRange({ min: rangeMinLimit, max: rangeInitialMax });
|
|
247
|
+
setResetCounter((prev) => prev + 1);
|
|
248
|
+
};
|
|
239
249
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
250
|
+
const renderBackdrop = useCallback(
|
|
251
|
+
(props: BottomSheetBackdropProps) => (
|
|
252
|
+
<BottomSheetBackdrop
|
|
253
|
+
{...props}
|
|
254
|
+
appearsOnIndex={0}
|
|
255
|
+
disappearsOnIndex={-1}
|
|
256
|
+
pressBehavior="close"
|
|
257
|
+
opacity={0.5}
|
|
258
|
+
/>
|
|
259
|
+
),
|
|
260
|
+
[]
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
if (!visible) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
244
266
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
<
|
|
271
|
-
<Text style={[styles.
|
|
272
|
-
{
|
|
267
|
+
return (
|
|
268
|
+
<GestureHandlerRootView style={styles.gestureHandlerRoot}>
|
|
269
|
+
<BottomSheet
|
|
270
|
+
ref={bottomSheetRef}
|
|
271
|
+
index={isVisible ? bottomSheetIndex : -1}
|
|
272
|
+
snapPoints={snapPoints}
|
|
273
|
+
onChange={handleSheetChanges}
|
|
274
|
+
handleComponent={() => null}
|
|
275
|
+
style={bottomSheetStyle}
|
|
276
|
+
backgroundStyle={{ backgroundColor: theme.surface }}
|
|
277
|
+
handleIndicatorStyle={[styles.handleIndicator, handleIndicatorStyle]}
|
|
278
|
+
enablePanDownToClose={true}
|
|
279
|
+
backdropComponent={renderBackdrop}
|
|
280
|
+
>
|
|
281
|
+
<View style={[styles.container, containerStyle]}>
|
|
282
|
+
<View style={[styles.header, headerStyle]}>
|
|
283
|
+
<Text style={[styles.title, titleStyle]}>{headerTitleText}</Text>
|
|
284
|
+
<TouchableOpacity onPress={handleResetAll}>
|
|
285
|
+
<Text style={[styles.resetText, resetTextStyle]}>
|
|
286
|
+
{headerResetText}
|
|
287
|
+
</Text>
|
|
288
|
+
</TouchableOpacity>
|
|
289
|
+
</View>
|
|
290
|
+
<BottomSheetView style={{ paddingBottom: 75 }}>
|
|
291
|
+
{sortOptions && sortOptions.length > 0 && (
|
|
292
|
+
<View style={[styles.section, sectionStyle, sortSectionStyle]}>
|
|
293
|
+
<Text style={[styles.sectionTitle, sectionTitleStyle]}>
|
|
294
|
+
{sortSectionTitle}
|
|
273
295
|
</Text>
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
handleCheckboxChange(option.id)
|
|
293
|
-
}
|
|
294
|
-
/>
|
|
295
|
-
<Text style={[styles.optionText, optionTextStyle]}>
|
|
296
|
-
{option.name}
|
|
297
|
-
</Text>
|
|
298
|
-
</View>
|
|
299
|
-
))}
|
|
300
|
-
</View>
|
|
301
|
-
)}
|
|
296
|
+
{sortOptions.map((option) => (
|
|
297
|
+
<View
|
|
298
|
+
style={[styles.optionRow, optionRowStyle]}
|
|
299
|
+
key={option.id}
|
|
300
|
+
>
|
|
301
|
+
<Checkbox
|
|
302
|
+
value={option.id == checkedItem}
|
|
303
|
+
color={checkboxColor}
|
|
304
|
+
hitSlop={{ top: 10, right: 10, bottom: 10, left: 10 }}
|
|
305
|
+
onValueChange={() => handleCheckboxChange(option.id)}
|
|
306
|
+
/>
|
|
307
|
+
<Text style={[styles.optionText, optionTextStyle]}>
|
|
308
|
+
{option.name}
|
|
309
|
+
</Text>
|
|
310
|
+
</View>
|
|
311
|
+
))}
|
|
312
|
+
</View>
|
|
313
|
+
)}
|
|
302
314
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
315
|
+
{showPointsRange && (
|
|
316
|
+
<View style={[styles.section, sectionStyle]}>
|
|
317
|
+
<Text style={[styles.sectionTitle, sectionTitleStyle]}>
|
|
318
|
+
{pointsRangeSectionTitle}
|
|
319
|
+
</Text>
|
|
320
|
+
<PointsRangeSelector
|
|
321
|
+
resetKey={resetCounter}
|
|
322
|
+
initialMax={rangeInitialMax}
|
|
323
|
+
initialMin={rangeInitialMin}
|
|
324
|
+
minLimit={rangeMinLimit}
|
|
325
|
+
maxLimit={rangeMaxLimit}
|
|
326
|
+
isRTL={isRTL}
|
|
327
|
+
containerStyle={pointsRangeContainerStyle}
|
|
328
|
+
inputsContainerStyle={pointsRangeInputsContainerStyle}
|
|
329
|
+
customInputContainerStyle={
|
|
330
|
+
pointsRangeCustomInputContainerStyle
|
|
331
|
+
}
|
|
332
|
+
customInputFieldStyle={pointsRangeCustomInputFieldStyle}
|
|
333
|
+
sliderContainerStyle={pointsRangeSliderContainerStyle}
|
|
334
|
+
multiSliderContainerStyle={
|
|
335
|
+
pointsRangeMultiSliderContainerStyle
|
|
336
|
+
}
|
|
337
|
+
trackStyle={pointsRangeTrackStyle}
|
|
338
|
+
selectedTrackStyle={pointsRangeSelectedTrackStyle}
|
|
339
|
+
unselectedTrackStyle={pointsRangeUnselectedTrackStyle}
|
|
340
|
+
markerStyle={pointsRangeMarkerStyle}
|
|
341
|
+
markerEnabledStyle={pointsRangeMarkerEnabledStyle}
|
|
342
|
+
markerDisabledStyle={pointsRangeMarkerDisabledStyle}
|
|
343
|
+
markerDotStyle={pointsRangeMarkerDotStyle}
|
|
344
|
+
inputProps={pointsRangeInputProps}
|
|
345
|
+
multiSliderProps={pointsRangeMultiSliderProps}
|
|
346
|
+
onChange={(min: number, max: number) => {
|
|
347
|
+
setPointsRange({ min, max });
|
|
348
|
+
}}
|
|
349
|
+
/>
|
|
350
|
+
</View>
|
|
351
|
+
)}
|
|
340
352
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
</View>
|
|
353
|
+
{brands && brands.length > 0 && (
|
|
354
|
+
<View style={[styles.section, sectionStyle]}>
|
|
355
|
+
<Text style={[styles.sectionTitle, sectionTitleStyle]}>
|
|
356
|
+
{brandSectionTile}
|
|
357
|
+
</Text>
|
|
358
|
+
<View style={[styles.brandsGrid, brandContainerStyle]}>
|
|
359
|
+
{brands.map((brand) => (
|
|
360
|
+
<BrandIcon
|
|
361
|
+
key={brand.id}
|
|
362
|
+
size={50}
|
|
363
|
+
selected={selectedBrands[brand.id]}
|
|
364
|
+
onPress={() => handleBrandSelect(brand.id.toString())}
|
|
365
|
+
brand={{
|
|
366
|
+
id: brand.id,
|
|
367
|
+
name: brand.name,
|
|
368
|
+
logo: brand.logo,
|
|
369
|
+
}}
|
|
370
|
+
selectionIndicatorIcon={
|
|
371
|
+
brandActiveIcon || (
|
|
372
|
+
<Ionicons
|
|
373
|
+
name="checkmark-outline"
|
|
374
|
+
color={theme.onPrimary}
|
|
375
|
+
/>
|
|
376
|
+
)
|
|
377
|
+
}
|
|
378
|
+
selectionIndicatorStyle={brandActiveIconStyle}
|
|
379
|
+
/>
|
|
380
|
+
))}
|
|
370
381
|
</View>
|
|
371
|
-
|
|
382
|
+
</View>
|
|
383
|
+
)}
|
|
372
384
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
385
|
+
<TouchableOpacity
|
|
386
|
+
style={[styles.applyButton, applyButtonStyle]}
|
|
387
|
+
onPress={handleApplyFilter}
|
|
388
|
+
>
|
|
389
|
+
<Text style={[styles.applyButtonText, applyButtonTextStyle]}>
|
|
390
|
+
{applyButtonText}
|
|
391
|
+
</Text>
|
|
392
|
+
</TouchableOpacity>
|
|
393
|
+
</BottomSheetView>
|
|
394
|
+
</View>
|
|
395
|
+
</BottomSheet>
|
|
396
|
+
</GestureHandlerRootView>
|
|
397
|
+
);
|
|
398
|
+
};
|
|
387
399
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
400
|
+
const createStyles = (theme: ThemeType, isRTL: boolean) =>
|
|
401
|
+
StyleSheet.create({
|
|
402
|
+
// overlayContainer is likely not needed anymore
|
|
403
|
+
// overlay: { ... }, // Removed - handled by backdropComponent
|
|
404
|
+
gestureHandlerRoot: {
|
|
405
|
+
// Style needed for GestureHandlerRootView if it needs specific layout,
|
|
406
|
+
// often just flex: 1 or position absolute covering the screen
|
|
407
|
+
position: 'absolute',
|
|
408
|
+
top: 0,
|
|
409
|
+
left: 0,
|
|
410
|
+
right: 0,
|
|
411
|
+
bottom: 0,
|
|
412
|
+
zIndex: 1000, // Ensure it's above other content
|
|
413
|
+
},
|
|
414
|
+
container: {
|
|
415
|
+
flex: 1,
|
|
416
|
+
paddingHorizontal: 25,
|
|
417
|
+
backgroundColor: theme.surface, // Background is set on BottomSheet backgroundStyle now
|
|
418
|
+
},
|
|
419
|
+
handleIndicator: {
|
|
420
|
+
width: 40,
|
|
421
|
+
height: 4,
|
|
422
|
+
backgroundColor: theme.border,
|
|
423
|
+
alignSelf: "center",
|
|
424
|
+
marginTop: 8,
|
|
425
|
+
borderRadius: 2,
|
|
426
|
+
},
|
|
427
|
+
header: {
|
|
428
|
+
flexDirection: isRTL ? "row-reverse" : "row",
|
|
429
|
+
justifyContent: "space-between",
|
|
430
|
+
alignItems: "center",
|
|
431
|
+
paddingVertical: 15,
|
|
432
|
+
borderBottomWidth: 1,
|
|
433
|
+
borderBottomColor: theme.border,
|
|
434
|
+
},
|
|
435
|
+
title: {
|
|
436
|
+
fontSize: 18,
|
|
437
|
+
fontWeight: "bold",
|
|
438
|
+
color: theme.text,
|
|
439
|
+
textAlign: isRTL ? "right" : "left",
|
|
440
|
+
},
|
|
441
|
+
resetText: {
|
|
442
|
+
fontSize: 14,
|
|
443
|
+
color: theme.primary,
|
|
444
|
+
fontWeight: "500",
|
|
445
|
+
textAlign: isRTL ? "left" : "right",
|
|
446
|
+
},
|
|
447
|
+
section: {
|
|
448
|
+
marginTop: 20,
|
|
449
|
+
},
|
|
450
|
+
sectionTitle: {
|
|
451
|
+
fontSize: 16,
|
|
452
|
+
fontWeight: "500",
|
|
453
|
+
color: theme.helper,
|
|
454
|
+
marginBottom: 15,
|
|
455
|
+
textAlign: isRTL ? "right" : "left",
|
|
456
|
+
},
|
|
457
|
+
optionRow: {
|
|
458
|
+
flexDirection: isRTL ? "row-reverse" : "row",
|
|
459
|
+
alignItems: "center",
|
|
460
|
+
marginBottom: 15,
|
|
461
|
+
gap: 5,
|
|
462
|
+
},
|
|
463
|
+
optionText: {
|
|
464
|
+
fontSize: 15,
|
|
465
|
+
color: theme.text,
|
|
466
|
+
textAlign: isRTL ? "right" : "left",
|
|
467
|
+
marginLeft: isRTL ? 0 : 8,
|
|
468
|
+
marginRight: isRTL ? 8 : 0,
|
|
469
|
+
},
|
|
470
|
+
brandsGrid: {
|
|
471
|
+
flexDirection: "row",
|
|
472
|
+
flexWrap: "wrap",
|
|
473
|
+
gap: 10,
|
|
474
|
+
justifyContent: isRTL ? "flex-end" : "flex-start",
|
|
475
|
+
},
|
|
476
|
+
applyButton: {
|
|
477
|
+
backgroundColor: theme.primary,
|
|
478
|
+
borderRadius: 30,
|
|
479
|
+
paddingVertical: 15,
|
|
480
|
+
alignItems: "center",
|
|
481
|
+
marginTop: 30,
|
|
482
|
+
// Consider adding marginBottom if needed, especially inside BottomSheetView
|
|
483
|
+
// marginBottom: 20,
|
|
484
|
+
},
|
|
485
|
+
applyButtonText: {
|
|
486
|
+
color: theme.onPrimary,
|
|
487
|
+
fontSize: 16,
|
|
488
|
+
fontWeight: "bold",
|
|
489
|
+
},
|
|
490
|
+
});
|
|
478
491
|
|
|
479
|
-
|
|
492
|
+
export default Filters;
|