Skip to content

Commit

Permalink
last batch of UIExplorer flowification
Browse files Browse the repository at this point in the history
  • Loading branch information
Basil Hosmer committed Mar 24, 2015
1 parent 23094db commit 6daf7d2
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 6 deletions.
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

[libs]
Libraries/react-native/react-native-interface.js
Examples/UIExplorer/ImageMocks.js

[options]
module.system=haste
1 change: 1 addition & 0 deletions Examples/UIExplorer/ImageCapInsetsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ImageCapInsetsExample
* @flow
*/
'use strict';

Expand Down
2 changes: 2 additions & 0 deletions Examples/UIExplorer/ImageExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';

Expand Down
35 changes: 35 additions & 0 deletions Examples/UIExplorer/ImageMocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';

declare module 'image!story-background' {
declare var uri: string;
declare var isStatic: boolean;
}

declare module 'image!uie_comment_highlighted' {
declare var uri: string;
declare var isStatic: boolean;
}

declare module 'image!uie_comment_normal' {
declare var uri: string;
declare var isStatic: boolean;
}

declare module 'image!uie_thumb_normal' {
declare var uri: string;
declare var isStatic: boolean;
}

declare module 'image!uie_thumb_selected' {
declare var uri: string;
declare var isStatic: boolean;
}
4 changes: 3 additions & 1 deletion Examples/UIExplorer/MapViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';

Expand Down Expand Up @@ -188,7 +190,7 @@ exports.description = 'Base component to display maps';
exports.examples = [
{
title: 'Map',
render() { return <MapViewExample />; }
render(): ReactElement { return <MapViewExample />; }
},
{
title: 'Map shows user location',
Expand Down
4 changes: 3 additions & 1 deletion Examples/UIExplorer/TabBarExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';

Expand All @@ -31,7 +33,7 @@ var TabBarExample = React.createClass({
};
},

_renderContent: function(color, pageText) {
_renderContent: function(color: string, pageText: string) {
return (
<View style={[styles.tabContent, {backgroundColor: color}]}>
<Text style={styles.tabText}>{pageText}</Text>
Expand Down
23 changes: 19 additions & 4 deletions Examples/UIExplorer/createExamplePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule createExamplePage
* @flow
*/
'use strict';

Expand All @@ -16,7 +17,19 @@ var UIExplorerPage = require('./UIExplorerPage');

var invariant = require('invariant');

var createExamplePage = function(title, exampleModule) {
class Example extends React.Component {
title: string;
description: string;
}

type ExampleModule = {
title: string;
description: string;
examples: Array<Example>;
};

var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
: ReactClass<any, any, any> {
invariant(!!exampleModule.examples, 'The module must have examples');

var ExamplePage = React.createClass({
Expand All @@ -31,15 +44,17 @@ var createExamplePage = function(title, exampleModule) {
var originalRenderComponent = React.renderComponent;
var originalRender = React.render;
var renderedComponent;
React.render = React.renderComponent = function(element, container) {
// TODO remove typecasts when Flow bug #6560135 is fixed
// and workaround is removed from react-native.js
(React: Object).render = (React: Object).renderComponent = function(element, container) {
renderedComponent = element;
};
var result = example.render(null);
if (result) {
renderedComponent = result;
}
React.renderComponent = originalRenderComponent;
React.render = originalRender;
(React: Object).renderComponent = originalRenderComponent;
(React: Object).render = originalRender;
return (
<UIExplorerBlock
key={i}
Expand Down

0 comments on commit 6daf7d2

Please sign in to comment.