Bläddra i källkod

header in vclase

David 9 år sedan
förälder
incheckning
565fbaaadb
3 ändrade filer med 17 tillägg och 27 borttagningar
  1. 3 2
      src/scenes/Clase.js
  2. 12 2
      src/scenes/Clase/Comentarios.js
  3. 2 23
      src/scenes/Clase/Teoria.js

+ 3 - 2
src/scenes/Clase.js

@@ -40,7 +40,7 @@ class Clase extends Component {
 
 		const ScrollableTabView = require('react-native-scrollable-tab-view');
 
-		const { titulo, profesor, texto, comentarios, respuestas } = this.props.clase;
+		const { titulo, profesor, texto, comentarios, respuestas, fecha } = this.props.clase;
 
 		const icon = local ? 'ios-star' : 'ios-star-outline';
 		const title = local ? 'Borrar clase' : 'Guardar clase';
@@ -50,11 +50,12 @@ class Clase extends Component {
 
 			<ScrollableTabView style={[styles.container, { flex: 1 }]}>
 				<Teoria
-					titulo={titulo} profesor={profesor} texto={texto} style={{ flex: 1 }} tabLabel='Teoria'
+					titulo={titulo} profesor={profesor} fecha={fecha} texto={texto} style={{ flex: 1 }} tabLabel='Teoria'
 				/>
 				<View tabLabel='Videos' />
 				<Comentarios
 					style={{ flex: 1 }} comentarios={comentarios}
+					titulo={titulo} profesor={profesor} fecha={fecha}
 					respuestas={respuestas} tabLabel='Comentarios'
 				/>
 			</ScrollableTabView>

+ 12 - 2
src/scenes/Clase/Comentarios.js

@@ -1,6 +1,7 @@
 import React, { Component } from 'react';
 import { Text, ListView, View, Image, TextInput } from 'react-native';
 import { Card, CardSection, Button } from '../../components/common';
+import Header from './Header';
 
 class Comentarios extends Component {
 
@@ -82,6 +83,15 @@ class Comentarios extends Component {
     );
   }
 
+  renderHeader() {
+  	const out = (
+		<View>
+		<Header titulo={this.props.titulo} profesor={this.props.profesor} fecha={this.props.fecha} />
+			{this.renderNewComment()}
+		</View>
+	);
+	return out;
+  }
   renderNewComment() {
     return (
       <Card>
@@ -108,7 +118,7 @@ class Comentarios extends Component {
         this.props.comentarios.length === 0) {
           return (
             <View style={{ margin: 10 }}>
-              { this.renderNewComment()}
+              {this.renderNewComment()}
               <Text style={{ fontSize: 14, alignSelf: 'center' }}>
                 Aún no hay comentarios
               </Text>
@@ -119,7 +129,7 @@ class Comentarios extends Component {
     return (
 		<ListView
             enableEmptySections
-            renderHeader={this.renderNewComment}
+            renderHeader={this.renderHeader.bind(this)}
             dataSource={this.dataSource}
             renderRow={this.renderComentario.bind(this)}
 		/>

+ 2 - 23
src/scenes/Clase/Teoria.js

@@ -2,34 +2,13 @@ import React, { Component } from 'react';
 import { Text, WebView, View, TouchableOpacity } from 'react-native';
 import { Actions } from 'react-native-router-flux';
 import { Card, CardSection, Button } from '../../components/common';
+import Header from './Header';
 
 class Teoria extends Component {
-	renderProf(p) {
-		if (!Array.isArray(p))
-			p = [ p ];
-		return p.map( e => {
-			<Text key={e._id} style={{ color: '#007aff', fontWeight: '600' }}>
-				{e.nombre} {e.apellido}
-			</Text>
-		});
-	}
-
 	render() {
-		//console.log('teoria', this.props);
-
 		return (
 			<View style={{ flex: 1 }}>
-		        <CardSection>
-		          <Text>{this.props.titulo}</Text>
-		        </CardSection>
-
-		        <CardSection>
-					<TouchableOpacity onPress={() => Actions.ViewProf({ id: this.props.profesor._id})}>
-						<Text>Profesor: </Text>
-						{this.renderProf(this.props.profesor)}
-					</TouchableOpacity>
-		        </CardSection>
-
+				<Header titulo={this.props.titulo} profesor={this.props.profesor} fecha={this.props.fecha} />
 		        <CardSection style={{ flex: 1, alignItems: 'stretch' }}>
 		            <WebView
 		              scalesPageToFit={true}