ENEI2019-Public/App/app/screens/Calendar.js

426 lines
11 KiB
JavaScript
Raw Normal View History

2019-03-10 20:17:58 +00:00
import * as React from "react";
2019-02-06 23:24:00 +00:00
import {
2019-03-10 20:17:58 +00:00
View,
StyleSheet,
Dimensions,
Image,
ScrollView,
Text,
Button,
TouchableOpacity,
Animated
} 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";
2019-02-06 23:24:00 +00:00
2019-03-10 20:17:58 +00:00
import * as Progress from "react-native-progress";
2019-02-06 23:24:00 +00:00
2019-03-10 20:17:58 +00:00
import { connect } from "react-redux";
2019-02-06 23:24:00 +00:00
2019-03-10 20:17:58 +00:00
import { bindActionCreators } from "redux";
2019-03-12 03:34:40 +00:00
import PTRView from 'react-native-pull-to-refresh';
2019-03-10 20:17:58 +00:00
import * as Actions from "../store/actions"; //Import your actionss
2019-02-03 20:54:27 +00:00
2019-03-10 20:17:58 +00:00
const formatObj = obj => {
let a = {};
2019-02-06 23:24:00 +00:00
2019-03-10 20:17:58 +00:00
a.push({});
2019-02-06 23:24:00 +00:00
2019-03-10 20:17:58 +00:00
return a;
2019-02-08 18:56:38 +00:00
};
2019-02-03 20:54:27 +00:00
2019-02-08 18:56:38 +00:00
class Calendar extends React.Component {
2019-03-10 20:17:58 +00:00
state = {
index: 0,
routes: [
{ key: "first", weekDay: "sex", day: 12 },
{ key: "second", weekDay: "sab", day: 13 },
{ key: "third", weekDay: "dom", day: 14 },
{ key: "fourth", weekDay: "seg", day: 15 }
],
CP: "SEM",
cpColor: "white",
careerPath: { name: "", color: "" }
};
componentDidMount() {
this.props.getEvents(this.props.user);
2019-03-15 22:07:22 +00:00
this.props.getSessions(this.props.token);
2019-03-10 20:17:58 +00:00
}
_openDetails = () => {
console.log("los");
};
renderDetail = ({ item, index }) => {
const { navigate } = this.props.navigation;
// <Image source={{ uri:item.imageUrl, width:'100%' , height:100 }} style={{borderRadius:0}}/>
return (
<TouchableOpacity
onPress={() => navigate("calendarDetail", { info: item })}
>
<View style={styles.event}>
<View style={styles.titleContainer}>
<Text style={[styles.title]}>{item.name}</Text>
<Text style={{ color: "black" }}>Local: 1</Text>
2019-02-18 19:55:53 +00:00
</View>
2019-02-08 18:56:38 +00:00
2019-03-10 20:17:58 +00:00
<View>
<Text style={styles.description}>{item.description}</Text>
<View style={styles.details}>
<Progress.Bar
color={"#000000"}
2019-03-13 20:42:20 +00:00
progress={0}
2019-03-10 20:17:58 +00:00
unfilledColor={"white"}
width={210}
/>
<Text>
{item.Enrolled} / {item.MaxAttendees}
</Text>
2019-02-22 23:38:34 +00:00
</View>
2019-03-10 20:17:58 +00:00
</View>
</View>
</TouchableOpacity>
);
};
_update = () => {
this.setState({ user: this.props.user });
console.log(this.props.events);
};
_renderTabBar = props => {
const inputRange = props.navigationState.routes.map((x, i) => i);
return (
<View style={styles.tabBar}>
{props.navigationState.routes.map((route, i) => {
const bgcolor = props.position.interpolate({
inputRange,
outputRange: inputRange.map(inputIndex =>
inputIndex === i ? "#CC1A17" : "rgba(0,0,0,0)"
)
});
const color = props.position.interpolate({
inputRange,
outputRange: inputRange.map(inputIndex =>
inputIndex === i ? "white" : "black"
)
});
return (
<TouchableOpacity
style={styles.tabItem}
onPress={() => this.setState({ index: i })}
>
<Text style={{ color: "#7A7B7B" }}>
{route.weekDay}
</Text>
<Animated.Text
style={{
backgroundColor: bgcolor,
borderRadius: 0,
padding: 10,
marginTop: 5,
color: color,
fontSize: 15
}}
>
{route.day}
</Animated.Text>
</TouchableOpacity>
);
})}
</View>
);
};
constructor() {
super();
}
2019-03-12 03:34:40 +00:00
_refresh=()=>{
this.props.getEvents(this.props.user);
2019-03-15 22:07:22 +00:00
2019-03-12 03:34:40 +00:00
}
2019-03-10 20:17:58 +00:00
render() {
const ThirdRoute = () => (
<ScrollView contentContainerStyle={styles.contentContainer}>
{this.props.events != undefined && (
<Timeline
data={this.props.c}
timeContainerStyle={{ marginTop: 0 }}
timeStyle={{
textAlign: "center",
height: 100,
color: "#CC1A17",
padding: 5,
fontSize: 23
}}
descriptionStyle={{ color: "red" }}
renderDetail={this.renderDetail}
lineColor="rgba(0,0,0,0)"
lineWidth={1}
separator={false}
flatListProps={{
style: {
margin: 15
}
}}
circleSize={0}
dotColor={"#CC1A17"}
keyExtractor={(item, index) => index.toString()}
/>
)}
</ScrollView>
);
const FourthRoute = () => (
<ScrollView contentContainerStyle={styles.contentContainer}>
{this.props.events != undefined && (
<Timeline
data={this.props.d}
timeContainerStyle={{ marginTop: 0 }}
timeStyle={{
textAlign: "center",
// backgroundColor: 'red',
height: 100,
color: "#CC1A17",
padding: 5,
//marginTop:10,
// fontWeight:'bold',
fontSize: 23
//borderRadius: 13
}}
descriptionStyle={{ color: "red" }}
renderDetail={this.renderDetail}
lineColor="rgba(0,0,0,0)"
lineWidth={1}
separator={false}
flatListProps={{
style: {
margin: 15
}
}}
circleSize={0}
dotColor={"#CC1A17"}
keyExtractor={(item, index) => index.toString()}
/>
)}
</ScrollView>
);
const FirstRoute = () => (
<ScrollView contentContainerStyle={styles.contentContainer}>
{this.props.events != undefined && (
<Timeline
data={this.props.a}
timeContainerStyle={{ marginTop: 0 }}
timeStyle={{
textAlign: "center",
height: 100,
color: "#CC1A17",
padding: 5,
fontSize: 23
}}
descriptionStyle={{ color: "red" }}
renderDetail={this.renderDetail}
lineColor="rgba(0,0,0,0)"
lineWidth={1}
separator={false}
flatListProps={{
style: {
margin: 15
}
}}
circleSize={0}
dotColor={"#CC1A17"}
keyExtractor={(item, index) => index.toString()}
/>
)}
</ScrollView>
);
const SecondRoute = () => (
<ScrollView contentContainerStyle={styles.contentContainer}>
{this.props.events != undefined && (
<Timeline
data={this.props.b}
timeContainerStyle={{ marginTop: 0 }}
timeStyle={{
textAlign: "center",
height: 100,
color: "#CC1A17",
padding: 5,
fontSize: 23
//borderRadius: 13
}}
descriptionStyle={{ color: "red" }}
renderDetail={this.renderDetail}
lineColor="rgba(0,0,0,0)"
lineWidth={1}
separator={false}
flatListProps={{
style: {
margin: 15
}
}}
circleSize={0}
dotColor={"#CC1A17"}
keyExtractor={(item, index) => index.toString()}
/>
)}
</ScrollView>
);
return (
2019-03-12 03:34:40 +00:00
2019-03-10 20:17:58 +00:00
<View style={{ flex: 1 }}>
2019-03-12 03:34:40 +00:00
2019-03-10 20:17:58 +00:00
<View>
{this.props.careerPath != undefined && (
<Text
style={{
backgroundColor: this.props.careerPath.color,
color: "white",
fontWeight: "bold",
fontSize: 15,
textAlign: "center",
padding:15
}}
>
{this.props.careerPath.name}
</Text>
)}
</View>
2019-03-12 03:34:40 +00:00
2019-03-10 20:17:58 +00:00
<TabView
navigationState={this.state}
renderScene={SceneMap({
first: FirstRoute,
second: SecondRoute,
third: ThirdRoute,
fourth: FourthRoute
})}
renderTabBar={this._renderTabBar}
useNativeDriver={false}
onIndexChange={index => this.setState({ index })}
initialLayout={{
width: Dimensions.get("window").width,
height: Dimensions.get("window").height
}}
style={{ backgroundColor: "#F2F2F2" }}
indicatorStyle={{ backgroundColor: "pink" }}
/>
2019-03-12 07:31:41 +00:00
<Button onPress={this._refresh} title="Refresh" color="#841584"
/>
2019-03-10 20:17:58 +00:00
</View>
2019-03-12 03:34:40 +00:00
2019-03-10 20:17:58 +00:00
);
}
2019-01-30 14:32:25 +00:00
}
const styles = StyleSheet.create({
2019-03-10 20:17:58 +00:00
tabBar: {
flexDirection: "row",
paddingTop: 0,
marginTop: 0,
backgroundColor: "white",
borderWidth: 1,
borderRadius: 2,
borderColor: "#ddd",
borderBottomWidth: 0,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.8,
shadowRadius: 2,
elevation: 2
},
tabItem: {
flex: 1,
alignItems: "center",
padding: 10
},
details: {
backgroundColor: "#FFFFFF",
borderBottomRightRadius: 10,
borderBottomLeftRadius: 10,
padding: 10,
paddingTop: 0
},
description: {
padding: 10,
paddingLeft: 0,
paddingTop: 0
},
title: {
color: "#212121",
fontWeight: "bold",
fontSize: 15
},
titleContainer: {
padding: 10
},
event: {
borderRadius: 5,
backgroundColor: "#FFFFFF",
marginLeft: -25,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 1,
elevation: 2,
marginRight: 2
},
scene: {
flex: 1
},
contentContainer: {
//paddingVertical: 20,
backgroundColor: "#F2F2F2"
}
2019-02-08 18:56:38 +00:00
});
2019-03-10 20:17:58 +00:00
RkTheme.setType("RkCard", "story", {
img: {
height: 100,
opacity: 0.7
},
header: {
alignSelf: "center"
},
content: {
alignSelf: "center"
}
2019-02-08 18:56:38 +00:00
});
2019-02-06 23:24:00 +00:00
2019-02-03 20:54:27 +00:00
function mapStateToProps(state, props) {
2019-03-10 20:17:58 +00:00
return {
token: state.apiReducer.token,
user: state.apiReducer.user,
logged: state.apiReducer.logged,
events: state.apiReducer.events,
userDetails: state.apiReducer.userDetails,
sessions: state.apiReducer.sessions,
careerPath: state.apiReducer.careerPath,
a: state.apiReducer.a,
b: state.apiReducer.b,
c: state.apiReducer.c,
d: state.apiReducer.d
};
2019-02-03 20:54:27 +00:00
}
function mapDispatchToProps(dispatch) {
2019-03-10 20:17:58 +00:00
return bindActionCreators(Actions, dispatch);
2019-02-03 20:54:27 +00:00
}
2019-03-10 20:17:58 +00:00
export default connect(
mapStateToProps,
mapDispatchToProps
2019-03-13 20:42:20 +00:00
)(Calendar);