generated from SteamDeckHomebrew/decky-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: decouple Controller component
* 275ms delayPromise no longer needed * loading state no longer needed Signed-off-by: eXhumer <[email protected]>
- Loading branch information
Showing
7 changed files
with
76 additions
and
63 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
PanelSectionRow, | ||
gamepadDialogClasses, | ||
joinClassNames, | ||
} from "@decky/ui"; | ||
|
||
import { IconContext } from "react-icons"; | ||
import { BiBluetooth, BiUsb } from "react-icons/bi"; | ||
|
||
import BatteryIcon from "./BatteryIcon"; | ||
import VendorIcon from "./VendorIcon"; | ||
import { IController } from "../types"; | ||
|
||
const FieldWithSeparator = joinClassNames(gamepadDialogClasses.Field, gamepadDialogClasses.WithBottomSeparatorStandard); | ||
|
||
type ControllerProps = { | ||
controller: IController; | ||
}; | ||
|
||
const Controller = ({ controller }: ControllerProps) => { | ||
return ( | ||
<PanelSectionRow> | ||
<div className={FieldWithSeparator}> | ||
<div className={gamepadDialogClasses.FieldLabelRow}> | ||
<div className={gamepadDialogClasses.FieldLabel}> | ||
<IconContext.Provider value={{ style: { verticalAlign: 'middle', marginRight: '10px' } }}> | ||
{controller.bluetooth ? <BiBluetooth /> : <BiUsb />} | ||
</IconContext.Provider> | ||
<IconContext.Provider value={{ style: { verticalAlign: 'middle', marginRight: '5px' } }}> | ||
<VendorIcon controller={controller}/> | ||
</IconContext.Provider> | ||
{controller.name} | ||
</div> | ||
{ | ||
(controller.capacity > 0 || controller.status !== "unknown") && | ||
<div className={gamepadDialogClasses.FieldChildrenInner}> | ||
{ | ||
// only show battery capacity for non-MS vendors unless capacity is > 0 and over BT | ||
// since we don't have the battery capacity yet for Xbox over USB | ||
(controller.vendorId != 0x045E || (controller.capacity > 0 && controller.bluetooth)) && | ||
<span style={{ display: "inline-block", textAlign: "right", }}>{controller.capacity}%</span> | ||
} | ||
<IconContext.Provider value={{ style: { verticalAlign: 'middle', marginLeft: "6px" }, size: '2em' }}> | ||
<BatteryIcon controller={controller}/> | ||
</IconContext.Provider> | ||
</div> | ||
} | ||
</div> | ||
</div> | ||
</PanelSectionRow> | ||
); | ||
}; | ||
|
||
export default Controller; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters