calender updates

This commit is contained in:
henrydays 2019-02-06 23:24:00 +00:00
parent b30b76d655
commit ed2c0835cc
13 changed files with 570 additions and 89 deletions

View File

@ -4,6 +4,7 @@ export const CHECK_USER='CHECK_USER';
export const LOGOUT_USER= 'LOGOUT_USER';
export const USER_INFO= 'USER_INFO'
export const HOLD='HOLD'
export const GET_EVENTS='GET_EVENTS'
import { AsyncStorage } from 'react-native';
@ -27,6 +28,37 @@ export function getData(){
};
}
export function getEvents(user){
return (dispatch)=>{
var o=[];
console.log("chegou aqui")
for(var key in user.Sessions){
o.push({
time:user.Sessions[key].SessionStart.substr(11, 14),
timeEnd: user.Sessions[key].SessionEnd.substr(11, 14),
lineColor:'#009688',
imageUrl: 'https://d2v9y0dukr6mq2.cloudfront.net/video/thumbnail/Vjkyj2hBg/welcome-white-sign-with-falling-colorful-confetti-animation-on-white-background_sglmmh3qm__F0013.png',
description:user.Sessions[key].Description,
name:user.Sessions[key].Name,
Enrolled:user.Sessions[key].Enrolled,
MaxAttendees:user.Sessions[key].MaxAttendees
})
}
dispatch({
type: GET_EVENTS,
events: o
});
}
}
const saveToken = async token => {
@ -81,6 +113,55 @@ const deleteToken = async () => {
}
}
const renewToken=(refresh)=>{
var details = {
'grant_type': 'refresh_token',
'refresh_token':refresh
};
var formBody = [];
for (var property in details) {
var encodedKey = encodeURIComponent(property);
var encodedValue = encodeURIComponent(details[property]);
formBody.push(encodedKey + "=" + encodedValue);
}
formBody = formBody.join("&");
console.log(refresh);
fetch('http://enei2019.uingress.com/internal/api/token', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: formBody
}).catch(err=>{
}).then(parsed=>{
// console.log(a);
var obj={
access_token:parsed.access_token,
expirationDateToken:Math.round(new Date().getTime()/1000) + parsed.expires_in,
refreshToken:parsed.refresh_token,
valid:true
};
})
return obj;
}
export function login(user, pass){
@ -191,6 +272,8 @@ export function hold(){
}
}
export function getUserInfo(token){
return (dispatch)=>{
@ -218,6 +301,8 @@ export function getUserInfo(token){
dispatch({ type: USER_INFO, user: obj,onHold:false, logged:true });
}).catch(function(res){
dispatch({ type: USER_INFO, user: '',onHold:false, logged:true });
})
@ -274,10 +359,18 @@ export function checkUser(){
//se expirar
if(Math.round(new Date().getTime()/1000) >= a.expirationDateToken){
a.valid=false;
// a.valid=false;
//chamar funçao para renovar
console.log("expirou")
renewToken(a.refreshToken).then(a=>{
// a.valid=true;
deleteToken();
saveToken(a);
console.log("asdasdasdasd")
dispatch({type: CHECK_USER, token:a, logged:true, onHold:false});
})
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -1,6 +1,6 @@
import { combineReducers } from 'redux';
import { DATA_AVAILABLE, API_LOGIN, CHECK_USER, LOGOUT_USER, USER_INFO, HOLD } from "../actions/" //Import the actions types constant we defined in our actions
import { DATA_AVAILABLE, API_LOGIN, CHECK_USER, LOGOUT_USER, USER_INFO, HOLD, GET_EVENTS } from "../actions/" //Import the actions types constant we defined in our actions
let dataState = { data: [], loading:true ,token:true};
@ -15,7 +15,7 @@ const dataReducer = (state = dataState, action) => {
}
};
let apiState= { token:{valid:false}, tokenData:'error', logged:false, onHold:true, user:{}}
let apiState= { token:{valid:false}, tokenData:'error', logged:false, onHold:true, user:{}, events:[]}
const apiReducer = (state = apiState, action) => {
@ -49,6 +49,12 @@ const apiReducer = (state = apiState, action) => {
state=Object.assign({},state, { user: action.user, token: action.token , loggedIn:action.loggedIn, onHold:action.onHold});
return state;
case GET_EVENTS:
state=Object.assign({},state, { events: action.events});
return state;
default:

View File

@ -1,84 +1,326 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import * as React from 'react';
import { View, StyleSheet, Dimensions , Image, ScrollView,Text, Button} from 'react-native';
import { TabView, TabBar, SceneMap } from 'react-native-tab-view';
import {
RkButton,RkCard, RkText,
RkTheme
} from 'react-native-ui-kitten';
import Timeline from 'react-native-timeline-feed'
import * as Progress from 'react-native-progress';
import { connect } from 'react-redux';
import {bindActionCreators} from 'redux';
import * as Actions from '../actions';
class Calendar extends React.Component {
constructor(props) {
super(props);
this.state = {
token:{valid:false},
logged:true,
onHold:true,
user:{}
};
}
componentDidMount() {
import * as Actions from '../actions'; //Import your actionss
this.props.hold();
//this.props.logoutUser();
//console.log(this.props.token);
this.props.getUserInfo(this.props.token);
//console.log('logged:'+this.props.logged);
//console.log(this.props)
//console.log(this.props.user)
const formatObj= (obj)=>{
let a={};
a.push({
})
return a
}
render() {
const { navigate } = this.props.navigation;
const ThirdRoute = () => (
<View style={[styles.scene, { backgroundColor: '#efc44a' }]} />
);
const FourthRoute = () => (
<View style={[styles.scene, { backgroundColor: '#49ef97' }]} />
);
class Calendar extends React.Component {
state = {
index: 0,
routes: [
{ key: 'first', title: 'Sex 12' },
{ key: 'second', title: 'Sab 13' },
{ key: 'third', title: 'Dom 14' },
{ key: 'fourth', title: 'Seg 15' },
],
};
componentDidMount(){
this.props.getEvents(this.props.user);
console.log('didMount');
console.log(this.props.events);
}
renderDetail = ({ item, index })=> {
// <Image source={{ uri:item.imageUrl, width:'100%' , height:100 }} style={{borderRadius:0}}/>
return (
if(this.props.user.Name!=undefined){
console.log(this.props.user.Name)
<View style={styles.event}>
<Text style={[styles.title]}>{item.name}</Text>
<View>
return (
<View style={styles.container}>
<Text style={styles.title}>a{this.props.user.Name}</Text>
<Text style={styles.description}>{item.description}</Text>
<View style={styles.details}>
<Progress.Bar color={'#42a5f5'} progress={0.3} unfilledColor = {'white'}width={210} />
<Text>{item.Enrolled} / {item.MaxAttendees}</Text>
</View>
</View>
);
}
</View>
);
}
renderEvents = ({ item, index })=> {
return (
<View style={styles.event}>
<Text style={[styles.title]}>{item.title}</Text>
<View>
<Image source={{ uri:item.imageUrl, width:'100%' , height:100 }} style={{borderRadius:0}}/>
<Text style={styles.description}>{item.description}</Text>
<View style={styles.details}>
<Progress.Bar color={'#42a5f5'} progress={0.3} unfilledColor = {'white'}width={210} />
<Text>1/50</Text>
</View>
</View>
</View>
);
}
_update=()=>{
this.setState({ user: this.props.user });
console.log(this.props.events);
}
constructor(){
return (
<View style={styles.container}>
<Text style={styles.title}>fk</Text>
</View>
);
}
super()
const archeryImgSource = require('../assets/img/archery.png');
const badmintonImgSource = require('../assets/img/badminton.png');
const lunchImgSource = require('../assets/img/lunch.png');
const soccerImgSource = require('../assets/img/soccer.png');
const dumbbellImgSource = require('../assets/img/dumbbell.png');
const ArcheryImage = (props) => <Image source={archeryImgSource} {...props} />;
const BadmintonImage = (props) => <Image source={badmintonImgSource} {...props} />;
const LunchImage = (props) => <Image source={lunchImgSource} {...props} />;
const SoccerImage = (props) => <Image source={soccerImgSource} {...props} />;
const DumbbellImage = (props) => <Image source={dumbbellImgSource} {...props} />;
const VectorIconImage = (props) => <Image source={vectorIconImgSource} {...props} />;
this.data = [
{
time: '09:30',
title: 'Sessão de Check-In',
description: 'Os participantes devem fazer o check-in e recolher o kit fornecido pela organização',
lineColor:'#009688',
icon: ArcheryImage,
imageUrl: 'https://blogsimages.adobe.com/conversations/files/2014/03/Check_In-1.jpg'
},
{
time: '17:45',
title: 'Sessão de Abertura',
lineColor:'#009688',
description: 'Bem vindo a Coimbra, a cidade dos estudantes! Obrigado por participares na 13ª edição do ENEI.',
icon: BadmintonImage,
imageUrl: 'https://d2v9y0dukr6mq2.cloudfront.net/video/thumbnail/Vjkyj2hBg/welcome-white-sign-with-falling-colorful-confetti-animation-on-white-background_sglmmh3qm__F0013.png'
},
{
time: '19:30',
title: 'Jantar',
lineColor:'#009688',
description: 'Time to eat',
icon: BadmintonImage,
imageUrl: 'https://www.retailmenot.com/blog/wp-content/uploads/2016/08/kids-eat-free-hero1-1471459190.jpg'
},
{
time: '23:30',
title: 'Festarola',
lineColor:'#009688',
description: 'Sabes beber? Se não sabes, aprende com os da casa!',
icon: BadmintonImage,
imageUrl: 'http://www.revistaversatille.com.br/wp-content/uploads/Party.jpg'
},
]
}
render() {
const FirstRoute = () => (
<ScrollView contentContainerStyle={styles.contentContainer} >
<Button onPress={this._update} title="LOGOUT"/>
<Timeline
data={this.props.events}
timeContainerStyle={{minWidth:52, marginTop: 5}}
timeStyle={{textAlign: 'center', backgroundColor:'#ff9797', color:'white', padding:5, borderRadius:13}}
descriptionStyle={{color:'gray'}}
renderDetail={this.renderDetail}
flatListProps={{
style:{
margin:15
}
}}
keyExtractor={(item, index) => index.toString()}
/>
</ScrollView>
)
const SecondRoute = () => (
<ScrollView contentContainerStyle={styles.contentContainer} >
<Timeline
data={this.props.events}
timeContainerStyle={{minWidth:52, marginTop: 5}}
timeStyle={{textAlign: 'center', backgroundColor:'#ff9797', color:'white', padding:5, borderRadius:13}}
descriptionStyle={{color:'gray'}}
renderDetail={this.renderDetail}
flatListProps={{
style:{
margin:15
}
}}
keyExtractor={(item, index) => index.toString()}
/>
</ScrollView>
)
return (
<TabView
navigationState={this.state}
renderScene={SceneMap({
first: FirstRoute,
second: SecondRoute,
third: ThirdRoute,
fourth: FourthRoute
})}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width,height: Dimensions.get('window').height}}
/>
);
}
}
const styles = StyleSheet.create({
container: {
details:{
backgroundColor:"#e0e0e0",
borderBottomRightRadius:10,
borderBottomLeftRadius:10,
padding:10
},
description:{
padding:10
},
title:{
color:'#212121',
fontWeight: 'bold',
fontSize:15,
padding:10
},
event:{
borderRadius:10,
backgroundColor:'#eeeeee',
},
scene: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'space-around',
},
contentContainer: {
paddingVertical: 20
}
});RkTheme.setType('RkCard', 'story', {
img: {
height: 100,
opacity: 0.7
},
header: {
alignSelf: 'center'
},
content:{
alignSelf:'center'
}
});
function mapStateToProps(state, props) {
return {
token: state.apiReducer.token,
loggedIn: state.apiReducer.loggedIn,
onHold: state.apiReducer.onHold,
logged:state.apiReducer.logged,
user:state.apiReducer.user
token: state.apiReducer.token,
user: state.apiReducer.user,
logged: state.apiReducer.logged,
events: state.apiReducer.events
}
}

View File

@ -1,22 +1,48 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import * as React from 'react';
import { View, StyleSheet, Dimensions } from 'react-native';
import { TabView, TabBar, SceneMap } from 'react-native-tab-view';
export default class Eventos extends React.Component {
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<Text style={styles.title}>Eventos</Text>
</View>
);
}
const FirstRoute = () => (
<View style={[styles.scene, { backgroundColor: '#ff4081' }]} />
);
const SecondRoute = () => (
<View style={[styles.scene, { backgroundColor: '#673ab7' }]} />
);
export default class Eventos extends React.Component {
state = {
index: 0,
routes: [
{ key: 'first', title: 'Sex 12' },
{ key: 'second', title: 'Sab 13' },
{ key: 'second', title: 'Dom 14' },
{ key: 'second', title: 'Seg 15' },
],
};
render() {
return (
<TabView
navigationState={this.state}
renderScene={SceneMap({
first: FirstRoute,
second: SecondRoute,
})}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width }}
/>
);
}
}
const styles = StyleSheet.create({
container: {
scene: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'space-around',
}
},
});

View File

@ -50,13 +50,19 @@ class Home extends Component {
//console.log(th2is.props)
//console.log(this.props.user)
console.log(this.props.user)
}
bClick(){
let a={};
// this.setState({ user: this.props.user });
// console.log(this.props.user)
//
//var navigate = this.props.navigation.navigate
}
@ -69,8 +75,26 @@ class Home extends Component {
}
update=()=>{
this.setState({ user: this.props.user });
console.log('update' +this.props.user);
var o=[];
for(var key in this.props.user.Sessions){
o.push({
time:this.props.user.Sessions[key].SessionStart.substr(11, 16),
timeEnd: this.props.user.Sessions[key].SessionEnd.substr(11, 16),
lineColor:'#009688',
imageUrl: 'https://d2v9y0dukr6mq2.cloudfront.net/video/thumbnail/Vjkyj2hBg/welcome-white-sign-with-falling-colorful-confetti-animation-on-white-background_sglmmh3qm__F0013.png',
description:this.props.user.Sessions[key].Description,
name:this.props.user.Sessions[key].Name,
})
}
console.log(this.props.user.Sessions);
}
render() {
@ -91,22 +115,19 @@ class Home extends Component {
if(this.props.logged){
console.log(this.props.logged);
console.log(this.props.user);
console.log("puta que pariu")
return (
<View >
<Text>{this.props.logged}</Text>
<Button onPress={this._logout} title="LOGOUT"/>
<Text> Nomess: {this.props.user.Name}</Text>
<View>
<Text>{this.state.user.Name}</Text>
<Button onPress={this.update} title="update"/>
</View>
<Button onPress={this.bClick} title="Parse"/>
<Text> Nomess: {this.props.user.Name}</Text>
<Text> city: {this.props.user.City}</Text>
<Text> phone: {this.props.user.Mobile}</Text>
</View>
);

89
App/package-lock.json generated
View File

@ -5586,6 +5586,45 @@
"object-visit": "^1.0.0"
}
},
"material-icons-react": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/material-icons-react/-/material-icons-react-1.0.4.tgz",
"integrity": "sha512-ZTCD0Nl+/hTyvONWz8N6gCrpLWfbkOF77NWbD9ThYdkBK8gtvFMc/ORS8nfU0qlmS1wNdVXf1oTaBRWLCiNkxw==",
"requires": {
"prop-types": "^15.6.1",
"react": "^15.0.0",
"react-dom": "^15.0.0",
"webfontloader": "^1.6.28"
},
"dependencies": {
"fbjs": {
"version": "0.8.17",
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz",
"integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=",
"requires": {
"core-js": "^1.0.0",
"isomorphic-fetch": "^2.1.1",
"loose-envify": "^1.0.0",
"object-assign": "^4.1.0",
"promise": "^7.1.1",
"setimmediate": "^1.0.5",
"ua-parser-js": "^0.7.18"
}
},
"react": {
"version": "15.6.2",
"resolved": "https://registry.npmjs.org/react/-/react-15.6.2.tgz",
"integrity": "sha1-26BDSrQ5z+gvEI8PURZjkIF5qnI=",
"requires": {
"create-react-class": "^15.6.0",
"fbjs": "^0.8.9",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.0",
"prop-types": "^15.5.10"
}
}
}
},
"math-random": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz",
@ -6725,6 +6764,33 @@
}
}
},
"react-dom": {
"version": "15.6.2",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-15.6.2.tgz",
"integrity": "sha1-Qc+t9pO3V/rycIRDodH9WgK+9zA=",
"requires": {
"fbjs": "^0.8.9",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.0",
"prop-types": "^15.5.10"
},
"dependencies": {
"fbjs": {
"version": "0.8.17",
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz",
"integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=",
"requires": {
"core-js": "^1.0.0",
"isomorphic-fetch": "^2.1.1",
"loose-envify": "^1.0.0",
"object-assign": "^4.1.0",
"promise": "^7.1.1",
"setimmediate": "^1.0.5",
"ua-parser-js": "^0.7.18"
}
}
}
},
"react-is": {
"version": "16.7.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.7.0.tgz",
@ -6848,6 +6914,14 @@
"resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-1.1.1.tgz",
"integrity": "sha512-t0Ujm177bagjUOSzhpmkSz+LqFW04HnY9TeZFavDCmV521fQvFz82aD+POXqWsAdsJVOK3umJYBNNqCjC3g0hQ=="
},
"react-native-progress": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/react-native-progress/-/react-native-progress-3.5.0.tgz",
"integrity": "sha512-Tgc002D0BGes1fTlObu/qNItlsTPYKFrF9XRQaJLme77TNxNX9I04sgIz3kaq8O4R+z/jlai64dk1HDEDQhzMA==",
"requires": {
"prop-types": "^15.5.8"
}
},
"react-native-qrcode-scanner": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/react-native-qrcode-scanner/-/react-native-qrcode-scanner-1.1.2.tgz",
@ -6885,6 +6959,16 @@
"prop-types": "^15.6.1"
}
},
"react-native-timeline-feed": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/react-native-timeline-feed/-/react-native-timeline-feed-1.0.1.tgz",
"integrity": "sha512-M5027tP7lb48calaWZOZ8E0SAttU5sPaLoDOC4w3bYiWmUqlbh47awrBeGKwyOeE8ggy+j+KXrtCyA65HQzlxA=="
},
"react-native-timeline-listview": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/react-native-timeline-listview/-/react-native-timeline-listview-0.2.3.tgz",
"integrity": "sha1-5Gt/D9LCIGMp7uYZR5XgOJmv6II="
},
"react-native-ui-kitten": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/react-native-ui-kitten/-/react-native-ui-kitten-3.1.2.tgz",
@ -8735,6 +8819,11 @@
"minimist": "^1.2.0"
}
},
"webfontloader": {
"version": "1.6.28",
"resolved": "https://registry.npmjs.org/webfontloader/-/webfontloader-1.6.28.tgz",
"integrity": "sha1-23hhKSU8tujq5UwvsF+HCvZnW64="
},
"webidl-conversions": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz",

View File

@ -8,6 +8,7 @@
},
"dependencies": {
"axios": "^0.18.0",
"material-icons-react": "^1.0.4",
"react": "16.6.3",
"react-native": "0.57.8",
"react-native-app-intro-slider": "^1.0.1",
@ -16,7 +17,10 @@
"react-native-gesture-handler": "^1.0.15",
"react-native-ionicons": "^4.5.5",
"react-native-loader": "^1.2.1",
"react-native-progress": "^3.5.0",
"react-native-qrcode-scanner": "^1.1.2",
"react-native-timeline-feed": "^1.0.1",
"react-native-timeline-listview": "^0.2.3",
"react-native-ui-kitten": "^3.1.2",
"react-native-vector-icons": "^6.1.0",
"react-navigation": "^3.0.9",