Skip to content

Commit 970dd8a

Browse files
committed
Merge branch 'oss-sync/master' into import_everycommit
2 parents 99bbd4a + 75e4e12 commit 970dd8a

36 files changed

+622
-631
lines changed

Diff for: Examples/UIExplorer/MapViewExample.js

+64-18
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,44 @@ var {
2424
View,
2525
} = React;
2626

27+
var regionText = {
28+
latitude: '0',
29+
longitude: '0',
30+
latitudeDelta: '0',
31+
longitudeDelta: '0',
32+
}
33+
2734
var MapRegionInput = React.createClass({
2835

2936
propTypes: {
3037
region: React.PropTypes.shape({
31-
latitude: React.PropTypes.number,
32-
longitude: React.PropTypes.number,
33-
latitudeDelta: React.PropTypes.number,
34-
longitudeDelta: React.PropTypes.number,
38+
latitude: React.PropTypes.number.isRequired,
39+
longitude: React.PropTypes.number.isRequired,
40+
latitudeDelta: React.PropTypes.number.isRequired,
41+
longitudeDelta: React.PropTypes.number.isRequired,
3542
}),
3643
onChange: React.PropTypes.func.isRequired,
3744
},
3845

3946
getInitialState: function() {
4047
return {
41-
latitude: 0,
42-
longitude: 0,
43-
latitudeDelta: 0,
44-
longitudeDelta: 0,
48+
region: {
49+
latitude: 0,
50+
longitude: 0,
51+
latitudeDelta: 0,
52+
longitudeDelta: 0,
53+
}
4554
};
4655
},
4756

4857
componentWillReceiveProps: function(nextProps) {
49-
this.setState(nextProps.region);
58+
this.setState({
59+
region: nextProps.region || this.getInitialState().region
60+
});
5061
},
5162

5263
render: function() {
53-
var region = this.state;
64+
var region = this.state.region || this.getInitialState().region;
5465
return (
5566
<View>
5667
<View style={styles.row}>
@@ -61,6 +72,7 @@ var MapRegionInput = React.createClass({
6172
value={'' + region.latitude}
6273
style={styles.textInput}
6374
onChange={this._onChangeLatitude}
75+
selectTextOnFocus={true}
6476
/>
6577
</View>
6678
<View style={styles.row}>
@@ -71,6 +83,7 @@ var MapRegionInput = React.createClass({
7183
value={'' + region.longitude}
7284
style={styles.textInput}
7385
onChange={this._onChangeLongitude}
86+
selectTextOnFocus={true}
7487
/>
7588
</View>
7689
<View style={styles.row}>
@@ -81,6 +94,7 @@ var MapRegionInput = React.createClass({
8194
value={'' + region.latitudeDelta}
8295
style={styles.textInput}
8396
onChange={this._onChangeLatitudeDelta}
97+
selectTextOnFocus={true}
8498
/>
8599
</View>
86100
<View style={styles.row}>
@@ -91,6 +105,7 @@ var MapRegionInput = React.createClass({
91105
value={'' + region.longitudeDelta}
92106
style={styles.textInput}
93107
onChange={this._onChangeLongitudeDelta}
108+
selectTextOnFocus={true}
94109
/>
95110
</View>
96111
<View style={styles.changeButton}>
@@ -103,23 +118,29 @@ var MapRegionInput = React.createClass({
103118
},
104119

105120
_onChangeLatitude: function(e) {
106-
this.setState({latitude: parseFloat(e.nativeEvent.text)});
121+
regionText.latitude = e.nativeEvent.text;
107122
},
108123

109124
_onChangeLongitude: function(e) {
110-
this.setState({longitude: parseFloat(e.nativeEvent.text)});
125+
regionText.longitude = e.nativeEvent.text;
111126
},
112127

113128
_onChangeLatitudeDelta: function(e) {
114-
this.setState({latitudeDelta: parseFloat(e.nativeEvent.text)});
129+
regionText.latitudeDelta = e.nativeEvent.text;
115130
},
116131

117132
_onChangeLongitudeDelta: function(e) {
118-
this.setState({longitudeDelta: parseFloat(e.nativeEvent.text)});
133+
regionText.longitudeDelta = e.nativeEvent.text;
119134
},
120135

121136
_change: function() {
122-
this.props.onChange(this.state);
137+
this.setState({
138+
latitude: parseFloat(regionText.latitude),
139+
longitude: parseFloat(regionText.longitude),
140+
latitudeDelta: parseFloat(regionText.latitudeDelta),
141+
longitudeDelta: parseFloat(regionText.longitudeDelta),
142+
});
143+
this.props.onChange(this.state.region);
123144
},
124145

125146
});
@@ -130,6 +151,8 @@ var MapViewExample = React.createClass({
130151
return {
131152
mapRegion: null,
132153
mapRegionInput: null,
154+
annotations: null,
155+
isFirstLoad: true,
133156
};
134157
},
135158

@@ -138,8 +161,10 @@ var MapViewExample = React.createClass({
138161
<View>
139162
<MapView
140163
style={styles.map}
141-
onRegionChange={this._onRegionChanged}
164+
onRegionChange={this._onRegionChange}
165+
onRegionChangeComplete={this._onRegionChangeComplete}
142166
region={this.state.mapRegion}
167+
annotations={this.state.annotations}
143168
/>
144169
<MapRegionInput
145170
onChange={this._onRegionInputChanged}
@@ -149,14 +174,35 @@ var MapViewExample = React.createClass({
149174
);
150175
},
151176

152-
_onRegionChanged(region) {
153-
this.setState({mapRegionInput: region});
177+
_getAnnotations(region) {
178+
return [{
179+
longitude: region.longitude,
180+
latitude: region.latitude,
181+
title: 'You Are Here',
182+
}];
183+
},
184+
185+
_onRegionChange(region) {
186+
this.setState({
187+
mapRegionInput: region,
188+
});
189+
},
190+
191+
_onRegionChangeComplete(region) {
192+
if (this.state.isFirstLoad) {
193+
this.setState({
194+
mapRegionInput: region,
195+
annotations: this._getAnnotations(region),
196+
isFirstLoad: false,
197+
});
198+
}
154199
},
155200

156201
_onRegionInputChanged(region) {
157202
this.setState({
158203
mapRegion: region,
159204
mapRegionInput: region,
205+
annotations: this._getAnnotations(region),
160206
});
161207
},
162208

Diff for: Examples/UIExplorer/TextInputExample.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ var styles = StyleSheet.create({
109109
flex: 1,
110110
},
111111
label: {
112-
width: 80,
112+
width: 120,
113113
justifyContent: 'flex-end',
114114
flexDirection: 'row',
115115
marginRight: 10,
@@ -311,4 +311,29 @@ exports.examples = [
311311
);
312312
}
313313
},
314+
{
315+
title: 'Clear and select',
316+
render: function () {
317+
return (
318+
<View>
319+
<WithLabel label="clearTextOnFocus">
320+
<TextInput
321+
placeholder="text is cleared on focus"
322+
value="text is cleared on focus"
323+
style={styles.default}
324+
clearTextOnFocus={true}
325+
/>
326+
</WithLabel>
327+
<WithLabel label="selectTextOnFocus">
328+
<TextInput
329+
placeholder="text is selected on focus"
330+
value="text is selected on focus"
331+
style={styles.default}
332+
selectTextOnFocus={true}
333+
/>
334+
</WithLabel>
335+
</View>
336+
);
337+
}
338+
},
314339
];
Loading

Diff for: Examples/UIExplorer/UIExplorerTests/UIExplorerTests.m

+7-4
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ - (void)setUp
3939
#endif
4040
NSString *version = [[UIDevice currentDevice] systemVersion];
4141
RCTAssert([version isEqualToString:@"8.1"], @"Snapshot tests should be run on iOS 8.1, found %@", version);
42-
_runner = initRunnerForApp(@"Examples/UIExplorer/UIExplorerApp");
42+
_runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerApp");
4343

44-
// If tests have changes, set recordMode = YES below and run the affected tests on an iPhone5, iOS 8.1 simulator.
44+
// If tests have changes, set recordMode = YES below and run the affected
45+
// tests on an iPhone5, iOS 8.1 simulator.
4546
_runner.recordMode = NO;
4647
}
4748

@@ -58,8 +59,10 @@ - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
5859
return NO;
5960
}
6061

61-
// Make sure this test runs first (underscores sort early) otherwise the other tests will tear out the rootView
62-
- (void)test__RootViewLoadsAndRenders {
62+
// Make sure this test runs first (underscores sort early) otherwise the
63+
// other tests will tear out the rootView
64+
- (void)test__RootViewLoadsAndRenders
65+
{
6366
UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
6467
RCTAssert([vc.view isKindOfClass:[RCTRootView class]], @"This test must run first.");
6568
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];

Diff for: IntegrationTests/IntegrationTestsTests/IntegrationTestsTests.m

+13-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ @interface IntegrationTestsTests : XCTestCase
1818

1919
@end
2020

21-
@implementation IntegrationTestsTests {
21+
@implementation IntegrationTestsTests
22+
{
2223
RCTTestRunner *_runner;
2324
}
2425

@@ -28,10 +29,11 @@ - (void)setUp
2829
RCTAssert(!__LP64__, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
2930
#endif
3031
NSString *version = [[UIDevice currentDevice] systemVersion];
31-
RCTAssert([version isEqualToString:@"8.1"], @"Tests should be run on iOS 8.1, found %@", version);
32-
_runner = initRunnerForApp(@"IntegrationTests/IntegrationTestsApp");
32+
RCTAssert([version integerValue] == 8, @"Tests should be run on iOS 8.x, found %@", version);
33+
_runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp");
3334

34-
// If tests have changes, set recordMode = YES below and run the affected tests on an iPhone5, iOS 8.1 simulator.
35+
// If tests have changes, set recordMode = YES below and run the affected
36+
// tests on an iPhone5, iOS 8.1 simulator.
3537
_runner.recordMode = NO;
3638
}
3739

@@ -44,15 +46,19 @@ - (void)testTheTester
4446

4547
- (void)testTheTester_waitOneFrame
4648
{
47-
[_runner runTest:_cmd module:@"IntegrationTestHarnessTest" initialProps:@{@"waitOneFrame": @YES} expectErrorBlock:nil];
49+
[_runner runTest:_cmd
50+
module:@"IntegrationTestHarnessTest"
51+
initialProps:@{@"waitOneFrame": @YES}
52+
expectErrorBlock:nil];
4853
}
4954

50-
- (void)testTheTester_ExpectError
55+
// TODO: this seems to stall forever - figure out why
56+
- (void)DISABLED_testTheTester_ExpectError
5157
{
5258
[_runner runTest:_cmd
5359
module:@"IntegrationTestHarnessTest"
5460
initialProps:@{@"shouldThrow": @YES}
55-
expectErrorRegex:[NSRegularExpression regularExpressionWithPattern:@"because shouldThrow" options:0 error:nil]];
61+
expectErrorRegex:@"because shouldThrow"];
5662
}
5763

5864
- (void)testTimers

Diff for: Libraries/Components/MapView/MapView.js

+19
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ var MapView = React.createClass({
9595
longitudeDelta: React.PropTypes.number.isRequired,
9696
}),
9797

98+
/**
99+
* Map annotations with title/subtitle.
100+
*/
101+
annotations: React.PropTypes.arrayOf(React.PropTypes.shape({
102+
/**
103+
* The location of the annotation.
104+
*/
105+
latitude: React.PropTypes.number.isRequired,
106+
longitude: React.PropTypes.number.isRequired,
107+
108+
/**
109+
* Annotation title/subtile.
110+
*/
111+
title: React.PropTypes.string,
112+
subtitle: React.PropTypes.string,
113+
})),
114+
98115
/**
99116
* Maximum size of area that can be displayed.
100117
*/
@@ -142,6 +159,7 @@ var MapView = React.createClass({
142159
pitchEnabled={this.props.pitchEnabled}
143160
scrollEnabled={this.props.scrollEnabled}
144161
region={this.props.region}
162+
annotations={this.props.annotations}
145163
maxDelta={this.props.maxDelta}
146164
minDelta={this.props.minDelta}
147165
legalLabelInsets={this.props.legalLabelInsets}
@@ -165,6 +183,7 @@ var RCTMap = createReactIOSNativeComponentClass({
165183
pitchEnabled: true,
166184
scrollEnabled: true,
167185
region: {diff: deepDiffer},
186+
annotations: {diff: deepDiffer},
168187
maxDelta: true,
169188
minDelta: true,
170189
legalLabelInsets: {diff: insetsDiffer},

Diff for: Libraries/Components/TextInput/TextInput.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ var RCTTextFieldAttributes = merge(RCTTextViewAttributes, {
5858
caretHidden: true,
5959
enabled: true,
6060
clearButtonMode: true,
61+
clearTextOnFocus: true,
62+
selectTextOnFocus: true,
6163
});
6264

6365
var onlyMultiline = {
@@ -267,7 +269,17 @@ var TextInput = React.createClass({
267269
'unless-editing',
268270
'always',
269271
]),
270-
272+
/**
273+
* If true, clears the text field automatically when editing begins
274+
*/
275+
clearTextOnFocus: PropTypes.bool,
276+
/**
277+
* If true, selected the text automatically when editing begins
278+
*/
279+
selectTextOnFocus: PropTypes.bool,
280+
/**
281+
* Styles
282+
*/
271283
style: Text.propTypes.style,
272284
/**
273285
* Used to locate this view in end-to-end tests.
@@ -431,6 +443,8 @@ var TextInput = React.createClass({
431443
autoCapitalize={autoCapitalize}
432444
autoCorrect={this.props.autoCorrect}
433445
clearButtonMode={clearButtonMode}
446+
clearTextOnFocus={this.props.clearTextOnFocus}
447+
selectTextOnFocus={this.props.selectTextOnFocus}
434448
/>;
435449
} else {
436450
for (var propKey in notMultiline) {

0 commit comments

Comments
 (0)