import { View, Text, TouchableOpacity, StyleSheet } from "react-native" import { Ionicons } from "@expo/vector-icons" import BottomSheet, { BottomSheetBackdrop, BottomSheetFlatList } from "@gorhom/bottom-sheet" import { useTranslation } from "react-i18next" interface VariantOption { id: string | null label: string description: string } interface Props { variants: Record | undefined selected: string | null isDark: boolean onSelect: (variant: string | null) => void sheetRef: React.RefObject } export function VariantPicker({ variants, selected, isDark, onSelect, sheetRef }: Props) { const { t } = useTranslation() const effortDescriptions: Record = { low: t("chat.variantPicker.effort.low"), medium: t("chat.variantPicker.effort.medium"), high: t("chat.variantPicker.effort.high"), } const autoOption: VariantOption = { id: null, label: t("chat.variantPicker.autoLabel"), description: t("chat.variantPicker.autoDescription"), } const options: VariantOption[] = [ autoOption, ...Object.keys(variants || {}).map((id) => ({ id, label: id.charAt(0).toUpperCase() + id.slice(1), description: effortDescriptions[id] ?? id, })), ] const handleSelect = (id: string | null) => { onSelect(id) sheetRef.current?.close() } return ( ( )} > {t("chat.variantPicker.title")} item.id ?? "auto"} renderItem={({ item }: { item: VariantOption }) => { const active = item.id === selected return ( handleSelect(item.id)} testID={`variant-option-${item.id ?? "auto"}`} > {item.label} {item.description} {active && } ) }} contentContainerStyle={s.content} /> ) } const s = StyleSheet.create({ sheet: { backgroundColor: "#ffffff" }, sheetDark: { backgroundColor: "#1a1a1a" }, header: { paddingHorizontal: 16, paddingBottom: 12 }, title: { fontSize: 18, fontWeight: "700", color: "#0a0a0a" }, textWhite: { color: "#ffffff" }, metaDark: { color: "#666666" }, content: { paddingBottom: 40 }, row: { flexDirection: "row", alignItems: "center", paddingHorizontal: 16, paddingVertical: 14, borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: "#e5e5e5", }, rowDark: { borderBottomColor: "#2a2a2a" }, rowSelected: { backgroundColor: "#f5f3ff" }, rowSelectedDark: { backgroundColor: "#1f1a2e" }, rowText: { flex: 1 }, rowName: { fontSize: 15, fontWeight: "600", color: "#0a0a0a" }, rowDesc: { fontSize: 12, color: "#999999", marginTop: 2 }, })