summaryrefslogtreecommitdiff
path: root/src/components/InstallationButton.tsx
blob: de7d454bc70edec0c4a401912c86518df2cc9cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { ButtonItem, PanelSectionRow } from "@decky/ui";
import { FaDownload, FaTrash } from "react-icons/fa";

interface InstallationButtonProps {
  isInstalled: boolean;
  isInstalling: boolean;
  isUninstalling: boolean;
  onInstall: () => void;
  onUninstall: () => void;
}

export function InstallationButton({
  isInstalled,
  isInstalling,
  isUninstalling,
  onInstall,
  onUninstall
}: InstallationButtonProps) {
  const renderInstallButtonContent = () => {
    if (isInstalling) {
      return (
        <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
          <div>{isInstalled ? "Updating..." : "Installing..."}</div>
        </div>
      );
    }

    return (
      <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
        <FaDownload />
        <div>{isInstalled ? "Update LSFG-VK" : "Install / Update LSFG-VK"}</div>
      </div>
    );
  };

  const renderUninstallButtonContent = () => {
    if (isUninstalling) {
      return (
        <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
          <div>Uninstalling...</div>
        </div>
      );
    }

    return (
      <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
        <FaTrash />
        <div>Uninstall LSFG-VK</div>
      </div>
    );
  };

  return (
    <>
      <PanelSectionRow>
        <ButtonItem
          layout="below"
          onClick={onInstall}
          disabled={isInstalling || isUninstalling}
        >
          {renderInstallButtonContent()}
        </ButtonItem>
      </PanelSectionRow>

      {isInstalled && (
        <PanelSectionRow>
          <ButtonItem
            layout="below"
            onClick={onUninstall}
            disabled={isInstalling || isUninstalling}
          >
            {renderUninstallButtonContent()}
          </ButtonItem>
        </PanelSectionRow>
      )}
    </>
  );
}