@@ -72,7 +72,11 @@ export type RadioButtonPropTypes = RadioGroupContextPropTypes & ViewProps & {
72
72
* Should the icon be on the right side of the label
73
73
*/
74
74
iconOnRight ?: boolean ;
75
- }
75
+ /**
76
+ * Should the content be rendered right to the button
77
+ */
78
+ contentOnRight ?: boolean ;
79
+ } ;
76
80
77
81
interface RadioButtonState {
78
82
opacityAnimationValue : Animated . Value ;
@@ -206,10 +210,10 @@ class RadioButton extends PureComponent<Props, RadioButtonState> {
206
210
}
207
211
208
212
renderLabel ( ) {
209
- const { label, labelStyle} = this . props ;
213
+ const { label, labelStyle, contentOnRight } = this . props ;
210
214
return (
211
215
label && (
212
- < Text marginL-10 style = { labelStyle } >
216
+ < Text marginL-10 = { ! contentOnRight } marginR-10 = { contentOnRight } style = { labelStyle } >
213
217
{ label }
214
218
</ Text >
215
219
)
@@ -222,9 +226,24 @@ class RadioButton extends PureComponent<Props, RadioButtonState> {
222
226
return iconSource && < Image style = { style } source = { iconSource } /> ;
223
227
}
224
228
225
- render ( ) {
226
- const { onPress, onValueChange, ...others } = this . props ;
229
+ renderButton ( ) {
227
230
const { opacityAnimationValue, scaleAnimationValue} = this . state ;
231
+
232
+ return (
233
+ < View style = { this . getRadioButtonOutlineStyle ( ) } >
234
+ < Animated . View
235
+ style = { [
236
+ this . getRadioButtonInnerStyle ( ) ,
237
+ { opacity : opacityAnimationValue } ,
238
+ { transform : [ { scale : scaleAnimationValue } ] }
239
+ ] }
240
+ />
241
+ </ View >
242
+ ) ;
243
+ }
244
+
245
+ render ( ) {
246
+ const { onPress, onValueChange, contentOnRight, ...others } = this . props ;
228
247
const Container = onPress || onValueChange ? TouchableOpacity : View ;
229
248
230
249
return (
@@ -234,21 +253,13 @@ class RadioButton extends PureComponent<Props, RadioButtonState> {
234
253
centerV
235
254
activeOpacity = { 1 }
236
255
{ ...others }
237
- style = { undefined }
238
256
onPress = { this . onPress }
239
257
{ ...this . getAccessibilityProps ( ) }
240
258
>
241
- < View style = { this . getRadioButtonOutlineStyle ( ) } >
242
- < Animated . View
243
- style = { [
244
- this . getRadioButtonInnerStyle ( ) ,
245
- { opacity : opacityAnimationValue } ,
246
- { transform : [ { scale : scaleAnimationValue } ] }
247
- ] }
248
- />
249
- </ View >
259
+ { ! contentOnRight && this . renderButton ( ) }
250
260
{ this . props . iconOnRight ? this . renderLabel ( ) : this . renderIcon ( ) }
251
261
{ this . props . iconOnRight ? this . renderIcon ( ) : this . renderLabel ( ) }
262
+ { contentOnRight && this . renderButton ( ) }
252
263
</ Container >
253
264
) ;
254
265
}
0 commit comments