* [UI > Plugins] Add unproxied plugin warning prompt * [UI > Plugins] Show msg if developer not enabled * [UI > Plugins] Prettier-be-gone! --------- Co-authored-by: Beef <beefers@riseup.net>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { ReactNative as RN, stylesheet, clipboard } from "@metro/common";
|
|
import { HTTP_REGEX_MULTI } from "@lib/constants";
|
|
import { showInputAlert } from "@ui/alerts";
|
|
import { getAssetIDByName } from "@ui/assets";
|
|
import { semanticColors } from "@ui/color";
|
|
|
|
const styles = stylesheet.createThemedStyleSheet({
|
|
icon: {
|
|
marginRight: 10,
|
|
tintColor: semanticColors.HEADER_PRIMARY,
|
|
},
|
|
});
|
|
|
|
interface InstallButtonProps {
|
|
alertTitle: string;
|
|
installFunction: (id: string) => Promise<void>;
|
|
}
|
|
|
|
export default function InstallButton({ alertTitle, installFunction: fetchFunction }: InstallButtonProps) {
|
|
return (
|
|
<RN.TouchableOpacity onPress={() =>
|
|
clipboard.getString().then((content) =>
|
|
showInputAlert({
|
|
title: alertTitle,
|
|
initialValue: content.match(HTTP_REGEX_MULTI)?.[0] ?? "",
|
|
placeholder: "https://example.com/",
|
|
onConfirm: (input: string) => fetchFunction(input),
|
|
confirmText: "Install",
|
|
cancelText: "Cancel",
|
|
})
|
|
)
|
|
}>
|
|
<RN.Image style={styles.icon} source={getAssetIDByName("ic_add_24px")} />
|
|
</RN.TouchableOpacity>
|
|
);
|
|
}
|