Skip to content

Commit

Permalink
Merge branch 'oss-sync/master' into import_everycommit
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeux committed Apr 15, 2015
2 parents 99bbd4a + 75e4e12 commit 970dd8a
Show file tree
Hide file tree
Showing 36 changed files with 622 additions and 631 deletions.
82 changes: 64 additions & 18 deletions Examples/UIExplorer/MapViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,44 @@ var {
View,
} = React;

var regionText = {
latitude: '0',
longitude: '0',
latitudeDelta: '0',
longitudeDelta: '0',
}

var MapRegionInput = React.createClass({

propTypes: {
region: React.PropTypes.shape({
latitude: React.PropTypes.number,
longitude: React.PropTypes.number,
latitudeDelta: React.PropTypes.number,
longitudeDelta: React.PropTypes.number,
latitude: React.PropTypes.number.isRequired,
longitude: React.PropTypes.number.isRequired,
latitudeDelta: React.PropTypes.number.isRequired,
longitudeDelta: React.PropTypes.number.isRequired,
}),
onChange: React.PropTypes.func.isRequired,
},

getInitialState: function() {
return {
latitude: 0,
longitude: 0,
latitudeDelta: 0,
longitudeDelta: 0,
region: {
latitude: 0,
longitude: 0,
latitudeDelta: 0,
longitudeDelta: 0,
}
};
},

componentWillReceiveProps: function(nextProps) {
this.setState(nextProps.region);
this.setState({
region: nextProps.region || this.getInitialState().region
});
},

render: function() {
var region = this.state;
var region = this.state.region || this.getInitialState().region;
return (
<View>
<View style={styles.row}>
Expand All @@ -61,6 +72,7 @@ var MapRegionInput = React.createClass({
value={'' + region.latitude}
style={styles.textInput}
onChange={this._onChangeLatitude}
selectTextOnFocus={true}
/>
</View>
<View style={styles.row}>
Expand All @@ -71,6 +83,7 @@ var MapRegionInput = React.createClass({
value={'' + region.longitude}
style={styles.textInput}
onChange={this._onChangeLongitude}
selectTextOnFocus={true}
/>
</View>
<View style={styles.row}>
Expand All @@ -81,6 +94,7 @@ var MapRegionInput = React.createClass({
value={'' + region.latitudeDelta}
style={styles.textInput}
onChange={this._onChangeLatitudeDelta}
selectTextOnFocus={true}
/>
</View>
<View style={styles.row}>
Expand All @@ -91,6 +105,7 @@ var MapRegionInput = React.createClass({
value={'' + region.longitudeDelta}
style={styles.textInput}
onChange={this._onChangeLongitudeDelta}
selectTextOnFocus={true}
/>
</View>
<View style={styles.changeButton}>
Expand All @@ -103,23 +118,29 @@ var MapRegionInput = React.createClass({
},

_onChangeLatitude: function(e) {
this.setState({latitude: parseFloat(e.nativeEvent.text)});
regionText.latitude = e.nativeEvent.text;
},

_onChangeLongitude: function(e) {
this.setState({longitude: parseFloat(e.nativeEvent.text)});
regionText.longitude = e.nativeEvent.text;
},

_onChangeLatitudeDelta: function(e) {
this.setState({latitudeDelta: parseFloat(e.nativeEvent.text)});
regionText.latitudeDelta = e.nativeEvent.text;
},

_onChangeLongitudeDelta: function(e) {
this.setState({longitudeDelta: parseFloat(e.nativeEvent.text)});
regionText.longitudeDelta = e.nativeEvent.text;
},

_change: function() {
this.props.onChange(this.state);
this.setState({
latitude: parseFloat(regionText.latitude),
longitude: parseFloat(regionText.longitude),
latitudeDelta: parseFloat(regionText.latitudeDelta),
longitudeDelta: parseFloat(regionText.longitudeDelta),
});
this.props.onChange(this.state.region);
},

});
Expand All @@ -130,6 +151,8 @@ var MapViewExample = React.createClass({
return {
mapRegion: null,
mapRegionInput: null,
annotations: null,
isFirstLoad: true,
};
},

Expand All @@ -138,8 +161,10 @@ var MapViewExample = React.createClass({
<View>
<MapView
style={styles.map}
onRegionChange={this._onRegionChanged}
onRegionChange={this._onRegionChange}
onRegionChangeComplete={this._onRegionChangeComplete}
region={this.state.mapRegion}
annotations={this.state.annotations}
/>
<MapRegionInput
onChange={this._onRegionInputChanged}
Expand All @@ -149,14 +174,35 @@ var MapViewExample = React.createClass({
);
},

_onRegionChanged(region) {
this.setState({mapRegionInput: region});
_getAnnotations(region) {
return [{
longitude: region.longitude,
latitude: region.latitude,
title: 'You Are Here',
}];
},

_onRegionChange(region) {
this.setState({
mapRegionInput: region,
});
},

_onRegionChangeComplete(region) {
if (this.state.isFirstLoad) {
this.setState({
mapRegionInput: region,
annotations: this._getAnnotations(region),
isFirstLoad: false,
});
}
},

_onRegionInputChanged(region) {
this.setState({
mapRegion: region,
mapRegionInput: region,
annotations: this._getAnnotations(region),
});
},

Expand Down
27 changes: 26 additions & 1 deletion Examples/UIExplorer/TextInputExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var styles = StyleSheet.create({
flex: 1,
},
label: {
width: 80,
width: 120,
justifyContent: 'flex-end',
flexDirection: 'row',
marginRight: 10,
Expand Down Expand Up @@ -311,4 +311,29 @@ exports.examples = [
);
}
},
{
title: 'Clear and select',
render: function () {
return (
<View>
<WithLabel label="clearTextOnFocus">
<TextInput
placeholder="text is cleared on focus"
value="text is cleared on focus"
style={styles.default}
clearTextOnFocus={true}
/>
</WithLabel>
<WithLabel label="selectTextOnFocus">
<TextInput
placeholder="text is selected on focus"
value="text is selected on focus"
style={styles.default}
selectTextOnFocus={true}
/>
</WithLabel>
</View>
);
}
},
];
Binary file modified ...enceImages/Examples-UIExplorer-UIExplorerApp/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions Examples/UIExplorer/UIExplorerTests/UIExplorerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ - (void)setUp
#endif
NSString *version = [[UIDevice currentDevice] systemVersion];
RCTAssert([version isEqualToString:@"8.1"], @"Snapshot tests should be run on iOS 8.1, found %@", version);
_runner = initRunnerForApp(@"Examples/UIExplorer/UIExplorerApp");
_runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerApp");

// If tests have changes, set recordMode = YES below and run the affected tests on an iPhone5, iOS 8.1 simulator.
// If tests have changes, set recordMode = YES below and run the affected
// tests on an iPhone5, iOS 8.1 simulator.
_runner.recordMode = NO;
}

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

// Make sure this test runs first (underscores sort early) otherwise the other tests will tear out the rootView
- (void)test__RootViewLoadsAndRenders {
// Make sure this test runs first (underscores sort early) otherwise the
// other tests will tear out the rootView
- (void)test__RootViewLoadsAndRenders
{
UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
RCTAssert([vc.view isKindOfClass:[RCTRootView class]], @"This test must run first.");
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
Expand Down
20 changes: 13 additions & 7 deletions IntegrationTests/IntegrationTestsTests/IntegrationTestsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ @interface IntegrationTestsTests : XCTestCase

@end

@implementation IntegrationTestsTests {
@implementation IntegrationTestsTests
{
RCTTestRunner *_runner;
}

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

// If tests have changes, set recordMode = YES below and run the affected tests on an iPhone5, iOS 8.1 simulator.
// If tests have changes, set recordMode = YES below and run the affected
// tests on an iPhone5, iOS 8.1 simulator.
_runner.recordMode = NO;
}

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

- (void)testTheTester_waitOneFrame
{
[_runner runTest:_cmd module:@"IntegrationTestHarnessTest" initialProps:@{@"waitOneFrame": @YES} expectErrorBlock:nil];
[_runner runTest:_cmd
module:@"IntegrationTestHarnessTest"
initialProps:@{@"waitOneFrame": @YES}
expectErrorBlock:nil];
}

- (void)testTheTester_ExpectError
// TODO: this seems to stall forever - figure out why
- (void)DISABLED_testTheTester_ExpectError
{
[_runner runTest:_cmd
module:@"IntegrationTestHarnessTest"
initialProps:@{@"shouldThrow": @YES}
expectErrorRegex:[NSRegularExpression regularExpressionWithPattern:@"because shouldThrow" options:0 error:nil]];
expectErrorRegex:@"because shouldThrow"];
}

- (void)testTimers
Expand Down
19 changes: 19 additions & 0 deletions Libraries/Components/MapView/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ var MapView = React.createClass({
longitudeDelta: React.PropTypes.number.isRequired,
}),

/**
* Map annotations with title/subtitle.
*/
annotations: React.PropTypes.arrayOf(React.PropTypes.shape({
/**
* The location of the annotation.
*/
latitude: React.PropTypes.number.isRequired,
longitude: React.PropTypes.number.isRequired,

/**
* Annotation title/subtile.
*/
title: React.PropTypes.string,
subtitle: React.PropTypes.string,
})),

/**
* Maximum size of area that can be displayed.
*/
Expand Down Expand Up @@ -142,6 +159,7 @@ var MapView = React.createClass({
pitchEnabled={this.props.pitchEnabled}
scrollEnabled={this.props.scrollEnabled}
region={this.props.region}
annotations={this.props.annotations}
maxDelta={this.props.maxDelta}
minDelta={this.props.minDelta}
legalLabelInsets={this.props.legalLabelInsets}
Expand All @@ -165,6 +183,7 @@ var RCTMap = createReactIOSNativeComponentClass({
pitchEnabled: true,
scrollEnabled: true,
region: {diff: deepDiffer},
annotations: {diff: deepDiffer},
maxDelta: true,
minDelta: true,
legalLabelInsets: {diff: insetsDiffer},
Expand Down
16 changes: 15 additions & 1 deletion Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ var RCTTextFieldAttributes = merge(RCTTextViewAttributes, {
caretHidden: true,
enabled: true,
clearButtonMode: true,
clearTextOnFocus: true,
selectTextOnFocus: true,
});

var onlyMultiline = {
Expand Down Expand Up @@ -267,7 +269,17 @@ var TextInput = React.createClass({
'unless-editing',
'always',
]),

/**
* If true, clears the text field automatically when editing begins
*/
clearTextOnFocus: PropTypes.bool,
/**
* If true, selected the text automatically when editing begins
*/
selectTextOnFocus: PropTypes.bool,
/**
* Styles
*/
style: Text.propTypes.style,
/**
* Used to locate this view in end-to-end tests.
Expand Down Expand Up @@ -431,6 +443,8 @@ var TextInput = React.createClass({
autoCapitalize={autoCapitalize}
autoCorrect={this.props.autoCorrect}
clearButtonMode={clearButtonMode}
clearTextOnFocus={this.props.clearTextOnFocus}
selectTextOnFocus={this.props.selectTextOnFocus}
/>;
} else {
for (var propKey in notMultiline) {
Expand Down
Loading

0 comments on commit 970dd8a

Please sign in to comment.