Skip to content

Commit

Permalink
Init flow types
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebuilds committed Mar 5, 2017
1 parent ece6bc7 commit 8c99793
Show file tree
Hide file tree
Showing 67 changed files with 5,705 additions and 260 deletions.
46 changes: 46 additions & 0 deletions .flowconfig
@@ -0,0 +1,46 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/

[options]
emoji=true

module.system=haste

experimental.strict_type_args=true

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-8]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-8]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

unsafe.enable_getters_and_setters=true

[version]
0.39.0
1 change: 1 addition & 0 deletions __tests__/scenes/Info/components/CodeOfConduct.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand Down
1 change: 1 addition & 0 deletions __tests__/scenes/Info/components/Organiser.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand Down
1 change: 1 addition & 0 deletions __tests__/scenes/Info/index.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand Down
3 changes: 2 additions & 1 deletion __tests__/scenes/Schedule/components/Break.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand All @@ -7,7 +8,7 @@ import Break from '../../../../app/scenes/Schedule/components/Break';
describe('Schedule - Break', () => {
it('renders correctly', () => {
const tree = renderer.create(
<Break />
<Break status="present" />
).toJSON();

expect(tree).toMatchSnapshot();
Expand Down
1 change: 1 addition & 0 deletions __tests__/scenes/Schedule/components/NowButton.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand Down
1 change: 1 addition & 0 deletions __tests__/scenes/Schedule/components/SplashScreen.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand Down
8 changes: 7 additions & 1 deletion __tests__/scenes/Schedule/components/Talk.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand All @@ -7,7 +8,12 @@ import Talk from '../../../../app/scenes/Schedule/components/Talk';
describe('Schedule - Talk', () => {
it('renders correctly', () => {
const tree = renderer.create(
<Talk onPress={() => {}} />
<Talk onPress={() => {}}
speakerAvatarUri=""
speakerName=""
startTime=""
status="present"
title=""/>
).toJSON();

expect(tree).toMatchSnapshot();
Expand Down
1 change: 1 addition & 0 deletions __tests__/scenes/Schedule/index.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand Down
3 changes: 2 additions & 1 deletion __tests__/scenes/Talk/components/Hint.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand All @@ -7,7 +8,7 @@ import Hint from '../../../../app/scenes/Talk/components/Hint';
describe('Talk - Hint', () => {
it('renders correctly', () => {
const tree = renderer.create(
<Hint />
<Hint onClose={() => {}} />
).toJSON();

expect(tree).toMatchSnapshot();
Expand Down
1 change: 1 addition & 0 deletions __tests__/scenes/Talk/components/Pane.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand Down
1 change: 1 addition & 0 deletions __tests__/scenes/Talk/components/Preview.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand Down
1 change: 1 addition & 0 deletions __tests__/scenes/Talk/components/Speaker.test.js
@@ -1,3 +1,4 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
Expand Down
24 changes: 23 additions & 1 deletion __tests__/scenes/Talk/index.test.js
@@ -1,13 +1,35 @@
// @flow
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';

import Talk from '../../../app/scenes/Talk';

const talk = {
id: "",
summary: "",
title: "",
speaker: {
avatar: "",
github: "",
name: "",
twitter: "",
summary: "",
},
time: {
start: new Date,
end: new Date,
},
};

describe('Talk', () => {
it('renders correctly', () => {
const tree = renderer.create(
<Talk navigator={{}} />
<Talk navigator={{}}
talk={talk}
nextTalk={null}
prevTalk={null}
introduceUI={false}/>
).toJSON();

expect(tree).toMatchSnapshot();
Expand Down
2 changes: 2 additions & 0 deletions __tests__/setup.js
@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import { View } from 'react-native';

Expand All @@ -12,6 +13,7 @@ mockdate.set(1422778155399, -660);
// React Native Built-Ins
// ------------------------
// React Native UI Manager needs a focus function.
// $FlowFixMe
import { UIManager } from 'NativeModules';
UIManager.focus = jest.fn();
UIManager.createView = jest.fn(() => <View />);
Expand Down
18 changes: 8 additions & 10 deletions app/ReactConf2017.js
@@ -1,3 +1,4 @@
// @flow
import React, { Component } from 'react';
import { AppState, Navigator, StatusBar, StyleSheet } from 'react-native';
import codePush from 'react-native-code-push';
Expand All @@ -9,12 +10,6 @@ const Scenes = { Info, Schedule, Talk };
const DEFAULT_VIEW = 'Schedule';

class ReactConf2017 extends Component {
constructor () {
super();

this.handleAppStateChange = this.handleAppStateChange.bind(this);
this.syncAppVersion = this.syncAppVersion.bind(this);
}
componentDidMount () {
this.syncAppVersion();
StatusBar.setBarStyle('light-content', true);
Expand All @@ -23,14 +18,17 @@ class ReactConf2017 extends Component {
componentWillUnmount () {
AppState.removeEventListener('change', this.handleAppStateChange);
}
handleAppStateChange (currentAppState) {

handleAppStateChange = (currentAppState: string) => {
if (currentAppState === 'active') {
this.syncAppVersion();
}
}
syncAppVersion () {
};

syncAppVersion = () => {
codePush.sync({ mandatoryInstallMode: codePush.InstallMode.IMMEDIATE });
}
};

render () {
const renderScene = (route, navigator) => {
const SceneComponent = Scenes[route.scene];
Expand Down
16 changes: 7 additions & 9 deletions app/components/Avatar/index.js
@@ -1,9 +1,15 @@
// @flow
import React, { PropTypes } from 'react';
import { Image, View } from 'react-native';

import theme from '../../theme';

export default function Avatar ({ size, source }) {
type Props = {
size?: number,
source: string,
};

export default function Avatar ({ size = 44, source }: Props) {
const styles = {
wrapper: {
backgroundColor: theme.color.sceneBg,
Expand All @@ -27,11 +33,3 @@ export default function Avatar ({ size, source }) {
</View>
);
};

Avatar.propTypes = {
size: PropTypes.number,
source: PropTypes.string,
};
Avatar.defaultProps = {
size: 44,
};
38 changes: 25 additions & 13 deletions app/components/DraggableView/index.js
@@ -1,10 +1,34 @@
// @flow
import React, { Component, PropTypes } from 'react';
import { Animated, PanResponder } from 'react-native';

const SWIPE_THRESHOLD = 80;

type Props = {
allowX: boolean,
allowY: boolean,
onMove?: () => mixed,
onRelease: () => mixed,
children?: Array<React.Element<mixed>>,
};

type State = {
pan: Animated.Value,
};

export default class DraggableView extends Component {
constructor (props) {
props: Props;
state: State;

_panResponder: PanResponder;

static defaultProps = {
allowX: true,
allowY: true,
style: {},
};

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

this.state = {
Expand Down Expand Up @@ -54,15 +78,3 @@ export default class DraggableView extends Component {
);
}
};

DraggableView.propTypes = {
allowX: PropTypes.bool,
allowY: PropTypes.bool,
onMove: PropTypes.func,
onRelease: PropTypes.func,
};
DraggableView.defaultProps = {
allowX: true,
allowY: true,
style: {},
};
13 changes: 7 additions & 6 deletions app/components/ListTitle/index.js
@@ -1,9 +1,15 @@
// @flow
import React, { PropTypes } from 'react';
import { PixelRatio, Text, View } from 'react-native';

import theme from '../../theme';

export default function ListTitle ({ bordered, text }) {
type Props = {
bordered?: boolean,
text: string,
};

export default function ListTitle ({ bordered, text }: Props) {
const styles = {
text: {
color: theme.color.text,
Expand Down Expand Up @@ -31,8 +37,3 @@ export default function ListTitle ({ bordered, text }) {
</View>
);
};

ListTitle.propTypes = {
bordered: PropTypes.bool,
text: PropTypes.string.isRequired,
};

0 comments on commit 8c99793

Please sign in to comment.