Skip to content
Source
Sign inSign up

AppSymbol.android.tsx

386 lines17.0 KB

1import type { Icon } from "@tabler/icons-react-native/types";
2/* Package-root imports eagerly register the entire Tabler icon set in Metro. */
3import IconAdjustmentsHorizontal from "@tabler/icons-react-native/IconAdjustmentsHorizontal";
4import IconAlignLeft from "@tabler/icons-react-native/IconAlignLeft";
5import IconAlertCircle from "@tabler/icons-react-native/IconAlertCircle";
6import IconAlertTriangle from "@tabler/icons-react-native/IconAlertTriangle";
7import IconApps from "@tabler/icons-react-native/IconApps";
8import IconArchive from "@tabler/icons-react-native/IconArchive";
9import IconCalendarClock from "@tabler/icons-react-native/IconCalendarClock";
10import IconArrowBackUp from "@tabler/icons-react-native/IconArrowBackUp";
11import IconArrowDown from "@tabler/icons-react-native/IconArrowDown";
12import IconArrowForwardUp from "@tabler/icons-react-native/IconArrowForwardUp";
13import IconArrowLeft from "@tabler/icons-react-native/IconArrowLeft";
14import IconArrowRight from "@tabler/icons-react-native/IconArrowRight";
15import IconArrowDownCircle from "@tabler/icons-react-native/IconArrowDownCircle";
16import IconArrowRightCircle from "@tabler/icons-react-native/IconArrowRightCircle";
17import IconArrowUp from "@tabler/icons-react-native/IconArrowUp";
18import IconArrowUpCircle from "@tabler/icons-react-native/IconArrowUpCircle";
19import IconArrowUpRight from "@tabler/icons-react-native/IconArrowUpRight";
20import IconArrowUpRightCircle from "@tabler/icons-react-native/IconArrowUpRightCircle";
21import IconArrowsLeftRight from "@tabler/icons-react-native/IconArrowsLeftRight";
22import IconArrowsDiagonal2 from "@tabler/icons-react-native/IconArrowsDiagonal2";
23import IconArrowsMinimize from "@tabler/icons-react-native/IconArrowsMinimize";
24import IconBan from "@tabler/icons-react-native/IconBan";
25import IconBellRinging from "@tabler/icons-react-native/IconBellRinging";
26import IconBolt from "@tabler/icons-react-native/IconBolt";
27import IconBox from "@tabler/icons-react-native/IconBox";
28import IconBrain from "@tabler/icons-react-native/IconBrain";
29import IconCamera from "@tabler/icons-react-native/IconCamera";
30import IconCar from "@tabler/icons-react-native/IconCar";
31import IconChartBar from "@tabler/icons-react-native/IconChartBar";
32import IconCheck from "@tabler/icons-react-native/IconCheck";
33import IconCloud from "@tabler/icons-react-native/IconCloud";
34import IconChevronDown from "@tabler/icons-react-native/IconChevronDown";
35import IconChevronLeft from "@tabler/icons-react-native/IconChevronLeft";
36import IconChevronRight from "@tabler/icons-react-native/IconChevronRight";
37import IconChevronUp from "@tabler/icons-react-native/IconChevronUp";
38import IconCircle from "@tabler/icons-react-native/IconCircle";
39import IconCircleFilled from "@tabler/icons-react-native/IconCircleFilled";
40import IconCircleCheck from "@tabler/icons-react-native/IconCircleCheck";
41import IconCircleDashed from "@tabler/icons-react-native/IconCircleDashed";
42import IconCircleDot from "@tabler/icons-react-native/IconCircleDot";
43import IconCircleXFilled from "@tabler/icons-react-native/IconCircleXFilled";
44import IconMoodPlus from "@tabler/icons-react-native/IconMoodPlus";
45import IconTag from "@tabler/icons-react-native/IconTag";
46import IconTicket from "@tabler/icons-react-native/IconTicket";
47import IconClock from "@tabler/icons-react-native/IconClock";
48import IconClipboard from "@tabler/icons-react-native/IconClipboard";
49import IconCode from "@tabler/icons-react-native/IconCode";
50import IconCopy from "@tabler/icons-react-native/IconCopy";
51import IconDatabase from "@tabler/icons-react-native/IconDatabase";
52import IconDeviceDesktop from "@tabler/icons-react-native/IconDeviceDesktop";
53import IconDeviceLaptop from "@tabler/icons-react-native/IconDeviceLaptop";
54import IconDeviceMobile from "@tabler/icons-react-native/IconDeviceMobile";
55import IconDots from "@tabler/icons-react-native/IconDots";
56import IconPlusMinus from "@tabler/icons-react-native/IconPlusMinus";
57import IconDotsVertical from "@tabler/icons-react-native/IconDotsVertical";
58import IconDotsCircleHorizontal from "@tabler/icons-react-native/IconDotsCircleHorizontal";
59import IconEdit from "@tabler/icons-react-native/IconEdit";
60import IconExternalLink from "@tabler/icons-react-native/IconExternalLink";
61import IconEyeOff from "@tabler/icons-react-native/IconEyeOff";
62import IconEye from "@tabler/icons-react-native/IconEye";
63import IconFileText from "@tabler/icons-react-native/IconFileText";
64import IconFileDiff from "@tabler/icons-react-native/IconFileDiff";
65import IconFilter from "@tabler/icons-react-native/IconFilter";
66import IconFilterFilled from "@tabler/icons-react-native/IconFilterFilled";
67import IconFlask from "@tabler/icons-react-native/IconFlask";
68import IconFolder from "@tabler/icons-react-native/IconFolder";
69import IconFolderOpen from "@tabler/icons-react-native/IconFolderOpen";
70import IconHeadphones from "@tabler/icons-react-native/IconHeadphones";
71import IconFolderPlus from "@tabler/icons-react-native/IconFolderPlus";
72import IconGitPullRequestClosed from "@tabler/icons-react-native/IconGitPullRequestClosed";
73import IconGitPullRequestDraft from "@tabler/icons-react-native/IconGitPullRequestDraft";
74import IconGitCommit from "@tabler/icons-react-native/IconGitCommit";
75import IconGitBranch from "@tabler/icons-react-native/IconGitBranch";
76import IconGitMerge from "@tabler/icons-react-native/IconGitMerge";
77import IconGitPullRequest from "@tabler/icons-react-native/IconGitPullRequest";
78import IconHammer from "@tabler/icons-react-native/IconHammer";
79import IconHome from "@tabler/icons-react-native/IconHome";
80import IconInfoCircle from "@tabler/icons-react-native/IconInfoCircle";
81import IconKeyboard from "@tabler/icons-react-native/IconKeyboard";
82import IconKeyboardHide from "@tabler/icons-react-native/IconKeyboardHide";
83import IconLock from "@tabler/icons-react-native/IconLock";
84import IconLayoutColumns from "@tabler/icons-react-native/IconLayoutColumns";
85import IconLayoutSidebar from "@tabler/icons-react-native/IconLayoutSidebar";
86import IconLayoutSidebarRight from "@tabler/icons-react-native/IconLayoutSidebarRight";
87import IconLetterSpacing from "@tabler/icons-react-native/IconLetterSpacing";
88import IconMicrophone from "@tabler/icons-react-native/IconMicrophone";
89import IconLink from "@tabler/icons-react-native/IconLink";
90import IconListNumbers from "@tabler/icons-react-native/IconListNumbers";
91import IconMenu2 from "@tabler/icons-react-native/IconMenu2";
92import IconMessageCircleQuestion from "@tabler/icons-react-native/IconMessageCircleQuestion";
93import IconMessage from "@tabler/icons-react-native/IconMessage";
94import IconMessageDots from "@tabler/icons-react-native/IconMessageDots";
95import IconMessagePlus from "@tabler/icons-react-native/IconMessagePlus";
96import IconMinus from "@tabler/icons-react-native/IconMinus";
97import IconMoon from "@tabler/icons-react-native/IconMoon";
98import IconNetwork from "@tabler/icons-react-native/IconNetwork";
99import IconPalette from "@tabler/icons-react-native/IconPalette";
100import IconPencil from "@tabler/icons-react-native/IconPencil";
101import IconPlug from "@tabler/icons-react-native/IconPlug";
102import IconPhoto from "@tabler/icons-react-native/IconPhoto";
103import IconPin from "@tabler/icons-react-native/IconPin";
104import IconPinnedOff from "@tabler/icons-react-native/IconPinnedOff";
105import IconPlayerPause from "@tabler/icons-react-native/IconPlayerPause";
106import IconPlayerPlay from "@tabler/icons-react-native/IconPlayerPlay";
107import IconPlayerStopFilled from "@tabler/icons-react-native/IconPlayerStopFilled";
108import IconPlus from "@tabler/icons-react-native/IconPlus";
109import IconQrcode from "@tabler/icons-react-native/IconQrcode";
110import IconRefresh from "@tabler/icons-react-native/IconRefresh";
111import IconRobot from "@tabler/icons-react-native/IconRobot";
112import IconSearch from "@tabler/icons-react-native/IconSearch";
113import IconShare from "@tabler/icons-react-native/IconShare";
114import IconServer from "@tabler/icons-react-native/IconServer";
115import IconSettings from "@tabler/icons-react-native/IconSettings";
116import IconStack2 from "@tabler/icons-react-native/IconStack2";
117import IconStar from "@tabler/icons-react-native/IconStar";
118import IconStarFilled from "@tabler/icons-react-native/IconStarFilled";
119import IconStethoscope from "@tabler/icons-react-native/IconStethoscope";
120import IconSun from "@tabler/icons-react-native/IconSun";
121import IconShieldQuestion from "@tabler/icons-react-native/IconShieldQuestion";
122import IconTarget from "@tabler/icons-react-native/IconTarget";
123import IconTerminal2 from "@tabler/icons-react-native/IconTerminal2";
124import IconTextDecrease from "@tabler/icons-react-native/IconTextDecrease";
125import IconTextIncrease from "@tabler/icons-react-native/IconTextIncrease";
126import IconTool from "@tabler/icons-react-native/IconTool";
127import IconTrash from "@tabler/icons-react-native/IconTrash";
128import IconTypography from "@tabler/icons-react-native/IconTypography";
129import IconDownload from "@tabler/icons-react-native/IconDownload";
130import IconSitemap from "@tabler/icons-react-native/IconSitemap";
131import IconUpload from "@tabler/icons-react-native/IconUpload";
132import IconUserCircle from "@tabler/icons-react-native/IconUserCircle";
133import IconUserCheck from "@tabler/icons-react-native/IconUserCheck";
134import IconUserX from "@tabler/icons-react-native/IconUserX";
135import IconUserQuestion from "@tabler/icons-react-native/IconUserQuestion";
136import IconUserPlus from "@tabler/icons-react-native/IconUserPlus";
137import IconUsers from "@tabler/icons-react-native/IconUsers";
138import IconWifi from "@tabler/icons-react-native/IconWifi";
139import IconWifiOff from "@tabler/icons-react-native/IconWifiOff";
140import IconWorld from "@tabler/icons-react-native/IconWorld";
141import IconX from "@tabler/icons-react-native/IconX";
142import type { AndroidSymbol, SFSymbol, SymbolViewProps } from "expo-symbols";
143import { withUniwind } from "uniwind";
144​
145const ANDROID_ICON_BY_SF_SYMBOL = {
146 plusminus: IconPlusMinus,
147 "git.pull-request.closed": IconGitPullRequestClosed,
148 "git.pull-request.draft": IconGitPullRequestDraft,
149 "git.commit": IconGitCommit,
150 "arrow.branch": IconGitBranch,
151 "arrow.left": IconArrowLeft,
152 "arrow.right": IconArrowRight,
153 "arrow.left.arrow.right": IconArrowsLeftRight,
154 "arrow.clockwise": IconRefresh,
155 "arrow.down": IconArrowDown,
156 "arrow.down.circle": IconArrowDownCircle,
157 "arrow.right.circle": IconArrowRightCircle,
158 "arrow.triangle.branch": IconGitBranch,
159 "arrow.triangle.merge": IconGitMerge,
160 "arrow.triangle.pull": IconGitPullRequest,
161 "square.3.layers.3d": IconStack2,
162 "arrow.turn.left.up": IconArrowBackUp,
163 "arrow.up": IconArrowUp,
164 "arrow.up.circle": IconArrowUpCircle,
165 "arrow.up.left.and.arrow.down.right": IconArrowsDiagonal2,
166 "arrow.down.right.and.arrow.up.left": IconArrowsMinimize,
167 "arrow.up.right": IconArrowUpRight,
168 "arrow.up.right.circle": IconArrowUpRightCircle,
169 "arrow.uturn.backward": IconArrowBackUp,
170 "arrow.uturn.forward": IconArrowForwardUp,
171 archivebox: IconArchive,
172 "archivebox.fill": IconArchive,
173 "bell.badge": IconBellRinging,
174 "bolt.circle": IconBolt,
175 "bolt.horizontal.circle": IconBolt,
176 brain: IconBrain,
177 "cable.connector": IconPlug,
178 camera: IconCamera,
179 car: IconCar,
180 "chart.bar.xaxis": IconChartBar,
181 checkmark: IconCheck,
182 "checkmark.circle": IconCircleCheck,
183 "checkmark.circle.fill": IconCircleCheck,
184 circle: IconCircle,
185 "circle.fill": IconCircleFilled,
186 "circle.dashed": IconCircleDashed,
187 "circle.inset.filled": IconCircleDot,
188 "circle.dashed.inset.filled": IconCircleDot,
189 "calendar.badge.clock": IconCalendarClock,
190 clock: IconClock,
191 timer: IconClock,
192 "face.smiling": IconMoodPlus,
193 tag: IconTag,
194 ticket: IconTicket,
195 cloud: IconCloud,
196 cube: IconBox,
197 "chevron.down": IconChevronDown,
198 "chevron.left": IconChevronLeft,
199 "chevron.left.forwardslash.chevron.right": IconCode,
200 "chevron.right": IconChevronRight,
201 "chevron.up": IconChevronUp,
202 desktopcomputer: IconDeviceDesktop,
203 doc: IconFileText,
204 "doc.on.doc": IconCopy,
205 "doc.text": IconFileText,
206 "file.diff": IconFileDiff,
207 ellipsis: IconDots,
208 moon: IconMoon,
209 "ellipsis.circle": IconDotsCircleHorizontal,
210 "exclamationmark.triangle": IconAlertTriangle,
211 "exclamationmark.circle": IconAlertCircle,
212 eye: IconEye,
213 "eye.slash": IconEyeOff,
214 flask: IconFlask,
215 folder: IconFolder,
216 "folder.badge.plus": IconFolderPlus,
217 "folder.fill": IconFolder,
218 gearshape: IconSettings,
219 globe: IconWorld,
220 hammer: IconHammer,
221 headphones: IconHeadphones,
222 house: IconHome,
223 "info.circle": IconInfoCircle,
224 internaldrive: IconDatabase,
225 iphone: IconDeviceMobile,
226 keyboard: IconKeyboard,
227 laptopcomputer: IconDeviceLaptop,
228 link: IconLink,
229 "list.number": IconListNumbers,
230 "line.3.horizontal": IconMenu2,
231 "line.3.horizontal.decrease": IconFilter,
232 "line.3.horizontal.decrease.circle": IconFilter,
233 "line.3.horizontal.decrease.circle.fill": IconFilterFilled,
234 macmini: IconServer,
235 macstudio: IconDeviceDesktop,
236 magnifyingglass: IconSearch,
237 mic: IconMicrophone,
238 paintbrush: IconPalette,
239 pencil: IconPencil,
240 "person.crop.circle": IconUserCircle,
241 "person.2": IconUsers,
242 "person.fill.checkmark": IconUserCheck,
243 "person.fill.xmark": IconUserX,
244 "person.badge.clock": IconUserQuestion,
245 "person.badge.plus": IconUserPlus,
246 photo: IconPhoto,
247 pin: IconPin,
248 "pin.slash": IconPinnedOff,
249 play: IconPlayerPlay,
250 pause: IconPlayerPause,
251 plus: IconPlus,
252 minus: IconMinus,
253 "slash.circle": IconBan,
254 "qrcode.viewfinder": IconQrcode,
255 "point.3.connected.trianglepath.dotted": IconNetwork,
256 flowchart: IconSitemap,
257 "point.topleft.down.curvedto.point.bottomright.up": IconGitMerge,
258 safari: IconExternalLink,
259 "server.rack": IconServer,
260 stethoscope: IconStethoscope,
261 "sidebar.left": IconLayoutSidebar,
262 "sidebar.right": IconLayoutSidebarRight,
263 "slider.horizontal.3": IconAdjustmentsHorizontal,
264 "square.and.arrow.up": IconShare,
265 "square.and.pencil": IconEdit,
266 "square.on.square": IconCopy,
267 "square.grid.2x2": IconApps,
268 "square.split.2x1": IconLayoutColumns,
269 star: IconStar,
270 "star.fill": IconStarFilled,
271 "sun.max": IconSun,
272 "stop.fill": IconPlayerStopFilled,
273 target: IconTarget,
274 terminal: IconTerminal2,
275 "text.alignleft": IconAlignLeft,
276 "text.bubble": IconMessage,
277 "questionmark.bubble": IconMessageCircleQuestion,
278 "exclamationmark.shield": IconShieldQuestion,
279 "bubble.left.and.bubble.right": IconMessage,
280 "bubble.left": IconMessage,
281 "plus.bubble": IconMessagePlus,
282 "ellipsis.bubble": IconMessageDots,
283 robot: IconRobot,
284 "text.word.spacing": IconLetterSpacing,
285 "textformat.size": IconTypography,
286 "textformat.size.larger": IconTextIncrease,
287 "textformat.size.smaller": IconTextDecrease,
288 "tray.and.arrow.down": IconDownload,
289 "tray.and.arrow.up": IconUpload,
290 trash: IconTrash,
291 wifi: IconWifi,
292 "wifi.slash": IconWifiOff,
293 "wrench.and.screwdriver": IconTool,
294 xmark: IconX,
295 "xmark.circle.fill": IconCircleXFilled,
296} satisfies Partial<
297 Record<
298 | SFSymbol
299 | "git.pull-request.closed"
300 | "git.pull-request.draft"
301 | "git.commit"
302 | "file.diff"
303 | "robot",
304 Icon
305 >
306>;
307const SF_ICON_LOOKUP: Partial<
308 Record<
309 | SFSymbol
310 | "git.pull-request.closed"
311 | "git.pull-request.draft"
312 | "git.commit"
313 | "file.diff"
314 | "robot",
315 Icon
316 >
317> = ANDROID_ICON_BY_SF_SYMBOL;
318​
319const ANDROID_ICON_BY_MATERIAL_NAME = {
320 bolt: IconBolt,
321 build: IconTool,
322 chat: IconMessage,
323 chat_bubble: IconMessage,
324 check: IconCheck,
325 close: IconX,
326 construction: IconHammer,
327 content_copy: IconCopy,
328 content_paste: IconClipboard,
329 desktop_windows: IconDeviceDesktop,
330 edit: IconEdit,
331 error: IconAlertCircle,
332 folder: IconFolder,
333 folder_open: IconFolderOpen,
334 keyboard: IconKeyboard,
335 keyboard_arrow_down: IconChevronDown,
336 keyboard_arrow_up: IconChevronUp,
337 keyboard_hide: IconKeyboardHide,
338 lock: IconLock,
339 more_vert: IconDotsVertical,
340 merge: IconGitMerge,
341 psychology: IconBrain,
342 public: IconWorld,
343 remove: IconMinus,
344 smartphone: IconDeviceMobile,
345 terminal: IconTerminal2,
346 visibility: IconEye,
347} satisfies Partial<Record<AndroidSymbol, Icon>>;
348​
349export type { SFSymbol } from "expo-symbols";
350export type AppSymbolName =
351 | keyof typeof ANDROID_ICON_BY_SF_SYMBOL
352 | {
353 ios: SFSymbol;
354 android: keyof typeof ANDROID_ICON_BY_MATERIAL_NAME;
355 };
356​
357export type AppSymbolViewProps = Omit<SymbolViewProps, "name"> & { name: AppSymbolName };
358​
359export function isAppSymbolName(name: string): name is Extract<AppSymbolName, string> {
360 return Object.prototype.hasOwnProperty.call(ANDROID_ICON_BY_SF_SYMBOL, name);
362​
363function AppSymbolView(props: AppSymbolViewProps) {
364 const materialName = typeof props.name === "string" ? undefined : props.name.android;
365 const sfSymbol = typeof props.name === "string" ? props.name : props.name.ios;
366 const AndroidIcon =
367 (materialName ? ANDROID_ICON_BY_MATERIAL_NAME[materialName] : undefined) ??
368 (sfSymbol ? SF_ICON_LOOKUP[sfSymbol] : undefined);
369​
370 if (!AndroidIcon) {
371 return props.fallback ?? null;
372 }
373​
374 return (
375 <AndroidIcon
376 accessibilityLabel={props.accessibilityLabel}
377 color={props.tintColor}
378 size={props.size}
379 strokeWidth={2}
380 style={props.style}
381 testID={props.testID}
382 />
383 );
385​
386export const SymbolView = withUniwind(AppSymbolView);