From 46487d2aee90951a616d5752b8d0af4bdab11d22 Mon Sep 17 00:00:00 2001 From: Beef Date: Thu, 16 Feb 2023 02:16:51 +0000 Subject: [PATCH] [UI > PluginCard] Some needed fixes --- src/ui/settings/components/PluginCard.tsx | 28 +++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/ui/settings/components/PluginCard.tsx b/src/ui/settings/components/PluginCard.tsx index f1e3488..acaf30c 100644 --- a/src/ui/settings/components/PluginCard.tsx +++ b/src/ui/settings/components/PluginCard.tsx @@ -15,23 +15,27 @@ import copyText from "@utils/copyText"; const colorModule = findByProps("SemanticColorsByThemeTable"); const colorMap = (colorModule?.SemanticColor ?? constants.ThemeColorMap); +// TODO: Replace with our eventual dialog API +const Dialog = findByProps("show", "openLazy", "close"); + const { FormRow, FormSwitch } = Forms; const { TouchableOpacity, Image } = General; +// TODO: These styles work weirdly. iOS has cramped text, Android with low DPI probably does too. Fix? const styles = stylesheet.createThemedStyleSheet({ card: { backgroundColor: colorMap?.BACKGROUND_SECONDARY, borderRadius: 5, - margin: 10, - marginTop: 0, + marginHorizontal: 10, + marginBottom: 10, }, header: { + padding: 0, backgroundColor: colorMap?.BACKGROUND_TERTIARY, borderTopLeftRadius: 5, borderTopRightRadius: 5, }, actions: { - justifyContent: "flex-end", flexDirection: "row-reverse", alignItems: "center", }, @@ -51,6 +55,7 @@ export default function PluginCard({ plugin }: PluginCardProps) { const settings = getSettings(plugin.id); const navigation = NavigationNative.useNavigation(); const [removed, setRemoved] = React.useState(false); + // This is needed because of Reactâ„¢ if (removed) return null; @@ -58,10 +63,12 @@ export default function PluginCard({ plugin }: PluginCardProps) { i.name).join(", ")}`} leading={} trailing={ { if (v) startPlugin(plugin.id); else stopPlugin(plugin.id); @@ -74,10 +81,17 @@ export default function PluginCard({ plugin }: PluginCardProps) { trailing={ { - removePlugin(plugin.id); - setRemoved(true); - }} + onPress={() => Dialog.show({ + title: "Wait!", + body: `Are you sure you wish to delete ${plugin.manifest.name}?`, + confirmText: "Delete", + cancelText: "Cancel", + confirmColor: "red", + onConfirm: () => { + removePlugin(plugin.id); + setRemoved(true); + } + })} >