more UIExplorer flow

This commit is contained in:
Basil Hosmer 2015-03-23 11:36:57 -07:00
parent a6b154332b
commit d6bb48d972
22 changed files with 49 additions and 21 deletions

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -150,7 +151,7 @@ var NavigatorIOSExample = React.createClass({
}); });
}, },
_renderRow: function(title, onPress) { _renderRow: function(title: string, onPress: Function) {
return ( return (
<View> <View>
<TouchableHighlight onPress={onPress}> <TouchableHighlight onPress={onPress}>

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -120,16 +121,16 @@ exports.examples = [
{ {
title: 'NetInfo.isConnected', title: 'NetInfo.isConnected',
description: 'Asyncronously load and observe connectivity', description: 'Asyncronously load and observe connectivity',
render() { return <IsConnected />; } render(): ReactElement { return <IsConnected />; }
}, },
{ {
title: 'NetInfo.reachabilityIOS', title: 'NetInfo.reachabilityIOS',
description: 'Asyncronously load and observe iOS reachability', description: 'Asyncronously load and observe iOS reachability',
render() { return <ReachabilityCurrent />; } render(): ReactElement { return <ReachabilityCurrent />; }
}, },
{ {
title: 'NetInfo.reachabilityIOS', title: 'NetInfo.reachabilityIOS',
description: 'Observed updates to iOS reachability', description: 'Observed updates to iOS reachability',
render() { return <ReachabilitySubscription />; } render(): ReactElement { return <ReachabilitySubscription />; }
}, },
]; ];

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -105,7 +106,7 @@ exports.description = 'Render lists of selectable options with UIPickerView.';
exports.examples = [ exports.examples = [
{ {
title: '<PickerIOS>', title: '<PickerIOS>',
render: function() { render: function(): ReactElement {
return <PickerExample />; return <PickerExample />;
}, },
}]; }];

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -50,6 +51,6 @@ exports.description = 'Slider input for numeric values';
exports.examples = [ exports.examples = [
{ {
title: 'SliderIOS', title: 'SliderIOS',
render() { return <SliderExample />; } render(): ReactElement { return <SliderExample />; }
} }
]; ];

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -118,22 +119,22 @@ exports.description = 'Native boolean input';
exports.examples = [ exports.examples = [
{ {
title: 'Switches can be set to true or false', title: 'Switches can be set to true or false',
render() { return <BasicSwitchExample />; } render(): ReactElement { return <BasicSwitchExample />; }
}, },
{ {
title: 'Switches can be disabled', title: 'Switches can be disabled',
render() { return <DisabledSwitchExample />; } render(): ReactElement { return <DisabledSwitchExample />; }
}, },
{ {
title: 'Custom colors can be provided', title: 'Custom colors can be provided',
render() { return <ColorSwitchExample />; } render(): ReactElement { return <ColorSwitchExample />; }
}, },
{ {
title: 'Change events can be detected', title: 'Change events can be detected',
render() { return <EventSwitchExample />; } render(): ReactElement { return <EventSwitchExample />; }
}, },
{ {
title: 'Switches are controlled components', title: 'Switches are controlled components',
render() { return <SwitchIOS />; } render(): ReactElement { return <SwitchIOS />; }
} }
]; ];

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -199,7 +200,7 @@ exports.examples = [
}, },
}, { }, {
title: 'Toggling Attributes', title: 'Toggling Attributes',
render: function() { render: function(): ReactElement {
return <AttributeToggler />; return <AttributeToggler />;
}, },
}, { }, {

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -164,7 +165,7 @@ exports.examples = [
}, },
{ {
title: 'Event handling', title: 'Event handling',
render: () => <TextEventsExample />, render: function(): ReactElement { return <TextEventsExample /> },
}, },
{ {
title: 'Colored input text', title: 'Colored input text',

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -31,6 +32,12 @@ var Button = React.createClass({
var TimerTester = React.createClass({ var TimerTester = React.createClass({
mixins: [TimerMixin], mixins: [TimerMixin],
_ii: 0,
_iters: 0,
_start: 0,
_timerFn: (null : ?(() => any)),
_handle: (null : any),
render: function() { render: function() {
var args = 'fn' + (this.props.dt !== undefined ? ', ' + this.props.dt : ''); var args = 'fn' + (this.props.dt !== undefined ? ', ' + this.props.dt : '');
return ( return (
@ -71,7 +78,7 @@ var TimerTester = React.createClass({
'Elapsed time: ' + e + ' ms\n' + (e / this._ii) + ' ms / iter'; 'Elapsed time: ' + e + ' ms\n' + (e / this._ii) + ' ms / iter';
console.log(msg); console.log(msg);
AlertIOS.alert(msg); AlertIOS.alert(msg);
this._start = null; this._start = 0;
this.forceUpdate(() => { this._ii = 0; }); this.forceUpdate(() => { this._ii = 0; });
return; return;
} }
@ -153,7 +160,7 @@ exports.examples = [
title: 'this.setInterval(fn, t)', title: 'this.setInterval(fn, t)',
description: 'Execute function fn every t milliseconds until cancelled ' + description: 'Execute function fn every t milliseconds until cancelled ' +
'or component is unmounted.', 'or component is unmounted.',
render: function() { render: function(): ReactElement {
var IntervalExample = React.createClass({ var IntervalExample = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -53,14 +54,14 @@ exports.examples = [
}, },
}, { }, {
title: '<Text onPress={fn}> with highlight', title: '<Text onPress={fn}> with highlight',
render: function() { render: function(): ReactElement {
return <TextOnPressBox />; return <TextOnPressBox />;
}, },
}, { }, {
title: 'Touchable feedback events', title: 'Touchable feedback events',
description: '<Touchable*> components accept onPress, onPressIn, ' + description: '<Touchable*> components accept onPress, onPressIn, ' +
'onPressOut, and onLongPress as props.', 'onPressOut, and onLongPress as props.',
render: function() { render: function(): ReactElement {
return <TouchableFeedbackEvents />; return <TouchableFeedbackEvents />;
}, },
}]; }];

View File

@ -2,6 +2,7 @@
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* *
* @providesModule UIExplorerApp * @providesModule UIExplorerApp
* @flow
*/ */
'use strict'; 'use strict';

View File

@ -2,6 +2,7 @@
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* *
* @providesModule UIExplorerBlock * @providesModule UIExplorerBlock
* @flow
*/ */
'use strict'; 'use strict';
@ -19,7 +20,7 @@ var UIExplorerBlock = React.createClass({
}, },
getInitialState: function() { getInitialState: function() {
return {description: null}; return {description: (null: ?string)};
}, },
render: function() { render: function() {

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';

View File

@ -2,6 +2,7 @@
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* *
* @providesModule UIExplorerPage * @providesModule UIExplorerPage
* @flow
*/ */
'use strict'; 'use strict';

View File

@ -2,6 +2,7 @@
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* *
* @providesModule UIExplorerTitle * @providesModule UIExplorerTitle
* @flow
*/ */
'use strict'; 'use strict';

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';

View File

@ -1,5 +1,6 @@
/** /**
* Copyright 2004-present Facebook. All Rights Reserved. * Copyright 2004-present Facebook. All Rights Reserved.
* @flow
*/ */
'use strict'; 'use strict';
@ -35,6 +36,8 @@ var WebViewExample = React.createClass({
}; };
}, },
inputText: '',
handleTextInputChange: function(event) { handleTextInputChange: function(event) {
this.inputText = event.nativeEvent.text; this.inputText = event.nativeEvent.text;
}, },
@ -259,6 +262,6 @@ exports.description = 'Base component to display web content';
exports.examples = [ exports.examples = [
{ {
title: 'WebView', title: 'WebView',
render() { return <WebViewExample />; } render(): ReactElement { return <WebViewExample />; }
} }
]; ];

View File

@ -21,7 +21,7 @@ var StatusBarIOS = {
slide: RCTStatusBarManager.Animation.slide, slide: RCTStatusBarManager.Animation.slide,
}, },
setStyle(style: number, animated: boolean) { setStyle(style: number, animated?: boolean) {
animated = animated || false; animated = animated || false;
RCTStatusBarManager.setStyle(style, animated); RCTStatusBarManager.setStyle(style, animated);
}, },

View File

@ -43,7 +43,7 @@ class AlertIOS {
*/ */
static alert( static alert(
title: ?string, title: ?string,
message: ?string, message?: ?string,
buttons?: Array<{ buttons?: Array<{
text: ?string; text: ?string;
onPress: ?Function; onPress: ?Function;