[Flow] v0.11.0 cleaning - Part 14 (react-native-github)
This commit is contained in:
parent
4a137aa840
commit
184bb1151a
|
@ -150,7 +150,7 @@ class Game2048 extends React.Component {
|
||||||
startX: number;
|
startX: number;
|
||||||
startY: number;
|
startY: number;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props: {}) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
board: new GameBoard(),
|
board: new GameBoard(),
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/**
|
||||||
|
* The examples provided by Facebook are for non-commercial testing and
|
||||||
|
* evaluation purposes only.
|
||||||
|
*
|
||||||
|
* Facebook reserves all rights not expressly granted.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @providesModule ExampleTypes
|
||||||
|
* @flow
|
||||||
|
*/
|
||||||
|
|
||||||
|
export type Example = {
|
||||||
|
title: string,
|
||||||
|
render: () => ?ReactElement<any, any, any>,
|
||||||
|
description?: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ExampleModule = {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
examples: Array<Example>;
|
||||||
|
external?: bool;
|
||||||
|
};
|
||||||
|
|
|
@ -168,7 +168,7 @@ var MapViewExample = React.createClass({
|
||||||
/>
|
/>
|
||||||
<MapRegionInput
|
<MapRegionInput
|
||||||
onChange={this._onRegionInputChanged}
|
onChange={this._onRegionInputChanged}
|
||||||
region={this.state.mapRegionInput}
|
region={this.state.mapRegionInput || undefined}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
|
@ -181,7 +181,13 @@ var BoxOnlyExample = React.createClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var exampleClasses = [
|
type ExampleClass = {
|
||||||
|
Component: ReactClass<any, any, any>,
|
||||||
|
title: string,
|
||||||
|
description: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
var exampleClasses: Array<ExampleClass> = [
|
||||||
{
|
{
|
||||||
Component: NoneExample,
|
Component: NoneExample,
|
||||||
title: '`none`',
|
title: '`none`',
|
||||||
|
|
|
@ -30,6 +30,8 @@ var {
|
||||||
var { TestModule } = React.addons;
|
var { TestModule } = React.addons;
|
||||||
var Settings = require('Settings');
|
var Settings = require('Settings');
|
||||||
|
|
||||||
|
import type { Example, ExampleModule } from 'ExampleTypes';
|
||||||
|
|
||||||
var createExamplePage = require('./createExamplePage');
|
var createExamplePage = require('./createExamplePage');
|
||||||
|
|
||||||
var COMPONENTS = [
|
var COMPONENTS = [
|
||||||
|
@ -107,9 +109,17 @@ COMPONENTS.concat(APIS).forEach((Example) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
class UIExplorerList extends React.Component {
|
type Props = {
|
||||||
|
navigator: Array<{title: string, component: ReactClass<any,any,any>}>,
|
||||||
|
onExternalExampleRequested: Function,
|
||||||
|
};
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
|
|
||||||
|
class UIExplorerList extends React.Component {
|
||||||
|
props: Props;
|
||||||
|
|
||||||
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
dataSource: ds.cloneWithRowsAndSections({
|
dataSource: ds.cloneWithRowsAndSections({
|
||||||
|
@ -149,7 +159,7 @@ class UIExplorerList extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_renderSectionHeader(data, section) {
|
_renderSectionHeader(data: any, section: string) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.sectionHeader}>
|
<View style={styles.sectionHeader}>
|
||||||
<Text style={styles.sectionHeaderTitle}>
|
<Text style={styles.sectionHeaderTitle}>
|
||||||
|
@ -159,7 +169,7 @@ class UIExplorerList extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_renderRow(example, i) {
|
_renderRow(example: ExampleModule, i: number) {
|
||||||
return (
|
return (
|
||||||
<View key={i}>
|
<View key={i}>
|
||||||
<TouchableHighlight onPress={() => this._onPressRow(example)}>
|
<TouchableHighlight onPress={() => this._onPressRow(example)}>
|
||||||
|
@ -177,7 +187,7 @@ class UIExplorerList extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_search(text) {
|
_search(text: mixed) {
|
||||||
var regex = new RegExp(text, 'i');
|
var regex = new RegExp(text, 'i');
|
||||||
var filter = (component) => regex.test(component.title);
|
var filter = (component) => regex.test(component.title);
|
||||||
|
|
||||||
|
@ -191,7 +201,7 @@ class UIExplorerList extends React.Component {
|
||||||
Settings.set({searchText: text});
|
Settings.set({searchText: text});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPressRow(example) {
|
_onPressRow(example: ExampleModule) {
|
||||||
if (example.external) {
|
if (example.external) {
|
||||||
this.props.onExternalExampleRequested(example);
|
this.props.onExternalExampleRequested(example);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,16 +23,7 @@ var UIExplorerPage = require('./UIExplorerPage');
|
||||||
|
|
||||||
var invariant = require('invariant');
|
var invariant = require('invariant');
|
||||||
|
|
||||||
class Example extends React.Component {
|
import type { Example, ExampleModule } from 'ExampleTypes';
|
||||||
title: string;
|
|
||||||
description: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type ExampleModule = {
|
|
||||||
title: string;
|
|
||||||
description: string;
|
|
||||||
examples: Array<Example>;
|
|
||||||
};
|
|
||||||
|
|
||||||
var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
|
var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
|
||||||
: ReactClass<any, any, any> {
|
: ReactClass<any, any, any> {
|
||||||
|
@ -44,7 +35,7 @@ var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
|
||||||
description: exampleModule.description,
|
description: exampleModule.description,
|
||||||
},
|
},
|
||||||
|
|
||||||
getBlock: function(example, i) {
|
getBlock: function(example: Example, i) {
|
||||||
// Hack warning: This is a hack because the www UI explorer requires
|
// Hack warning: This is a hack because the www UI explorer requires
|
||||||
// renderComponent to be called.
|
// renderComponent to be called.
|
||||||
var originalRender = React.render;
|
var originalRender = React.render;
|
||||||
|
|
|
@ -92,6 +92,8 @@ var getPhotosReturnChecker = createStrictShapeTypeChecker({
|
||||||
});
|
});
|
||||||
|
|
||||||
class CameraRoll {
|
class CameraRoll {
|
||||||
|
|
||||||
|
static GroupTypesOptions: Array<string>;
|
||||||
/**
|
/**
|
||||||
* Saves the image with tag `tag` to the camera roll.
|
* Saves the image with tag `tag` to the camera roll.
|
||||||
*
|
*
|
||||||
|
|
|
@ -67,9 +67,9 @@ class PixelRatio {
|
||||||
static getPixelSizeForLayoutSize(layoutSize: number): number {
|
static getPixelSizeForLayoutSize(layoutSize: number): number {
|
||||||
return Math.round(layoutSize * PixelRatio.get());
|
return Math.round(layoutSize * PixelRatio.get());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// No-op for iOS, but used on the web. Should not be documented.
|
// No-op for iOS, but used on the web. Should not be documented.
|
||||||
PixelRatio.startDetecting = function() {};
|
static startDetecting() {}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = PixelRatio;
|
module.exports = PixelRatio;
|
||||||
|
|
Loading…
Reference in New Issue