David 9 anni fa
parent
commit
2321151441
2 ha cambiato i file con 30 aggiunte e 5 eliminazioni
  1. 1 1
      src/components/Clase.js
  2. 29 4
      src/components/Clase/Comentarios.js

+ 1 - 1
src/components/Clase.js

@@ -21,7 +21,7 @@ class Clase extends Component {
       return <Teoria titulo={titulo} profesor={profesor} texto={texto} />;
 
     if ( this.state.page === 'Comentarios' )
-      return <Comentarios comentarios={comentarios} respuestas={respuestas} />;
+      return <Comentarios style={{flex:1}} comentarios={comentarios} respuestas={respuestas} />;
 
     return <Text>{this.state.page}!!!</Text>;
   }

+ 29 - 4
src/components/Clase/Comentarios.js

@@ -1,7 +1,7 @@
 import React, { Component } from 'react';
 import { Text, ListView, View, TouchableOpacity, Image } from 'react-native';
 import { Actions } from 'react-native-router-flux';
-import { Card, CardSection, Button } from '../common';
+import { Card, CardSection, Button, Input } from '../common';
 
 class Comentarios extends Component {
 
@@ -47,15 +47,40 @@ class Comentarios extends Component {
       </Card>
     );
   }
-	render() {
-		//console.log("teoria", this.props);
-		return (
+
+  renderList() {
+    if (this.props.comentarios === undefined ||
+        this.props.comentarios.length == 0 ) {
+          return (
+            <View>
+              <Text> Aún no hay comentarios </Text>
+              <Card >
+                <CardSection>
+                  <Text> Dejar un comentario </Text>
+                </CardSection>
+                <CardSection>
+                  <Input multiline={true} placeholder="comentario"></Input>
+                </CardSection>
+                <CardSection>
+                  <Button>Enviar</Button>
+                </CardSection>
+              </Card>
+            </View>
+          );
+    }
+
+    return (
         <ListView
+          enableEmptySections
           dataSource={this.dataSource}
           renderRow={this.renderComentario.bind(this)}
           style={{flex:1, marginBottom:50}}
           />
 		);
+  }
+	render() {
+		//console.log("teoria", this.props);
+		return this.renderList();
 	}
 }