Skip to content

Commit

Permalink
Upgrade Flow to 0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
frantic committed Jun 24, 2016
1 parent d1cafab commit a9b6cd5
Show file tree
Hide file tree
Showing 35 changed files with 199 additions and 132 deletions.
5 changes: 4 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
.*/*.web.js
.*/*.android.js

# Ignore templates with `@flow` in header
.*/local-cli/generator.*

# Some modules have their own node_modules with overlap
.*/node_modules/node-haste/.*

Expand Down Expand Up @@ -88,4 +91,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

[version]
0.22.0
^0.25.0
12 changes: 8 additions & 4 deletions js/Playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ var React = require('React');
var View = require('View');

class Playground extends React.Component {
state: {
content: Array<ReactElement>;
};

constructor() {
super();
const content = [];
Expand All @@ -38,6 +42,7 @@ class Playground extends React.Component {
var Module = require('F8Header');
// var Module = require('./tabs/schedule/AddToScheduleButton');
// var Module = require('./rating/Header');
// $FlowFixMe: doesn't understand static
Module.__cards__(define);
this.state = {content};
}
Expand All @@ -52,10 +57,9 @@ class Playground extends React.Component {
}

class Example extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
state = {
inner: null
};

render() {
const content = this.props.render(this.state.inner, (inner) => this.setState({inner}));
Expand Down
12 changes: 8 additions & 4 deletions js/common/F8Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ var View = require('View');
class F8Button extends React.Component {
props: {
type: 'primary' | 'secondary' | 'bordered';
icon: number;
icon?: number;
caption: string;
style: any;
onPress: () => void;
style?: any;
onPress: () => mixed;
};

static defaultProps = {
type: 'primary',
};

render() {
Expand All @@ -50,7 +54,7 @@ class F8Button extends React.Component {
icon = <Image source={this.props.icon} style={styles.icon} />;
}
let content;
if (this.props.type === 'primary' || this.props.type === undefined) {
if (this.props.type === 'primary') {
content = (
<LinearGradient
start={[0.5, 1]} end={[1, 1]}
Expand Down
10 changes: 5 additions & 5 deletions js/common/F8DrawerLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class F8DrawerLayout extends React.Component {
constructor(props: any, context: any) {
super(props, context);

this.openDrawer = this.openDrawer.bind(this);
this.closeDrawer = this.closeDrawer.bind(this);
this.onDrawerOpen = this.onDrawerOpen.bind(this);
this.onDrawerClose = this.onDrawerClose.bind(this);
this.handleBackButton = this.handleBackButton.bind(this);
(this: any).openDrawer = this.openDrawer.bind(this);
(this: any).closeDrawer = this.closeDrawer.bind(this);
(this: any).onDrawerOpen = this.onDrawerOpen.bind(this);
(this: any).onDrawerClose = this.onDrawerClose.bind(this);
(this: any).handleBackButton = this.handleBackButton.bind(this);
}

render() {
Expand Down
15 changes: 9 additions & 6 deletions js/common/F8Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@ export type Item = {
};

export type Props = {
title: string;
title?: string;
leftItem?: Item;
rightItem?: Item;
extraItems?: Array<Item>;
foreground?: Foreground;
style: any;
children: any;
style?: any;
children?: any;
};

class F8HeaderAndroid extends React.Component {
static height: number;
props: Props;

render() {
Expand Down Expand Up @@ -122,6 +123,7 @@ class F8HeaderAndroid extends React.Component {


class F8HeaderIOS extends React.Component {
static height: number;
props: Props;

render() {
Expand Down Expand Up @@ -240,9 +242,8 @@ var styles = StyleSheet.create({

const Header = Platform.OS === 'ios' ? F8HeaderIOS : F8HeaderAndroid;
Header.height = HEADER_HEIGHT;

module.exports = Header;
module.exports.__cards__ = (define) => {
// $FlowFixMe
Header.__cards__ = (define) => {
const menuItem = {
title: 'Menu',
icon: require('./img/hamburger.png'),
Expand Down Expand Up @@ -303,3 +304,5 @@ module.exports.__cards__ = (define) => {
/>
));
};

module.exports = Header;
2 changes: 1 addition & 1 deletion js/common/F8SegmentedControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class F8SegmentedControl extends React.Component {
selectionColor: ?string;
selectedIndex: number;
onChange: (newIndex: number) => void;
style: any;
style?: any;
};

render() {
Expand Down
6 changes: 3 additions & 3 deletions js/common/ItemsWithSeparator.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ var View = require('View');

class ItemsWithSeparator extends React.Component {
props: {
style: any;
separatorStyle: any;
children: any;
style?: any;
separatorStyle?: any;
children?: any;
};

render() {
Expand Down
35 changes: 18 additions & 17 deletions js/common/ListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ type Props = {
selectedSectionColor: string;
backgroundImage: number;
backgroundColor: string;
parallaxContent: ?ReactElement;
parallaxContent?: ?ReactElement;
stickyHeader?: ?ReactElement;
onSegmentChange?: (segment: number) => void;
children: any;
children?: any;
};

type State = {
Expand Down Expand Up @@ -110,22 +110,32 @@ class RelayLoading extends React.Component {

class ListContainer extends React.Component {
props: Props;
state: State;
_refs: Array<any>;
_pinned: any;

static defaultProps = {
selectedSectionColor: 'white',
};

static contextTypes = {
openDrawer: React.PropTypes.func,
hasUnreadNotifications: React.PropTypes.number,
};

constructor(props: Props) {
super(props);

this.state = ({
this.state = {
idx: this.props.selectedSegment || 0,
anim: new Animated.Value(0),
stickyHeaderHeight: 0,
}: State);
};

this.renderFakeHeader = this.renderFakeHeader.bind(this);
this.handleStickyHeaderLayout = this.handleStickyHeaderLayout.bind(this);
this.handleShowMenu = this.handleShowMenu.bind(this);
this.handleSelectSegment = this.handleSelectSegment.bind(this);
(this: any).renderFakeHeader = this.renderFakeHeader.bind(this);
(this: any).handleStickyHeaderLayout = this.handleStickyHeaderLayout.bind(this);
(this: any).handleShowMenu = this.handleShowMenu.bind(this);
(this: any).handleSelectSegment = this.handleSelectSegment.bind(this);
this._refs = [];
}

Expand Down Expand Up @@ -354,15 +364,6 @@ class ListContainer extends React.Component {
}
}

ListContainer.defaultProps = {
selectedSectionColor: 'white',
};

ListContainer.contextTypes = {
openDrawer: React.PropTypes.func,
hasUnreadNotifications: React.PropTypes.number,
};

var styles = StyleSheet.create({
container: {
flex: 1,
Expand Down
1 change: 1 addition & 0 deletions js/common/LoginButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class LoginButton extends React.Component {
<F8Button
style={[styles.button, this.props.style]}
caption="Please wait..."
onPress={() => {}}
/>
);
}
Expand Down
5 changes: 4 additions & 1 deletion js/common/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class MapView extends React.Component {
_isMounted: boolean;
props: {
map: ?Map;
style: any;
style?: any;
};
state: {
loaded: boolean;
};

constructor() {
Expand Down
15 changes: 10 additions & 5 deletions js/common/ParallaxBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var View = require('View');
var Image = require('Image');
var Dimensions = require('Dimensions');

// TODO: Remove this magic numbers
const HEIGHT = Dimensions.get('window').height > 600
? 200
: 150;
Expand All @@ -44,12 +45,19 @@ type Props = {
offset: Animated.Value;
backgroundImage: number;
backgroundShift: number; // 0..1
backgroundColor: number; // TODO: This makes it seems like image loads faster. Remove
children: any;
backgroundColor: string; // TODO: This makes it seems like image loads faster. Remove
children?: any;
}

type State = {
shift: Animated.Value;
};

class ParallaxBackground extends React.Component {
props: Props;
state: State;

static HEIGHT = HEIGHT;

constructor(props: Props) {
super(props);
Expand Down Expand Up @@ -150,9 +158,6 @@ class ParallaxBackground extends React.Component {
}
}

// TODO: Remove this magic numbers
ParallaxBackground.HEIGHT = HEIGHT;

var HEADER_HEIGHT = HEIGHT + 156;

var styles = StyleSheet.create({
Expand Down
28 changes: 17 additions & 11 deletions js/common/PureListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,32 @@ export type Data = Rows | RowsAndSections;
type RenderElement = () => ?ReactElement;

type Props = {
data: ?Data;
data: Data;
renderEmptyList?: ?RenderElement;
minContentHeight: number;
contentInset: { top: number; bottom: number; };
};

type State = {
contentHeight: number;
dataSource: ListView.DataSource;
};

// FIXME: Android has a bug when scrolling ListView the view insertions
// will make it go reverse. Temporary fix - pre-render more rows
const LIST_VIEW_PAGE_SIZE = Platform.OS === 'android' ? 20 : 1;

class PureListView extends React.Component {
props: Props;
state: State;

static defaultProps = {
data: [],
contentInset: { top: 0, bottom: 0 },
// TODO: This has to be scrollview height + fake header
minContentHeight: Dimensions.get('window').height + 20,
renderSeparator: (sectionID, rowID) => <View style={styles.separator} key={rowID} />,
};

constructor(props: Props) {
super(props);
Expand All @@ -66,8 +80,8 @@ class PureListView extends React.Component {
dataSource: cloneWithData(dataSource, props.data),
};

this.renderFooter = this.renderFooter.bind(this);
this.onContentSizeChange = this.onContentSizeChange.bind(this);
(this: any).renderFooter = this.renderFooter.bind(this);
(this: any).onContentSizeChange = this.onContentSizeChange.bind(this);
}

componentWillReceiveProps(nextProps: Props) {
Expand Down Expand Up @@ -119,14 +133,6 @@ class PureListView extends React.Component {
}
}

PureListView.defaultProps = {
data: [],
contentInset: { top: 0, bottom: 0 },
// TODO: This has to be scrollview height + fake header
minContentHeight: Dimensions.get('window').height + 20,
renderSeparator: (sectionID, rowID) => <View style={styles.separator} key={rowID} />,
};

function cloneWithData(dataSource: ListView.DataSource, data: ?Data) {
if (!data) {
return dataSource.cloneWithRows([]);
Expand Down
9 changes: 3 additions & 6 deletions js/login/LoginScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ var { skipLogin } = require('../actions');
var { connect } = require('react-redux');

class LoginScreen extends React.Component {
constructor(props) {
super(props);
this.state = {
anim: new Animated.Value(0),
};
}
state = {
anim: new Animated.Value(0),
};

componentDidMount() {
StatusBarIOS && StatusBarIOS.setStyle('default');
Expand Down
Loading

0 comments on commit a9b6cd5

Please sign in to comment.