/* * Vencord, a Discord client mod * Copyright (c) 2024 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { CodeBlock } from "@components/CodeBlock"; import { Heart } from "@components/Heart"; import { openInviteModal } from "@utils/discord"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import type { PluginNative } from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; import { Button, Clipboard, Forms, React, showToast, Toasts } from "@webpack/common"; import { Theme, ThemeInfoModalProps } from "../types"; import { DownloadIcon } from "../utils/Icons"; import { logger } from "./LikesComponent"; const Native = VencordNative.pluginHelpers.ThemeLibrary as PluginNative; const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers"); async function downloadTheme(themesDir: string, theme: Theme) { try { await Native.downloadTheme(themesDir, theme); showToast(`Downloaded ${theme.name}!`, Toasts.Type.SUCCESS); } catch (err: any) { logger.error(err); showToast(`Failed to download ${theme.name}! (check console)`, Toasts.Type.FAILURE); } } export const ThemeInfoModal: React.FC = ({ author, theme, ...props }) => { const content = window.atob(theme.content); const metadata = content.match(/\/\*\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g)?.[0] || ""; const donate = metadata.match(/@donate\s+(.+)/)?.[1] || ""; const version = metadata.match(/@version\s+(.+)/)?.[1] || ""; const { likes, guild, tags } = theme; return ( Theme Details Author
{author.username}
{version && ( <> Version {version} )} Likes {likes === 0 ? `Nobody liked this ${theme.type} yet.` : `${likes} users liked this ${theme.type}!`} {donate && ( <> Donate You can support the author by donating below! )} {guild && ( <> Support Server {guild.name} )} Source ))} > View Theme Source {tags && ( <> Tags {tags.map(tag => ( {tag} ))} )}
)); } else { await downloadTheme(themesDir, theme); } }} >
Download
); };