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