[UI] Alerts API (#21)
* [UI] Initial Alerts API * [UI > Alerts] showCustomAlert and showInputAlert * [Constants] Add HTTP_REGEX * [UI > Plugins] Use InputAlert for installing plugins * [UI > Plugins/PluginCard] Pass plugin index to PluginCard to add top margin * [UI > Alerts] Fix indentation
This commit is contained in:
parent
c3f7d60d85
commit
9fb99ced74
10 changed files with 175 additions and 35 deletions
|
@ -1,44 +1,18 @@
|
|||
import { ReactNative as RN } from "@metro/common";
|
||||
import { Forms } from "@ui/components";
|
||||
import { showToast } from "@ui/toasts";
|
||||
import { getAssetIDByName } from "@ui/assets";
|
||||
import { useProxy } from "@lib/storage";
|
||||
import { plugins, installPlugin } from "@lib/plugins";
|
||||
import { plugins } from "@lib/plugins";
|
||||
import PluginCard from "@ui/settings/components/PluginCard";
|
||||
import ErrorBoundary from "@ui/components/ErrorBoundary";
|
||||
|
||||
const { FormInput, FormRow } = Forms;
|
||||
|
||||
export default function Plugins() {
|
||||
useProxy(plugins);
|
||||
const [pluginUrl, setPluginUrl] = React.useState("");
|
||||
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<RN.View style={{ flex: 1 }}>
|
||||
<FormInput
|
||||
value={pluginUrl}
|
||||
onChange={(v: string) => setPluginUrl(v)}
|
||||
placeholder="https://example.com/"
|
||||
title="PLUGIN URL"
|
||||
/>
|
||||
<FormRow
|
||||
label="Install plugin"
|
||||
// I checked, this icon exists on a fresh Discord install. Please, stop disappearing.
|
||||
leading={<FormRow.Icon source={getAssetIDByName("ic_add_24px")} />}
|
||||
onPress={() => {
|
||||
installPlugin(pluginUrl).then(() => {
|
||||
setPluginUrl("");
|
||||
}).catch((e: Error) => {
|
||||
showToast(e.message, getAssetIDByName("Small"));
|
||||
});
|
||||
}
|
||||
}
|
||||
/>
|
||||
<RN.FlatList
|
||||
style={{ marginTop: 10 }}
|
||||
data={Object.values(plugins)}
|
||||
renderItem={({ item }) => <PluginCard plugin={item} />}
|
||||
renderItem={({ item, index }) => <PluginCard plugin={item} index={index} />}
|
||||
keyExtractor={item => item.id}
|
||||
/>
|
||||
</RN.View>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue