import { useState } from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import { Image } from 'expo-image';
import { Ionicons } from '@expo/vector-icons';
import Svg, { Path } from 'react-native-svg';
import { useColors } from '../../lib/theme';
import { resolveAvatar } from '../../lib/resolveAvatar';
import type { Plan } from '../../hooks/useUserPlan';
function GoogleIcon() {
return (
);
}
function AppleIcon() {
return (
);
}
export type AuthProvider = 'apple' | 'google' | 'email';
type Props = {
nickname: string;
email: string;
avatar: string | null;
plan: Plan;
memberSince: string;
provider: AuthProvider;
demographicsComplete?: boolean;
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: vivid gold, white text, premium-look mit sparkles-icon
legend: { bg: '#f59e0b', text: '#ffffff', border: '#d97706', icon: 'sparkles' },
};
export function ProfileHeader({
nickname,
email,
avatar,
plan,
memberSince,
provider,
demographicsComplete,
showDemographicsHint,
onEditAvatar,
onEditNickname,
onDemographicsHintPress,
}: Props) {
const colors = useColors();
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 in alignSelf:center-Wrapper (Pressable+style-fn ignoriert alignSelf manchmal in RN) */}
{showImage ? (
setImageFailed(true)}
style={{ width: 92, height: 92, borderRadius: 46 }}
/>
) : (
{initials}
)}
{/* Camera-Badge — iOS-Photos-Pattern: schwarzer Kreis, weißes Icon */}
{/* Nickname — ganze Zeile Pressable in alignSelf:center-Wrapper */}
{nickname}
{/* Plan-Tier-Badge direkt unter Nickname — Legend mit sparkles-icon */}
{planStyle.icon ? (
) : null}
{planLabel[plan].toUpperCase()}
{providerPillLabel ? (
{provider === 'google' ? : }
{providerPillLabel}
) : (
{email}
)}
Mitglied seit {memberSince}
{/* Freundlicher Hint — nur sichtbar wenn Demographics unvollständig.
Parent ist KEIN alignItems:center mehr — Hint nimmt natürlich volle Breite (default flex-stretch).
KEIN width:'100%' (Konflikt mit alignSelf:stretch in alignItems:center-Kontext war der Bug). */}
{showDemographicsHint ? (
Hilf uns rebreak besser zu machen
Fülle deine anonymen Daten aus.
) : null}
);
}