summaryrefslogtreecommitdiff
path: root/src/components/SetupTab.tsx
blob: d76920019a0d5cfcaef3a776e69eebd3553f8639 (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
import { ButtonItem, Field, PanelSection, PanelSectionRow } from "@decky/ui";
import { type SteamBranchStatus } from "../api/lsfgApi";
import t from "../i18n/i18n";

interface SetupTabProps {
  isInstalled: boolean;
  installationStatus: string;
  losslessScalingInstalled: boolean;
  losslessScalingStatus: string;
  steamBranchStatus: SteamBranchStatus | null;
  isInstalling: boolean;
  isUninstalling: boolean;
  onInstall: () => void;
  onUninstall: () => void;
}

export function SetupTab(props: SetupTabProps) {
  const {
    isInstalled,
    installationStatus,
    losslessScalingInstalled,
    losslessScalingStatus,
    steamBranchStatus,
    isInstalling,
    isUninstalling,
    onInstall,
    onUninstall,
  } = props;
  const losslessScalingAppInstalled = losslessScalingInstalled || steamBranchStatus?.installed === true;
  const buttonLabel = isInstalling
    ? t("INSTALL_INSTALLING", "Installing...")
    : isUninstalling
      ? t("INSTALL_UNINSTALLING", "Uninstalling...")
      : isInstalled
        ? t("INSTALL_UNINSTALL_BTN", "Uninstall LSFG-VK")
        : t("INSTALL_INSTALL_BTN", "Install LSFG-VK");

  return (
    <PanelSection title="Setup">
      <PanelSectionRow>
        <Field
          label="Lossless Scaling"
          description={losslessScalingAppInstalled ? "Installed" : losslessScalingStatus || "Not installed"}
        />
      </PanelSectionRow>
      <PanelSectionRow>
        <Field label="LSFG-VK" description={installationStatus} />
      </PanelSectionRow>
      {steamBranchStatus?.installed && (
        <PanelSectionRow>
          <Field
            label="Steam branch"
            description={`${steamBranchStatus.current_branch || "public"}${steamBranchStatus.needs_switch ? ` - ${steamBranchStatus.message}` : ""}`}
          />
        </PanelSectionRow>
      )}
      <PanelSectionRow>
        <ButtonItem
          layout="below"
          onClick={isInstalled ? onUninstall : onInstall}
          disabled={isInstalling || isUninstalling}
        >
          {buttonLabel}
        </ButtonItem>
      </PanelSectionRow>
    </PanelSection>
  );
}