import { useState } from 'react'; import { View, Text, Pressable, Image } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { colors } from '../../lib/theme'; import { resolveAvatar } from '../../lib/resolveAvatar'; import type { Plan } from '../../hooks/useUserPlan'; export type AuthProvider = 'apple' | 'google' | 'email'; type Props = { nickname: string; email: string; avatar: string | null; plan: Plan; memberSince: string; provider: AuthProvider; showDemographicsHint?: boolean; onEditAvatar?: () => void; onEditNickname?: () => void; onDemographicsHintPress?: () => void; }; const planLabel: Record = { free: 'Free', pro: 'Pro', legend: 'Legend', }; const planColors: Record = { free: { bg: '#f5f5f5', text: '#525252', border: '#e5e5e5' }, pro: { bg: '#fff7ed', text: '#c2410c', border: '#fed7aa' }, legend: { bg: '#fef9c3', text: '#854d0e', border: '#fde68a' }, }; export function ProfileHeader({ nickname, email, avatar, plan, memberSince, provider, showDemographicsHint, onEditAvatar, onEditNickname, onDemographicsHintPress, }: Props) { const [imageFailed, setImageFailed] = useState(false); const avatarUrl = resolveAvatar(avatar, nickname); const initials = nickname.slice(0, 2).toUpperCase(); const showImage = !!avatar && !imageFailed; const planStyle = planColors[plan]; const providerPillLabel = provider === 'apple' ? 'via Apple Sign-In' : provider === 'google' ? 'via Google Sign-In' : null; return ( {/* Avatar — Pressable; Camera-Badge ist eigene Pressable (vorher nur dekoratives View) */} ({ position: 'relative', opacity: pressed ? 0.85 : 1, })} > {showImage ? ( setImageFailed(true)} style={{ width: 92, height: 92, borderRadius: 46 }} /> ) : ( {initials} )} {/* Camera-Badge — iOS-Photos-Pattern: blauer Kreis, weißes Icon */} {/* Nickname — ganze Zeile Pressable (iOS-Settings-Pattern), kein hässliches Pencil */} ({ flexDirection: 'row', alignItems: 'center', marginTop: 16, gap: 6, opacity: pressed ? 0.5 : 1, })} > {nickname} {providerPillLabel ? ( {providerPillLabel} ) : ( {email} )} {planLabel[plan].toUpperCase()} Mitglied seit {memberSince} {/* Freundlicher Hint statt Progress-Bar — nur sichtbar wenn Demographics unvollständig */} {showDemographicsHint ? ( ({ alignSelf: 'stretch', marginTop: 14, paddingHorizontal: 14, paddingVertical: 10, borderRadius: 12, backgroundColor: '#f5f8ff', borderWidth: 1, borderColor: '#dbe5ff', flexDirection: 'row', alignItems: 'center', gap: 10, opacity: pressed ? 0.7 : 1, })} > Hilf uns rebreak besser zu machen — fülle deine anonymen Daten aus. ) : null} ); }