|
|
@@ -0,0 +1,89 @@
|
|
|
+import React, { Component } from 'react';
|
|
|
+import { Text, ListView, View, TouchableOpacity } from 'react-native';
|
|
|
+import { connect } from 'react-redux';
|
|
|
+import { Actions } from 'react-native-router-flux';
|
|
|
+import { Card, CardSection, Button } from '../components/common/';
|
|
|
+
|
|
|
+class LSListaClases extends Component {
|
|
|
+ componentWillMount() {
|
|
|
+ this.createDataSource(this.props);
|
|
|
+ }
|
|
|
+ componentWillReceiveProps(){
|
|
|
+ this.createDataSource(this.props);
|
|
|
+ }
|
|
|
+ createDataSource({clases}){
|
|
|
+ const ds = new ListView.DataSource({
|
|
|
+ rowHasChanged: (r1,r2) => r1 !== r2
|
|
|
+ });
|
|
|
+ this.dataSource = ds.cloneWithRows(clases);
|
|
|
+ }
|
|
|
+
|
|
|
+ onClassPress(clase) {
|
|
|
+ //Actions.ViewClase({ cursada, _id:id });
|
|
|
+ const { titulo, profesor, texto } = clase;
|
|
|
+ Actions.Teoria({ titulo, profesor, texto });
|
|
|
+ }
|
|
|
+
|
|
|
+ renderButton(data) {
|
|
|
+ return (
|
|
|
+ <CardSection>
|
|
|
+ <Button
|
|
|
+ onPress={ () => this.onClassPress(data)}>
|
|
|
+ Ingresar
|
|
|
+ </Button>
|
|
|
+ </CardSection>
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ renderRow(data) {
|
|
|
+ const moment = require('moment');
|
|
|
+ const fecha = moment(data.fecha).local().format('DD/MM/YY');
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Card>
|
|
|
+ <CardSection>
|
|
|
+ <Text>{data.titulo}</Text>
|
|
|
+ </CardSection>
|
|
|
+
|
|
|
+ <CardSection>
|
|
|
+ <Text style={{flex:1}}>Profesor:</Text>
|
|
|
+ <Text style={{flex:1, fontWeight: '600'}}>
|
|
|
+ {data.profesor.nombre} {data.profesor.apellido}
|
|
|
+ </Text>
|
|
|
+ </CardSection>
|
|
|
+
|
|
|
+ <CardSection>
|
|
|
+ <Text style={{flex:1}}>Fecha:</Text>
|
|
|
+ <Text style={{flex:1}}>{fecha}</Text>
|
|
|
+ </CardSection>
|
|
|
+
|
|
|
+ {this.renderButton(data)}
|
|
|
+ </Card>
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ const { cursada } = this.props;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <View style={{flex:1}}>
|
|
|
+ <CardSection>
|
|
|
+ <Text style={{textAlign:'center', flex: 1, fontSize:18}}>
|
|
|
+ Clases Descargadas
|
|
|
+ </Text>
|
|
|
+ </CardSection>
|
|
|
+ <ListView
|
|
|
+ enableEmptySections
|
|
|
+ dataSource={this.dataSource}
|
|
|
+ renderRow={this.renderRow.bind(this)}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const mapStateToProps = state => {
|
|
|
+ return { clases: state.LocalStorageReducer.clases };
|
|
|
+};
|
|
|
+
|
|
|
+export default connect(mapStateToProps)(LSListaClases);
|