Commit e4795bc9 authored by Wietse Kuipers's avatar Wietse Kuipers

Switch to airbnb style guide and upgrade some packages

parent db42a1e7
......@@ -23,7 +23,7 @@
"indent": [
"error",
2,
{"Switchcase": true}
{"SwitchCase": 1}
],
"linebreak-style": [
"error",
......
......@@ -13,5 +13,5 @@ New and improved ThaliApp
Ensure that the development server is started with `react-native start`.
Deploy the app on a running emulator or connected Android Phone with `react-native run-android`.
##Debugging
## Debugging
Open the console with `react-native log-android`.
......@@ -2,6 +2,6 @@ import * as types from './actionTypes';
export function login() {
return {
type: types.LOGIN
type: types.LOGIN,
};
}
import React, {Component} from 'react';
import {View, Text, TextInput, Button} from 'react-native';
import React, { Component } from 'react';
import { View, Text, TextInput, Button } from 'react-native';
export default class Login extends Component {
constructor(props) {
super(props);
this.state = {
username: '',
password: '',
};
}
render() {
const { loggedIn, login } = this.props;
console.log(loggedIn);
return (
<View>
<TextInput
placeholder="Username"
/>
<TextInput
placeholder="Password"
secureTextEntry={true}
/>
<Button title="Log in" onPress={login}/>
<Text>{loggedIn ? 'MEMES' : 'MMS'}</Text>
<TextInput
placeholder="Username"
/>
<TextInput
placeholder="Password"
secureTextEntry
/>
<Button title="Log in" onPress={login} />
<Text>{loggedIn ? 'MEMES' : 'MMS'}</Text>
</View>
);
}
......
import React,{Component} from 'react';
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import Login from '../components/Login';
import {bindActionCreators} from 'redux';
import * as ThaliAppActions from '../actions/ThaliAppActions';
import { connect } from 'react-redux';
class ThaliApp extends Component {
constructor(props) {
super(props);
}
render() {
const { state, actions } = this.props;
return (
<Login
loggedIn={state.loggedIn}
{...actions}
<Login
loggedIn={state.loggedIn}
{...actions}
/>
);
}
......@@ -22,9 +19,9 @@ class ThaliApp extends Component {
export default connect(
state => (
{state: state.login}
{ state: state.login }
),
dispatch => (
{ actions: bindActionCreators(ThaliAppActions, dispatch) }
),
(dispatch) => (
{actions: bindActionCreators(ThaliAppActions, dispatch)}
)
)(ThaliApp);
import React, {Component} from 'react';
import React, { Component } from 'react';
import { createStore, applyMiddleware, combineReducers } from 'redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
......@@ -14,7 +14,7 @@ export default class App extends Component {
render() {
return (
<Provider store={store}>
<ThaliApp />
<ThaliApp />
</Provider>
);
}
......
import login from './login';
export {
login
login,
};
import * as types from '../actions/actionTypes';
const initialState = {
loggedIn: false
loggedIn: false,
};
export default function login(state = initialState, action = {}) {
console.log(state);
switch (action.type) {
case types.LOGIN:
console.log({...state, loggedIn: true});
return {...state, loggedIn: true};
return { ...state, loggedIn: true };
default:
return {...state};
return { ...state };
}
}
import {StyleSheet, Dimensions} from 'react-native';
import { StyleSheet, Dimensions } from 'react-native';
let magenta = '#E62272';
let deviceWidth = Dimensions.get('window').width;
let deviceHeigth = Dimensions.get('window').heigth;
let margin = 10;
const magenta = '#E62272';
const deviceWidth = Dimensions.get('window').width;
const deviceHeigth = Dimensions.get('window').heigth;
const margin = 10;
const styles = StyleSheet.create({
body : {
body: {
padding: 10,
flex: 1,
flexDirection: 'column',
alignItems: 'center'
alignItems: 'center',
},
bodyText: {
fontFamily: 'opensans',
},
textInput: {
alignSelf: 'stretch'
alignSelf: 'stretch',
},
logo: {
width: deviceWidth - margin,
resizeMode: 'contain'
resizeMode: 'contain',
},
button: {
color: magenta
}
color: magenta,
},
});
export {styles};
export { styles };
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment