├── .watchmanconfig
├── .gitignore
├── App.js
├── .DS_Store
├── app
├── .DS_Store
├── components
│ ├── Logo
│ │ ├── index.js
│ │ ├── images
│ │ │ ├── logo.png
│ │ │ ├── logo@2x.png
│ │ │ ├── logo@3x.png
│ │ │ ├── background.png
│ │ │ ├── background@2x.png
│ │ │ └── background@3x.png
│ │ ├── styles.js
│ │ └── Logo.js
│ ├── .DS_Store
│ ├── Header
│ │ ├── index.js
│ │ ├── images
│ │ │ ├── gear.png
│ │ │ ├── gear@2x.png
│ │ │ └── gear@3x.png
│ │ ├── styles.js
│ │ └── Header.js
│ ├── Container
│ │ ├── index.js
│ │ ├── styles.js
│ │ └── Container.js
│ ├── Button
│ │ ├── .DS_Store
│ │ ├── index.js
│ │ ├── images
│ │ │ ├── icon.png
│ │ │ ├── icon@2x.png
│ │ │ └── icon@3x.png
│ │ ├── styles.js
│ │ └── ClearButton.js
│ ├── Text
│ │ ├── index.js
│ │ ├── styles.js
│ │ └── LastConverted.js
│ ├── List
│ │ ├── images
│ │ │ ├── check.png
│ │ │ ├── check@2x.png
│ │ │ └── check@3x.png
│ │ ├── index.js
│ │ ├── Separator.js
│ │ ├── styles.js
│ │ ├── Icon.js
│ │ └── ListItem.js
│ ├── TextInput
│ │ ├── index.js
│ │ ├── styles.js
│ │ └── InputWithButton.js
│ └── Alert
│ │ ├── index.js
│ │ ├── connectAlert.js
│ │ └── AlertProvider.js
├── actions
│ ├── theme.js
│ └── currencies.js
├── reducers
│ ├── index.js
│ ├── theme.js
│ └── currencies.js
├── data
│ └── currencies.js
├── config
│ ├── store.js
│ ├── sagas.js
│ └── routes.js
├── index.js
└── screens
│ ├── Options.js
│ ├── Themes.js
│ ├── CurrencyList.js
│ └── Home.js
├── app.json
├── .babelrc
├── .vscode
└── settings.json
├── jsconfig.json
├── App.test.js
├── .eslintrc.json
├── .upgrade-info
└── branches.txt
├── package.json
├── .flowconfig
└── README.md
/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .expo/
3 | npm-debug.*
4 |
--------------------------------------------------------------------------------
/App.js:
--------------------------------------------------------------------------------
1 | import App from './app/index';
2 |
3 | export default App;
4 |
--------------------------------------------------------------------------------
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/.DS_Store
--------------------------------------------------------------------------------
/app/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/.DS_Store
--------------------------------------------------------------------------------
/app/components/Logo/index.js:
--------------------------------------------------------------------------------
1 | import Logo from './Logo';
2 | import styles from './styles';
3 |
4 | export { Logo, styles };
5 |
--------------------------------------------------------------------------------
/app/components/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/.DS_Store
--------------------------------------------------------------------------------
/app/components/Header/index.js:
--------------------------------------------------------------------------------
1 | import Header from './Header';
2 | import styles from './styles';
3 |
4 | export { Header, styles };
5 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "expo": {
3 | "sdkVersion": "23.0.0",
4 | "orientation": "portrait",
5 | "privacy": "public"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/app/components/Container/index.js:
--------------------------------------------------------------------------------
1 | import Container from './Container';
2 | import styles from './styles';
3 |
4 | export { Container, styles };
5 |
--------------------------------------------------------------------------------
/app/components/Button/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Button/.DS_Store
--------------------------------------------------------------------------------
/app/components/Button/index.js:
--------------------------------------------------------------------------------
1 | import ClearButton from './ClearButton';
2 | import styles from './styles';
3 |
4 | export { ClearButton, styles };
5 |
--------------------------------------------------------------------------------
/app/components/Text/index.js:
--------------------------------------------------------------------------------
1 | import LastConverted from './LastConverted';
2 | import styles from './styles';
3 |
4 | export { LastConverted, styles };
5 |
--------------------------------------------------------------------------------
/app/components/Button/images/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Button/images/icon.png
--------------------------------------------------------------------------------
/app/components/Header/images/gear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Header/images/gear.png
--------------------------------------------------------------------------------
/app/components/List/images/check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/List/images/check.png
--------------------------------------------------------------------------------
/app/components/Logo/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Logo/images/logo.png
--------------------------------------------------------------------------------
/app/components/List/images/check@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/List/images/check@2x.png
--------------------------------------------------------------------------------
/app/components/List/images/check@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/List/images/check@3x.png
--------------------------------------------------------------------------------
/app/components/Logo/images/logo@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Logo/images/logo@2x.png
--------------------------------------------------------------------------------
/app/components/Logo/images/logo@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Logo/images/logo@3x.png
--------------------------------------------------------------------------------
/app/components/TextInput/index.js:
--------------------------------------------------------------------------------
1 | import InputWithButton from './InputWithButton';
2 | import styles from './styles';
3 |
4 | export { InputWithButton, styles };
5 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["babel-preset-expo"],
3 | "env": {
4 | "development": {
5 | "plugins": ["transform-react-jsx-source"]
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/app/components/Button/images/icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Button/images/icon@2x.png
--------------------------------------------------------------------------------
/app/components/Button/images/icon@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Button/images/icon@3x.png
--------------------------------------------------------------------------------
/app/components/Header/images/gear@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Header/images/gear@2x.png
--------------------------------------------------------------------------------
/app/components/Header/images/gear@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Header/images/gear@3x.png
--------------------------------------------------------------------------------
/app/components/Logo/images/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Logo/images/background.png
--------------------------------------------------------------------------------
/app/components/Alert/index.js:
--------------------------------------------------------------------------------
1 | import AlertProvider from './AlertProvider';
2 | import connectAlert from './connectAlert';
3 |
4 | export { AlertProvider, connectAlert };
5 |
--------------------------------------------------------------------------------
/app/components/Logo/images/background@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Logo/images/background@2x.png
--------------------------------------------------------------------------------
/app/components/Logo/images/background@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HandlebarLabs/react-native-apps-to-production-starter/HEAD/app/components/Logo/images/background@3x.png
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "prettier.eslintIntegration": true,
4 | "editor.formatOnSave": true
5 | }
6 |
--------------------------------------------------------------------------------
/app/actions/theme.js:
--------------------------------------------------------------------------------
1 | export const CHANGE_PRIMARY_COLOR = 'CHANGE_PRIMARY_COLOR';
2 |
3 | export const changePrimaryColor = color => ({
4 | type: CHANGE_PRIMARY_COLOR,
5 | color,
6 | });
7 |
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "allowSyntheticDefaultImports": true
5 | },
6 | "exclude": [
7 | "node_modules"
8 | ]
9 | }
--------------------------------------------------------------------------------
/app/components/List/index.js:
--------------------------------------------------------------------------------
1 | import ListItem from './ListItem';
2 | import styles from './styles';
3 | import Separator from './Separator';
4 | import Icon from './Icon';
5 |
6 | export { ListItem, styles, Separator, Icon };
7 |
--------------------------------------------------------------------------------
/app/reducers/index.js:
--------------------------------------------------------------------------------
1 | import { combineReducers } from 'redux';
2 |
3 | import currencies from './currencies';
4 | import theme from './theme';
5 |
6 | export default combineReducers({
7 | currencies,
8 | theme,
9 | });
10 |
--------------------------------------------------------------------------------
/app/components/List/Separator.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { View } from 'react-native';
3 |
4 | import styles from './styles';
5 |
6 | const Separator = () => ;
7 |
8 | export default Separator;
9 |
--------------------------------------------------------------------------------
/app/components/Text/styles.js:
--------------------------------------------------------------------------------
1 | import EStyleSheet from 'react-native-extended-stylesheet';
2 |
3 | export default EStyleSheet.create({
4 | smallText: {
5 | color: '$white',
6 | textAlign: 'center',
7 | fontSize: 12,
8 | },
9 | });
10 |
--------------------------------------------------------------------------------
/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import App from './App';
3 |
4 | import renderer from 'react-test-renderer';
5 |
6 | it('renders without crashing', () => {
7 | const rendered = renderer.create().toJSON();
8 | expect(rendered).toBeTruthy();
9 | });
10 |
--------------------------------------------------------------------------------
/app/components/Container/styles.js:
--------------------------------------------------------------------------------
1 | import EStyleSheet from 'react-native-extended-stylesheet';
2 |
3 | export default EStyleSheet.create({
4 | container: {
5 | flex: 1,
6 | alignItems: 'center',
7 | justifyContent: 'center',
8 | backgroundColor: '$primaryBlue',
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/app/reducers/theme.js:
--------------------------------------------------------------------------------
1 | import { CHANGE_PRIMARY_COLOR } from '../actions/theme';
2 |
3 | const initialState = {
4 | primaryColor: '#4F6D7A',
5 | };
6 |
7 | export default (state = initialState, action) => {
8 | switch (action.type) {
9 | case CHANGE_PRIMARY_COLOR:
10 | return { ...state, primaryColor: action.color };
11 | default:
12 | return state;
13 | }
14 | };
15 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "airbnb",
3 | "parser": "babel-eslint",
4 | "env": {
5 | "browser": true
6 | },
7 | "plugins": ["react"],
8 | "rules": {
9 | "react/jsx-filename-extension": [
10 | 2,
11 | {
12 | "extensions": [".js", ".jsx"]
13 | }
14 | ],
15 | "react/forbid-prop-types": [0],
16 | "react/require-default-props": [0],
17 | "global-require": [0]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/components/Header/styles.js:
--------------------------------------------------------------------------------
1 | import EStyleSheet from 'react-native-extended-stylesheet';
2 |
3 | export default EStyleSheet.create({
4 | container: {
5 | position: 'absolute',
6 | left: 0,
7 | top: 0,
8 | right: 0,
9 | '@media ios': {
10 | paddingTop: 20,
11 | },
12 | },
13 | button: {
14 | alignSelf: 'flex-end',
15 | paddingVertical: 5,
16 | paddingHorizontal: 20,
17 | },
18 | icon: {
19 | width: 18,
20 | },
21 | });
22 |
--------------------------------------------------------------------------------
/app/data/currencies.js:
--------------------------------------------------------------------------------
1 | export default [
2 | 'AUD',
3 | 'BGN',
4 | 'BRL',
5 | 'CAD',
6 | 'CHF',
7 | 'CNY',
8 | 'CZK',
9 | 'DKK',
10 | 'EUR',
11 | 'GBP',
12 | 'HKD',
13 | 'HRK',
14 | 'HUF',
15 | 'IDR',
16 | 'ILS',
17 | 'INR',
18 | 'JPY',
19 | 'KRW',
20 | 'MXN',
21 | 'MYR',
22 | 'NOK',
23 | 'NZD',
24 | 'PHP',
25 | 'PLN',
26 | 'RON',
27 | 'RUB',
28 | 'SEK',
29 | 'SGD',
30 | 'THB',
31 | 'TRY',
32 | 'USD',
33 | 'ZAR',
34 | ];
35 |
--------------------------------------------------------------------------------
/app/components/Button/styles.js:
--------------------------------------------------------------------------------
1 | import EStyleSheet from 'react-native-extended-stylesheet';
2 |
3 | export default EStyleSheet.create({
4 | container: {
5 | alignItems: 'center',
6 | },
7 | wrapper: {
8 | flexDirection: 'row',
9 | alignItems: 'center',
10 | },
11 | icon: {
12 | width: 19,
13 | marginRight: 11,
14 | },
15 | text: {
16 | color: '$white',
17 | fontSize: 14,
18 | paddingVertical: 20,
19 | fontWeight: '300',
20 | },
21 | });
22 |
--------------------------------------------------------------------------------
/app/config/store.js:
--------------------------------------------------------------------------------
1 | import { createStore, applyMiddleware } from 'redux';
2 | import logger from 'redux-logger';
3 | import createSagaMiddleware from 'redux-saga';
4 |
5 | import reducer from '../reducers';
6 | import rootSaga from './sagas';
7 |
8 | const sagaMiddleware = createSagaMiddleware();
9 | const middleware = [sagaMiddleware];
10 | if (process.env.NODE_ENV === 'development') {
11 | middleware.push(logger);
12 | }
13 |
14 | const store = createStore(reducer, applyMiddleware(...middleware));
15 |
16 | sagaMiddleware.run(rootSaga);
17 |
18 | export default store;
19 |
--------------------------------------------------------------------------------
/app/components/Header/Header.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React from 'react';
3 | import { View, Image, TouchableOpacity } from 'react-native';
4 |
5 | import styles from './styles';
6 |
7 | const Header = ({ onPress }) => (
8 |
9 |
10 |
11 |
12 |
13 | );
14 |
15 | Header.propTypes = {
16 | onPress: PropTypes.func,
17 | };
18 |
19 | export default Header;
20 |
--------------------------------------------------------------------------------
/app/components/Container/Container.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React from 'react';
3 | import { View } from 'react-native';
4 |
5 | import styles from './styles';
6 |
7 | const Container = ({ children, backgroundColor }) => {
8 | const containerStyles = [styles.container];
9 | if (backgroundColor) {
10 | containerStyles.push({ backgroundColor });
11 | }
12 | return (
13 |
14 | {children}
15 |
16 | );
17 | };
18 |
19 | Container.propTypes = {
20 | children: PropTypes.any,
21 | backgroundColor: PropTypes.string,
22 | };
23 |
24 | export default Container;
25 |
--------------------------------------------------------------------------------
/app/components/Text/LastConverted.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React from 'react';
3 | import { Text } from 'react-native';
4 | import moment from 'moment';
5 |
6 | import styles from './styles';
7 |
8 | const LastConverted = ({ date, base, quote, conversionRate }) => (
9 |
10 | 1 {base} = {conversionRate} {quote} as of {moment(date).format('MMMM D, YYYY')}
11 |
12 | );
13 |
14 | LastConverted.propTypes = {
15 | date: PropTypes.object,
16 | base: PropTypes.string,
17 | quote: PropTypes.string,
18 | conversionRate: PropTypes.number,
19 | };
20 |
21 | export default LastConverted;
22 |
--------------------------------------------------------------------------------
/app/components/Button/ClearButton.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React from 'react';
3 | import { Text, TouchableOpacity, Image, View } from 'react-native';
4 |
5 | import styles from './styles';
6 |
7 | const ClearButton = ({ text, onPress }) => (
8 |
9 |
10 |
11 | {text}
12 |
13 |
14 | );
15 |
16 | ClearButton.propTypes = {
17 | text: PropTypes.string,
18 | onPress: PropTypes.func,
19 | };
20 |
21 | export default ClearButton;
22 |
--------------------------------------------------------------------------------
/app/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import EStyleSheet from 'react-native-extended-stylesheet';
3 | import { Provider } from 'react-redux';
4 |
5 | import Navigator from './config/routes';
6 | import { AlertProvider } from './components/Alert';
7 | import store from './config/store';
8 |
9 | EStyleSheet.build({
10 | $primaryBlue: '#4F6D7A',
11 | $primaryOrange: '#D57A66',
12 | $primaryGreen: '#00BD9D',
13 | $primaryPurple: '#9E768F',
14 |
15 | $white: '#FFFFFF',
16 | $lightGray: '#F0F0F0',
17 | $border: '#E2E2E2',
18 | $inputText: '#797979',
19 | $darkText: '#343434',
20 | });
21 |
22 | export default () => (
23 |
24 |
25 |
26 |
27 |
28 | );
29 |
--------------------------------------------------------------------------------
/app/components/Alert/connectAlert.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable react/prefer-stateless-function */
2 | import PropTypes from 'prop-types';
3 |
4 | import React, { Component } from 'react';
5 | import hoistNonReactStatic from 'hoist-non-react-statics';
6 |
7 | const connectAlert = (WrappedComponent) => {
8 | class ConnectedAlert extends Component {
9 | render() {
10 | return (
11 |
16 | );
17 | }
18 | }
19 |
20 | ConnectedAlert.contextTypes = {
21 | alertWithType: PropTypes.func,
22 | alert: PropTypes.func,
23 | };
24 |
25 | return hoistNonReactStatic(ConnectedAlert, WrappedComponent);
26 | };
27 |
28 | export default connectAlert;
29 |
--------------------------------------------------------------------------------
/app/components/Logo/styles.js:
--------------------------------------------------------------------------------
1 | import { Dimensions } from 'react-native';
2 | import EStyleSheet from 'react-native-extended-stylesheet';
3 |
4 | const imageWidth = Dimensions.get('window').width / 2;
5 |
6 | export default EStyleSheet.create({
7 | $smallContainerSize: imageWidth / 2,
8 | $smallImageSize: imageWidth / 4,
9 | $largeContainerSize: imageWidth,
10 | $largeImageSize: imageWidth / 2,
11 | container: {
12 | alignItems: 'center',
13 | },
14 | containerImage: {
15 | alignItems: 'center',
16 | justifyContent: 'center',
17 | width: '$largeContainerSize',
18 | height: '$largeContainerSize',
19 | },
20 | logo: {
21 | width: '$largeImageSize',
22 | tintColor: '$primaryBlue',
23 | },
24 | text: {
25 | color: '$white',
26 | fontSize: 28,
27 | letterSpacing: -0.5,
28 | marginTop: 15,
29 | fontWeight: '600',
30 | },
31 | });
32 |
--------------------------------------------------------------------------------
/app/components/List/styles.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet } from 'react-native';
2 | import EStyleSheet from 'react-native-extended-stylesheet';
3 |
4 | export default EStyleSheet.create({
5 | $underlayColor: '$border',
6 | row: {
7 | paddingHorizontal: 20,
8 | paddingVertical: 16,
9 | justifyContent: 'space-between',
10 | alignItems: 'center',
11 | flexDirection: 'row',
12 | backgroundColor: '$white',
13 | },
14 | text: {
15 | color: '$darkText',
16 | fontSize: 16,
17 | },
18 | separator: {
19 | backgroundColor: '$border',
20 | height: StyleSheet.hairlineWidth,
21 | flex: 1,
22 | marginLeft: 20,
23 | },
24 | icon: {
25 | backgroundColor: 'transparent',
26 | borderRadius: 15,
27 | width: 30,
28 | height: 30,
29 | alignItems: 'center',
30 | justifyContent: 'center',
31 | },
32 | iconVisible: {
33 | backgroundColor: '$primaryBlue',
34 | },
35 | checkIcon: {
36 | width: 18,
37 | },
38 | });
39 |
--------------------------------------------------------------------------------
/app/actions/currencies.js:
--------------------------------------------------------------------------------
1 | export const CHANGE_CURRENCY_AMOUNT = 'CHANGE_CURRENCY_AMOUNT';
2 | export const SWAP_CURRENCY = 'SWAP_CURRENCY';
3 | export const CHANGE_BASE_CURRENCY = 'CHANGE_BASE_CURRENCY';
4 | export const CHANGE_QUOTE_CURRENCY = 'CHANGE_QUOTE_CURRENCY';
5 | export const GET_INITIAL_CONVERSION = 'GET_INITIAL_CONVERSION';
6 |
7 | export const CONVERSION_RESULT = 'CONVERSION_RESULT';
8 | export const CONVERSION_ERROR = 'CONVERSION_ERROR';
9 |
10 | export const getInitialConversion = () => ({
11 | type: GET_INITIAL_CONVERSION,
12 | });
13 |
14 | export const changeCurrencyAmount = amount => ({
15 | type: CHANGE_CURRENCY_AMOUNT,
16 | amount: parseFloat(amount),
17 | });
18 |
19 | export const swapCurrency = () => ({
20 | type: SWAP_CURRENCY,
21 | });
22 |
23 | export const changeBaseCurrency = currency => ({
24 | type: CHANGE_BASE_CURRENCY,
25 | currency,
26 | });
27 |
28 | export const changeQuoteCurrency = currency => ({
29 | type: CHANGE_QUOTE_CURRENCY,
30 | currency,
31 | });
32 |
--------------------------------------------------------------------------------
/app/components/Alert/AlertProvider.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React, { Component } from 'react';
3 | import { View } from 'react-native';
4 | import DropdownAlert from 'react-native-dropdownalert';
5 |
6 | class AlertProvider extends Component {
7 | static childContextTypes = {
8 | alertWithType: PropTypes.func,
9 | alert: PropTypes.func,
10 | };
11 |
12 | static propTypes = {
13 | children: PropTypes.any,
14 | };
15 |
16 | getChildContext() {
17 | return {
18 | alert: (...args) => this.dropdown.alert(...args),
19 | alertWithType: (...args) => this.dropdown.alertWithType(...args),
20 | };
21 | }
22 |
23 | render() {
24 | return (
25 |
26 | {React.Children.only(this.props.children)}
27 | {
29 | this.dropdown = ref;
30 | }}
31 | />
32 |
33 | );
34 | }
35 | }
36 |
37 | export default AlertProvider;
38 |
--------------------------------------------------------------------------------
/app/components/List/Icon.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React from 'react';
3 | import { View, Image } from 'react-native';
4 |
5 | import styles from './styles';
6 |
7 | const Icon = ({ visible, checkmark, iconBackground }) => {
8 | if (visible) {
9 | const iconStyles = [styles.icon];
10 | if (visible) {
11 | iconStyles.push(styles.iconVisible);
12 | }
13 | if (iconBackground) {
14 | iconStyles.push({ backgroundColor: iconBackground });
15 | }
16 | return (
17 |
18 | {checkmark
19 | ?
24 | : null}
25 |
26 | );
27 | }
28 |
29 | return ;
30 | };
31 |
32 | Icon.propTypes = {
33 | visible: PropTypes.bool,
34 | checkmark: PropTypes.bool,
35 | iconBackground: PropTypes.string,
36 | };
37 |
38 | export default Icon;
39 |
--------------------------------------------------------------------------------
/.upgrade-info/branches.txt:
--------------------------------------------------------------------------------
1 | master
2 | module-1
3 | module-1-lesson-2-packages
4 | module-1-lesson-3-network
5 | module-1-lesson-4-display-status
6 | module-1-lesson-5-persist
7 | module-1-lesson-6-error-offline
8 | module-1-lesson-7-clear-errors
9 | module-2
10 | module-2-lesson-2-flash-input
11 | module-2-lesson-3-animate-in
12 | module-2-lesson-4-disable
13 | module-3
14 | module-3-lesson-3-setup
15 | module-3-lesson-4-coverage
16 | module-3-lesson-5-organizing
17 | module-3-lesson-6-snapshot
18 | module-3-lesson-7-build-styles
19 | module-3-lesson-8-actions
20 | module-3-lesson-9-reducers
21 | module-3-lesson-10-interactions
22 | module-3-lesson-11-screens
23 | module-4
24 | module-4-lesson-5-ejecting
25 | module-4-lesson-7-ios-icon
26 | module-4-lesson-8-ios-splash
27 | module-4-lesson-9-ios-prep
28 | module-4-lesson-10-ios-create
29 | module-4-lesson-12-android-icon
30 | module-4-lesson-13-android-splash
31 | module-4-lesson-14-android-prep
32 | module-5
33 | module-5-lesson-2-fastlane-ios
34 | module-5-lesson-4-fastlane-android
35 | module-5-lesson-7-codepush
36 |
--------------------------------------------------------------------------------
/app/components/List/ListItem.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React from 'react';
3 | import { View, Text, TouchableHighlight } from 'react-native';
4 |
5 | import styles from './styles';
6 | import Icon from './Icon';
7 |
8 | const ListItem = ({
9 | text,
10 | onPress,
11 | checkmark = true,
12 | selected = false,
13 | visible = true,
14 | customIcon = null,
15 | iconBackground,
16 | }) => (
17 |
18 |
19 | {text}
20 | {selected
21 | ?
22 | : }
23 | {customIcon}
24 |
25 |
26 | );
27 |
28 | ListItem.propTypes = {
29 | text: PropTypes.string,
30 | onPress: PropTypes.func,
31 | checkmark: PropTypes.bool,
32 | selected: PropTypes.bool,
33 | visible: PropTypes.bool,
34 | customIcon: PropTypes.element,
35 | iconBackground: PropTypes.string,
36 | };
37 |
38 | export default ListItem;
39 |
--------------------------------------------------------------------------------
/app/config/sagas.js:
--------------------------------------------------------------------------------
1 | import { takeEvery, call, put, select } from 'redux-saga/effects';
2 |
3 | import {
4 | CHANGE_BASE_CURRENCY,
5 | GET_INITIAL_CONVERSION,
6 | SWAP_CURRENCY,
7 | CONVERSION_RESULT,
8 | CONVERSION_ERROR,
9 | } from '../actions/currencies';
10 |
11 | export const getLatestRate = currency => fetch(`http://api.fixer.io/latest?base=${currency}`);
12 |
13 | const fetchLatestConversionRates = function* (action) {
14 | try {
15 | let currency = action.currency;
16 | if (currency === undefined) {
17 | currency = yield select(state => state.currencies.baseCurrency);
18 | }
19 | const response = yield call(getLatestRate, currency);
20 | const result = yield response.json();
21 | if (result.error) {
22 | yield put({ type: CONVERSION_ERROR, error: result.error });
23 | } else {
24 | yield put({ type: CONVERSION_RESULT, result });
25 | }
26 | } catch (error) {
27 | yield put({ type: CONVERSION_ERROR, error: error.message });
28 | }
29 | };
30 |
31 | const rootSaga = function* () {
32 | yield takeEvery(GET_INITIAL_CONVERSION, fetchLatestConversionRates);
33 | yield takeEvery(CHANGE_BASE_CURRENCY, fetchLatestConversionRates);
34 | yield takeEvery(SWAP_CURRENCY, fetchLatestConversionRates);
35 | };
36 |
37 | export default rootSaga;
38 |
--------------------------------------------------------------------------------
/app/components/TextInput/styles.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet } from 'react-native';
2 | import EStyleSheet from 'react-native-extended-stylesheet';
3 |
4 | const INPUT_HEIGHT = 48;
5 | const BORDER_RADIUS = 4;
6 |
7 | export default EStyleSheet.create({
8 | $buttonBackgroundColorBase: '$white',
9 | $buttonBackgroundColorModifier: 0.1,
10 | container: {
11 | backgroundColor: '$white',
12 | width: '90%',
13 | height: INPUT_HEIGHT,
14 | flexDirection: 'row',
15 | alignItems: 'center',
16 | borderRadius: BORDER_RADIUS,
17 | marginVertical: 11,
18 | },
19 | containerDisabled: {
20 | backgroundColor: '$lightGray',
21 | },
22 | buttonContainer: {
23 | height: INPUT_HEIGHT,
24 | alignItems: 'center',
25 | justifyContent: 'center',
26 | backgroundColor: '$white',
27 | borderTopLeftRadius: BORDER_RADIUS,
28 | borderBottomLeftRadius: BORDER_RADIUS,
29 | },
30 | buttonText: {
31 | fontWeight: '600',
32 | fontSize: 20,
33 | paddingHorizontal: 16,
34 | color: '$primaryBlue',
35 | },
36 | separator: {
37 | height: INPUT_HEIGHT,
38 | width: StyleSheet.hairlineWidth,
39 | backgroundColor: '$border',
40 | },
41 | input: {
42 | flex: 1,
43 | height: INPUT_HEIGHT,
44 | borderTopRightRadius: BORDER_RADIUS,
45 | paddingHorizontal: 8,
46 | color: '$inputText',
47 | fontSize: 18,
48 | },
49 | });
50 |
--------------------------------------------------------------------------------
/app/config/routes.js:
--------------------------------------------------------------------------------
1 | import { StatusBar } from 'react-native';
2 | import { StackNavigator } from 'react-navigation';
3 |
4 | import Home from '../screens/Home';
5 | import CurrencyList from '../screens/CurrencyList';
6 | import Options from '../screens/Options';
7 | import Themes from '../screens/Themes';
8 |
9 | const HomeStack = StackNavigator(
10 | {
11 | Home: {
12 | screen: Home,
13 | navigationOptions: {
14 | header: () => null,
15 | headerTitle: 'Home',
16 | },
17 | },
18 | Options: {
19 | screen: Options,
20 | navigationOptions: {
21 | headerTitle: 'Options',
22 | },
23 | },
24 | Themes: {
25 | screen: Themes,
26 | navigationOptions: {
27 | headerTitle: 'Themes',
28 | },
29 | },
30 | },
31 | {
32 | headerMode: 'screen',
33 | },
34 | );
35 |
36 | const CurrencyListStack = StackNavigator({
37 | CurrencyList: {
38 | screen: CurrencyList,
39 | navigationOptions: ({ navigation }) => ({
40 | headerTitle: navigation.state.params.title,
41 | }),
42 | },
43 | });
44 |
45 | export default StackNavigator(
46 | {
47 | Home: {
48 | screen: HomeStack,
49 | },
50 | CurrencyList: {
51 | screen: CurrencyListStack,
52 | },
53 | },
54 | {
55 | mode: 'modal',
56 | headerMode: 'none',
57 | cardStyle: { paddingTop: StatusBar.currentHeight },
58 | },
59 | );
60 |
--------------------------------------------------------------------------------
/app/components/TextInput/InputWithButton.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React from 'react';
3 | import { View, TextInput, TouchableHighlight, Text } from 'react-native';
4 | import color from 'color';
5 |
6 | import styles from './styles';
7 |
8 | const InputWithButton = (props) => {
9 | const underlayColor = color(styles.$buttonBackgroundColorBase).darken(
10 | styles.$buttonBackgroundColorModifier,
11 | );
12 |
13 | const containerStyles = [styles.container];
14 | if (props.editable === false) {
15 | containerStyles.push(styles.containerDisabled);
16 | }
17 |
18 | const buttonTextStyles = [styles.buttonText];
19 | if (props.textColor) {
20 | buttonTextStyles.push({ color: props.textColor });
21 | }
22 |
23 | return (
24 |
25 |
30 | {props.buttonText}
31 |
32 |
33 |
34 |
35 | );
36 | };
37 |
38 | InputWithButton.propTypes = {
39 | onPress: PropTypes.func,
40 | buttonText: PropTypes.string,
41 | editable: PropTypes.bool,
42 | textColor: PropTypes.string,
43 | };
44 |
45 | export default InputWithButton;
46 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "CurrencyConverter-Starter",
3 | "version": "0.1.0",
4 | "private": true,
5 | "devDependencies": {
6 | "babel-eslint": "^8.0.2",
7 | "eslint": "^4.12.0",
8 | "eslint-config-airbnb": "^16.1.0",
9 | "eslint-plugin-import": "^2.7.0",
10 | "eslint-plugin-jsx-a11y": "^6.0.2",
11 | "eslint-plugin-react": "^7.5.1",
12 | "jest-expo": "^23.0.0",
13 | "prettier": "^1.5.3",
14 | "prettier-eslint": "^8.2.2",
15 | "react-native-scripts": "1.7.0",
16 | "react-test-renderer": "^16.1.1"
17 | },
18 | "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
19 | "scripts": {
20 | "start": "react-native-scripts start",
21 | "eject": "react-native-scripts eject",
22 | "android": "react-native-scripts android",
23 | "ios": "react-native-scripts ios",
24 | "test": "node node_modules/jest/bin/jest.js --watch",
25 | "lint": "eslint app/",
26 | "lint:fix": "eslint app/ --fix"
27 | },
28 | "jest": {
29 | "preset": "jest-expo"
30 | },
31 | "dependencies": {
32 | "@expo/vector-icons": "^6.2.0",
33 | "color": "^2.0.0",
34 | "expo": "^23.0.2",
35 | "hoist-non-react-statics": "^2.3.0",
36 | "moment": "^2.18.1",
37 | "prop-types": "^15.5.10",
38 | "react": "^16.1.1",
39 | "react-native": "^0.50.4",
40 | "react-native-dropdownalert": "^3.1.2",
41 | "react-native-extended-stylesheet": "^0.8.0",
42 | "react-navigation": "^1.0.0-beta.21",
43 | "react-redux": "^5.0.4",
44 | "redux": "^3.7.2",
45 | "redux-logger": "^3.0.1",
46 | "redux-saga": "^0.15.3"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/screens/Options.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React, { Component } from 'react';
3 | import { ScrollView, StatusBar, Platform, Linking } from 'react-native';
4 | import { Ionicons } from '@expo/vector-icons';
5 | import { ListItem, Separator } from '../components/List';
6 | import { connectAlert } from '../components/Alert';
7 |
8 | const ICON_PREFIX = Platform.OS === 'ios' ? 'ios' : 'md';
9 | const ICON_COLOR = '#868686';
10 | const ICON_SIZE = 23;
11 |
12 | class Options extends Component {
13 | static propTypes = {
14 | navigation: PropTypes.object,
15 | alertWithType: PropTypes.func,
16 | };
17 |
18 | handlePressThemes = () => {
19 | this.props.navigation.navigate('Themes');
20 | };
21 |
22 | handlePressSite = () => {
23 | Linking.openURL('http://fixer.io').catch(() =>
24 | this.props.alertWithType('error', 'Sorry!', "Fixer.io can't be opened right now."),
25 | );
26 | };
27 |
28 | render() {
29 | return (
30 |
31 |
32 |
37 | }
38 | />
39 |
40 | }
44 | />
45 |
46 |
47 | );
48 | }
49 | }
50 | export default connectAlert(Options);
51 |
--------------------------------------------------------------------------------
/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | ; We fork some components by platform
3 | .*/*[.]android.js
4 |
5 | ; Ignore "BUCK" generated dirs
6 | /\.buckd/
7 |
8 | ; Ignore unexpected extra "@providesModule"
9 | .*/node_modules/.*/node_modules/fbjs/.*
10 |
11 | ; Ignore duplicate module providers
12 | ; For RN Apps installed via npm, "Libraries" folder is inside
13 | ; "node_modules/react-native" but in the source repo it is in the root
14 | .*/Libraries/react-native/React.js
15 | .*/Libraries/react-native/ReactNative.js
16 |
17 | ; Additional create-react-native-app ignores
18 |
19 | ; Ignore duplicate module providers
20 | .*/node_modules/fbemitter/lib/*
21 |
22 | ; Ignore misbehaving dev-dependencies
23 | .*/node_modules/xdl/build/*
24 | .*/node_modules/reqwest/tests/*
25 |
26 | ; Ignore missing expo-sdk dependencies (temporarily)
27 | ; https://github.com/exponent/exponent-sdk/issues/36
28 | .*/node_modules/expo/src/*
29 |
30 | ; Ignore react-native-fbads dependency of the expo sdk
31 | .*/node_modules/react-native-fbads/*
32 |
33 | [include]
34 |
35 | [libs]
36 | node_modules/react-native/Libraries/react-native/react-native-interface.js
37 | node_modules/react-native/flow
38 | flow/
39 |
40 | [options]
41 | module.system=haste
42 |
43 | emoji=true
44 |
45 | experimental.strict_type_args=true
46 |
47 | munge_underscores=true
48 |
49 | 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'
50 |
51 | suppress_type=$FlowIssue
52 | suppress_type=$FlowFixMe
53 | suppress_type=$FixMe
54 |
55 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-0]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
56 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-0]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
57 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
58 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
59 |
60 | unsafe.enable_getters_and_setters=true
61 |
62 | [version]
63 | ^0.40.0
64 |
--------------------------------------------------------------------------------
/app/screens/Themes.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React, { Component } from 'react';
3 | import { ScrollView, StatusBar } from 'react-native';
4 | import EStyleSheet from 'react-native-extended-stylesheet';
5 | import { connect } from 'react-redux';
6 |
7 | import { ListItem, Separator } from '../components/List';
8 | import { changePrimaryColor } from '../actions/theme';
9 |
10 | const styles = EStyleSheet.create({
11 | $blue: '$primaryBlue',
12 | $orange: '$primaryOrange',
13 | $green: '$primaryGreen',
14 | $purple: '$primaryPurple',
15 | });
16 |
17 | class Themes extends Component {
18 | static propTypes = {
19 | navigation: PropTypes.object,
20 | dispatch: PropTypes.func,
21 | };
22 |
23 | handlePressTheme = (color) => {
24 | this.props.dispatch(changePrimaryColor(color));
25 | this.props.navigation.goBack();
26 | };
27 |
28 | render() {
29 | return (
30 |
31 |
32 | this.handlePressTheme(styles.$blue)}
35 | selected
36 | checkmark={false}
37 | iconBackground={styles.$blue}
38 | />
39 |
40 | this.handlePressTheme(styles.$orange)}
43 | selected
44 | checkmark={false}
45 | iconBackground={styles.$orange}
46 | />
47 |
48 | this.handlePressTheme(styles.$green)}
51 | selected
52 | checkmark={false}
53 | iconBackground={styles.$green}
54 | />
55 |
56 | this.handlePressTheme(styles.$purple)}
59 | selected
60 | checkmark={false}
61 | iconBackground={styles.$purple}
62 | />
63 |
64 |
65 | );
66 | }
67 | }
68 | export default connect()(Themes);
69 |
--------------------------------------------------------------------------------
/app/screens/CurrencyList.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React, { Component } from 'react';
3 | import { FlatList, StatusBar, View } from 'react-native';
4 | import { connect } from 'react-redux';
5 |
6 | import { ListItem, Separator } from '../components/List';
7 | import currencies from '../data/currencies';
8 | import { changeBaseCurrency, changeQuoteCurrency } from '../actions/currencies';
9 |
10 | class CurrencyList extends Component {
11 | static propTypes = {
12 | navigation: PropTypes.object,
13 | dispatch: PropTypes.func,
14 | baseCurrency: PropTypes.string,
15 | quoteCurrency: PropTypes.string,
16 | };
17 |
18 | handlePress = (currency) => {
19 | const { type } = this.props.navigation.state.params;
20 | if (type === 'base') {
21 | this.props.dispatch(changeBaseCurrency(currency));
22 | } else if (type === 'quote') {
23 | this.props.dispatch(changeQuoteCurrency(currency));
24 | }
25 |
26 | this.props.navigation.goBack(null);
27 | };
28 |
29 | render() {
30 | let comparisonCurrency = this.props.baseCurrency;
31 | if (this.props.navigation.state.params.type === 'quote') {
32 | comparisonCurrency = this.props.quoteCurrency;
33 | }
34 |
35 | return (
36 |
37 |
38 | (
41 | this.handlePress(item)}
45 | iconBackground={this.props.primaryColor}
46 | />
47 | )}
48 | keyExtractor={item => item}
49 | ItemSeparatorComponent={Separator}
50 | />
51 |
52 | );
53 | }
54 | }
55 |
56 | const mapStateToProps = state => ({
57 | baseCurrency: state.currencies.baseCurrency,
58 | quoteCurrency: state.currencies.quoteCurrency,
59 | primaryColor: state.theme.primaryColor,
60 | });
61 |
62 | export default connect(mapStateToProps)(CurrencyList);
63 |
--------------------------------------------------------------------------------
/app/reducers/currencies.js:
--------------------------------------------------------------------------------
1 | import {
2 | CHANGE_CURRENCY_AMOUNT,
3 | SWAP_CURRENCY,
4 | CHANGE_BASE_CURRENCY,
5 | CHANGE_QUOTE_CURRENCY,
6 | GET_INITIAL_CONVERSION,
7 | CONVERSION_RESULT,
8 | CONVERSION_ERROR,
9 | } from '../actions/currencies';
10 |
11 | const initialState = {
12 | baseCurrency: 'USD',
13 | quoteCurrency: 'GBP',
14 | amount: 100,
15 | conversions: {},
16 | error: null,
17 | };
18 |
19 | const setConversions = (state, action) => {
20 | let conversion = {
21 | isFetching: true,
22 | date: '',
23 | rates: {},
24 | };
25 |
26 | if (state.conversions[action.currency]) {
27 | conversion = state.conversions[action.currency];
28 | }
29 |
30 | return {
31 | ...state.conversions,
32 | [action.currency]: conversion,
33 | };
34 | };
35 |
36 | export default (state = initialState, action) => {
37 | switch (action.type) {
38 | case CHANGE_CURRENCY_AMOUNT:
39 | return { ...state, amount: action.amount || 0 };
40 | case SWAP_CURRENCY:
41 | return {
42 | ...state,
43 | baseCurrency: state.quoteCurrency,
44 | quoteCurrency: state.baseCurrency,
45 | };
46 | case CHANGE_BASE_CURRENCY:
47 | return {
48 | ...state,
49 | baseCurrency: action.currency,
50 | conversions: setConversions(state, action),
51 | };
52 | case CHANGE_QUOTE_CURRENCY:
53 | return {
54 | ...state,
55 | quoteCurrency: action.currency,
56 | conversions: setConversions(state, action),
57 | };
58 | case GET_INITIAL_CONVERSION:
59 | return { ...state, conversions: setConversions(state, { currency: state.baseCurrency }) };
60 | case CONVERSION_RESULT:
61 | return {
62 | ...state,
63 | baseCurrency: action.result.base,
64 | conversions: {
65 | ...state.conversions,
66 | [action.result.base]: {
67 | isFetching: false,
68 | ...action.result,
69 | },
70 | },
71 | };
72 | case CONVERSION_ERROR:
73 | return { ...state, error: action.error };
74 | default:
75 | return state;
76 | }
77 | };
78 |
--------------------------------------------------------------------------------
/app/components/Logo/Logo.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React, { Component } from 'react';
3 | import { View, Text, Keyboard, Animated, Platform, StyleSheet } from 'react-native';
4 |
5 | import styles from './styles';
6 |
7 | const ANIMATION_DURATION = 250;
8 |
9 | class Logo extends Component {
10 | static propTypes = {
11 | tintColor: PropTypes.string,
12 | };
13 |
14 | constructor(props) {
15 | super(props);
16 |
17 | this.state = {
18 | containerImageWidth: new Animated.Value(styles.$largeContainerSize),
19 | imageWidth: new Animated.Value(styles.$largeImageSize),
20 | };
21 | }
22 |
23 | componentDidMount() {
24 | const name = Platform.OS === 'ios' ? 'Will' : 'Did';
25 | this.keyboardDidShowListener = Keyboard.addListener(
26 | `keyboard${name}Show`,
27 | this.keyboardWillShow,
28 | );
29 | this.keyboardDidHideListener = Keyboard.addListener(
30 | `keyboard${name}Hide`,
31 | this.keyboardWillHide,
32 | );
33 | }
34 |
35 | componentWillUnmount() {
36 | this.keyboardDidShowListener.remove();
37 | this.keyboardDidHideListener.remove();
38 | }
39 |
40 | keyboardWillShow = () => {
41 | Animated.parallel([
42 | Animated.timing(this.state.containerImageWidth, {
43 | toValue: styles.$smallContainerSize,
44 | duration: ANIMATION_DURATION,
45 | }),
46 | Animated.timing(this.state.imageWidth, {
47 | toValue: styles.$smallImageSize,
48 | duration: ANIMATION_DURATION,
49 | }),
50 | ]).start();
51 | };
52 |
53 | keyboardWillHide = () => {
54 | Animated.parallel([
55 | Animated.timing(this.state.containerImageWidth, {
56 | toValue: styles.$largeContainerSize,
57 | duration: ANIMATION_DURATION,
58 | }),
59 | Animated.timing(this.state.imageWidth, {
60 | toValue: styles.$largeImageSize,
61 | duration: ANIMATION_DURATION,
62 | }),
63 | ]).start();
64 | };
65 |
66 | render() {
67 | const containerImageStyles = [
68 | styles.containerImage,
69 | { width: this.state.containerImageWidth, height: this.state.containerImageWidth },
70 | ];
71 | const imageStyles = [
72 | styles.logo,
73 | { width: this.state.imageWidth },
74 | this.props.tintColor ? { tintColor: this.props.tintColor } : null,
75 | ];
76 |
77 | return (
78 |
79 |
80 |
85 |
90 |
91 | Currency Converter
92 |
93 | );
94 | }
95 | }
96 |
97 | export default Logo;
98 |
--------------------------------------------------------------------------------
/app/screens/Home.js:
--------------------------------------------------------------------------------
1 | import PropTypes from 'prop-types';
2 | import React, { Component } from 'react';
3 | import { StatusBar, KeyboardAvoidingView } from 'react-native';
4 | import { connect } from 'react-redux';
5 |
6 | import { Container } from '../components/Container';
7 | import { Logo } from '../components/Logo';
8 | import { InputWithButton } from '../components/TextInput';
9 | import { ClearButton } from '../components/Button';
10 | import { LastConverted } from '../components/Text';
11 | import { Header } from '../components/Header';
12 | import { connectAlert } from '../components/Alert';
13 |
14 | import { changeCurrencyAmount, swapCurrency, getInitialConversion } from '../actions/currencies';
15 |
16 | class Home extends Component {
17 | static propTypes = {
18 | navigation: PropTypes.object,
19 | dispatch: PropTypes.func,
20 | baseCurrency: PropTypes.string,
21 | quoteCurrency: PropTypes.string,
22 | amount: PropTypes.number,
23 | conversionRate: PropTypes.number,
24 | lastConvertedDate: PropTypes.object,
25 | isFetching: PropTypes.bool,
26 | primaryColor: PropTypes.string,
27 | currencyError: PropTypes.string,
28 | alertWithType: PropTypes.func,
29 | };
30 |
31 | componentWillMount() {
32 | this.props.dispatch(getInitialConversion());
33 | }
34 |
35 | componentWillReceiveProps(nextProps) {
36 | if (nextProps.currencyError && !this.props.currencyError) {
37 | this.props.alertWithType('error', 'Error', nextProps.currencyError);
38 | }
39 | }
40 |
41 | handleChangeText = (text) => {
42 | this.props.dispatch(changeCurrencyAmount(text));
43 | };
44 |
45 | handlePressBaseCurrency = () => {
46 | this.props.navigation.navigate('CurrencyList', { title: 'Base Currency', type: 'base' });
47 | };
48 |
49 | handlePressQuoteCurrency = () => {
50 | this.props.navigation.navigate('CurrencyList', { title: 'Quote Currency', type: 'quote' });
51 | };
52 |
53 | handleSwapCurrency = () => {
54 | this.props.dispatch(swapCurrency());
55 | };
56 |
57 | handleOptionsPress = () => {
58 | this.props.navigation.navigate('Options');
59 | };
60 |
61 | render() {
62 | let quotePrice = '...';
63 | if (!this.props.isFetching) {
64 | quotePrice = (this.props.amount * this.props.conversionRate).toFixed(2);
65 | }
66 |
67 | return (
68 |
69 |
70 |
71 |
72 |
73 |
81 |
88 |
94 |
95 |
96 |
97 | );
98 | }
99 | }
100 |
101 | const mapStateToProps = (state) => {
102 | const baseCurrency = state.currencies.baseCurrency;
103 | const quoteCurrency = state.currencies.quoteCurrency;
104 | const conversionSelector = state.currencies.conversions[baseCurrency] || {};
105 | const rates = conversionSelector.rates || {};
106 |
107 | return {
108 | baseCurrency,
109 | quoteCurrency,
110 | amount: state.currencies.amount,
111 | conversionRate: rates[quoteCurrency] || 0,
112 | lastConvertedDate: conversionSelector.date ? new Date(conversionSelector.date) : new Date(),
113 | isFetching: conversionSelector.isFetching,
114 | primaryColor: state.theme.primaryColor,
115 | currencyError: state.currencies.error,
116 | };
117 | };
118 |
119 | export default connect(mapStateToProps)(connectAlert(Home));
120 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DEPRECATED
2 | This repo has been deprecated in favor of a new one. Please see [this repo](https://github.com/HandlebarLabs/production-ready-react-native) for updates instead.
3 |
4 | ---
5 |
6 | This project was bootstrapped with [Create React Native App](https://github.com/react-community/create-react-native-app).
7 |
8 | Below you'll find information about performing common tasks. The most recent version of this guide is available [here](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md).
9 |
10 | ## Table of Contents
11 |
12 | * [Updating to New Releases](#updating-to-new-releases)
13 | * [Available Scripts](#available-scripts)
14 | * [npm start](#npm-start)
15 | * [npm test](#npm-test)
16 | * [npm run ios](#npm-run-ios)
17 | * [npm run android](#npm-run-android)
18 | * [npm run eject](#npm-run-eject)
19 | * [Writing and Running Tests](#writing-and-running-tests)
20 | * [Environment Variables](#environment-variables)
21 | * [Configuring Packager IP Address](#configuring-packager-ip-address)
22 | * [Adding Flow](#adding-flow)
23 | * [Customizing App Display Name and Icon](#customizing-app-display-name-and-icon)
24 | * [Sharing and Deployment](#sharing-and-deployment)
25 | * [Publishing to Expo's React Native Community](#publishing-to-expos-react-native-community)
26 | * [Building an Expo "standalone" app](#building-an-expo-standalone-app)
27 | * [Ejecting from Create React Native App](#ejecting-from-create-react-native-app)
28 | * [Build Dependencies (Xcode & Android Studio)](#build-dependencies-xcode-android-studio)
29 | * [Should I Use ExpoKit?](#should-i-use-expokit)
30 | * [Troubleshooting](#troubleshooting)
31 | * [Networking](#networking)
32 | * [iOS Simulator won't open](#ios-simulator-wont-open)
33 | * [QR Code does not scan](#qr-code-does-not-scan)
34 |
35 | ## Updating to New Releases
36 |
37 | You should only need to update the global installation of `create-react-native-app` very rarely, ideally never.
38 |
39 | Updating the `react-native-scripts` dependency of your app should be as simple as bumping the version number in `package.json` and reinstalling your project's dependencies.
40 |
41 | Upgrading to a new version of React Native requires updating the `react-native`, `react`, and `expo` package versions, and setting the correct `sdkVersion` in `app.json`. See the [versioning guide](https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md) for up-to-date information about package version compatibility.
42 |
43 | ## Available Scripts
44 |
45 | If Yarn was installed when the project was initialized, then dependencies will have been installed via Yarn, and you should probably use it to run these commands as well. Unlike dependency installation, command running syntax is identical for Yarn and NPM at the time of this writing.
46 |
47 | ### `npm start`
48 |
49 | Runs your app in development mode.
50 |
51 | Open it in the [Expo app](https://expo.io) on your phone to view it. It will reload if you save edits to your files, and you will see build errors and logs in the terminal.
52 |
53 | Sometimes you may need to reset or clear the React Native packager's cache. To do so, you can pass the `--reset-cache` flag to the start script:
54 |
55 | ```
56 | npm start -- --reset-cache
57 | # or
58 | yarn start -- --reset-cache
59 | ```
60 |
61 | #### `npm test`
62 |
63 | Runs the [jest](https://github.com/facebook/jest) test runner on your tests.
64 |
65 | #### `npm run ios`
66 |
67 | Like `npm start`, but also attempts to open your app in the iOS Simulator if you're on a Mac and have it installed.
68 |
69 | #### `npm run android`
70 |
71 | Like `npm start`, but also attempts to open your app on a connected Android device or emulator. Requires an installation of Android build tools (see [React Native docs](https://facebook.github.io/react-native/docs/getting-started.html) for detailed setup). We also recommend installing Genymotion as your Android emulator. Once you've finished setting up the native build environment, there are two options for making the right copy of `adb` available to Create React Native App:
72 |
73 | ##### Using Android Studio's `adb`
74 |
75 | 1. Make sure that you can run adb from your terminal.
76 | 2. Open Genymotion and navigate to `Settings -> ADB`. Select “Use custom Android SDK tools” and update with your [Android SDK directory](https://stackoverflow.com/questions/25176594/android-sdk-location).
77 |
78 | ##### Using Genymotion's `adb`
79 |
80 | 1. Find Genymotion’s copy of adb. On macOS for example, this is normally `/Applications/Genymotion.app/Contents/MacOS/tools/`.
81 | 2. Add the Genymotion tools directory to your path (instructions for [Mac](http://osxdaily.com/2014/08/14/add-new-path-to-path-command-line/), [Linux](http://www.computerhope.com/issues/ch001647.htm), and [Windows](https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/)).
82 | 3. Make sure that you can run adb from your terminal.
83 |
84 | #### `npm run eject`
85 |
86 | This will start the process of "ejecting" from Create React Native App's build scripts. You'll be asked a couple of questions about how you'd like to build your project.
87 |
88 | **Warning:** Running eject is a permanent action (aside from whatever version control system you use). An ejected app will require you to have an [Xcode and/or Android Studio environment](https://facebook.github.io/react-native/docs/getting-started.html) set up.
89 |
90 | ## Customizing App Display Name and Icon
91 |
92 | You can edit `app.json` to include [configuration keys](https://docs.expo.io/versions/latest/guides/configuration.html) under the `expo` key.
93 |
94 | To change your app's display name, set the `expo.name` key in `app.json` to an appropriate string.
95 |
96 | To set an app icon, set the `expo.icon` key in `app.json` to be either a local path or a URL. It's recommended that you use a 512x512 png file with transparency.
97 |
98 | ## Writing and Running Tests
99 |
100 | This project is set up to use [jest](https://facebook.github.io/jest/) for tests. You can configure whatever testing strategy you like, but jest works out of the box. Create test files in directories called `__tests__` to have the files loaded by jest. See the [the template project](https://github.com/react-community/create-react-native-app/tree/master/react-native-scripts/template/__tests__) for an example test. The [jest documentation](https://facebook.github.io/jest/docs/getting-started.html) is also a wonderful resource, as is the [React Native testing tutorial](https://facebook.github.io/jest/docs/tutorial-react-native.html).
101 |
102 | ## Environment Variables
103 |
104 | You can configure some of Create React Native App's behavior using environment variables.
105 |
106 | ### Configuring Packager IP Address
107 |
108 | When starting your project, you'll see something like this for your project URL:
109 |
110 | ```
111 | exp://192.168.0.2:19000
112 | ```
113 |
114 | The "manifest" at that URL tells the Expo app how to retrieve and load your app's JavaScript bundle, so even if you load it in the app via a URL like `exp://localhost:19000`, the Expo client app will still try to retrieve your app at the IP address that the start script provides.
115 |
116 | In some cases, this is less than ideal. This might be the case if you need to run your project inside of a virtual machine and you have to access the packager via a different IP address than the one which prints by default. In order to override the IP address or hostname that is detected by Create React Native App, you can specify your own hostname via the `REACT_NATIVE_PACKAGER_HOSTNAME` environment variable:
117 |
118 | Mac and Linux:
119 |
120 | ```
121 | REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start
122 | ```
123 |
124 | Windows:
125 | ```
126 | set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname'
127 | npm start
128 | ```
129 |
130 | The above example would cause the development server to listen on `exp://my-custom-ip-address-or-hostname:19000`.
131 |
132 | ## Adding Flow
133 |
134 | Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept.
135 |
136 | React Native works with [Flow](http://flowtype.org/) out of the box, as long as your Flow version matches the one used in the version of React Native.
137 |
138 | To add a local dependency to the correct Flow version to a Create React Native App project, follow these steps:
139 |
140 | 1. Find the Flow `[version]` at the bottom of the included [.flowconfig](.flowconfig)
141 | 2. Run `npm install --save-dev flow-bin@x.y.z` (or `yarn add --dev flow-bin@x.y.z`), where `x.y.z` is the .flowconfig version number.
142 | 3. Add `"flow": "flow"` to the `scripts` section of your `package.json`.
143 | 4. Add `// @flow` to any files you want to type check (for example, to `App.js`).
144 |
145 | Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors.
146 | You can optionally use a [plugin for your IDE or editor](https://flow.org/en/docs/editors/) for a better integrated experience.
147 |
148 | To learn more about Flow, check out [its documentation](https://flow.org/).
149 |
150 | ## Sharing and Deployment
151 |
152 | Create React Native App does a lot of work to make app setup and development simple and straightforward, but it's very difficult to do the same for deploying to Apple's App Store or Google's Play Store without relying on a hosted service.
153 |
154 | ### Publishing to Expo's React Native Community
155 |
156 | Expo provides free hosting for the JS-only apps created by CRNA, allowing you to share your app through the Expo client app. This requires registration for an Expo account.
157 |
158 | Install the `exp` command-line tool, and run the publish command:
159 |
160 | ```
161 | $ npm i -g exp
162 | $ exp publish
163 | ```
164 |
165 | ### Building an Expo "standalone" app
166 |
167 | You can also use a service like [Expo's standalone builds](https://docs.expo.io/versions/latest/guides/building-standalone-apps.html) if you want to get an IPA/APK for distribution without having to build the native code yourself.
168 |
169 | ### Ejecting from Create React Native App
170 |
171 | If you want to build and deploy your app yourself, you'll need to eject from CRNA and use Xcode and Android Studio.
172 |
173 | This is usually as simple as running `npm run eject` in your project, which will walk you through the process. Make sure to install `react-native-cli` and follow the [native code getting started guide for React Native](https://facebook.github.io/react-native/docs/getting-started.html).
174 |
175 | #### Should I Use ExpoKit?
176 |
177 | If you have made use of Expo APIs while working on your project, then those API calls will stop working if you eject to a regular React Native project. If you want to continue using those APIs, you can eject to "React Native + ExpoKit" which will still allow you to build your own native code and continue using the Expo APIs. See the [ejecting guide](https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md) for more details about this option.
178 |
179 | ## Troubleshooting
180 |
181 | ### Networking
182 |
183 | If you're unable to load your app on your phone due to a network timeout or a refused connection, a good first step is to verify that your phone and computer are on the same network and that they can reach each other. Create React Native App needs access to ports 19000 and 19001 so ensure that your network and firewall settings allow access from your device to your computer on both of these ports.
184 |
185 | Try opening a web browser on your phone and opening the URL that the packager script prints, replacing `exp://` with `http://`. So, for example, if underneath the QR code in your terminal you see:
186 |
187 | ```
188 | exp://192.168.0.1:19000
189 | ```
190 |
191 | Try opening Safari or Chrome on your phone and loading
192 |
193 | ```
194 | http://192.168.0.1:19000
195 | ```
196 |
197 | and
198 |
199 | ```
200 | http://192.168.0.1:19001
201 | ```
202 |
203 | If this works, but you're still unable to load your app by scanning the QR code, please open an issue on the [Create React Native App repository](https://github.com/react-community/create-react-native-app) with details about these steps and any other error messages you may have received.
204 |
205 | If you're not able to load the `http` URL in your phone's web browser, try using the tethering/mobile hotspot feature on your phone (beware of data usage, though), connecting your computer to that WiFi network, and restarting the packager.
206 |
207 | ### iOS Simulator won't open
208 |
209 | If you're on a Mac, there are a few errors that users sometimes see when attempting to `npm run ios`:
210 |
211 | * "non-zero exit code: 107"
212 | * "You may need to install Xcode" but it is already installed
213 | * and others
214 |
215 | There are a few steps you may want to take to troubleshoot these kinds of errors:
216 |
217 | 1. Make sure Xcode is installed and open it to accept the license agreement if it prompts you. You can install it from the Mac App Store.
218 | 2. Open Xcode's Preferences, the Locations tab, and make sure that the `Command Line Tools` menu option is set to something. Sometimes when the CLI tools are first installed by Homebrew this option is left blank, which can prevent Apple utilities from finding the simulator. Make sure to re-run `npm/yarn run ios` after doing so.
219 | 3. If that doesn't work, open the Simulator, and under the app menu select `Reset Contents and Settings...`. After that has finished, quit the Simulator, and re-run `npm/yarn run ios`.
220 |
221 | ### QR Code does not scan
222 |
223 | If you're not able to scan the QR code, make sure your phone's camera is focusing correctly, and also make sure that the contrast on the two colors in your terminal is high enough. For example, WebStorm's default themes may [not have enough contrast](https://github.com/react-community/create-react-native-app/issues/49) for terminal QR codes to be scannable with the system barcode scanners that the Expo app uses.
224 |
225 | If this causes problems for you, you may want to try changing your terminal's color theme to have more contrast, or running Create React Native App from a different terminal. You can also manually enter the URL printed by the packager script in the Expo app's search bar to load it manually.
226 |
--------------------------------------------------------------------------------