import React, { useState } from "react"; import { View, Text, TouchableOpacity, StyleSheet, Modal, Platform, ScrollView, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { TripStatus } from "./types"; import { useI18n } from "@/hooks/use-i18n"; interface StatusDropdownProps { value: TripStatus | null; onChange: (value: TripStatus | null) => void; } export default function StatusDropdown({ value, onChange, }: StatusDropdownProps) { const { t } = useI18n(); const [isOpen, setIsOpen] = useState(false); const STATUS_OPTIONS: Array<{ value: TripStatus | null; label: string }> = [ { value: null, label: t("diary.statusDropdown.placeholder") }, { value: 0, label: t("diary.statusDropdown.created") }, { value: 1, label: t("diary.statusDropdown.pending") }, { value: 2, label: t("diary.statusDropdown.approved") }, { value: 3, label: t("diary.statusDropdown.active") }, { value: 4, label: t("diary.statusDropdown.completed") }, { value: 5, label: t("diary.statusDropdown.cancelled") }, ]; const selectedLabel = STATUS_OPTIONS.find((opt) => opt.value === value)?.label || t("diary.statusDropdown.placeholder"); const handleSelect = (status: TripStatus | null) => { onChange(status); setIsOpen(false); }; return ( {t("diary.statusDropdown.label")} setIsOpen(true)} activeOpacity={0.7} > {selectedLabel} setIsOpen(false)} > setIsOpen(false)} > {STATUS_OPTIONS.map((option, index) => ( handleSelect(option.value)} > {option.label} {value === option.value && ( )} ))} ); } const styles = StyleSheet.create({ container: { marginBottom: 20, }, label: { fontSize: 16, fontWeight: "600", color: "#111827", marginBottom: 8, fontFamily: Platform.select({ ios: "System", android: "Roboto", default: "System", }), }, selector: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", backgroundColor: "#FFFFFF", borderWidth: 1, borderColor: "#D1D5DB", borderRadius: 8, paddingHorizontal: 16, paddingVertical: 12, }, selectorText: { fontSize: 16, color: "#111827", fontFamily: Platform.select({ ios: "System", android: "Roboto", default: "System", }), }, placeholder: { color: "#9CA3AF", }, modalOverlay: { flex: 1, backgroundColor: "rgba(0, 0, 0, 0.5)", justifyContent: "center", alignItems: "center", }, modalContent: { backgroundColor: "#FFFFFF", borderRadius: 12, width: "80%", maxHeight: "60%", overflow: "hidden", shadowColor: "#000", shadowOffset: { width: 0, height: 4, }, shadowOpacity: 0.3, shadowRadius: 8, elevation: 8, }, option: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", paddingHorizontal: 20, paddingVertical: 16, borderBottomWidth: 1, borderBottomColor: "#F3F4F6", }, selectedOption: { backgroundColor: "#EFF6FF", }, optionText: { fontSize: 16, color: "#111827", fontFamily: Platform.select({ ios: "System", android: "Roboto", default: "System", }), }, selectedOptionText: { color: "#3B82F6", fontWeight: "600", }, });