import { type ReactNode } from 'react' import { View, Text, TouchableOpacity, StyleSheet, ActivityIndicator, TextInput, type StyleProp, type ViewStyle, type TextStyle, } from 'react-native' import { Feather } from '@expo/vector-icons' import { useTheme } from '../constants/ThemeContext' import { statusColor, type ThemeTokens } from '../constants/ItmsTheme' /** 카드 컨테이너. */ export function Card({ children, style }: { children: ReactNode; style?: StyleProp }) { const { t } = useTheme() return ( {children} ) } /** 진행상태 배지(라벨 부분일치 색). */ export function StatusPill({ label }: { label?: string | null }) { const { t } = useTheme() const text = (label ?? '').toString() || '-' const color = statusColor(label, t) return ( {text} ) } /** 기본 버튼(primary/ghost/danger/outline). */ export function Btn({ label, onPress, kind = 'primary', busy, disabled, icon, style, }: { label: string; onPress: () => void; kind?: 'primary' | 'ghost' | 'danger' | 'outline' busy?: boolean; disabled?: boolean; icon?: keyof typeof Feather.glyphMap; style?: StyleProp }) { const { t } = useTheme() const bg = kind === 'primary' ? t.brand : kind === 'danger' ? t.danger : 'transparent' const fg = kind === 'ghost' || kind === 'outline' ? t.text : t.onBrand const border = kind === 'outline' ? t.border : 'transparent' return ( {busy ? : ( <> {icon && } {label} )} ) } /** 라벨 + 입력 필드. */ export function Field({ label, value, onChangeText, placeholder, keyboardType, multiline, secureTextEntry, autoCapitalize, }: { label?: string; value: string; onChangeText: (s: string) => void; placeholder?: string keyboardType?: 'default' | 'number-pad' | 'email-address'; multiline?: boolean; secureTextEntry?: boolean autoCapitalize?: 'none' | 'sentences' }) { const { t } = useTheme() return ( {!!label && {label}} ) } /** 빈 상태 안내(서버 미기동/무결과 공통). */ export function EmptyState({ icon = 'inbox', text }: { icon?: keyof typeof Feather.glyphMap; text: string }) { const { t } = useTheme() return ( {text} ) } /** 전체 화면 로딩. */ export function Loading() { const { t } = useTheme() return ( ) } /** 라벨:값 한 줄. */ export function Row({ label, value }: { label: string; value?: ReactNode }) { const { t } = useTheme() return ( {label} {typeof value === 'string' || typeof value === 'number' ? {value || '-'} : (value ?? -)} ) } /** 섹션 제목. */ export function SectionTitle({ children, style }: { children: ReactNode; style?: StyleProp }) { const { t } = useTheme() return {children} } /** 인라인 에러 텍스트. */ export function ErrText({ msg }: { msg?: string }) { const { t } = useTheme() if (!msg) return null return {msg} } export type { ThemeTokens }