Parcourir la source

new menu screen

David il y a 9 ans
Parent
commit
934be9cecf

+ 6 - 4
src/Router.js

@@ -20,6 +20,11 @@ const scenes = Actions.create(
 			<Scene key="register" component={RegisterForm} title="Registrarse" />
 		</Scene>
 
+		<Scene key="Menu" hideNavBar={false}>
+			<Scene key="MenuScene" title="Menu" component={Menu} panHandlers={null} direction="vertical" />
+			<Scene key="Teoria" title="Teoria" component={Teoria} />
+		</Scene>
+
 		<Scene key="main" hideNavBar={false}>
 			<Scene key="ListaCursadas" rightTitle="test" onRight={ () => Actions.Live() } component={ListaCursadas} title="Cursadas" />
 			<Scene key="ViewCursada" component={ListaClases} title="Clases" />
@@ -27,10 +32,7 @@ const scenes = Actions.create(
 			<Scene key="ViewProf" component={Profesor} title="Profesor" />
 			<Scene key="Live" title="Curso en vivo" component={LiveVideo} />
 		</Scene>
-		<Scene key="Menu" hideNavBar={false}>
-			<Scene key="MenuScene" title="Menu" component={Menu} panHandlers={null} direction="vertical" />
-			<Scene key="Teoria" title="Teoria" component={Teoria} />
-		</Scene>
+
 
 	</Scene>
 );

+ 1 - 1
src/actions/AuthActions.js

@@ -44,5 +44,5 @@ const loginUserSuccess = (dispatch, user) => {
     type: LOGIN_USER_SUCCESS,
     payload: user
   });
-  Actions.main();
+  Actions.Menu();
 };

+ 1 - 1
src/scenes/Clase.js

@@ -105,7 +105,7 @@ const mapStateToProps = state => {
 	const local = localClases.filter( c => {
 		return c._id === curClase._id
 	}).length > 0;
-	
+
 	return { loading, clase: curClase, local };
 };
 

+ 89 - 0
src/scenes/LSListaClases.js

@@ -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);

+ 2 - 5
src/scenes/ListaCursadas.js

@@ -1,7 +1,7 @@
 import React, { Component } from 'react';
 import { View, Text, ListView } from 'react-native';
 import { connect } from 'react-redux';
-import { initLSClase, cursadasFetch } from '../actions/';
+import { cursadasFetch } from '../actions/';
 import ItemCursada from './Cursada/ItemCursada';
 import MyActionButton from '../components/ActionButton';
 import { ConnectionError } from '../components/common';
@@ -10,8 +10,6 @@ class ListaCursadas extends Component  {
 
 	componentWillMount() {
     	this.props.cursadasFetch();
-		this.props.initLSClase();
-		
 		this.createDataSource(this.props);
 	}
 	componentWillReceiveProps(nextProps) {
@@ -48,8 +46,7 @@ class ListaCursadas extends Component  {
 
 const mapStateToProps = state => {
 	const { cursadas, cursos, error }  = state.cursadasR;
-	//console.log(state.cursadasR);
 	return { cursadas, cursos, error };
 };
 
-export default connect(mapStateToProps, { initLSClase, cursadasFetch })(ListaCursadas);
+export default connect(mapStateToProps, { cursadasFetch })(ListaCursadas);

+ 47 - 8
src/scenes/Menu.js

@@ -1,15 +1,54 @@
 import React, { Component } from 'react';
 import { View, Text } from 'react-native';
+import { connect } from 'react-redux';
+
+import { initLSClase } from '../actions/';
 import MyAbout from './MyAbout';
+import LSListaClases from './LSListaClases';
+import { Card, CardSection } from '../components/common';
 
 class Menu extends Component  {
-  render() {
-    return (
-      <View style={{flex:1}}>
-        <MyAbout />
-      </View>
-    );
-  };
+	componentWillMount(){
+		this.props.initLSClase();
+	}
+	componentWillReceiveProps() {
+		this.props.initLSClase();
+	}
+	render() {
+		return (
+			<View style={{flex:1}}>
+				<Card>
+					<CardSection>
+						<Text>Cursadas</Text>
+					</CardSection>
+				</Card>
+
+				<Card>
+					<CardSection>
+						<Text>Curso en vivo</Text>
+					</CardSection>
+				</Card>
+
+				<Card>
+					<CardSection>
+						<Text>Clases descargadas</Text>
+					</CardSection>
+				</Card>
+
+				<Card>
+					<CardSection>
+					<Text>Perfil</Text>
+					</CardSection>
+				</Card>
+
+				<Card>
+					<CardSection>
+					<Text>Como llegar / acerca de / ??</Text>
+					</CardSection>
+				</Card>
+			</View>
+		);
+	};
 }
 
-export default Menu;
+export default connect(null, { initLSClase })(Menu);