// app/(tabs)/profile.tsx import { View, ScrollView, ImageBackground } from 'react-native'; import { useState, useEffect } from 'react'; import { Settings, LogIn, Bell } from 'lucide-react-native'; import { H1 } from '@/components/ui/typography'; import { Button } from '@/components/ui/button'; import { Text } from '@/components/ui/text'; import Header from '@/components/Header'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { TabScreen } from '@/components/layout/TabScreen'; import UserAvatar from '@/components/UserAvatar'; import { useNDKCurrentUser } from '@/lib/hooks/useNDK'; import NostrLoginSheet from '@/components/sheets/NostrLoginSheet'; export default function ProfileScreen() { const insets = useSafeAreaInsets(); const { currentUser, isAuthenticated } = useNDKCurrentUser(); const [profileImageUrl, setProfileImageUrl] = useState(undefined); const [bannerImageUrl, setBannerImageUrl] = useState(undefined); const [aboutText, setAboutText] = useState(undefined); const [isLoginSheetOpen, setIsLoginSheetOpen] = useState(false); const displayName = isAuthenticated ? (currentUser?.profile?.displayName || currentUser?.profile?.name || 'Nostr User') : 'Guest User'; const username = isAuthenticated ? (currentUser?.profile?.nip05 || '@user') : '@guest'; // Reset profile data when authentication state changes useEffect(() => { if (!isAuthenticated) { setProfileImageUrl(undefined); setBannerImageUrl(undefined); setAboutText(undefined); } }, [isAuthenticated]); // Extract profile data from Nostr profile useEffect(() => { if (currentUser?.profile) { console.log('Profile data:', currentUser.profile); // Extract image URL const imageUrl = currentUser.profile.image || currentUser.profile.picture || (currentUser.profile as any).avatar || undefined; setProfileImageUrl(imageUrl); // Extract banner URL const bannerUrl = currentUser.profile.banner || (currentUser.profile as any).background || undefined; setBannerImageUrl(bannerUrl); // Extract about text const about = currentUser.profile.about || (currentUser.profile as any).description || undefined; setAboutText(about); } }, [currentUser?.profile]); // Show different UI when not authenticated if (!isAuthenticated) { return (
console.log('Open notifications')} > } />

Guest User

Not logged in Login with your Nostr private key to view and manage your profile.
{/* NostrLoginSheet */} setIsLoginSheetOpen(false)} /> ); } return (
{/* Banner Image */} {bannerImageUrl ? ( ) : ( )} {/* Profile Avatar and Name - positioned to overlap the banner */}

{displayName}

{username} {/* About section */} {aboutText && ( {aboutText} )}
{/* Stats */} 24 Workouts 12 Templates 3 Programs
); }