content: import React, { Component } from 'react';
  import { StyleSheet, View, Image } from 'react-native';
  import { Container, Header, Content, Card, CardItem, Thumbnail, Text, Button, Left, Body, Right } from 'native-base';
  import Timestamp from 'react-timestamp';
  import Icon from 'react-native-vector-icons/MaterialIcons'
  
  import firebase from 'firebase'
  
  import { StarBtn, StarredBtn } from './StarBtn'
  
  // import LocalizedStrings from 'react-native-localization'
  
  
  class RecomendRef extends Component{
    constructor(props) {
      super(props);
      this.state = {
        profile_image:'',
        star:'',
      };
    }
  
    starBtnClick = () => {
      const myUserId = this.props.myuid
      const starUserData = this.props.searchRef.uid
      firebase.database().ref('users/' + starUserData + '/userStar').once("value").then(function(snapshot) {
        const starData = snapshot.val()
        var updates = {}
        if(starData.stars&&starData.stars[myUserId]){
          updates['users/' + starUserData + '/userStar/stars/' + myUserId]= null
          updates['users/' + starUserData + '/userStar/starCount']= starData.starCount-1
          updates['users/' + myUserId + '/starred_users/' + starUserData]= null
        }else{
          updates['users/' + starUserData + '/userStar/stars/' + myUserId]= true
          updates['users/' + starUserData + '/userStar/starCount']= starData.starCount+1
          updates['users/' + myUserId + '/starred_users/' + starUserData]= true
        }
        return  firebase.database().ref().update(updates)
      })
    }
  
    render() {
      return (
        <Card>
          <CardItem>
            <Left>
              <Thumbnail source={{uri:this.props.searchRef.profile_image}} />
              <Body>
                <Text style={{fontWeight:'bold'}}>{this.props.searchRef.user}</Text>
              </Body>
            </Left>
          </CardItem>
          <CardItem>
            <Body>
              <Text>
                {this.props.searchRef.explain}
              </Text>
            </Body>
          </CardItem>
          <CardItem>
            {
              this.props.searchRef.uid === this.props.myuid
              ? <Left></Left>
              : <Left>
                {
                (this.props.searchRef.userStar.stars && this.props.searchRef.userStar.stars[this.props.myuid])
                  ?<StarredBtn onStarBtnClick={this.starBtnClick}/>
                  :<StarBtn onStarBtnClick={this.starBtnClick}/>
                }
                </Left>
            }
          </CardItem>
        </Card>
      )
    }
  }
  
  export default RecomendRef
  