Skip to content

Commit 9cfd033

Browse files
author
Matthieu Napoli
committed
Merge branch 'master' into readme
2 parents 597d7ee + 26747f8 commit 9cfd033

File tree

15 files changed

+199
-77
lines changed

15 files changed

+199
-77
lines changed

App/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { Component } from 'react'
2-
import HomeScreen from 'App/Containers/HomeScreen'
32
import { Provider } from 'react-redux'
43
import { PersistGate } from 'redux-persist/lib/integration/react'
54
import createStore from 'App/Stores'
5+
import ExampleScreen from './Containers/Example/ExampleScreen'
66

77
const { store, persistor } = createStore()
88

@@ -21,7 +21,7 @@ export default class App extends Component {
2121
* @see https://github.com/rt2zz/redux-persist/blob/master/docs/PersistGate.md
2222
*/}
2323
<PersistGate loading={null} persistor={persistor}>
24-
<HomeScreen />
24+
<ExampleScreen />
2525
</PersistGate>
2626
</Provider>
2727
)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import React from 'react'
2+
import { Platform, Text, View, Button } from 'react-native'
3+
import { connect } from 'react-redux'
4+
import { PropTypes } from 'prop-types'
5+
import ExampleActions from 'App/Stores/Example/Actions'
6+
import { isHot } from 'App/Stores/Example/Selectors'
7+
import Style from './ExampleScreenStyle'
8+
9+
const instructions = Platform.select({
10+
ios: 'Press Cmd+R to reload,\nCmd+D or shake for dev menu.',
11+
android: 'Double tap R on your keyboard to reload,\nShake or press menu button for dev menu.',
12+
})
13+
14+
class ExampleScreen extends React.Component {
15+
componentDidMount() {
16+
this.props.fetchTemperature()
17+
}
18+
19+
render() {
20+
let temperature = this.props.temperatureIsLoading ? '...' : this.props.temperature
21+
if (temperature === null) {
22+
temperature = '??'
23+
}
24+
25+
return (
26+
<View style={Style.container}>
27+
<Text style={Style.title}>Welcome to React Native!</Text>
28+
<Text style={Style.text}>To get started, edit App.js</Text>
29+
<Text style={Style.text}>{instructions}</Text>
30+
<Text style={Style.text}>The weather temperature is: {temperature}</Text>
31+
<Text style={Style.text}>{this.props.isHot ? "It's pretty hot!" : ''}</Text>
32+
<Text style={Style.text}>{this.props.temperatureErrorMessage}</Text>
33+
<Button onPress={this.props.fetchTemperature} title="Refresh" />
34+
</View>
35+
)
36+
}
37+
}
38+
39+
ExampleScreen.propsTypes = {
40+
temperature: PropTypes.number,
41+
temperatureErrorMessage: PropTypes.string,
42+
}
43+
44+
const mapStateToProps = (state) => ({
45+
temperature: state.example.get('temperature'),
46+
temperatureErrorMessage: state.example.get('temperatureErrorMessage'),
47+
temperatureIsLoading: state.example.get('temperatureIsLoading'),
48+
isHot: isHot(state),
49+
})
50+
51+
const mapDispatchToProps = (dispatch) => ({
52+
fetchTemperature: () => dispatch(ExampleActions.fetchTemperature()),
53+
})
54+
55+
export default connect(
56+
mapStateToProps,
57+
mapDispatchToProps
58+
)(ExampleScreen)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { StyleSheet } from 'react-native'
2+
import Fonts from 'App/Theme/Fonts'
3+
import ApplicationStyles from 'App/Theme/ApplicationStyles'
4+
5+
export default StyleSheet.create({
6+
container: {
7+
...ApplicationStyles.screen.container,
8+
},
9+
title: {
10+
...Fonts.style.h1,
11+
textAlign: 'center',
12+
margin: 10,
13+
},
14+
text: {
15+
...Fonts.style.normal,
16+
textAlign: 'center',
17+
marginBottom: 5,
18+
},
19+
})

App/Containers/HomeScreen.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

App/Images/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory contains the application's images.

App/Stores/CreateStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import immutableTransform from 'redux-persist-transform-immutable'
66
/**
77
* This import defaults to localStorage for web and AsyncStorage for react-native.
88
*
9-
* Kind in mind this storage *is not secure*. Do not use it to store sensitive information
9+
* Keep in mind this storage *is not secure*. Do not use it to store sensitive information
1010
* (like API tokens, private and sensitive data, etc.).
1111
*
1212
* If you need to store sensitive information, use redux-persist-sensitive-storage.

App/Theme/ApplicationStyles.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* This file defines the base application styles.
3+
*
4+
* Use it to define generic component styles (e.g. the default text styles, default button styles...).
5+
*/
6+
7+
export default {
8+
screen: {
9+
container: {
10+
flex: 1,
11+
},
12+
},
13+
}

App/Theme/Colors.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* This file contains the application's colors.
3+
*
4+
* Define color here instead of duplicating them throughout the components.
5+
* That allows to change them more easily later on.
6+
*/
7+
8+
export default {
9+
transparent: 'rgba(0,0,0,0)',
10+
// Example colors:
11+
text: '#212529',
12+
primary: '#007bff',
13+
success: '#28a745',
14+
error: '#dc3545',
15+
}

App/Theme/Fonts.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const type = {
2+
base: 'inherit',
3+
}
4+
5+
const size = {
6+
h1: 38,
7+
h2: 34,
8+
h3: 30,
9+
input: 18,
10+
regular: 17,
11+
medium: 14,
12+
small: 12,
13+
}
14+
15+
const style = {
16+
h1: {
17+
fontFamily: type.base,
18+
fontSize: size.h1,
19+
},
20+
h2: {
21+
fontFamily: type.base,
22+
fontSize: size.h2,
23+
},
24+
h3: {
25+
fontFamily: type.base,
26+
fontSize: size.h3,
27+
},
28+
normal: {
29+
fontFamily: type.base,
30+
fontSize: size.regular,
31+
},
32+
}
33+
34+
export default {
35+
type,
36+
size,
37+
style,
38+
}

App/Theme/Images.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Images should be stored in the `App/Images` directory and referenced using variables defined here.
3+
*/
4+
5+
export default {
6+
// logo: require('../Images/logo.png'),
7+
}

0 commit comments

Comments
 (0)