-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradiobutton.tsx
76 lines (71 loc) · 1.86 KB
/
radiobutton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import React, {useEffect} from 'react';
import {useState} from 'react';
import {
Text, //First letter Capital
View,
Button,
StyleSheet,
TextInput,
FlatList,
ScrollView,
KeyboardAvoidingView,
TouchableOpacity,
} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {Home} from './components/Home';
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';
const App = () => {
const [selectedRadio, setselectedRadio] = useState(1);
return (
<View style={styles.main}>
<TouchableOpacity onPress={() => setselectedRadio(1)}>
<View style={styles.radioWrapper}>
<View style={styles.radio}>
{selectedRadio === 1 ? <View style={styles.radioBg}></View> : null}
</View>
<Text style={styles.radioText}>Radio 1</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => setselectedRadio(2)}>
<View style={styles.radioWrapper}>
<View style={styles.radio}>
{selectedRadio === 2 ? <View style={styles.radioBg}></View> : null}
</View>
<Text style={styles.radioText}>Radio 2</Text>
</View>
</TouchableOpacity>
</View>
);
};
const styles = StyleSheet.create({
main: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
radioText: {
fontSize: 20,
},
radio: {
height: 40,
width: 40,
borderColor: 'black',
borderWidth: 2,
borderRadius: 20,
margin: 10,
},
radioBg: {
backgroundColor: 'green',
height: 28,
width: 28,
borderRadius: 28,
margin: 4,
},
radioWrapper: {
flexDirection: 'row',
alignItems: 'center',
},
});
export default App;