1 回答

TA貢獻1808條經驗 獲得超4個贊
onPress 函數將給出一個 prop,它給出相應的 ToggleButton Pressed 的索引,如果按下第一個按鈕,它給出 0,否則它給出 1 通過這個你可以切換視圖,
const select_radio_props = [
? { label: 'first', value: 0 },
? { label: 'second', value: 1 },
];
export default () => {
? const [value1, onChangeText1] = React.useState('');
? const [value2, onChangeText2] = React.useState('');
? const [value3, onChangeText3] = React.useState('');
? const [initialRadioForm, setInitialRadioForm] = useState(0);
? const [visible, setVisible] = useState(false);
? return (
? ? <>
? ? ? <ScrollView
? ? ? ? behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
? ? ? ? style={styles.container}>
? ? ? ? <View style={styles.MainScreen}>
? ? ? ? ? <View style={styles.WhereToCheckTextView}>
? ? ? ? ? ? <Text style={styles.WhereToCheckText}>where</Text>
? ? ? ? ? </View>
? ? ? ? ? <View style={styles.RadioFormView}>
? ? ? ? ? ? <RadioForm
? ? ? ? ? ? ? formHorizontal={true}
? ? ? ? ? ? ? selectedButtonColor="black"
? ? ? ? ? ? ? buttonColor={'black'}
? ? ? ? ? ? ? animation={true}
? ? ? ? ? ? ? labelHorizontal={true}
? ? ? ? ? ? ? labelStyle={{
? ? ? ? ? ? ? ? fontSize: 18,
? ? ? ? ? ? ? ? left: 5,
? ? ? ? ? ? ? ? color: 'black',
? ? ? ? ? ? ? }}
? ? ? ? ? ? ? buttonSize={20}
? ? ? ? ? ? ? radio_props={select_radio_props}
? ? ? ? ? ? ? initial={initialRadioForm}
? ? ? ? ? ? ? onPress={(val) => {
? ? ? ? ? ? ? ? setVisible(val === 1);
? ? ? ? ? ? ? }}
? ? ? ? ? ? />
? ? ? ? ? </View>
? ? ? ? ? {visible && (
? ? ? ? ? ? <View style={{ width: 200, height: 100, backgroundColor: 'red' }} />
? ? ? ? ? )}
? ? ? ? </View>
? ? ? </ScrollView>
? ? </>
? );
};
添加回答
舉報