chahinebrini 0d52cb1846 fix(ui): keyboard-first-tap, Teilen-Button bigger, Header-Icon hitSlop
(app)/index.tsx:
- FlatList keyboardShouldPersistTaps="handled" — Bild-Icon im ComposeCard
  reagiert ab erstem Tap auch wenn Tastatur offen. Vorher dismisste der
  Tap nur die Tastatur (RN-Default "never").

ComposeCard.tsx Teilen-Button:
- height 44→52, px-5→px-6, paper-plane-outline-Icon size 18 + text-base
  Nunito_700Bold. Standard-iOS-Filled-Primary-Button-Style.

AppHeader.tsx Bell + Avatar:
- hitSlop 4pt allseitig auf beiden Pressables — effective tap-area
  36→44pt ohne Layout-Verschiebung
- Bell-Icon size 18→22 (konsistent mit Avatar-36pt-Kreis)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 21:23:46 +02:00

122 lines
4.9 KiB
TypeScript

import { useState } from 'react';
import { View, Text, Pressable, Image } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Ionicons } from '@expo/vector-icons';
import { useRouter, type RelativePathString } from 'expo-router';
import { useTranslation } from 'react-i18next';
import { useAuthStore } from '../stores/auth';
import { useNotificationStore } from '../stores/notifications';
import { resolveAvatar } from '../lib/resolveAvatar';
import { useMe } from '../hooks/useMe';
import { NotificationsDropdown } from './NotificationsDropdown';
import { HeaderDropdownMenu } from './header/HeaderDropdownMenu';
type Props = {
notifCount?: number;
showBack?: boolean;
title?: string;
};
export function AppHeader({ notifCount, showBack, title }: Props = {}) {
const insets = useSafeAreaInsets();
const router = useRouter();
const { t } = useTranslation();
const { user } = useAuthStore();
const { me } = useMe();
const storeUnread = useNotificationStore((s) => s.unread);
const badge = notifCount ?? storeUnread;
const [notifOpen, setNotifOpen] = useState(false);
const [menuOpen, setMenuOpen] = useState(false);
const firstName = (user?.user_metadata?.first_name as string | undefined) ?? '';
const lastName = (user?.user_metadata?.last_name as string | undefined) ?? '';
const email = user?.email ?? '';
const initials = (() => {
if (me?.nickname) return me.nickname.slice(0, 2).toUpperCase();
return ((firstName.charAt(0) + (lastName.charAt(0) || email.charAt(0))).toUpperCase() || '?');
})();
// Avatar: aus DB (`/api/auth/me` → profiles.avatar). Kann Hero-Avatar-ID
// ("spider"/"hulk"/...) ODER Custom-Photo-URL (https://... von Foto-Upload)
// sein. resolveAvatar handlet beide Fälle.
const avatarUrl = me ? resolveAvatar(me.avatar, me.nickname ?? '') : '';
const [avatarLoadFailed, setAvatarLoadFailed] = useState(false);
const showAvatarImage = !!avatarUrl && !avatarLoadFailed && !!me?.avatar;
const headerHeight = insets.top + 56;
return (
<View
className="bg-white border-b border-neutral-200"
style={{ paddingTop: insets.top }}
>
<View className="h-14 flex-row items-center justify-between px-5">
<View className="flex-row items-center" style={{ gap: 8 }}>
{showBack ? (
<Pressable
onPress={() => router.back()}
hitSlop={10}
className="w-9 h-9 rounded-full items-center justify-center"
style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1, marginLeft: -8 })}
accessibilityLabel="Zurück"
>
<Ionicons name="chevron-back" size={22} color="#0a0a0a" />
</Pressable>
) : null}
<Text className="text-lg text-midnight-900 tracking-tight" style={{ fontFamily: 'Nunito_700Bold' }}>
{title ?? t('appHeader.appName')}
</Text>
</View>
<View className="flex-row items-center gap-1">
<Pressable
onPress={() => setNotifOpen(true)}
hitSlop={{ top: 4, bottom: 4, left: 4, right: 4 }}
className="w-9 h-9 rounded-full bg-white items-center justify-center"
style={({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })}
>
<Ionicons name="notifications-outline" size={22} color="#737373" />
{badge > 0 && (
<View className="absolute top-0 right-0 w-4 h-4 rounded-full bg-rebreak-500 items-center justify-center">
<Text className="text-white text-[9px]" style={{ fontFamily: 'Nunito_700Bold' }}>
{badge > 9 ? '9+' : String(badge)}
</Text>
</View>
)}
</Pressable>
{/* Avatar = Trigger für Dropdown-Menu (kein separates 3-Punkte-Icon) */}
<Pressable
onPress={() => setMenuOpen(true)}
hitSlop={{ top: 4, bottom: 4, left: 4, right: 4 }}
className={`w-9 h-9 rounded-full items-center justify-center overflow-hidden ${showAvatarImage ? 'bg-neutral-100' : 'bg-rebreak-500'}`}
style={({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })}
>
{showAvatarImage ? (
<Image
source={{ uri: avatarUrl }}
onError={() => setAvatarLoadFailed(true)}
style={{ width: 36, height: 36, borderRadius: 18 }}
/>
) : (
<Text className="text-white text-xs" style={{ fontFamily: 'Nunito_700Bold' }}>{initials}</Text>
)}
</Pressable>
<HeaderDropdownMenu
visible={menuOpen}
onClose={() => setMenuOpen(false)}
topOffset={headerHeight + 6}
/>
</View>
</View>
<NotificationsDropdown
visible={notifOpen}
onClose={() => setNotifOpen(false)}
topOffset={headerHeight}
/>
</View>
);
}