Skip to content

Commit

Permalink
[Flow] v0.11.0 cleaning - Part 14 (react-native-github)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabelevi authored and vjeux committed May 13, 2015
1 parent 4a137aa commit 184bb11
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Examples/2048/Game2048.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Game2048 extends React.Component {
startX: number;
startY: number;

constructor(props) {
constructor(props: {}) {
super(props);
this.state = {
board: new GameBoard(),
Expand Down
30 changes: 30 additions & 0 deletions Examples/UIExplorer/ExampleTypes.js
Original file line number Diff line number Diff line change
@@ -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;
};

2 changes: 1 addition & 1 deletion Examples/UIExplorer/MapViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var MapViewExample = React.createClass({
/>
<MapRegionInput
onChange={this._onRegionInputChanged}
region={this.state.mapRegionInput}
region={this.state.mapRegionInput || undefined}
/>
</View>
);
Expand Down
8 changes: 7 additions & 1 deletion Examples/UIExplorer/PointerEventsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
title: '`none`',
Expand Down
20 changes: 15 additions & 5 deletions Examples/UIExplorer/UIExplorerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var {
var { TestModule } = React.addons;
var Settings = require('Settings');

import type { Example, ExampleModule } from 'ExampleTypes';

var createExamplePage = require('./createExamplePage');

var COMPONENTS = [
Expand Down Expand Up @@ -107,9 +109,17 @@ COMPONENTS.concat(APIS).forEach((Example) => {
}
});

type Props = {
navigator: Array<{title: string, component: ReactClass<any,any,any>}>,
onExternalExampleRequested: Function,
};



class UIExplorerList extends React.Component {
props: Props;

constructor(props) {
constructor(props: Props) {
super(props);
this.state = {
dataSource: ds.cloneWithRowsAndSections({
Expand Down Expand Up @@ -149,7 +159,7 @@ class UIExplorerList extends React.Component {
);
}

_renderSectionHeader(data, section) {
_renderSectionHeader(data: any, section: string) {
return (
<View style={styles.sectionHeader}>
<Text style={styles.sectionHeaderTitle}>
Expand All @@ -159,7 +169,7 @@ class UIExplorerList extends React.Component {
);
}

_renderRow(example, i) {
_renderRow(example: ExampleModule, i: number) {
return (
<View key={i}>
<TouchableHighlight onPress={() => this._onPressRow(example)}>
Expand All @@ -177,7 +187,7 @@ class UIExplorerList extends React.Component {
);
}

_search(text) {
_search(text: mixed) {
var regex = new RegExp(text, 'i');
var filter = (component) => regex.test(component.title);

Expand All @@ -191,7 +201,7 @@ class UIExplorerList extends React.Component {
Settings.set({searchText: text});
}

_onPressRow(example) {
_onPressRow(example: ExampleModule) {
if (example.external) {
this.props.onExternalExampleRequested(example);
return;
Expand Down
13 changes: 2 additions & 11 deletions Examples/UIExplorer/createExamplePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@ var UIExplorerPage = require('./UIExplorerPage');

var invariant = require('invariant');

class Example extends React.Component {
title: string;
description: string;
}

type ExampleModule = {
title: string;
description: string;
examples: Array<Example>;
};
import type { Example, ExampleModule } from 'ExampleTypes';

var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
: ReactClass<any, any, any> {
Expand All @@ -44,7 +35,7 @@ var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
description: exampleModule.description,
},

getBlock: function(example, i) {
getBlock: function(example: Example, i) {
// Hack warning: This is a hack because the www UI explorer requires
// renderComponent to be called.
var originalRender = React.render;
Expand Down
2 changes: 2 additions & 0 deletions Libraries/CameraRoll/CameraRoll.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ var getPhotosReturnChecker = createStrictShapeTypeChecker({
});

class CameraRoll {

static GroupTypesOptions: Array<string>;
/**
* Saves the image with tag `tag` to the camera roll.
*
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Utilities/PixelRatio.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class PixelRatio {
static getPixelSizeForLayoutSize(layoutSize: number): number {
return Math.round(layoutSize * PixelRatio.get());
}
}

// No-op for iOS, but used on the web. Should not be documented.
PixelRatio.startDetecting = function() {};
// No-op for iOS, but used on the web. Should not be documented.
static startDetecting() {}
}

module.exports = PixelRatio;

0 comments on commit 184bb11

Please sign in to comment.