import React, { useState } from "react"; import { View, Text, Modal, TouchableOpacity, StyleSheet, Platform, ScrollView, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import StatusDropdown from "./StatusDropdown"; import DateRangePicker from "./DateRangePicker"; import { TripStatus } from "./types"; interface FilterModalProps { visible: boolean; onClose: () => void; onApply: (filters: FilterValues) => void; } export interface FilterValues { status: TripStatus | null; startDate: Date | null; endDate: Date | null; } export default function FilterModal({ visible, onClose, onApply, }: FilterModalProps) { const [status, setStatus] = useState(null); const [startDate, setStartDate] = useState(null); const [endDate, setEndDate] = useState(null); const handleReset = () => { setStatus(null); setStartDate(null); setEndDate(null); }; const handleApply = () => { onApply({ status, startDate, endDate }); onClose(); }; const hasFilters = status !== null || startDate !== null || endDate !== null; return ( e.stopPropagation()} > {/* Header */} Bộ lọc {/* Content */} {/* Filter Results Preview */} {hasFilters && ( Bộ lọc đã chọn: {status && ( Trạng thái: {status} )} {startDate && ( Từ: {startDate.toLocaleDateString("vi-VN")} )} {endDate && ( Đến: {endDate.toLocaleDateString("vi-VN")} )} )} {/* Footer */} Đặt lại Áp dụng ); } const styles = StyleSheet.create({ overlay: { flex: 1, backgroundColor: "rgba(0, 0, 0, 0.5)", justifyContent: "flex-end", }, modalContainer: { backgroundColor: "#FFFFFF", borderTopLeftRadius: 24, borderTopRightRadius: 24, maxHeight: "80%", shadowColor: "#000", shadowOffset: { width: 0, height: -4, }, shadowOpacity: 0.1, shadowRadius: 12, elevation: 8, }, header: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingHorizontal: 20, paddingVertical: 16, borderBottomWidth: 1, borderBottomColor: "#F3F4F6", }, closeButton: { padding: 4, }, title: { fontSize: 18, fontWeight: "700", color: "#111827", fontFamily: Platform.select({ ios: "System", android: "Roboto", default: "System", }), }, placeholder: { width: 32, }, content: { padding: 20, }, previewContainer: { marginTop: 20, padding: 16, backgroundColor: "#F9FAFB", borderRadius: 12, }, previewTitle: { fontSize: 14, fontWeight: "600", color: "#6B7280", marginBottom: 12, fontFamily: Platform.select({ ios: "System", android: "Roboto", default: "System", }), }, filterTag: { backgroundColor: "#EFF6FF", paddingHorizontal: 12, paddingVertical: 6, borderRadius: 16, marginBottom: 8, alignSelf: "flex-start", }, filterTagText: { fontSize: 14, color: "#3B82F6", fontFamily: Platform.select({ ios: "System", android: "Roboto", default: "System", }), }, footer: { flexDirection: "row", gap: 12, padding: 20, borderTopWidth: 1, borderTopColor: "#F3F4F6", }, resetButton: { flex: 1, backgroundColor: "#F3F4F6", paddingVertical: 14, borderRadius: 12, alignItems: "center", }, resetButtonText: { fontSize: 16, fontWeight: "600", color: "#6B7280", fontFamily: Platform.select({ ios: "System", android: "Roboto", default: "System", }), }, applyButton: { flex: 1, backgroundColor: "#3B82F6", paddingVertical: 14, borderRadius: 12, alignItems: "center", }, applyButtonText: { fontSize: 16, fontWeight: "600", color: "#FFFFFF", fontFamily: Platform.select({ ios: "System", android: "Roboto", default: "System", }), }, });