import { Button } from '@/components/ui/button';
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
} from '@/components/ui/sheet';
import { Text } from '@/components/ui/text';
import { View } from '@/components/ui/view';
import { useColor } from '@/hooks/useColor';
import { Filter } from 'lucide-react-native';
import React, { useState } from 'react';
import { StyleSheet, TouchableOpacity } from 'react-native';
export function SheetFilter() {
const [open, setOpen] = useState(false);
const [filters, setFilters] = useState({
category: 'all',
price: 'all',
rating: 'all',
brand: 'all',
});
const textColor = useColor('text');
const mutedColor = useColor('textMuted');
const borderColor = useColor('border');
const filterOptions = {
category: [
{ value: 'all', label: 'All Categories' },
{ value: 'electronics', label: 'Electronics' },
{ value: 'clothing', label: 'Clothing' },
{ value: 'books', label: 'Books' },
{ value: 'home', label: 'Home & Garden' },
],
price: [
{ value: 'all', label: 'Any Price' },
{ value: 'under-25', label: 'Under $25' },
{ value: '25-50', label: '$25 - $50' },
{ value: '50-100', label: '$50 - $100' },
{ value: 'over-100', label: 'Over $100' },
],
rating: [
{ value: 'all', label: 'Any Rating' },
{ value: '4-plus', label: '4+ Stars' },
{ value: '3-plus', label: '3+ Stars' },
{ value: '2-plus', label: '2+ Stars' },
],
brand: [
{ value: 'all', label: 'All Brands' },
{ value: 'apple', label: 'Apple' },
{ value: 'samsung', label: 'Samsung' },
{ value: 'nike', label: 'Nike' },
{ value: 'adidas', label: 'Adidas' },
],
};
const handleFilterChange = (
filterType: keyof typeof filters,
value: string
) => {
setFilters((prev) => ({ ...prev, [filterType]: value }));
};
const handleApplyFilters = () => {
// Apply filters logic here
console.log('Applied filters:', filters);
setOpen(false);
};
const handleClearFilters = () => {
setFilters({
category: 'all',
price: 'all',
rating: 'all',
brand: 'all',
});
};
const renderFilterSection = (
title: string,
filterType: keyof typeof filters,
options: { value: string; label: string }[]
) => (
{title}
{options.map((option) => (
handleFilterChange(filterType, option.value)}
>
{option.label}
))}
);
return (
Filter Products
Refine your search results using the filters below.
{renderFilterSection('Category', 'category', filterOptions.category)}
{renderFilterSection('Price Range', 'price', filterOptions.price)}
{renderFilterSection('Rating', 'rating', filterOptions.rating)}
{renderFilterSection('Brand', 'brand', filterOptions.brand)}
);
}
const styles = StyleSheet.create({
filterContainer: {
padding: 16,
gap: 24,
},
filterSection: {
gap: 12,
},
sectionTitle: {
fontSize: 18,
fontWeight: '600',
},
optionsContainer: {
gap: 8,
},
option: {
padding: 12,
borderRadius: 8,
borderWidth: 1,
},
optionText: {
fontSize: 16,
},
buttonContainer: {
flexDirection: 'row',
gap: 12,
marginTop: 12,
},
button: {
flex: 1,
},
});