Open History to see the last commit
1import type { Icon } from "@tabler/icons-react-native/types";
2/*
3 * Keep these as per-icon exports. Importing the package root eagerly registers
4 * the entire Tabler icon set in Metro.
5 */
6import IconAdjustmentsHorizontal from "@tabler/icons-react-native/IconAdjustmentsHorizontal";
7import IconAlignLeft from "@tabler/icons-react-native/IconAlignLeft";
8import IconAlertCircle from "@tabler/icons-react-native/IconAlertCircle";
9import IconAlertTriangle from "@tabler/icons-react-native/IconAlertTriangle";
10import IconApps from "@tabler/icons-react-native/IconApps";
11import IconArchive from "@tabler/icons-react-native/IconArchive";
12import IconArrowBackUp from "@tabler/icons-react-native/IconArrowBackUp";
13import IconArrowDown from "@tabler/icons-react-native/IconArrowDown";
14import IconArrowForwardUp from "@tabler/icons-react-native/IconArrowForwardUp";
15import IconArrowLeft from "@tabler/icons-react-native/IconArrowLeft";
16import IconArrowDownCircle from "@tabler/icons-react-native/IconArrowDownCircle";
17import IconArrowRightCircle from "@tabler/icons-react-native/IconArrowRightCircle";
18import IconArrowUp from "@tabler/icons-react-native/IconArrowUp";
19import IconArrowUpCircle from "@tabler/icons-react-native/IconArrowUpCircle";
20import IconArrowUpRight from "@tabler/icons-react-native/IconArrowUpRight";
21import IconArrowUpRightCircle from "@tabler/icons-react-native/IconArrowUpRightCircle";
22import IconArrowsDiagonal2 from "@tabler/icons-react-native/IconArrowsDiagonal2";
23import IconArrowsMinimize from "@tabler/icons-react-native/IconArrowsMinimize";
24import IconBellRinging from "@tabler/icons-react-native/IconBellRinging";
25import IconBolt from "@tabler/icons-react-native/IconBolt";
26import IconBox from "@tabler/icons-react-native/IconBox";
27import IconBrain from "@tabler/icons-react-native/IconBrain";
28import IconCamera from "@tabler/icons-react-native/IconCamera";
29import IconChartBar from "@tabler/icons-react-native/IconChartBar";
30import IconCheck from "@tabler/icons-react-native/IconCheck";
31import IconCloud from "@tabler/icons-react-native/IconCloud";
32import IconChevronDown from "@tabler/icons-react-native/IconChevronDown";
33import IconChevronLeft from "@tabler/icons-react-native/IconChevronLeft";
34import IconChevronRight from "@tabler/icons-react-native/IconChevronRight";
35import IconChevronUp from "@tabler/icons-react-native/IconChevronUp";
36import IconCircle from "@tabler/icons-react-native/IconCircle";
37import IconCircleCheck from "@tabler/icons-react-native/IconCircleCheck";
38import IconCircleXFilled from "@tabler/icons-react-native/IconCircleXFilled";
39import IconTicket from "@tabler/icons-react-native/IconTicket";
40import IconClock from "@tabler/icons-react-native/IconClock";
41import IconCode from "@tabler/icons-react-native/IconCode";
42import IconCopy from "@tabler/icons-react-native/IconCopy";
43import IconDatabase from "@tabler/icons-react-native/IconDatabase";
44import IconDeviceDesktop from "@tabler/icons-react-native/IconDeviceDesktop";
45import IconDeviceLaptop from "@tabler/icons-react-native/IconDeviceLaptop";
46import IconDeviceMobile from "@tabler/icons-react-native/IconDeviceMobile";
47import IconDots from "@tabler/icons-react-native/IconDots";
48import IconDotsVertical from "@tabler/icons-react-native/IconDotsVertical";
49import IconDotsCircleHorizontal from "@tabler/icons-react-native/IconDotsCircleHorizontal";
50import IconEdit from "@tabler/icons-react-native/IconEdit";
51import IconExternalLink from "@tabler/icons-react-native/IconExternalLink";
52import IconEye from "@tabler/icons-react-native/IconEye";
53import IconFileText from "@tabler/icons-react-native/IconFileText";
54import IconFilter from "@tabler/icons-react-native/IconFilter";
55import IconFilterFilled from "@tabler/icons-react-native/IconFilterFilled";
56import IconFolder from "@tabler/icons-react-native/IconFolder";
57import IconFolderOpen from "@tabler/icons-react-native/IconFolderOpen";
58import IconFolderPlus from "@tabler/icons-react-native/IconFolderPlus";
59import IconGitBranch from "@tabler/icons-react-native/IconGitBranch";
60import IconGitMerge from "@tabler/icons-react-native/IconGitMerge";
61import IconGitPullRequest from "@tabler/icons-react-native/IconGitPullRequest";
62import IconHammer from "@tabler/icons-react-native/IconHammer";
63import IconHome from "@tabler/icons-react-native/IconHome";
64import IconInfoCircle from "@tabler/icons-react-native/IconInfoCircle";
65import IconKeyboard from "@tabler/icons-react-native/IconKeyboard";
66import IconKeyboardHide from "@tabler/icons-react-native/IconKeyboardHide";
67import IconLock from "@tabler/icons-react-native/IconLock";
68import IconLayoutColumns from "@tabler/icons-react-native/IconLayoutColumns";
69import IconLayoutSidebar from "@tabler/icons-react-native/IconLayoutSidebar";
70import IconLayoutSidebarRight from "@tabler/icons-react-native/IconLayoutSidebarRight";
71import IconLetterSpacing from "@tabler/icons-react-native/IconLetterSpacing";
72import IconMicrophone from "@tabler/icons-react-native/IconMicrophone";
73import IconLink from "@tabler/icons-react-native/IconLink";
74import IconMenu2 from "@tabler/icons-react-native/IconMenu2";
75import IconMessage from "@tabler/icons-react-native/IconMessage";
76import IconMinus from "@tabler/icons-react-native/IconMinus";
77import IconMoon from "@tabler/icons-react-native/IconMoon";
78import IconNetwork from "@tabler/icons-react-native/IconNetwork";
79import IconPalette from "@tabler/icons-react-native/IconPalette";
80import IconPencil from "@tabler/icons-react-native/IconPencil";
81import IconPhoto from "@tabler/icons-react-native/IconPhoto";
82import IconPin from "@tabler/icons-react-native/IconPin";
83import IconPinnedOff from "@tabler/icons-react-native/IconPinnedOff";
84import IconPlayerPlay from "@tabler/icons-react-native/IconPlayerPlay";
85import IconPlayerStopFilled from "@tabler/icons-react-native/IconPlayerStopFilled";
86import IconPlus from "@tabler/icons-react-native/IconPlus";
87import IconQrcode from "@tabler/icons-react-native/IconQrcode";
88import IconRefresh from "@tabler/icons-react-native/IconRefresh";
89import IconSearch from "@tabler/icons-react-native/IconSearch";
90import IconServer from "@tabler/icons-react-native/IconServer";
91import IconSettings from "@tabler/icons-react-native/IconSettings";
92import IconSparkles from "@tabler/icons-react-native/IconSparkles";
93import IconStack2 from "@tabler/icons-react-native/IconStack2";
94import IconStar from "@tabler/icons-react-native/IconStar";
95import IconStarFilled from "@tabler/icons-react-native/IconStarFilled";
96import IconStethoscope from "@tabler/icons-react-native/IconStethoscope";
97import IconSun from "@tabler/icons-react-native/IconSun";
98import IconTerminal2 from "@tabler/icons-react-native/IconTerminal2";
99import IconTextDecrease from "@tabler/icons-react-native/IconTextDecrease";
100import IconTextIncrease from "@tabler/icons-react-native/IconTextIncrease";
101import IconTool from "@tabler/icons-react-native/IconTool";
102import IconTrash from "@tabler/icons-react-native/IconTrash";
103import IconTypography from "@tabler/icons-react-native/IconTypography";
104import IconUpload from "@tabler/icons-react-native/IconUpload";
105import IconUserCircle from "@tabler/icons-react-native/IconUserCircle";
106import IconWifiOff from "@tabler/icons-react-native/IconWifiOff";
107import IconWorld from "@tabler/icons-react-native/IconWorld";
108import IconX from "@tabler/icons-react-native/IconX";
109import type { AndroidSymbol, SFSymbol, SymbolViewProps } from "expo-symbols";
110import { withUniwind } from "uniwind";
111
112const ANDROID_ICON_BY_SF_SYMBOL = {
113 "arrow.branch": IconGitBranch,
114 "arrow.left": IconArrowLeft,
115 "arrow.clockwise": IconRefresh,
116 "arrow.down": IconArrowDown,
117 "arrow.down.circle": IconArrowDownCircle,
118 "arrow.right.circle": IconArrowRightCircle,
119 "arrow.triangle.branch": IconGitBranch,
120 "arrow.triangle.pull": IconGitPullRequest,
121 "square.3.layers.3d": IconStack2,
122 "arrow.turn.left.up": IconArrowBackUp,
123 "arrow.up": IconArrowUp,
124 "arrow.up.circle": IconArrowUpCircle,
125 "arrow.up.left.and.arrow.down.right": IconArrowsDiagonal2,
126 "arrow.down.right.and.arrow.up.left": IconArrowsMinimize,
127 "arrow.up.right": IconArrowUpRight,
128 "arrow.up.right.circle": IconArrowUpRightCircle,
129 "arrow.uturn.backward": IconArrowBackUp,
130 "arrow.uturn.forward": IconArrowForwardUp,
131 archivebox: IconArchive,
132 "archivebox.fill": IconArchive,
133 "bell.badge": IconBellRinging,
134 "bolt.circle": IconBolt,
135 "bolt.horizontal.circle": IconBolt,
136 brain: IconBrain,
137 camera: IconCamera,
138 "chart.bar.xaxis": IconChartBar,
139 checkmark: IconCheck,
140 "checkmark.circle": IconCircleCheck,
141 circle: IconCircle,
142 clock: IconClock,
143 timer: IconClock,
144 ticket: IconTicket,
145 cloud: IconCloud,
146 cube: IconBox,
147 "chevron.down": IconChevronDown,
148 "chevron.left": IconChevronLeft,
149 "chevron.left.forwardslash.chevron.right": IconCode,
150 "chevron.right": IconChevronRight,
151 "chevron.up": IconChevronUp,
152 desktopcomputer: IconDeviceDesktop,
153 "doc.on.doc": IconCopy,
154 "doc.text": IconFileText,
155 ellipsis: IconDots,
156 moon: IconMoon,
157 "ellipsis.circle": IconDotsCircleHorizontal,
158 "exclamationmark.triangle": IconAlertTriangle,
159 "exclamationmark.circle": IconAlertCircle,
160 eye: IconEye,
161 folder: IconFolder,
162 "folder.badge.plus": IconFolderPlus,
163 "folder.fill": IconFolder,
164 gearshape: IconSettings,
165 globe: IconWorld,
166 hammer: IconHammer,
167 house: IconHome,
168 "info.circle": IconInfoCircle,
169 internaldrive: IconDatabase,
170 keyboard: IconKeyboard,
171 laptopcomputer: IconDeviceLaptop,
172 link: IconLink,
173 "line.3.horizontal": IconMenu2,
174 "line.3.horizontal.decrease": IconFilter,
175 "line.3.horizontal.decrease.circle": IconFilter,
176 "line.3.horizontal.decrease.circle.fill": IconFilterFilled,
177 // Tabler has no Apple desktops; the closest silhouettes stand in on Android.
178 macmini: IconServer,
179 macstudio: IconDeviceDesktop,
180 magnifyingglass: IconSearch,
181 mic: IconMicrophone,
182 paintbrush: IconPalette,
183 pencil: IconPencil,
184 "person.crop.circle": IconUserCircle,
185 photo: IconPhoto,
186 pin: IconPin,
187 "pin.slash": IconPinnedOff,
188 play: IconPlayerPlay,
189 plus: IconPlus,
190 minus: IconMinus,
191 "qrcode.viewfinder": IconQrcode,
192 "point.3.connected.trianglepath.dotted": IconNetwork,
193 "point.topleft.down.curvedto.point.bottomright.up": IconGitMerge,
194 safari: IconExternalLink,
195 "server.rack": IconServer,
196 stethoscope: IconStethoscope,
197 "sidebar.left": IconLayoutSidebar,
198 "sidebar.right": IconLayoutSidebarRight,
199 "slider.horizontal.3": IconAdjustmentsHorizontal,
200 "square.and.pencil": IconEdit,
201 "square.on.square": IconCopy,
202 "square.grid.2x2": IconApps,
203 "square.split.2x1": IconLayoutColumns,
204 star: IconStar,
205 "star.fill": IconStarFilled,
206 "sun.max": IconSun,
207 "stop.fill": IconPlayerStopFilled,
208 terminal: IconTerminal2,
209 "text.alignleft": IconAlignLeft,
210 "text.bubble": IconMessage,
211 "text.word.spacing": IconLetterSpacing,
212 "textformat.size": IconTypography,
213 "textformat.size.larger": IconTextIncrease,
214 "textformat.size.smaller": IconTextDecrease,
215 "tray.and.arrow.up": IconUpload,
216 trash: IconTrash,
217 "wifi.slash": IconWifiOff,
218 xmark: IconX,
219 "xmark.circle.fill": IconCircleXFilled,
220} satisfies Partial<Record<SFSymbol, Icon>>;
221const SF_ICON_LOOKUP: Partial<Record<SFSymbol, Icon>> = ANDROID_ICON_BY_SF_SYMBOL;
222
223// Callers can pass `{ ios, android }` names where `android` is a Material
224// icon name (the raw expo-symbols contract). Resolve those here too so the
225// android key keeps working through this wrapper — it wins over the SF map
226// when both match (e.g. folder vs folder_open for expanded project groups).
227const ANDROID_ICON_BY_MATERIAL_NAME = {
228 auto_awesome: IconSparkles,
229 bolt: IconBolt,
230 build: IconTool,
231 chat_bubble: IconMessage,
232 check: IconCheck,
233 close: IconX,
234 construction: IconHammer,
235 content_copy: IconCopy,
236 desktop_windows: IconDeviceDesktop,
237 edit: IconEdit,
238 error: IconAlertCircle,
239 folder: IconFolder,
240 folder_open: IconFolderOpen,
241 keyboard: IconKeyboard,
242 keyboard_arrow_down: IconChevronDown,
243 keyboard_arrow_up: IconChevronUp,
244 keyboard_hide: IconKeyboardHide,
245 lock: IconLock,
246 more_vert: IconDotsVertical,
247 merge: IconGitMerge,
248 public: IconWorld,
249 remove: IconMinus,
250 smartphone: IconDeviceMobile,
251 terminal: IconTerminal2,
252 visibility: IconEye,
253} satisfies Partial<Record<AndroidSymbol, Icon>>;
254
255export type { SFSymbol } from "expo-symbols";
256export type AppSymbolName =
257 | keyof typeof ANDROID_ICON_BY_SF_SYMBOL
258 | {
259 ios: SFSymbol;
260 android: keyof typeof ANDROID_ICON_BY_MATERIAL_NAME;
261 };
262
263export type AppSymbolViewProps = Omit<SymbolViewProps, "name"> & { name: AppSymbolName };
264
265export function isAppSymbolName(name: string): name is Extract<AppSymbolName, string> {
266 return Object.prototype.hasOwnProperty.call(ANDROID_ICON_BY_SF_SYMBOL, name);
267}
268
269function AppSymbolView(props: AppSymbolViewProps) {
270 const materialName = typeof props.name === "string" ? undefined : props.name.android;
271 const sfSymbol = typeof props.name === "string" ? props.name : props.name.ios;
272 const AndroidIcon =
273 (materialName ? ANDROID_ICON_BY_MATERIAL_NAME[materialName] : undefined) ??
274 (sfSymbol ? SF_ICON_LOOKUP[sfSymbol] : undefined);
275
276 if (!AndroidIcon) {
277 return props.fallback ?? null;
278 }
279
280 return (
281 <AndroidIcon
282 accessibilityLabel={props.accessibilityLabel}
283 color={props.tintColor}
284 size={props.size}
285 strokeWidth={2}
286 style={props.style}
287 testID={props.testID}
288 />
289 );
290}
291
292/**
293 * expo-symbols and the Android Tabler fallback both expose tint as a native
294 * prop rather than a React Native style. Keep that third-party boundary here
295 * so callers can use Uniwind's `tintColorClassName` instead of subscribing to
296 * theme variables in every parent component.
297 */
298export const SymbolView = withUniwind(AppSymbolView);