Skip to content

Commit

Permalink
prepare for v0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Bamboooz committed Mar 30, 2024
1 parent 4e44822 commit 864a2e1
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 14 deletions.
7 changes: 6 additions & 1 deletion src-tauri/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ pub struct AudioDevice {
}

#[tauri::command]
pub fn list_audio_devices() -> Result<Vec<AudioDevice>, String> {
pub fn list_input_devices() -> Result<Vec<AudioDevice>, String> {
Ok(vec![])
}

#[tauri::command]
pub fn list_output_devices() -> Result<Vec<AudioDevice>, String> {
Ok(vec![])
}

Expand Down
3 changes: 2 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ fn main() {
filesystem::get_magnetar_path,
steam::fetch_all_steam_games,
steam::run_steam_scheme,
audio::list_audio_devices,
audio::list_input_devices,
audio::list_output_devices,
audio::set_device_volume,
audio::get_device_volume,
])
Expand Down
35 changes: 33 additions & 2 deletions src/components/Audio/Audio.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { IoIosArrowForward } from "react-icons/io";

import { cn } from "../../utils/tw";

Expand All @@ -10,8 +11,38 @@ interface AudioViewProps {
const AudioView: React.FC<AudioViewProps> = ({ selectedPage, pageId }) => {
return (
<>
<div className={cn(selectedPage === pageId ? "w-full h-full flex flex-col items-center justify-start overflow-auto" : "hidden")}>

<div className={cn(selectedPage === pageId ? "w-full h-full flex items-center justify-start py-2 px-6 gap-6" : "hidden")}>
<div className="h-full w-[50%] flex flex-col items-start justify-start gap-3">
<p className="text-neutral-300 text-[14px]">Output devices:</p>

<div title="Huawei Bluetooth Headphones Lite" className="w-full h-10 flex items-center justify-between px-3 rounded-sm border border-border">
<p className="text-neutral-400 text-[14px] truncate">Huawei Bluetooth Headphones Lite</p>
<IoIosArrowForward className="text-neutral-400 text-[14px] rotate-90 shrink-0" />
</div>

<p className="text-neutral-400 text-[14px] mt-4">Volume:</p>
<div className="w-full h-4 relative flex items-center justify-start">
<div className="bg-accent rounded-l-full w-[10%] h-1" />
<div className="bg-border rounded-r-full w-full h-1" />
<div className="h-2 w-2 rounded-full bg-neutral-400 absolute left-[calc(10%-0.25rem)]" />
</div>
</div>

<div className="h-full w-[50%] flex flex-col items-start justify-start gap-3">
<p className="text-neutral-300 text-[14px]">Input devices:</p>

<div title="NC-1" className="w-full h-10 flex items-center justify-between px-3 rounded-sm border border-border">
<p className="text-neutral-400 text-[14px] truncate">NC-1</p>
<IoIosArrowForward className="text-neutral-400 text-[14px] rotate-90 shrink-0" />
</div>

<p className="text-neutral-400 text-[14px] mt-4">Volume:</p>
<div className="w-full h-4 relative flex items-center justify-start">
<div className="bg-accent rounded-l-full w-[80%] h-1" />
<div className="bg-border rounded-r-full w-[calc(100%-80%)] h-1" />
<div className="h-2 w-2 rounded-full bg-neutral-400 absolute left-[calc(80%-0.25rem)]" />
</div>
</div>
</div>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Commands/CommandItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { invoke } from "@tauri-apps/api/tauri";
import { appWindow } from "@tauri-apps/api/window"
import { appWindow } from "@tauri-apps/api/window";
import { LuTerminal } from "react-icons/lu";
import { VscTerminalPowershell } from "react-icons/vsc";

Expand Down
51 changes: 43 additions & 8 deletions src/components/Games/Games.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useEffect, useState } from "react";
import { invoke } from "@tauri-apps/api/tauri";
import { appWindow } from "@tauri-apps/api/window"
import { FaSteam } from "react-icons/fa";

import GameListView from "./GameList";
import { cn } from "../../utils/tw";
Expand All @@ -19,6 +21,24 @@ interface GamesViewProps {
const GamesView: React.FC<GamesViewProps> = ({ search, selectedPage, pageId }) => {
const [games, setGames] = useState<SteamGame[]>([]);

const executeCommand = async (command: string) => {
await appWindow.hide();

await invoke("execute_command", { command: command, requiresAdministrator: false })
.catch(err => {
console.error(err);
});
};

const useSteamScheme = async (scheme: string) => {
await appWindow.hide();

await invoke("run_steam_scheme", { scheme: scheme })
.catch(err => {
console.error(err);
});
};

const displayedGames = games.filter((game) => game.name.toLowerCase().includes(search.toLowerCase()));

useEffect(() => {
Expand All @@ -33,14 +53,29 @@ const GamesView: React.FC<GamesViewProps> = ({ search, selectedPage, pageId }) =

return (
<>
<div className={cn(selectedPage === pageId ? "w-full h-full flex flex-col items-center overflow-auto" : "hidden", displayedGames.length > 0 ? "justify-start" : "justify-center")}>
{displayedGames.length > 0
? <>
<GameListView title="Installed" games={displayedGames.filter((game) => game.installed === "1")} />
<GameListView title="Not installed" games={displayedGames.filter((game) => game.installed === "0")} />
</>
: <p className="text-neutral-300 text-[18px] font-semibold">No games found.</p>
}
<div className={cn(selectedPage === pageId ? "w-full h-full flex flex-col items-center justify-start overflow-auto" : "hidden")}>
<div className="w-full flex flex-col my-2 items-start justify-between">
<div onClick={() => useSteamScheme("steam://run")} className="w-full h-12 flex items-center justify-start pl-6 gap-6 hover:bg-item-hover">
<FaSteam className="text-neutral-300 text-[26px]" />

<div className="flex flex-col items-start justify-center">
<p className="text-[14px] font-semibold text-neutral-300">Open steam</p>
<p className="text-[12px] text-neutral-400 truncate">start steam://run</p>
</div>
</div>

<div onClick={() => executeCommand("taskkill /f /im steam.exe")} className="w-full h-12 flex items-center justify-start pl-6 gap-6 hover:bg-item-hover">
<FaSteam className="text-neutral-300 text-[26px]" />

<div className="flex flex-col items-start justify-center">
<p className="text-[14px] font-semibold text-neutral-300">Close steam</p>
<p className="text-[12px] text-neutral-400 truncate">taskkill /f /im steam.exe</p>
</div>
</div>
</div>

<GameListView title="Installed" games={displayedGames.filter((game) => game.installed === "1")} />
<GameListView title="Not installed" games={displayedGames.filter((game) => game.installed === "0")} />
</div>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation/NavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const NavigationBar: React.FC<NavigationBarProps> = ({ selectedPage, setSelected
<PageButton text="Apps" targetPage={2} selectedPage={selectedPage} setSelectedPage={setSelectedPage} />
<PageButton text="Games" targetPage={3} selectedPage={selectedPage} setSelectedPage={setSelectedPage} />
<PageButton text="Commands" targetPage={4} selectedPage={selectedPage} setSelectedPage={setSelectedPage} />
<PageButton text="Audio" targetPage={5} selectedPage={selectedPage} setSelectedPage={setSelectedPage} />
{/*<PageButton text="Audio" targetPage={5} selectedPage={selectedPage} setSelectedPage={setSelectedPage} />*/}
</div>

{selectedPage !== 0 && selectedPage !== 1 && selectedPage !== 5 &&
Expand Down

0 comments on commit 864a2e1

Please sign in to comment.