36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
// Cross-platform Tab-Bar Icons.
|
|
//
|
|
// react-native-bottom-tabs akzeptiert `ImageSource | AppleIcon` als tabBarIcon.
|
|
// AppleIcon = SF Symbols → iOS-only. Auf Android müssen wir ImageSource liefern.
|
|
//
|
|
// Lösung: 5 PNG-Files (Ionicons-rastered) im assets/tabs/-Ordner. Metro bundelt
|
|
// sie automatisch + Android RES-Drawable wird via require()-Asset-Hash erzeugt.
|
|
// react-native-bottom-tabs wendet tabBarActiveTintColor automatisch als Tint an.
|
|
//
|
|
// Warum nicht Ionicons.getImageSource() at runtime? @expo/vector-icons v14
|
|
// expose-d die statische Methode nicht mehr — und der Vendor-Pfad nutzt
|
|
// RNVectorIconsManager (native), das Expo nicht bundled. Bundle-PNGs sind die
|
|
// einzige zuverlässige Lösung.
|
|
import { Platform, type ImageSourcePropType } from 'react-native';
|
|
|
|
export type TabKey = 'home' | 'chat' | 'coach' | 'blocker' | 'mail';
|
|
|
|
const ANDROID_ICONS: Record<TabKey, ImageSourcePropType> = {
|
|
home: require('../assets/tabs/home.png'),
|
|
chat: require('../assets/tabs/chatbubble.png'),
|
|
coach: require('../assets/tabs/sparkles.png'),
|
|
blocker: require('../assets/tabs/shield-checkmark.png'),
|
|
mail: require('../assets/tabs/mail.png'),
|
|
};
|
|
|
|
export function getTabIcon(key: TabKey): ImageSourcePropType | undefined {
|
|
if (Platform.OS !== 'android') return undefined;
|
|
return ANDROID_ICONS[key];
|
|
}
|
|
|
|
// Backwards-compat: noop. Andere Module rufen `preloadTabIcons()` aus dem alten
|
|
// async-getImageSource-Pattern auf.
|
|
export function preloadTabIcons(): Promise<void> {
|
|
return Promise.resolve();
|
|
}
|