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