import React from 'react'; import { View, Text, Pressable, TextInput, StyleSheet } from 'react-native'; import { Colors } from '../theme/colors'; import { FontSize, FontWeight, Radius, Spacing } from '../theme/layout'; import type { FeatureSummary } from './buildFeatureSummary'; import { t } from '../../i18n'; function hexWithAlpha(hex: string, alpha: string): string { if (/^#[0-9a-fA-F]{6}$/.test(hex)) return hex + alpha; return Colors.primaryGhost; } interface FeatureIntroCardProps { title: string; summary: FeatureSummary; filterBad: boolean; onFilterBad: (bad: boolean) => void; searchQuery: string; onSearchChange: (text: string) => void; showSearch: boolean; searchExpanded: boolean; onSearchExpandedChange: (expanded: boolean) => void; } export function FeatureIntroCard({ title, summary, filterBad, onFilterBad, searchQuery, onSearchChange, showSearch, searchExpanded, onSearchExpandedChange, }: FeatureIntroCardProps) { const { statusLabel, statusColor, supportsBadFilter } = summary; const metrics = [ summary.count != null ? t('panel.itemsCaptured', { count: summary.count }) : null, summary.badCount != null ? t('panel.badItems', { count: summary.badCount }) : null, summary.latestLabel ? t('panel.latest', { value: summary.latestLabel }) : null, ].filter((item): item is string => Boolean(item)); return ( {searchExpanded && showSearch ? ( onSearchExpandedChange(false)} > {t('common.done')} ) : ( {title} {metrics.length > 0 && ( {metrics.map((metric, index) => ( {metric} ))} )} {statusLabel && ( {statusLabel} )} {supportsBadFilter && ( onFilterBad(false)}> {t('common.all')} onFilterBad(true)}> {t('common.bad')} )} {showSearch && ( onSearchExpandedChange(true)} > ⌕ )} )} ); } const styles = StyleSheet.create({ bar: { paddingHorizontal: Spacing.MD, paddingTop: Spacing.MD, paddingBottom: Spacing.SM, borderBottomWidth: 1, borderBottomColor: Colors.panelDivider, backgroundColor: Colors.surface, }, titleRow: { minHeight: 50, flexDirection: 'row', alignItems: 'flex-start', gap: Spacing.SM, }, titleBlock: { flex: 1, minWidth: 0, }, title: { fontSize: FontSize.MD, fontWeight: FontWeight.bold, color: Colors.text, }, metricRow: { flexDirection: 'row', alignItems: 'center', gap: Spacing.SM, marginTop: Spacing.XS, minWidth: 0, }, metricText: { fontSize: FontSize.XS, fontWeight: FontWeight.semibold, color: Colors.textMuted, }, latestMetric: { flex: 1, minWidth: 0, color: Colors.textSecondary, }, actionBlock: { alignItems: 'flex-end', gap: Spacing.XS, maxWidth: 174, }, statusChip: { maxWidth: 174, minHeight: 22, paddingHorizontal: Spacing.SM, paddingVertical: 3, borderRadius: Radius.MD, backgroundColor: Colors.primaryGhost, flexDirection: 'row', alignItems: 'center', gap: Spacing.XS, }, statusDot: { width: 6, height: 6, borderRadius: 3, backgroundColor: Colors.textMuted, }, statusText: { fontSize: FontSize.XS, fontWeight: FontWeight.bold, color: Colors.textSecondary, }, actionRow: { flexDirection: 'row', alignItems: 'center', gap: Spacing.XS, }, filterRow: { flexDirection: 'row', borderRadius: Radius.MD, borderWidth: 1, borderColor: Colors.border, overflow: 'hidden', }, chip: { height: 24, minWidth: 42, paddingHorizontal: Spacing.SM, justifyContent: 'center', alignItems: 'center', backgroundColor: Colors.surfaceInset, }, chipActive: { backgroundColor: Colors.primary, }, chipBadActive: { backgroundColor: Colors.error, }, chipText: { fontSize: FontSize.XS, fontWeight: FontWeight.bold, color: Colors.textSecondary, }, chipTextActive: { color: Colors.textInverse, }, chipTextBad: { color: Colors.textInverse, }, searchRow: { minHeight: 50, flexDirection: 'row', alignItems: 'center', gap: Spacing.SM, }, searchInput: { flex: 1, height: 36, borderWidth: 1, borderColor: Colors.borderFocus, borderRadius: Radius.MD, backgroundColor: Colors.surfaceInset, paddingHorizontal: Spacing.MD, fontSize: FontSize.MD, color: Colors.text, }, searchTrigger: { width: 30, height: 24, borderRadius: Radius.MD, borderWidth: 1, borderColor: Colors.border, alignItems: 'center', justifyContent: 'center', backgroundColor: Colors.surfaceInset, }, searchTriggerActive: { borderColor: Colors.primary, backgroundColor: Colors.primaryGhost, }, searchTriggerText: { fontSize: FontSize.LG, color: Colors.textSecondary }, searchTriggerTextActive: { color: Colors.primary }, searchDone: { height: 32, paddingHorizontal: Spacing.SM, justifyContent: 'center', borderRadius: Radius.MD, }, searchDoneText: { color: Colors.primary, fontSize: FontSize.SM, fontWeight: FontWeight.semibold, }, });