import React from 'react'; import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { useTheme } from '@react-navigation/native'; import { useAppTheme } from '../theme/ThemeProvider'; // Typ für die Template-Props interface TemplateCardProps { id: string; name: string; description?: string | null; systemPrompt: string; color?: string; isDefault?: boolean; onPress: (id: string) => void; onEdit?: (id: string) => void; onDelete?: (id: string) => void; onSetDefault?: (id: string) => void; } export default function TemplateCard({ id, name, description, systemPrompt, color = '#0A84FF', isDefault = false, onPress, onEdit, onDelete, onSetDefault }: TemplateCardProps) { const { colors } = useTheme(); const { isDarkMode } = useAppTheme(); const backgroundColor = isDarkMode ? '#2C2C2E' : '#FFFFFF'; const textColor = isDarkMode ? '#FFFFFF' : '#000000'; const secondaryTextColor = isDarkMode ? 'rgba(255,255,255,0.7)' : 'rgba(0,0,0,0.7)'; // Kürze den System-Prompt für die Anzeige const truncatedPrompt = systemPrompt.length > 80 ? systemPrompt.substring(0, 80) + '...' : systemPrompt; return ( onPress(id)} > {/* Farbiger Indikator am linken Rand */} {name} {isDefault && ( Standard )} {description && ( {description} )} {truncatedPrompt} {/* Aktionen */} {onSetDefault && !isDefault && ( onSetDefault(id)} > )} {onEdit && ( onEdit(id)} > )} {onDelete && ( onDelete(id)} > )} ); } const styles = StyleSheet.create({ container: { flexDirection: 'row', borderRadius: 12, marginBottom: 12, overflow: 'hidden', shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 4, elevation: 3, }, defaultContainer: { borderWidth: 1, borderColor: '#0A84FF', }, colorIndicator: { width: 8, alignSelf: 'stretch', }, content: { flex: 1, padding: 16, }, header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8, }, name: { fontSize: 16, fontWeight: '600', flex: 1, }, defaultBadge: { backgroundColor: '#0A84FF', paddingHorizontal: 6, paddingVertical: 2, borderRadius: 4, marginLeft: 8, }, defaultText: { color: 'white', fontSize: 10, fontWeight: '600', }, description: { fontSize: 14, marginBottom: 8, }, prompt: { fontSize: 12, fontStyle: 'italic', }, actions: { padding: 8, justifyContent: 'center', }, actionButton: { padding: 8, }, });