Skip to content

Commit

Permalink
Tab Cloak + Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Cattn committed Sep 24, 2024
1 parent 4745f63 commit 4dfd34c
Show file tree
Hide file tree
Showing 13 changed files with 272 additions and 190 deletions.
4 changes: 2 additions & 2 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ export default function Navbar() {
</Tooltip> */}
<Tooltip delayDuration={0}>
<TooltipTrigger asChild>
<div
<div
onClick={() => {
navigate(`/settings`)
}}
className="font-bold hover:bg-zinc-700 transition-colors duration-150 aspect-square flex items-center justify-center cursor-pointer group"
>
<Settings className="group-active:scale-90 transition-all duration-300" />
</div>
</div>
</TooltipTrigger>
<TooltipContent side="right">
<p>Settings</p>
Expand Down
32 changes: 16 additions & 16 deletions src/internal/GBA.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Plugin } from "@/lib/types";
import { Gamepad } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Maximize2 } from "lucide-react";
import { Plugin } from "@/lib/types"
import { Gamepad } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Maximize2 } from "lucide-react"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { useState } from "react";
} from "@/components/ui/dropdown-menu"
import { useState } from "react"

const gba: Plugin = {
name: "GBA",
Expand All @@ -17,13 +17,13 @@ const gba: Plugin = {
icon: Gamepad,

page({ sdk }) {
console.log(sdk.plugins.isInstalled("bunker.gba"));
console.log(sdk.plugins.isInstalled("bunker.gba"))
const fullScreen = () => {
const iframe = document.getElementById("framey") as HTMLIFrameElement;
iframe.requestFullscreen();
};
const iframe = document.getElementById("framey") as HTMLIFrameElement
iframe.requestFullscreen()
}

const [url, setUrl] = useState("https://ilovemath.pics/");
const [url, setUrl] = useState("https://ilovemath.pics/")
return (
<div className="flex flex-col items-center justify-center w-full h-full mt-2">
<div className="w-[92%] h-[92%]">
Expand All @@ -45,14 +45,14 @@ const gba: Plugin = {
<DropdownMenuContent>
<DropdownMenuItem
onClick={() => {
setUrl("https://mathstudy.dev/gba");
setUrl("https://mathstudy.dev/gba")
}}
>
2.0
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
setUrl("https://ilovemath.pics/");
setUrl("https://ilovemath.pics/")
}}
>
3.0
Expand All @@ -61,8 +61,8 @@ const gba: Plugin = {
</DropdownMenu>
</div>
</div>
);
)
},
};
}

export default gba;
export default gba
130 changes: 98 additions & 32 deletions src/internal/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Plugin } from "@/lib/types"
import { Settings2 } from "lucide-react"
import { Switch } from "@/components/ui/switch"
import { Label } from "@/components/ui/label"
import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"

import { useState } from "react"

Expand All @@ -12,77 +14,141 @@ const Settings: Plugin = {
icon: Settings2,

page({ sdk }) {
const [pluginLocation, setPluginLocation] = useState(sdk.config.get("storageLocation"));
const [autoUpdate, setAutoUpdate] = useState(sdk.config.get("autoUpdate") === "true");
const [notifications, setNotifications] = useState(sdk.config.get("notifications") === "true");
const [pluginNotifs, setPluginNotifs] = useState(sdk.config.get("pluginNotifs") === "true");
const [pluginLocation, setPluginLocation] = useState(
sdk.config.get("storageLocation"),
)
const [autoUpdate, setAutoUpdate] = useState(
sdk.config.get("autoUpdate") === "true",
)
const [notifications, setNotifications] = useState(
sdk.config.get("notifications") === "true",
)
const [pluginNotifs, setPluginNotifs] = useState(
sdk.config.get("pluginNotifs") === "true",
)
const [title, setTitle] = useState(sdk.config.get("title") || "Bunker")

function setStorageLocation(checked: boolean) {
if (checked) {
sdk.config.set("storageLocation", "internal")
setPluginLocation("internal");
setPluginLocation("internal")
} else {
sdk.config.set("storageLocation", "external")
setPluginLocation("external");
setPluginLocation("external")
}
}

function autoUpdateSet(checked: boolean) {
if (checked) {
sdk.config.set("autoUpdate", "true")
setAutoUpdate(true);
setAutoUpdate(true)
} else {
sdk.config.set("autoUpdate", "false")
setAutoUpdate(false);
setAutoUpdate(false)
}
}

function notificationSet(checked: boolean) {
if (checked) {
sdk.config.set("notifications", "true")
setNotifications(true);
setNotifications(true)
} else {
sdk.config.set("notifications", "false")
setNotifications(false);
setNotifications(false)
}
}

function pluginNotifSet(checked: boolean) {
if (checked) {
sdk.config.set("pluginNotifs", "true")
setPluginNotifs(true);
setPluginNotifs(true)
} else {
sdk.config.set("pluginNotifs", "false")
setPluginNotifs(false);
setPluginNotifs(false)
}
}

function titleSet() {
sdk.config.set("title", title)
}

function resetTitle() {
setTitle("Bunker")
sdk.config.set("title", "Bunker")
}

return (
<div className="flex flex-col items-center w-full pt-16">
<h1 className="font-bold text-5xl">Settings </h1>
<div className="flex flex-col justify-center gap-4 mt-8">
<div className="flex flex-row items-center gap-4 mt-8">
<Switch id="storage-location" checked={pluginLocation === "internal"} onCheckedChange={(checked) => setStorageLocation(checked)} />
<Label className="text-md" htmlFor="storage-location">Store Plugins Internally</Label>
</div>
<div className="flex flex-row items-center gap-4 mt-2">
<Switch id="auto-update" checked={autoUpdate} onCheckedChange={(checked) => autoUpdateSet(checked)} />
<Label className="text-md" htmlFor="auto-update">Auto Update</Label>
</div>
<div className="flex flex-row items-center gap-4 mt-2">
<Switch id="notifications" checked={notifications} onCheckedChange={(checked) => notificationSet(checked)} />
<Label className="text-md" htmlFor="notifications">Disable All Notifications</Label>
</div>
<div className="flex flex-row items-center gap-4 mt-2">
<Switch id="pluginNotif" checked={pluginNotifs} onCheckedChange={(checked) => pluginNotifSet(checked)} />
<Label className="text-md" htmlFor="pluginNotif">Disable Notifications from Plugins</Label>
</div>
<div className="flex flex-col items-center w-full pt-16">
<h1 className="font-bold text-5xl">Settings </h1>
<div className="flex flex-col justify-center gap-4 mt-8">
<div className="flex flex-row items-center gap-4 mt-8">
<Switch
id="storage-location"
checked={pluginLocation === "internal"}
onCheckedChange={(checked) => setStorageLocation(checked)}
/>
<Label className="text-md" htmlFor="storage-location">
Store Plugins Internally
</Label>
</div>
<div className="flex flex-row items-center gap-4 mt-2">
<Switch
id="auto-update"
checked={autoUpdate}
onCheckedChange={(checked) => autoUpdateSet(checked)}
/>
<Label className="text-md" htmlFor="auto-update">
Auto Update
</Label>
</div>
<div className="flex flex-row items-center gap-4 mt-2">
<Switch
id="notifications"
checked={notifications}
onCheckedChange={(checked) => notificationSet(checked)}
/>
<Label className="text-md" htmlFor="notifications">
Disable All Notifications
</Label>
</div>
<div className="flex flex-row items-center gap-4 mt-2">
<Switch
id="pluginNotif"
checked={pluginNotifs}
onCheckedChange={(checked) => pluginNotifSet(checked)}
/>
<Label className="text-md" htmlFor="pluginNotif">
Disable Notifications from Plugins
</Label>
</div>
</div>
<h1 className="font-bold text-5xl mt-5">Tab Cloak </h1>
<div className="flex justify-center mt-8">
<form
onSubmit={(e) => {
e.preventDefault()
titleSet()
}}
>
<div className="flex justify-center gap-4">
<Input
onChange={(e) => setTitle(e.target.value)}
className="border-none w-full mb-1"
placeholder="Google Classroom"
/>
<Button onClick={titleSet} type="submit" className="bg-green-500">
Set Tab Cloak
</Button>
</div>
<Button onClick={resetTitle} className="bg-red-500 w-full mt-1">
Reset Tab Cloak
</Button>
</form>
</div>
</div>
)
},


onReady() {
console.log("Settings")
},
Expand Down
21 changes: 10 additions & 11 deletions src/internal/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ const Status: Plugin = {
</p>
<p>
Version:{" "}
<span className="text-orange-500 font-semibold">{bunker.version} (dev)</span>
<span className="text-orange-500 font-semibold">
{bunker.version} (dev)
</span>
</p>
<p>
<button
Expand All @@ -61,16 +63,13 @@ const Status: Plugin = {
<DialogTitle>v0.2.4</DialogTitle>
<DialogDescription>
What's new?
<br />
- Added changelog
<br />
- Added settings
<br />
- Added the ability to store plugins internally (unblockable)
<br />
- Added fullscreen to GBA + Viewer
<br />
- Added SDK! This is still a WIP, but soon you will see many more features which take advantage of it behind the scenes!
<br />- Added changelog
<br />- Added settings
<br />- Added the ability to store plugins internally
(unblockable)
<br />- Added fullscreen to GBA + Viewer
<br />- Added SDK! This is still a WIP, but soon you will see
many more features which take advantage of it behind the scenes!
<br />
</DialogDescription>
</DialogHeader>
Expand Down
14 changes: 8 additions & 6 deletions src/internal/Updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,18 @@ const Updater: Plugin = {
},
})
setUpdateText(`Version ${latestVersion} is now available`)
return;
} else if (semver.diff(latestVersion, installedVersion) == "minor") {
return
} else if (
semver.diff(latestVersion, installedVersion) == "minor"
) {
toast("New update available [" + latestVersion + "]", {
action: {
label: "Install Now",
onClick: () => updateBunker(),
},
})
setUpdateText(`Version ${latestVersion} is now available`)
return;
return
} else {
toast("New update available [" + latestVersion + "]", {
action: {
Expand All @@ -81,14 +83,14 @@ const Updater: Plugin = {
},
})
setUpdateText(`Version ${latestVersion} is now available`)
return;
return
}
} else if (semver.eq(installedVersion, latestVersion)) {
toast("No update available")
return;
return
} else {
toast("No update available")
return;
return
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Viewer: Plugin = {
)
},
page({ sdk }) {
console.log(sdk.plugins.isInstalled("bunker.gba"));
console.log(sdk.plugins.isInstalled("bunker.gba"))
const [url, setUrl] = useState("")
const [iframeVisable, setIframeVisable] = useState(false)

Expand Down
17 changes: 9 additions & 8 deletions src/lib/bunker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@ let pluginLocation: string = "internal"
let autoUpdate: string = "true"
let notifications: string = "false" // True = disable all notifications, false = enable all
let pluginNotifs: string = "true" // True = enabled plugin notifications, false = disabled plugin notifications

let title: string = "Bunker"

let Settings = new SDK("bunker.settings")


pluginLocation = Settings.config.get("storageLocation") || pluginLocation
// @ts-ignore
autoUpdate = Settings.config.get("autoUpdate") || autoUpdate;
autoUpdate = Settings.config.get("autoUpdate") || autoUpdate

// @ts-ignore
notifications = Settings.config.get("notifications") || notifications

// @ts-ignore
notifications = Settings.config.get("notifications") || notifications;
pluginNotifs = Settings.config.get("pluginNotifs") || pluginNotifs

// @ts-ignore
pluginNotifs = Settings.config.get("pluginNotifs") || pluginNotifs;
title = Settings.config.get("title") || title

const bunker = {
version,
pluginLocation,
autoUpdate,
notifications,
pluginNotifs
pluginNotifs,
title,
}
export default bunker


Loading

0 comments on commit 4dfd34c

Please sign in to comment.