mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at remove-preload 45 lines 1.0 kB view raw
1import React, {useState} from 'react' 2import {View} from 'react-native' 3import {RadioButton} from './RadioButton' 4import {ButtonType} from './Button' 5import {s} from 'lib/styles' 6 7export interface RadioGroupItem { 8 label: string | JSX.Element 9 key: string 10} 11 12export function RadioGroup({ 13 testID, 14 type, 15 items, 16 initialSelection = '', 17 onSelect, 18}: { 19 testID?: string 20 type?: ButtonType 21 items: RadioGroupItem[] 22 initialSelection?: string 23 onSelect: (key: string) => void 24}) { 25 const [selection, setSelection] = useState<string>(initialSelection) 26 const onSelectInner = (key: string) => { 27 setSelection(key) 28 onSelect(key) 29 } 30 return ( 31 <View> 32 {items.map((item, i) => ( 33 <RadioButton 34 key={item.key} 35 testID={testID ? `${testID}-${item.key}` : undefined} 36 style={i !== 0 ? s.mt2 : undefined} 37 type={type} 38 label={item.label} 39 isSelected={item.key === selection} 40 onPress={() => onSelectInner(item.key)} 41 /> 42 ))} 43 </View> 44 ) 45}