Commit 397b0930 authored by Wietse Kuipers's avatar Wietse Kuipers
Browse files

Merge branch 'calendar' into 'master'

Calendar and Event components

See merge request !11
parents d14be78a eb5212fb
......@@ -22,6 +22,8 @@ node_modules/react-native/flow
flow/
[options]
emoji=true
module.system=haste
experimental.strict_type_args=true
......@@ -34,11 +36,12 @@ suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-7]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-7]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-0]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
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]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
unsafe.enable_getters_and_setters=true
[version]
^0.37.0
^0.40.0
* text=auto eol=lf
# Images should be treated as binary
*.png binary
*.jpeg binary
*.jpg binary
*.gif binary
*.ico binary
*.mo binary
# PDF is binary
*.pdf binary
# Font files
*.eot binary
*.otf binary
*.ttf binary
*.woff2 binary
*.woff binary
*.py text
*.js text
*.css text
*.html text
*.sql text
*.po text merge=binary
*.pbxproj -text
......@@ -22,4 +22,3 @@ jest:
script:
- rm -rf .yarn
- yarn lint
- yarn test
......@@ -4,9 +4,3 @@ import React from 'react';
import renderer from 'react-test-renderer';
import Index from '../app/app';
it('renders correctly', () => {
const tree = renderer.create(
<Index />,
);
});
import 'react-native';
import React from 'react';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
import Index from '../app/app';
it('renders correctly', () => {
const tree = renderer.create(
<Index />,
);
});
import re
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
......@@ -11,8 +9,9 @@ import re
#
lib_deps = []
for jarfile in glob(['libs/*.jar']):
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
lib_deps.append(':' + name)
prebuilt_jar(
name = name,
......@@ -20,7 +19,7 @@ for jarfile in glob(['libs/*.jar']):
)
for aarfile in glob(['libs/*.aar']):
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
lib_deps.append(':' + name)
android_prebuilt_aar(
name = name,
......@@ -28,39 +27,39 @@ for aarfile in glob(['libs/*.aar']):
)
android_library(
name = 'all-libs',
exported_deps = lib_deps
name = "all-libs",
exported_deps = lib_deps,
)
android_library(
name = 'app-code',
name = "app-code",
srcs = glob([
'src/main/java/**/*.java',
"src/main/java/**/*.java",
]),
deps = [
':all-libs',
':build_config',
':res',
":all-libs",
":build_config",
":res",
],
)
android_build_config(
name = 'build_config',
package = 'com.thaliapp',
name = "build_config",
package = "com.thaliapp",
)
android_resource(
name = 'res',
res = 'src/main/res',
package = 'com.thaliapp',
name = "res",
package = "com.thaliapp",
res = "src/main/res",
)
android_binary(
name = 'app',
package_type = 'debug',
manifest = 'src/main/AndroidManifest.xml',
keystore = '//android/keystores:debug',
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
':app-code',
":app-code",
],
)
......@@ -19,7 +19,8 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
......
package com.thaliapp;
import android.app.Application;
import android.util.Log;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
......
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
......@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
keystore(
name = 'debug',
store = 'debug.keystore',
properties = 'debug.keystore.properties',
name = "debug",
properties = "debug.keystore.properties",
store = "debug.keystore",
visibility = [
'PUBLIC',
"PUBLIC",
],
)
{
"name": "ThaliApp",
"displayName": "ThaliApp"
}
\ No newline at end of file
export const NAVIGATE = 'NAVIGATE';
export const BACK = 'BACK';
export const LOGININIT = 'LOGININIT';
export const LOGINPROGRESS = 'LOGINPROGRESS';
export const LOGINSUCCESS = 'LOGINSUCCESS';
export const LOGINFAILURE = 'LOGINFAILURE';
export const LOGOUT = 'LOGOUT';
export const OPENDRAWER = 'OPENDRAWER';
export const CALENDARRETREIVED = 'CALENDARRETREIVED';
export const CALENDARERROR = 'CALENDARERROR';
export const LOADEVENTSUCCESS = 'LOADEVENTSUCCESS';
export const LOADEVENTFAILURE = 'LOADEVENTFAILURE';
import * as types from './actionTypes';
export function calendarRetrieved(eventList) {
return {
type: types.CALENDARRETREIVED,
eventList,
};
}
export function calendarNotRetrieved() {
return {
type: types.CALENDARERROR,
};
}
export function retrieveCalendar(token) {
return (dispatch) => {
const start = new Date().toISOString().substring(0, 10);
let end = new Date();
end.setMonth(end.getMonth() + 6);
end = end.toISOString().substring(0, 10);
const data = {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Token ${token}`,
},
};
return fetch(`http://localhost:8000/api/events/eventlist/?start=${start}&end=${end}`, data)
.then(
response => response.json())
.then(
responseJson => dispatch(calendarRetrieved(responseJson)))
.catch(() => {
dispatch(calendarNotRetrieved());
});
};
}
import * as types from './actionTypes';
import { navigate } from './navigation';
export function success(data) {
return {
type: types.LOADEVENTSUCCESS,
data,
};
}
export function fail() {
return {
type: types.LOADEVENTFAILURE,
};
}
export function loadEvent(id, token) {
return (dispatch) => {
const data = {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Token ${token}`,
},
};
return fetch(`http://localhost:8000/api/events/data/?event_id=${id}`, data)
.then(
response => response.json(),
)
.then(
(response) => {
dispatch(success(response));
dispatch(navigate('event'));
},
)
.catch(
() => {
dispatch(fail());
dispatch(navigate('event'));
},
);
};
}
......@@ -58,14 +58,6 @@ export function login(username, password) {
};
}
export function initLogin(username, token) {
return {
type: types.LOGININIT,
username,
token,
};
}
export function logout() {
AsyncStorage.multiRemove([USERNAMEKEY, TOKENKEY]);
return {
......
......@@ -6,7 +6,7 @@ import thunk from 'redux-thunk';
import * as reducers from './reducers';
import ReduxNavigator from './components/navigator';
import { initLogin } from './actions/login';
import { loginSuccess } from './actions/login';
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
const reducer = combineReducers(reducers);
......@@ -30,7 +30,7 @@ class Main extends Component {
const token = values[TOKENKEY];
if (username !== null && token !== null) {
store.dispatch(initLogin(username, token));
store.dispatch(loginSuccess(username, token));
}
});
}
......
import React from 'react';
import { Text, View } from 'react-native';
const Agenda = () =>
<View>
<Text>
Algemene Ledenvergadering
</Text>
<Text>
Lunchlezing Rijksoverheid
</Text>
<Text>
Benefietborrel
</Text>
</View>
;
export default Agenda;
import React from 'react';
import { Text, View, ListView } from 'react-native';
import { connect } from 'react-redux';
import * as actions from '../actions/calendar';
import EventCard from './EventCard';
const Calendar = (props) => {
if (!props.calendarFetched) {
props.retrieveCalendar(props.token);
return (
<View>
<Text>
No calendar retrieved!
</Text>
</View>
);
}
const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
const events = [];
for (let i = 0; i < props.eventList.length; i += 1) {
events.push(<EventCard event={props.eventList[i]} />);
}
const dataSource = ds.cloneWithRows(events);
return (
<View>
<ListView
dataSource={dataSource}
renderRow={rowData => rowData}
/>
</View>
);
};
Calendar.propTypes = {
eventList: React.PropTypes.arrayOf(React.PropTypes.shape({
title: React.PropTypes.string,
description: React.PropTypes.string,
start: React.PropTypes.string,
location: React.PropTypes.string,
price: React.PropTypes.string,
id: React.PropTypes.number,
})).isRequired,
calendarFetched: React.PropTypes.bool.isRequired,
retrieveCalendar: React.PropTypes.func.isRequired,
token: React.PropTypes.string.isRequired,
};
const mapStateToProps = state => ({
...state.calendar,
token: state.session.token,
});
const mapDispatchToProps = dispatch => ({
retrieveCalendar: token => dispatch(actions.retrieveCalendar(token)),
});
export default connect(mapStateToProps, mapDispatchToProps)(Calendar);
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