import Moment from 'moment';
import React, {useCallback, useState, useRef} from 'react';
import {
  Image,
  Text,
  View,
  TouchableOpacity,
  Dimensions,
  StyleSheet,
} from 'react-native';
import FastImage from 'react-native-fast-image';
import ButtonComponent from '../../../components/ButtonComponent';
import {GifType, IMAGES} from '../../../values/images';
const windowWidth = Dimensions.get('window').width;
const ProfileUserComponent = ({userDetails, onClose}) => {
  //console.log('userDetails', userDetails);
  return (
    <View style={styles.container}>
      <View>
        <ButtonComponent
          style={{position: 'absolute', top: 0, right: 0, zIndex: 100}}
          iconSource={IMAGES.IcCloseGrey}
          onPress={onClose}
          styleIcon={{width: 30, height: 30}}
        />
        <View
          style={[
            styles.viewContent,
            {justifyContent: 'center', alignItems: 'center'},
          ]}>
          <Image
            source={
              (userDetails.cover_image && {
                uri: 'https://meu.anawork.com' + userDetails.cover_image,
              }) ||
              IMAGES.ImageCoverBg
            }
            style={styles.coverImage}
          />
          <TouchableOpacity style={styles.viewAvatar}>
            <Image
              source={{
                uri: 'https://meu.anawork.com' + userDetails.avatar,
              }}
              style={styles.imgAvatar}
            />
          </TouchableOpacity>
          <Text style={{color: 'black', fontSize: 18}}>
            {`${userDetails.extend_user_full_name}`}
          </Text>
          <Text style={{marginBottom: 20}}>{userDetails.position}</Text>
        </View>
        <View style={[styles.viewContent, {padding: 10}]}>
          <View style={{borderBottomWidth: 1}}>
            <Text style={{fontSize: 17, color: 'black'}}>
              Thông tin cá nhân
            </Text>
          </View>
          <View style={styles.viewInfo}>
            <View style={{flex: 1, flexDirection: 'row'}}>
              <Image source={IMAGES.IcInfoGuess} style={{marginRight: 10}} />
              <View>
                <Text>Họ và tên</Text>
                <Text style={styles.subTxt}>
                  {userDetails.extend_user_full_name}
                </Text>
              </View>
            </View>
          </View>
          <View style={styles.viewInfo}>
            <View style={{flex: 1, flexDirection: 'row'}}>
              <Image source={IMAGES.IcInfoGuess} style={{marginRight: 10}} />
              <View>
                <Text>Giới tính</Text>
                <Text style={styles.subTxt}>
                  {userDetails.gender ? 'Nam' : 'Nữ'}
                </Text>
              </View>
            </View>
          </View>
          <View style={{...styles.viewInfo, flexDirection: 'row'}}>
            <Image
              source={IMAGES.IcPhone}
              style={{marginRight: 10, height: 20, width: 20}}
            />
            <View>
              <Text>Số điện thoại</Text>
              <Text style={styles.subTxt}>{userDetails.cell_phone}</Text>
            </View>
          </View>
          <View style={{flexDirection: 'row'}}>
            <Image
              source={IMAGES.IcMailGray}
              style={{marginRight: 10, height: 20, width: 20}}
            />
            <View>
              <Text>Email</Text>
              <Text style={styles.subTxt}>{userDetails.email}</Text>
            </View>
          </View>
        </View>
      </View>
    </View>
  );
};
const styles = StyleSheet.create({
  container: {
    backgroundColor: 'white',
    position: 'absolute',
    padding: 10,
    bottom: 0,
    borderTopLeftRadius: 10,
    borderTopRightRadius: 10,
    width: '100%',
    justifyContent: 'flex-end',
    minHeight: '50%',
    flex: 1,
  },
  viewContent: {
    borderWidth: 1,
    width: windowWidth - 20,
    borderColor: 'white',
    backgroundColor: 'white',
    alignSelf: 'center',
    marginTop: 10,
    marginBottom: 10,
  },
  coverImage: {
    width: windowWidth - 5,
    height: 120,
    resizeMode: 'cover',
  },
  viewAvatar: {
    borderWidth: 5,
    borderRadius: 60,
    borderColor: 'white',
    marginTop: -50,
    backgroundColor: 'white',
  },
  imgAvatar: {
    width: 90,
    height: 90,
    resizeMode: 'contain',
    alignSelf: 'center',
    borderRadius: 60,
  },
  viewInfo: {
    flexDirection: 'row',
    borderBottomWidth: 0.2,
    borderBottomColor: 'grey',
    marginTop: 5,
    paddingTop: 5,
    paddingBottom: 5,
  },
  subTxt: {
    color: 'black',
    fontWeight: 'bold',
  },
});
export default ProfileUserComponent;
