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

AppSymbol.android.tsx

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