1
1
import React , { Component } from 'react' ;
2
2
import { TouchableOpacity , ScrollView } from 'react-native' ;
3
- import { Assets , RadioButton , Colors , Shadows , RadioGroup , View , Text } from 'react-native-ui-lib' ; //eslint-disable-line
3
+ import { Assets , Colors , View , Text , RadioButton , RadioGroup } from 'react-native-ui-lib' ; //eslint-disable-line
4
4
const starIcon = require ( '../../assets/icons/star.png' ) ;
5
5
6
6
const COLORS = {
@@ -11,8 +11,10 @@ const COLORS = {
11
11
12
12
export default class RadioButtonScreen extends Component {
13
13
static colors = COLORS ;
14
+
14
15
constructor ( props ) {
15
16
super ( props ) ;
17
+
16
18
this . state = {
17
19
color : undefined ,
18
20
messageType : undefined ,
@@ -61,89 +63,85 @@ export default class RadioButtonScreen extends Component {
61
63
62
64
render ( ) {
63
65
return (
64
- < View flex useSafeArea bg-grey80 >
65
- < ScrollView >
66
- < View padding-page >
67
- < Text h1 marginB-s5 >
68
- Radio Buttons
69
- </ Text >
70
-
71
- < RadioGroup initialValue = { this . state . color || null } onValueChange = { value => this . setState ( { color : value } ) } >
72
- < Text marginB-20 text60 grey10 >
73
- Select a color{ '\n' }
74
- (enum with default value)
75
- </ Text >
76
- { this . renderRadioButton ( null , 'Default' ) }
77
- { this . renderRadioButtonForColorEnum ( RadioButtonScreen . colors . ORANGE ) }
78
- { this . renderRadioButtonForColorEnum ( RadioButtonScreen . colors . PURPLE ) }
79
- { this . renderRadioButtonForColorEnum ( RadioButtonScreen . colors . GREEN ) }
80
- < Text marginT-10 > You chose: { this . state . color ? this . state . color : 'Default' } </ Text >
81
- </ RadioGroup >
66
+ < View flex useSafeArea >
67
+ < ScrollView showsVerticalScrollIndicator = { false } contentContainerStyle = { { padding : 20 } } >
68
+ < Text h1 marginB-s5 $textDefault >
69
+ Radio Buttons
70
+ </ Text >
82
71
83
- < RadioGroup
84
- marginT-30
85
- initialValue = { this . state . textSide }
86
- onValueChange = { value => this . setState ( { textSide : value } ) }
87
- >
88
- < Text marginB-20 text60 grey10 >
89
- Alignments
90
- </ Text >
91
- { this . renderRadioButtonWithImageAndText ( 'right-icon' , 'Text on right' ) }
92
- { this . renderRadioButtonWithImageAndText ( 'left-icon' , 'Text on left' , true ) }
93
- { this . renderRadioButton ( 'left-content' , 'Content on left' , true ) }
94
- { this . renderRadioButton ( 'right-content' , 'Content on right' , { contentOnRight : true } ) }
95
- < Text marginT-10 > You chose: { this . state . textSide } </ Text >
96
- </ RadioGroup >
72
+ < RadioGroup initialValue = { this . state . color || null } onValueChange = { value => this . setState ( { color : value } ) } >
73
+ < Text marginB-20 text60 $textDefault >
74
+ Select a color{ '\n' }
75
+ (enum with default value)
76
+ </ Text >
77
+ { this . renderRadioButton ( null , 'Default' ) }
78
+ { this . renderRadioButtonForColorEnum ( RadioButtonScreen . colors . ORANGE ) }
79
+ { this . renderRadioButtonForColorEnum ( RadioButtonScreen . colors . PURPLE ) }
80
+ { this . renderRadioButtonForColorEnum ( RadioButtonScreen . colors . GREEN ) }
81
+ < Text marginT-10 > You chose: { this . state . color ? this . state . color : 'Default' } </ Text >
82
+ </ RadioGroup >
97
83
98
- < RadioGroup marginT-30 initialValue = { this . state . value } onValueChange = { value => this . setState ( { value} ) } >
99
- < Text marginB-20 text60 grey10 >
100
- Yes or No?
101
- </ Text >
102
- < View row >
103
- { this . renderRadioButtonWithImage ( 'yes' , Assets . icons . check , { tintColor : 'green' } ) }
104
- { this . renderRadioButtonWithImage ( 'no' , Assets . icons . x , { tintColor : 'red' } ) }
105
- </ View >
106
- < Text marginT-10 > You chose: { this . state . value } </ Text >
107
- </ RadioGroup >
84
+ < RadioGroup
85
+ marginT-30
86
+ initialValue = { this . state . textSide }
87
+ onValueChange = { value => this . setState ( { textSide : value } ) }
88
+ >
89
+ < Text marginB-20 text60 $textDefault >
90
+ Alignments
91
+ </ Text >
92
+ { this . renderRadioButtonWithImageAndText ( 'right-icon' , 'Text on right' ) }
93
+ { this . renderRadioButtonWithImageAndText ( 'left-icon' , 'Text on left' , true ) }
94
+ { this . renderRadioButton ( 'left-content' , 'Content on left' , true ) }
95
+ { this . renderRadioButton ( 'right-content' , 'Content on right' , { contentOnRight : true } ) }
96
+ < Text marginT-10 > You chose: { this . state . textSide } </ Text >
97
+ </ RadioGroup >
108
98
109
- < Text marginV-20 text60 grey10 >
110
- Use it without RadioGroup
99
+ < RadioGroup marginT-30 initialValue = { this . state . value } onValueChange = { value => this . setState ( { value} ) } >
100
+ < Text marginB-20 text60 $textDefault >
101
+ Yes or No?
111
102
</ Text >
112
- < View row centerV marginB-10 >
113
- < RadioButton
114
- selected = { this . state . individualValue2 }
115
- onPress = { ( ) => this . setState ( { individualValue2 : ! this . state . individualValue2 } ) }
116
- label = "Individual Radio Button (with style)"
117
- labelStyle = { { fontSize : 16 , fontWeight : 'bold' } }
118
- />
119
- </ View >
120
- < TouchableOpacity
121
- activeOpacity = { 1 }
122
- onPress = { ( ) => this . setState ( { individualValue : ! this . state . individualValue } ) }
123
- accessible = { false }
124
- >
125
- < View row centerV >
126
- < RadioButton selected = { this . state . individualValue } label = "Individual Radio Button (wrapped)" />
127
- </ View >
128
- </ TouchableOpacity >
129
- < View row centerV marginT-10 >
130
- < RadioButton
131
- disabled
132
- selected = { this . state . disabledValue }
133
- onPress = { ( ) => this . setState ( { disabledValue : ! this . state . disabledValue } ) }
134
- label = "Disabled Radio Button"
135
- />
136
- </ View >
137
- < View row centerV marginT-10 >
138
- < RadioButton
139
- disabled
140
- selected = { this . state . disabledSelectedValue }
141
- onPress = { ( ) => this . setState ( { disabledSelectedValue : ! this . state . disabledSelectedValue } ) }
142
- label = "Disabled Selected Radio Button"
143
- />
103
+ < View row >
104
+ { this . renderRadioButtonWithImage ( 'yes' , Assets . icons . check , { tintColor : 'green' } ) }
105
+ { this . renderRadioButtonWithImage ( 'no' , Assets . icons . x , { tintColor : 'red' } ) }
144
106
</ View >
107
+ < Text marginT-10 > You chose: { this . state . value } </ Text >
108
+ </ RadioGroup >
145
109
146
- < View style = { { height : 30 } } />
110
+ < Text marginV-20 text60 $textDefault >
111
+ Use it without RadioGroup
112
+ </ Text >
113
+ < View row centerV marginB-10 >
114
+ < RadioButton
115
+ selected = { this . state . individualValue2 }
116
+ onPress = { ( ) => this . setState ( { individualValue2 : ! this . state . individualValue2 } ) }
117
+ label = "Individual Radio Button (with style)"
118
+ labelStyle = { { fontSize : 16 , fontWeight : 'bold' } }
119
+ />
120
+ </ View >
121
+ < TouchableOpacity
122
+ activeOpacity = { 1 }
123
+ onPress = { ( ) => this . setState ( { individualValue : ! this . state . individualValue } ) }
124
+ accessible = { false }
125
+ >
126
+ < View row centerV >
127
+ < RadioButton selected = { this . state . individualValue } label = "Individual Radio Button (wrapped)" />
128
+ </ View >
129
+ </ TouchableOpacity >
130
+ < View row centerV marginT-10 >
131
+ < RadioButton
132
+ disabled
133
+ selected = { this . state . disabledValue }
134
+ onPress = { ( ) => this . setState ( { disabledValue : ! this . state . disabledValue } ) }
135
+ label = "Disabled Radio Button"
136
+ />
137
+ </ View >
138
+ < View row centerV marginT-10 >
139
+ < RadioButton
140
+ disabled
141
+ selected = { this . state . disabledSelectedValue }
142
+ onPress = { ( ) => this . setState ( { disabledSelectedValue : ! this . state . disabledSelectedValue } ) }
143
+ label = "Disabled Selected Radio Button"
144
+ />
147
145
</ View >
148
146
</ ScrollView >
149
147
</ View >
0 commit comments