Revert "chore(ui/plugins): use buttons for toggle instead of switch"
This reverts commit fdca1b74262593721611c6a464769d329043cd0c.
This commit is contained in:
parent
754cabf404
commit
d71d5037cd
1 changed files with 9 additions and 25 deletions
|
|
@ -2,8 +2,8 @@ import { CardWrapper } from "@core/ui/components/AddonCard";
|
||||||
import { requireAssetIndex } from "@lib/api/assets";
|
import { requireAssetIndex } from "@lib/api/assets";
|
||||||
import { useProxy } from "@lib/api/storage";
|
import { useProxy } from "@lib/api/storage";
|
||||||
import { BunnyPlugin, startPlugin, stopPlugin } from "@lib/managers/plugins";
|
import { BunnyPlugin, startPlugin, stopPlugin } from "@lib/managers/plugins";
|
||||||
import { Button, Card, IconButton, Stack, Text } from "@metro/common/components";
|
import { Card, IconButton, Stack, TableSwitch, Text } from "@metro/common/components";
|
||||||
import { createContext, useContext, useState } from "react";
|
import { createContext, useContext } from "react";
|
||||||
import { Image, View } from "react-native";
|
import { Image, View } from "react-native";
|
||||||
|
|
||||||
import { usePluginCardStyles } from "./usePluginCardStyles";
|
import { usePluginCardStyles } from "./usePluginCardStyles";
|
||||||
|
|
@ -50,28 +50,6 @@ function Title() {
|
||||||
</Text>;
|
</Text>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Toggle() {
|
|
||||||
const plugin = usePlugin();
|
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
|
|
||||||
const wrap = (promise: any) => {
|
|
||||||
setLoading(true);
|
|
||||||
Promise.resolve(promise).finally(() => setLoading(false));
|
|
||||||
};
|
|
||||||
|
|
||||||
return <Button
|
|
||||||
size="sm"
|
|
||||||
text={plugin.enabled ? "Disable" : "Enable"}
|
|
||||||
variant={plugin.enabled ? "secondary" : "primary"}
|
|
||||||
loading={loading}
|
|
||||||
disabled={loading}
|
|
||||||
onPress={() => {
|
|
||||||
if (plugin.enabled) wrap(stopPlugin(plugin.id));
|
|
||||||
else wrap(startPlugin(plugin.id));
|
|
||||||
}}
|
|
||||||
/>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function PluginCard({ item: plugin }: CardWrapper<BunnyPlugin>) {
|
export default function PluginCard({ item: plugin }: CardWrapper<BunnyPlugin>) {
|
||||||
useProxy(plugin);
|
useProxy(plugin);
|
||||||
|
|
||||||
|
|
@ -92,7 +70,13 @@ export default function PluginCard({ item: plugin }: CardWrapper<BunnyPlugin>) {
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
icon={requireAssetIndex("SettingsIcon")}
|
icon={requireAssetIndex("SettingsIcon")}
|
||||||
/>
|
/>
|
||||||
<Toggle />
|
<TableSwitch
|
||||||
|
value={plugin.enabled}
|
||||||
|
onValueChange={(v: boolean) => {
|
||||||
|
if (v) startPlugin(plugin.id);
|
||||||
|
else stopPlugin(plugin.id);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue