Added setting component for tray icon select

This commit is contained in:
MrGarlic 2024-05-04 20:33:09 -04:00
parent 0f1fd84854
commit 7dacbb7dda

View file

@ -0,0 +1,62 @@
/*
* SPDX-License-Identifier: GPL-3.0
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { Button, Forms, Toasts } from "@vencord/types/webpack/common";
import { SettingsComponent } from "./Settings";
export const TrayIconImagePicker: SettingsComponent = ({ settings }) => {
return (
<>
<Forms.FormText>
Tray icon is currently {" "}
{settings.trayIconPath ? (
<a
href="about:blank"
onClick={e => {
e.preventDefault();
VesktopNative.fileManager.showItemInFolder(settings.trayIconPath!);
}}
>
{settings.trayIconPath}
</a>
) : (
"the default location"
)}
</Forms.FormText>
<div className="vcd-location-btns">
<Button
size={Button.Sizes.SMALL}
onClick={async () => {
const choice = await VesktopNative.fileManager.selectTrayIcon();
switch (choice) {
case "cancelled":
return;
case "invalid":
Toasts.show({
message:
"Please select a valid .png or .jpg image!",
id: Toasts.genId(),
type: Toasts.Type.FAILURE
});
return;
}
settings.trayIconPath = choice;
}}
>
Change
</Button>
<Button
size={Button.Sizes.SMALL}
color={Button.Colors.RED}
onClick={() => (settings.trayIconPath = void 0)}
>
Reset
</Button>
</div>
</>
);
};