ui: icon namings at right side
This commit is contained in:
parent
f759fc0b71
commit
1ddd93342e
2 changed files with 53 additions and 42 deletions
|
@ -37,10 +37,10 @@ if (!isLinux)
|
|||
|
||||
const statusToSettingsKey = {
|
||||
icon: { key: "trayMainOverride", label: "Main Icon" },
|
||||
idle: { key: "trayIdleOverride", label: "Idle icon" },
|
||||
speaking: { key: "traySpeakingOverride", label: "Speaking icon" },
|
||||
muted: { key: "trayMutedOverride", label: "Muted icon" },
|
||||
deafened: { key: "trayDeafenedOverride", label: "Deafened icon" }
|
||||
idle: { key: "trayIdleOverride", label: "Idle Icon" },
|
||||
speaking: { key: "traySpeakingOverride", label: "Speaking Icon" },
|
||||
muted: { key: "trayMutedOverride", label: "Muted Icon" },
|
||||
deafened: { key: "trayDeafenedOverride", label: "Deafened Icon" }
|
||||
};
|
||||
|
||||
function trayEditButton(iconName: string) {
|
||||
|
@ -99,49 +99,53 @@ function TrayModalComponent({ modalProps, close }: { modalProps: any; close: ()
|
|||
<Modals.ModalContent className="vcd-custom-tray-modal">
|
||||
{Object.entries(statusToSettingsKey).map(([iconName, { key, label }]) => (
|
||||
<div key={iconName}>
|
||||
<Forms.FormTitle tag="h3">{label}</Forms.FormTitle>
|
||||
<Forms.FormSection className="vcd-custom-tray-icon-section">
|
||||
{trayEditButton(iconName)}
|
||||
<Button
|
||||
onClick={async () => {
|
||||
const choice = await VesktopNative.fileManager.selectTrayIcon(iconName);
|
||||
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;
|
||||
}
|
||||
|
||||
const iconKey =
|
||||
statusToSettingsKey[iconName as keyof typeof statusToSettingsKey].key;
|
||||
Settings[iconKey] = true;
|
||||
const iconDataURL = VesktopNative.tray.getIconSync(iconName);
|
||||
const img = document.getElementById(iconName) as HTMLImageElement;
|
||||
if (img) {
|
||||
img.src = iconDataURL;
|
||||
}
|
||||
setCurrentTrayIcon();
|
||||
}}
|
||||
look={Button.Looks.OUTLINED}
|
||||
>
|
||||
Choose icon
|
||||
</Button>
|
||||
{Settings[key] && (
|
||||
<div className="vcd-custom-tray-buttons">
|
||||
{trayEditButton(iconName)}
|
||||
<Button
|
||||
onClick={() => {
|
||||
Settings.trayMainOverride = false;
|
||||
onClick={async () => {
|
||||
const choice = await VesktopNative.fileManager.selectTrayIcon(iconName);
|
||||
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;
|
||||
}
|
||||
|
||||
const iconKey =
|
||||
statusToSettingsKey[iconName as keyof typeof statusToSettingsKey].key;
|
||||
Settings[iconKey] = true;
|
||||
const iconDataURL = VesktopNative.tray.getIconSync(iconName);
|
||||
const img = document.getElementById(iconName) as HTMLImageElement;
|
||||
if (img) {
|
||||
img.src = iconDataURL;
|
||||
}
|
||||
setCurrentTrayIcon();
|
||||
}}
|
||||
look={Button.Looks.LINK}
|
||||
look={Button.Looks.OUTLINED}
|
||||
>
|
||||
Reset Icon
|
||||
Choose Icon
|
||||
</Button>
|
||||
)}
|
||||
{Settings[key] && (
|
||||
<Button
|
||||
onClick={() => {
|
||||
Settings.trayMainOverride = false;
|
||||
setCurrentTrayIcon();
|
||||
}}
|
||||
look={Button.Looks.LINK}
|
||||
>
|
||||
Reset Icon
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<Forms.FormText>{label}</Forms.FormText>
|
||||
</div>
|
||||
</Forms.FormSection>
|
||||
<Forms.FormDivider className={`${Margins.top8} ${Margins.bottom8}`} />
|
||||
</div>
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
column-gap: 1em;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.vcd-custom-tray-icon-form-text {
|
||||
|
@ -90,3 +90,10 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.vcd-custom-tray-buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
column-gap: 1em;
|
||||
}
|
Loading…
Reference in a new issue