about summary refs log tree commit diff
path: root/src/view/com/util/forms/SelectableBtn.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-07-05 19:56:42 -0500
committerGitHub <noreply@github.com>2023-07-05 19:56:42 -0500
commit3a6073abb899cf3e73c530fceed2322955ee97b1 (patch)
treeeff2710d3d56712f79a3b5f7dab29604d55fed7e /src/view/com/util/forms/SelectableBtn.tsx
parentfe327300256a81adf261a7c8e9537b86feb0fd71 (diff)
downloadvoidsky-3a6073abb899cf3e73c530fceed2322955ee97b1.tar.zst
Added instructions for .well-known method (supersedes #887) (#979)
* Added instructions for .well-known method

* Factor out SelectableBtn

* Rework the ChangeHandle modal to be a little clearer

* Fix lint

* Fix desktop layout

---------

Co-authored-by: Haider Ali Punjabi <haiderali@cyberservices.com>
Co-authored-by: Haider Ali Punjabi <haideralipunjabi@hackesta.org>
Diffstat (limited to 'src/view/com/util/forms/SelectableBtn.tsx')
-rw-r--r--src/view/com/util/forms/SelectableBtn.tsx67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/view/com/util/forms/SelectableBtn.tsx b/src/view/com/util/forms/SelectableBtn.tsx
new file mode 100644
index 000000000..503c49b2f
--- /dev/null
+++ b/src/view/com/util/forms/SelectableBtn.tsx
@@ -0,0 +1,67 @@
+import React from 'react'
+import {Pressable, ViewStyle, StyleProp, StyleSheet} from 'react-native'
+import {Text} from '../text/Text'
+import {usePalette} from 'lib/hooks/usePalette'
+import {isDesktopWeb} from 'platform/detection'
+
+interface SelectableBtnProps {
+  selected: boolean
+  label: string
+  left?: boolean
+  right?: boolean
+  onSelect: () => void
+  accessibilityHint?: string
+  style?: StyleProp<ViewStyle>
+}
+
+export function SelectableBtn({
+  selected,
+  label,
+  left,
+  right,
+  onSelect,
+  accessibilityHint,
+  style,
+}: SelectableBtnProps) {
+  const pal = usePalette('default')
+  const palPrimary = usePalette('inverted')
+  return (
+    <Pressable
+      style={[
+        styles.selectableBtn,
+        left && styles.selectableBtnLeft,
+        right && styles.selectableBtnRight,
+        pal.border,
+        selected ? palPrimary.view : pal.view,
+        style,
+      ]}
+      onPress={onSelect}
+      accessibilityRole="button"
+      accessibilityLabel={label}
+      accessibilityHint={accessibilityHint}>
+      <Text style={selected ? palPrimary.text : pal.text}>{label}</Text>
+    </Pressable>
+  )
+}
+
+const styles = StyleSheet.create({
+  selectableBtn: {
+    flex: isDesktopWeb ? undefined : 1,
+    width: isDesktopWeb ? 100 : undefined,
+    flexDirection: 'row',
+    justifyContent: 'center',
+    borderWidth: 1,
+    borderLeftWidth: 0,
+    paddingHorizontal: 10,
+    paddingVertical: 10,
+  },
+  selectableBtnLeft: {
+    borderTopLeftRadius: 8,
+    borderBottomLeftRadius: 8,
+    borderLeftWidth: 1,
+  },
+  selectableBtnRight: {
+    borderTopRightRadius: 8,
+    borderBottomRightRadius: 8,
+  },
+})