Fixed Flow errors

Reviewed By: nicklockwood

Differential Revision: D2773940

fb-gh-sync-id: 3d632c57c411ddaf428c1d96d145da62dd115a14
This commit is contained in:
glevi@fb.com 2015-12-18 11:16:40 -08:00 committed by facebook-github-bot-9
parent 57a76c0c01
commit dc6ca95c3a
2 changed files with 57 additions and 18 deletions

View File

@ -33,19 +33,30 @@ var regionText = {
longitudeDelta: '0', longitudeDelta: '0',
}; };
type MapRegion = {
latitude: number,
longitude: number,
latitudeDelta?: number,
longitudeDelta?: number,
};
type MapRegionInputState = {
region: MapRegion,
};
var MapRegionInput = React.createClass({ var MapRegionInput = React.createClass({
propTypes: { propTypes: {
region: React.PropTypes.shape({ region: React.PropTypes.shape({
latitude: React.PropTypes.number.isRequired, latitude: React.PropTypes.number.isRequired,
longitude: React.PropTypes.number.isRequired, longitude: React.PropTypes.number.isRequired,
latitudeDelta: React.PropTypes.number.isRequired, latitudeDelta: React.PropTypes.number,
longitudeDelta: React.PropTypes.number.isRequired, longitudeDelta: React.PropTypes.number,
}), }),
onChange: React.PropTypes.func.isRequired, onChange: React.PropTypes.func.isRequired,
}, },
getInitialState() { getInitialState(): MapRegionInputState {
return { return {
region: { region: {
latitude: 0, latitude: 0,
@ -93,7 +104,9 @@ var MapRegionInput = React.createClass({
{'Latitude delta'} {'Latitude delta'}
</Text> </Text>
<TextInput <TextInput
value={'' + region.latitudeDelta} value={
region.latitudeDelta == null ? '' : String(region.latitudeDelta)
}
style={styles.textInput} style={styles.textInput}
onChange={this._onChangeLatitudeDelta} onChange={this._onChangeLatitudeDelta}
selectTextOnFocus={true} selectTextOnFocus={true}
@ -104,7 +117,9 @@ var MapRegionInput = React.createClass({
{'Longitude delta'} {'Longitude delta'}
</Text> </Text>
<TextInput <TextInput
value={'' + region.longitudeDelta} value={
region.longitudeDelta == null ? '' : String(region.longitudeDelta)
}
style={styles.textInput} style={styles.textInput}
onChange={this._onChangeLongitudeDelta} onChange={this._onChangeLongitudeDelta}
selectTextOnFocus={true} selectTextOnFocus={true}
@ -149,9 +164,34 @@ var MapRegionInput = React.createClass({
}); });
type Annotations = Array<{
animateDrop?: boolean,
latitude: number,
longitude: number,
title?: string,
subtitle?: string,
hasLeftCallout?: boolean,
hasRightCallout?: boolean,
onLeftCalloutPress?: Function,
onRightCalloutPress?: Function,
tintColor?: number | string,
image?: any,
id?: string,
view?: ReactElement,
leftCalloutView?: ReactElement,
rightCalloutView?: ReactElement,
detailCalloutView?: ReactElement,
}>;
type MapViewExampleState = {
isFirstLoad: boolean,
mapRegion?: MapRegion,
mapRegionInput?: MapRegion,
annotations?: Annotations,
};
var MapViewExample = React.createClass({ var MapViewExample = React.createClass({
getInitialState() { getInitialState(): MapViewExampleState {
return { return {
isFirstLoad: true, isFirstLoad: true,
}; };
@ -175,7 +215,7 @@ var MapViewExample = React.createClass({
); );
}, },
_getAnnotations(region) { _getAnnotations(region): Annotations {
return [{ return [{
longitude: region.longitude, longitude: region.longitude,
latitude: region.latitude, latitude: region.latitude,
@ -209,9 +249,14 @@ var MapViewExample = React.createClass({
}); });
type AnnotationExampleState = {
isFirstLoad: boolean,
annotations?: Annotations,
mapRegion?: MapRegion,
};
var AnnotationExample = React.createClass({ var AnnotationExample = React.createClass({
getInitialState() { getInitialState(): AnnotationExampleState {
return { return {
isFirstLoad: true, isFirstLoad: true,
}; };

View File

@ -26,12 +26,6 @@ const resolveAssetSource = require('resolveAssetSource');
const requireNativeComponent = require('requireNativeComponent'); const requireNativeComponent = require('requireNativeComponent');
type Event = Object; type Event = Object;
type MapRegion = {
latitude: number;
longitude: number;
latitudeDelta?: number;
longitudeDelta?: number;
};
const MapView = React.createClass({ const MapView = React.createClass({
mixins: [NativeMethodsMixin], mixins: [NativeMethodsMixin],