about summary refs log tree commit diff
path: root/src/view/com/util/forms/RadioGroup.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-12-18 17:28:28 -0600
committerPaul Frazee <pfrazee@gmail.com>2022-12-18 17:28:28 -0600
commit66a0f8e848342bb5e5ceda36f5095f3ad2b0de29 (patch)
treecacef9000a8060a2d3ae1e5b8981381314394c5b /src/view/com/util/forms/RadioGroup.tsx
parent36dc1c752556b8413dfb4d8fae6f930888489224 (diff)
downloadvoidsky-66a0f8e848342bb5e5ceda36f5095f3ad2b0de29.tar.zst
Add WIP 'report post' modal
Diffstat (limited to 'src/view/com/util/forms/RadioGroup.tsx')
-rw-r--r--src/view/com/util/forms/RadioGroup.tsx34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/view/com/util/forms/RadioGroup.tsx b/src/view/com/util/forms/RadioGroup.tsx
new file mode 100644
index 000000000..6684cde5c
--- /dev/null
+++ b/src/view/com/util/forms/RadioGroup.tsx
@@ -0,0 +1,34 @@
+import React, {useState} from 'react'
+import {View} from 'react-native'
+import {RadioButton} from './RadioButton'
+
+export interface RadioGroupItem {
+  label: string
+  key: string
+}
+
+export function RadioGroup({
+  items,
+  onSelect,
+}: {
+  items: RadioGroupItem[]
+  onSelect: (key: string) => void
+}) {
+  const [selection, setSelection] = useState<string>('')
+  const onSelectInner = (key: string) => {
+    setSelection(key)
+    onSelect(key)
+  }
+  return (
+    <View>
+      {items.map(item => (
+        <RadioButton
+          key={item.key}
+          label={item.label}
+          isSelected={item.key === selection}
+          onPress={() => onSelectInner(item.key)}
+        />
+      ))}
+    </View>
+  )
+}