1717
1818var React = require ( 'react-native' ) ;
1919var {
20- SwitchIOS ,
20+ Switch ,
2121 Text,
2222 View
2323} = React ;
@@ -32,11 +32,11 @@ var BasicSwitchExample = React.createClass({
3232 render ( ) {
3333 return (
3434 < View >
35- < SwitchIOS
35+ < Switch
3636 onValueChange = { ( value ) => this . setState ( { falseSwitchIsOn : value } ) }
3737 style = { { marginBottom : 10 } }
3838 value = { this . state . falseSwitchIsOn } />
39- < SwitchIOS
39+ < Switch
4040 onValueChange = { ( value ) => this . setState ( { trueSwitchIsOn : value } ) }
4141 value = { this . state . trueSwitchIsOn } />
4242 </ View >
@@ -48,11 +48,11 @@ var DisabledSwitchExample = React.createClass({
4848 render ( ) {
4949 return (
5050 < View >
51- < SwitchIOS
51+ < Switch
5252 disabled = { true }
5353 style = { { marginBottom : 10 } }
5454 value = { true } />
55- < SwitchIOS
55+ < Switch
5656 disabled = { true }
5757 value = { false } />
5858 </ View >
@@ -70,14 +70,14 @@ var ColorSwitchExample = React.createClass({
7070 render ( ) {
7171 return (
7272 < View >
73- < SwitchIOS
73+ < Switch
7474 onValueChange = { ( value ) => this . setState ( { colorFalseSwitchIsOn : value } ) }
7575 onTintColor = "#00ff00"
7676 style = { { marginBottom : 10 } }
7777 thumbTintColor = "#0000ff"
7878 tintColor = "#ff0000"
7979 value = { this . state . colorFalseSwitchIsOn } />
80- < SwitchIOS
80+ < Switch
8181 onValueChange = { ( value ) => this . setState ( { colorTrueSwitchIsOn : value } ) }
8282 onTintColor = "#00ff00"
8383 thumbTintColor = "#0000ff"
@@ -99,22 +99,22 @@ var EventSwitchExample = React.createClass({
9999 return (
100100 < View style = { { flexDirection : 'row' , justifyContent : 'space-around' } } >
101101 < View >
102- < SwitchIOS
102+ < Switch
103103 onValueChange = { ( value ) => this . setState ( { eventSwitchIsOn : value } ) }
104104 style = { { marginBottom : 10 } }
105105 value = { this . state . eventSwitchIsOn } />
106- < SwitchIOS
106+ < Switch
107107 onValueChange = { ( value ) => this . setState ( { eventSwitchIsOn : value } ) }
108108 style = { { marginBottom : 10 } }
109109 value = { this . state . eventSwitchIsOn } />
110110 < Text > { this . state . eventSwitchIsOn ? 'On' : 'Off' } </ Text >
111111 </ View >
112112 < View >
113- < SwitchIOS
113+ < Switch
114114 onValueChange = { ( value ) => this . setState ( { eventSwitchRegressionIsOn : value } ) }
115115 style = { { marginBottom : 10 } }
116116 value = { this . state . eventSwitchRegressionIsOn } />
117- < SwitchIOS
117+ < Switch
118118 onValueChange = { ( value ) => this . setState ( { eventSwitchRegressionIsOn : value } ) }
119119 style = { { marginBottom : 10 } }
120120 value = { this . state . eventSwitchRegressionIsOn } />
@@ -125,10 +125,7 @@ var EventSwitchExample = React.createClass({
125125 }
126126} ) ;
127127
128- exports . title = '<SwitchIOS>' ;
129- exports . displayName = 'SwitchExample' ;
130- exports . description = 'Native boolean input' ;
131- exports . examples = [
128+ var examples = [
132129 {
133130 title : 'Switches can be set to true or false' ,
134131 render ( ) : ReactElement { return < BasicSwitchExample /> ; }
@@ -137,16 +134,24 @@ exports.examples = [
137134 title : 'Switches can be disabled' ,
138135 render ( ) : ReactElement { return < DisabledSwitchExample /> ; }
139136 } ,
140- {
141- title : 'Custom colors can be provided' ,
142- render ( ) : ReactElement { return < ColorSwitchExample /> ; }
143- } ,
144137 {
145138 title : 'Change events can be detected' ,
146139 render ( ) : ReactElement { return < EventSwitchExample /> ; }
147140 } ,
148141 {
149142 title : 'Switches are controlled components' ,
150- render ( ) : ReactElement { return < SwitchIOS /> ; }
143+ render ( ) : ReactElement { return < Switch /> ; }
151144 }
152145] ;
146+
147+ if ( React . Platform . OS === 'ios' ) {
148+ examples . push ( {
149+ title : 'Custom colors can be provided' ,
150+ render ( ) : ReactElement { return < ColorSwitchExample /> ; }
151+ } ) ;
152+ }
153+
154+ exports . title = '<Switch>' ;
155+ exports . displayName = 'SwitchExample' ;
156+ exports . description = 'Native boolean input' ;
157+ exports . examples = examples ;
0 commit comments