Skip to content

Commit 4f5e588

Browse files
committed
Merge branch 'master' into tabbar
2 parents 62fbef1 + f8a4467 commit 4f5e588

File tree

129 files changed

+5138
-747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+5138
-747
lines changed

.flowconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ Examples/UIExplorer/ImageMocks.js
2929

3030
[options]
3131
module.system=haste
32+
33+
[version]
34+
0.10.0

CONTRIBUTING.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,27 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
5252

5353
### Code
5454

55-
* Use semicolons;
55+
#### General
56+
5657
* Add trailing commas,
5758
* 2 spaces for indentation (no tabs)
58-
* Prefer `'` over `"`
59-
* `'use strict';`
60-
* 80 character line length
6159
* "Attractive"
60+
61+
#### JavaScript
62+
63+
* Use semicolons;
64+
* `'use strict';`
65+
* Prefer `'` over `"`
6266
* Do not use the optional parameters of `setTimeout` and `setInterval`
67+
* 80 character line length
68+
69+
#### Objective-C
70+
71+
* Space after `@property` declarations
72+
* Brackets on *every* `if`, on the *same* line
73+
* `- method`, `@interface`, and `@implementation` brackets on the following line
74+
* *Try* to keep it around 80 characters line length (sometimes it's just not possible...)
75+
* `*` operator goes with the variable name (e.g. `NSObject *variableName;`)
6376

6477
### Documentation
6578

Examples/UIExplorer/BorderExample.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ var styles = StyleSheet.create({
5757
borderLeftWidth: 40,
5858
borderLeftColor: 'blue',
5959
},
60+
border5: {
61+
borderRadius: 50,
62+
borderTopWidth: 10,
63+
borderTopColor: 'red',
64+
borderRightWidth: 20,
65+
borderRightColor: 'yellow',
66+
borderBottomWidth: 30,
67+
borderBottomColor: 'green',
68+
borderLeftWidth: 40,
69+
borderLeftColor: 'blue',
70+
},
6071
});
6172

6273
exports.title = 'Border';
@@ -71,7 +82,7 @@ exports.examples = [
7182
},
7283
{
7384
title: 'Equal-Width / Same-Color',
74-
description: 'borderWidth & borderColor',
85+
description: 'borderWidth & borderColor & borderRadius',
7586
render() {
7687
return <View style={[styles.box, styles.borderRadius]} />;
7788
}
@@ -97,4 +108,11 @@ exports.examples = [
97108
return <View style={[styles.box, styles.border4]} />;
98109
}
99110
},
111+
{
112+
title: 'Custom Borders',
113+
description: 'border*Width & border*Color',
114+
render() {
115+
return <View style={[styles.box, styles.border5]} />;
116+
}
117+
},
100118
];

Examples/UIExplorer/GeolocationExample.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ var GeolocationExample = React.createClass({
5050
componentDidMount: function() {
5151
navigator.geolocation.getCurrentPosition(
5252
(initialPosition) => this.setState({initialPosition}),
53-
(error) => console.error(error)
53+
(error) => console.error(error),
54+
{enableHighAccuracy: true, timeout: 100, maximumAge: 1000}
5455
);
5556
this.watchID = navigator.geolocation.watchPosition((lastPosition) => {
5657
this.setState({lastPosition});
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/**
2+
* The examples provided by Facebook are for non-commercial testing and
3+
* evaluation purposes only.
4+
*
5+
* Facebook reserves all rights not expressly granted.
6+
*
7+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9+
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
10+
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
11+
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
12+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13+
*
14+
* @flow
15+
*/
16+
'use strict';
17+
18+
var React = require('react-native');
19+
var {
20+
SegmentedControlIOS,
21+
Text,
22+
View,
23+
StyleSheet
24+
} = React;
25+
26+
var BasicSegmentedControlExample = React.createClass({
27+
render() {
28+
return (
29+
<View>
30+
<View style={{marginBottom: 10}}>
31+
<SegmentedControlIOS values={['One', 'Two']} />
32+
</View>
33+
<View>
34+
<SegmentedControlIOS values={['One', 'Two', 'Three', 'Four', 'Five']} />
35+
</View>
36+
</View>
37+
);
38+
}
39+
});
40+
41+
var PreSelectedSegmentedControlExample = React.createClass({
42+
render() {
43+
return (
44+
<View>
45+
<View>
46+
<SegmentedControlIOS values={['One', 'Two']} selectedIndex={0} />
47+
</View>
48+
</View>
49+
);
50+
}
51+
});
52+
53+
var MomentarySegmentedControlExample = React.createClass({
54+
render() {
55+
return (
56+
<View>
57+
<View>
58+
<SegmentedControlIOS values={['One', 'Two']} momentary={true} />
59+
</View>
60+
</View>
61+
);
62+
}
63+
});
64+
65+
var DisabledSegmentedControlExample = React.createClass({
66+
render() {
67+
return (
68+
<View>
69+
<View>
70+
<SegmentedControlIOS enabled={false} values={['One', 'Two']} selectedIndex={1} />
71+
</View>
72+
</View>
73+
);
74+
},
75+
});
76+
77+
var ColorSegmentedControlExample = React.createClass({
78+
render() {
79+
return (
80+
<View>
81+
<View style={{marginBottom: 10}}>
82+
<SegmentedControlIOS tintColor="#ff0000" values={['One', 'Two', 'Three', 'Four']} selectedIndex={0} />
83+
</View>
84+
<View>
85+
<SegmentedControlIOS tintColor="#00ff00" values={['One', 'Two', 'Three']} selectedIndex={1} />
86+
</View>
87+
</View>
88+
);
89+
},
90+
});
91+
92+
var EventSegmentedControlExample = React.createClass({
93+
getInitialState() {
94+
return {
95+
values: ['One', 'Two', 'Three'],
96+
value: 'Not selected',
97+
selectedIndex: undefined
98+
};
99+
},
100+
101+
render() {
102+
return (
103+
<View>
104+
<Text style={styles.text} >
105+
Value: {this.state.value}
106+
</Text>
107+
<Text style={styles.text} >
108+
Index: {this.state.selectedIndex}
109+
</Text>
110+
<SegmentedControlIOS
111+
values={this.state.values}
112+
selectedIndex={this.state.selectedIndex}
113+
onChange={this._onChange}
114+
onValueChange={this._onValueChange} />
115+
</View>
116+
);
117+
},
118+
119+
_onChange(event) {
120+
this.setState({
121+
selectedIndex: event.nativeEvent.selectedIndex,
122+
});
123+
},
124+
125+
_onValueChange(value) {
126+
this.setState({
127+
value: value,
128+
});
129+
}
130+
});
131+
132+
var styles = StyleSheet.create({
133+
text: {
134+
fontSize: 14,
135+
textAlign: 'center',
136+
fontWeight: '500',
137+
margin: 10,
138+
},
139+
});
140+
141+
exports.title = '<SegmentedControlIOS>';
142+
exports.displayName = 'SegmentedControlExample';
143+
exports.description = 'Native segmented control';
144+
exports.examples = [
145+
{
146+
title: 'Segmented controls can have values',
147+
render(): ReactElement { return <BasicSegmentedControlExample />; }
148+
},
149+
{
150+
title: 'Segmented controls can have a pre-selected value',
151+
render(): ReactElement { return <PreSelectedSegmentedControlExample />; }
152+
},
153+
{
154+
title: 'Segmented controls can be momentary',
155+
render(): ReactElement { return <MomentarySegmentedControlExample />; }
156+
},
157+
{
158+
title: 'Segmented controls can be disabled',
159+
render(): ReactElement { return <DisabledSegmentedControlExample />; }
160+
},
161+
{
162+
title: 'Custom colors can be provided',
163+
render(): ReactElement { return <ColorSegmentedControlExample />; }
164+
},
165+
{
166+
title: 'Change events can be detected',
167+
render(): ReactElement { return <EventSegmentedControlExample />; }
168+
}
169+
];

Examples/UIExplorer/TextInputExample.js

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,32 @@ var styles = StyleSheet.create({
8888
height: 26,
8989
borderWidth: 0.5,
9090
borderColor: '#0f0f0f',
91-
padding: 4,
9291
flex: 1,
9392
fontSize: 13,
93+
padding: 4,
9494
},
9595
multiline: {
9696
borderWidth: 0.5,
9797
borderColor: '#0f0f0f',
9898
flex: 1,
9999
fontSize: 13,
100100
height: 50,
101+
padding: 4,
102+
marginBottom: 4,
103+
},
104+
multilineWithFontStyles: {
105+
color: 'blue',
106+
fontWeight: 'bold',
107+
fontSize: 18,
108+
fontFamily: 'Cochin',
109+
height: 60,
110+
},
111+
multilineChild: {
112+
width: 50,
113+
height: 40,
114+
position: 'absolute',
115+
right: 5,
116+
backgroundColor: 'red',
101117
},
102118
eventLabel: {
103119
margin: 3,
@@ -118,7 +134,7 @@ var styles = StyleSheet.create({
118134
});
119135

120136
exports.title = '<TextInput>';
121-
exports.description = 'Single-line text inputs.';
137+
exports.description = 'Single and multi-line text inputs.';
122138
exports.examples = [
123139
{
124140
title: 'Auto-focus',
@@ -313,7 +329,7 @@ exports.examples = [
313329
},
314330
{
315331
title: 'Clear and select',
316-
render: function () {
332+
render: function() {
317333
return (
318334
<View>
319335
<WithLabel label="clearTextOnFocus">
@@ -336,4 +352,42 @@ exports.examples = [
336352
);
337353
}
338354
},
355+
{
356+
title: 'Multiline',
357+
render: function() {
358+
return (
359+
<View>
360+
<TextInput
361+
placeholder="multiline text input"
362+
multiline={true}
363+
style={styles.multiline}
364+
/>
365+
<TextInput
366+
placeholder="mutliline text input with font styles and placeholder"
367+
multiline={true}
368+
clearTextOnFocus={true}
369+
autoCorrect={true}
370+
autoCapitalize="words"
371+
placeholderTextColor="red"
372+
keyboardType="url"
373+
style={[styles.multiline, styles.multilineWithFontStyles]}
374+
/>
375+
<TextInput
376+
placeholder="uneditable mutliline text input"
377+
editable={false}
378+
multiline={true}
379+
style={styles.multiline}
380+
/>
381+
<TextInput
382+
placeholder="multiline with children"
383+
multiline={true}
384+
enablesReturnKeyAutomatically={true}
385+
returnKeyType="go"
386+
style={styles.multiline}>
387+
<View style={styles.multilineChild}/>
388+
</TextInput>
389+
</View>
390+
)
391+
}
392+
}
339393
];

Examples/UIExplorer/UIExplorerBlock.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ var styles = StyleSheet.create({
7070
},
7171
titleContainer: {
7272
borderWidth: 0.5,
73+
borderRadius: 2.5,
7374
borderColor: '#d6d7da',
7475
backgroundColor: '#f6f7f8',
7576
paddingHorizontal: 10,
@@ -78,8 +79,10 @@ var styles = StyleSheet.create({
7879
titleRow: {
7980
flexDirection: 'row',
8081
justifyContent: 'space-between',
82+
backgroundColor: 'transparent',
8183
},
8284
titleText: {
85+
backgroundColor: 'transparent',
8386
fontSize: 14,
8487
fontWeight: '500',
8588
},
@@ -97,6 +100,7 @@ var styles = StyleSheet.create({
97100
height: 8,
98101
},
99102
children: {
103+
backgroundColor: 'transparent',
100104
padding: 10,
101105
}
102106
});

Examples/UIExplorer/UIExplorerList.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var COMPONENTS = [
4343
require('./NavigatorIOSExample'),
4444
require('./PickerIOSExample'),
4545
require('./ScrollViewExample'),
46+
require('./SegmentedControlIOSExample'),
4647
require('./SliderIOSExample'),
4748
require('./SwitchIOSExample'),
4849
require('./TabBarIOSExample'),
9.7 KB
Loading
208 Bytes
Loading

0 commit comments

Comments
 (0)