|
|
@@ -1,6 +1,5 @@
|
|
|
import React, { Component } from 'react';
|
|
|
-import { Text, ListView, View, TouchableOpacity, Image, TextInput } from 'react-native';
|
|
|
-import { Actions } from 'react-native-router-flux';
|
|
|
+import { Text, ListView, View, Image, TextInput } from 'react-native';
|
|
|
import { Card, CardSection, Button } from '../../components/common';
|
|
|
|
|
|
class Comentarios extends Component {
|
|
|
@@ -13,16 +12,17 @@ class Comentarios extends Component {
|
|
|
this.createDataSource(nextProps);
|
|
|
}
|
|
|
|
|
|
- createDataSource({comentarios, respuestas}){
|
|
|
+ createDataSource({ comentarios, respuestas }) {
|
|
|
const ds = new ListView.DataSource({
|
|
|
- rowHasChanged: (r1,r2) => r1 !== r2
|
|
|
+ rowHasChanged: (r1, r2) => r1 !== r2
|
|
|
});
|
|
|
|
|
|
- let c = comentarios.map(function(el) {
|
|
|
- el.respuestas = respuestas.filter(function(r){
|
|
|
- return (r.parent == el._id);
|
|
|
- })
|
|
|
- return el;
|
|
|
+ const c = comentarios.map(el => {
|
|
|
+ const ret = el;
|
|
|
+ ret.respuestas = respuestas.filter(r => {
|
|
|
+ return (r.parent === el._id);
|
|
|
+ });
|
|
|
+ return ret;
|
|
|
});
|
|
|
console.log(c);
|
|
|
this.dataSource = ds.cloneWithRows(c);
|
|
|
@@ -32,18 +32,21 @@ class Comentarios extends Component {
|
|
|
return `https://plataforma.especificosba.com.ar/images/perfiles/${id}.jpg`;
|
|
|
}
|
|
|
|
|
|
- renderRespuesta(item, key) {
|
|
|
+ renderRespuesta(item) {
|
|
|
return (
|
|
|
- <View key={item._id} style={{flex:1}}>
|
|
|
- <View style={{flexDirection: 'row'}}>
|
|
|
- <Image resizeMode='contain' source={{ uri: this.imageUri(item.userid) }} style={{flex:1, height:40}}/>
|
|
|
- <View style={{flex:2, justifyContent: 'center', alignItems:'center'}}>
|
|
|
+ <View key={item._id} style={{ flex: 1 }}>
|
|
|
+ <View style={{ flexDirection: 'row' }}>
|
|
|
+ <Image
|
|
|
+ resizeMode='contain' source={{ uri: this.imageUri(item.userid) }}
|
|
|
+ style={{ flex: 1, height: 40 }}
|
|
|
+ />
|
|
|
+ <View style={{ flex: 2, justifyContent: 'center', alignItems: 'center' }}>
|
|
|
<Text>{item.nombreUsuario}</Text>
|
|
|
<Text>{item.fecha}</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
- <CardSection style={{backgroundColor:'#eef'}}>
|
|
|
- <Text style={{color:'#000'}}>{item.texto}</Text>
|
|
|
+ <CardSection style={{ backgroundColor: '#eef' }}>
|
|
|
+ <Text style={{ color: '#000' }}>{item.texto}</Text>
|
|
|
</CardSection>
|
|
|
</View>
|
|
|
);
|
|
|
@@ -52,29 +55,29 @@ class Comentarios extends Component {
|
|
|
renderComentario(item) {
|
|
|
const uri = this.imageUri(item.userid);
|
|
|
|
|
|
- let Arr = item.respuestas.map( el => {
|
|
|
+ let Arr = item.respuestas.map(el => {
|
|
|
return this.renderRespuesta(el);
|
|
|
});
|
|
|
- if ( Arr != undefined && Arr.length > 0 ) {
|
|
|
- Arr = <View style={{backgroundColor:'#eef'}}>{Arr}</View>;
|
|
|
+ if (Arr !== undefined && Arr.length > 0) {
|
|
|
+ Arr = <View style={{ backgroundColor: '#eef' }}>{ Arr}</View>;
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
<Card>
|
|
|
|
|
|
<CardSection>
|
|
|
- <Image resizeMode='contain' source={{ uri }} style={{flex:1, height:70}}/>
|
|
|
- <View style={{flex:2, justifyContent: 'center', alignItems:'center'}}>
|
|
|
- <Text style={{alignSelf:'center'}}>{item.nombreUsuario}</Text>
|
|
|
- <Text style={{alignSelf:'center'}}>{item.fecha}</Text>
|
|
|
+ <Image resizeMode='contain' source={{ uri }} style={{ flex: 1, height: 70 }} />
|
|
|
+ <View style={{ flex: 2, justifyContent: 'center', alignItems: 'center' }}>
|
|
|
+ <Text style={{ alignSelf: 'center' }}>{ item.nombreUsuario}</Text>
|
|
|
+ <Text style={{ alignSelf: 'center' }}>{ item.fecha}</Text>
|
|
|
</View>
|
|
|
</CardSection>
|
|
|
|
|
|
<CardSection>
|
|
|
- <Text>{item.texto}</Text>
|
|
|
+ <Text>{ item.texto}</Text>
|
|
|
</CardSection>
|
|
|
|
|
|
- {Arr}
|
|
|
+ { Arr}
|
|
|
</Card>
|
|
|
);
|
|
|
}
|
|
|
@@ -83,15 +86,15 @@ class Comentarios extends Component {
|
|
|
return (
|
|
|
<Card>
|
|
|
<CardSection>
|
|
|
- <Text style={{justifyContent:'center'}}>
|
|
|
+ <Text style={{ justifyContent: 'center' }}>
|
|
|
Dejar un comentario
|
|
|
</Text>
|
|
|
</CardSection>
|
|
|
<CardSection>
|
|
|
<TextInput
|
|
|
- autoCorrect={true}
|
|
|
- multiline={true}
|
|
|
- style={{flex:1}}
|
|
|
+ autoCorrect
|
|
|
+ multiline
|
|
|
+ style={{ flex: 1 }}
|
|
|
/>
|
|
|
</CardSection>
|
|
|
<CardSection>
|
|
|
@@ -102,11 +105,11 @@ class Comentarios extends Component {
|
|
|
}
|
|
|
render() {
|
|
|
if (this.props.comentarios === undefined ||
|
|
|
- this.props.comentarios.length == 0 ) {
|
|
|
+ this.props.comentarios.length === 0) {
|
|
|
return (
|
|
|
- <View style={{margin:10}}>
|
|
|
- {this.renderNewComment()}
|
|
|
- <Text style={{fontSize:14,alignSelf:'center'}}>
|
|
|
+ <View style={{ margin: 10 }}>
|
|
|
+ { this.renderNewComment()}
|
|
|
+ <Text style={{ fontSize: 14, alignSelf: 'center' }}>
|
|
|
Aún no hay comentarios
|
|
|
</Text>
|
|
|
</View>
|
|
|
@@ -114,13 +117,13 @@ class Comentarios extends Component {
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
- <ListView
|
|
|
+ <ListView
|
|
|
enableEmptySections
|
|
|
renderHeader={this.renderNewComment}
|
|
|
dataSource={this.dataSource}
|
|
|
renderRow={this.renderComentario.bind(this)}
|
|
|
- />
|
|
|
- );
|
|
|
+ />
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
}
|