Skip to content

Commit 05f31a0

Browse files
andreasdrifacebook-github-bot-4
authored andcommitted
Update examples for the converged Switch component
Reviewed By: mkonicek Differential Revision: D2811302 Pulled By: bestander fb-gh-sync-id: 069dc618510124d6978464979774828c46670124
1 parent cb91d65 commit 05f31a0

File tree

5 files changed

+27
-92
lines changed

5 files changed

+27
-92
lines changed

Examples/UIExplorer/SwitchAndroidExample.android.js

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
var React = require('react-native');
1919
var {
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;
26 Bytes
Loading

Examples/UIExplorer/UIExplorerList.android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var COMPONENTS = [
2727
require('./ListViewExample'),
2828
require('./ProgressBarAndroidExample'),
2929
require('./ScrollViewSimpleExample'),
30-
require('./SwitchAndroidExample'),
30+
require('./SwitchExample'),
3131
require('./RefreshControlExample'),
3232
require('./PullToRefreshViewAndroidExample.android'),
3333
require('./TextExample.android'),

Examples/UIExplorer/UIExplorerList.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var COMPONENTS = [
4646
require('./ScrollViewExample'),
4747
require('./SegmentedControlIOSExample'),
4848
require('./SliderIOSExample'),
49-
require('./SwitchIOSExample'),
49+
require('./SwitchExample'),
5050
require('./TabBarIOSExample'),
5151
require('./TextExample.ios'),
5252
require('./TextInputExample.ios'),

0 commit comments

Comments
 (0)