import React, { useState } from 'react'; import { View, TouchableOpacity, Modal, ScrollView, Dimensions } from 'react-native'; import FontAwesome from '@expo/vector-icons/FontAwesome'; import { useTheme } from '~/utils/ThemeContext'; import { ThemedText, ThemedView } from './ThemedView'; const { width: SCREEN_WIDTH } = Dimensions.get('window'); interface FigureInfoModalProps { visible: boolean; onClose: () => void; title: string; creator: string; activeTab: 'character' | 'item1' | 'item2' | 'item3'; onTabChange: (tab: 'character' | 'item1' | 'item2' | 'item3') => void; characterInfo?: { character?: { description?: string; lore?: string; }; items?: Array<{ name?: string; description?: string; lore?: string; }>; }; } export const FigureInfoModal: React.FC = ({ visible, onClose, title, creator, activeTab, onTabChange, characterInfo, }) => { const { theme, isDark } = useTheme(); // Prüfen, ob Daten für die verschiedenen Tabs vorhanden sind const hasCharacter = !!characterInfo?.character?.description; const hasItems = !!characterInfo?.items && characterInfo.items.length > 0; const itemCount = hasItems ? Math.min(characterInfo!.items!.length, 3) : 0; // Rendere den Inhalt basierend auf dem aktiven Tab const renderContent = () => { if (activeTab === 'character' && hasCharacter) { return ( Character {characterInfo?.character?.description || 'No description available.'} {characterInfo?.character?.lore && ( Lore {characterInfo.character.lore} )} ); } else if (activeTab.startsWith('item') && hasItems) { const itemIndex = parseInt(activeTab.replace('item', '')) - 1; if (itemIndex >= 0 && itemIndex < itemCount) { const item = characterInfo!.items![itemIndex]; return ( {item.name || `Item ${itemIndex + 1}`} {item.description || 'No description available.'} {item.lore && ( Lore {item.lore} )} ); } } return ( No information available. ); }; return ( e.stopPropagation()} > {/* Header with title and creator */} {title} by {creator} {/* Content area */} {renderContent()} {/* Tab bar at the bottom */} {/* Character Tab */} onTabChange('character')} disabled={!hasCharacter} > Character {/* Item Tabs */} {[1, 2, 3].map((num) => ( itemCount >= num && onTabChange(`item${num}` as 'item1' | 'item2' | 'item3') } disabled={itemCount < num} > = num ? 1 : 0.3 }} /> Item {num} ))} ); };