Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AppSymbol.tsx

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