import type { ForgeTabIcon } from '@cdx-ui/icons/tab-icons'; import type { ForgeNativeBottomTabIcon, ForgeTabBarIcon } from './types'; /** * forgeTabIcon — iOS/Android implementation (see `forgeTabIcon.ts` for the * full contract and usage example). * * Returns a `tabBarIcon` function for `createNativeBottomTabNavigator` that * resolves the descriptor's pre-rasterized template PNGs: outlined at rest, * filled when focused (iOS only — Android tabs use one static icon and * express selection via tint). `tinted: true` makes the native tab bar apply * `tabBarActiveTintColor` / `tabBarInactiveTintColor` at runtime, so theming * and dark mode flow through `useForgeBottomTabScreenOptions` unchanged. */ export function forgeTabIcon(icon: ForgeTabIcon): ForgeTabBarIcon { const { native } = icon; if (!native) { const name = icon.Component.displayName ?? 'icon'; throw new Error( `forgeTabIcon: "${name}" has no native tab assets. Use a generated ` + `descriptor from '@cdx-ui/icons/tab-icons' (curated in the icon ` + `package's tab-icons.config.json), or pass a descriptor with your ` + `own template PNGs: { native: { outlined: require(...), filled: ` + `require(...) } } at a 24dp base size with @2x/@3x variants.`, ); } const resolve = ({ focused }: { focused: boolean }): ForgeNativeBottomTabIcon => ({ type: 'image', source: focused ? native.filled : native.outlined, tinted: true, }); return resolve as ForgeTabBarIcon; }