import React from 'react';
import {View, StyleSheet, ViewProps, Text} from 'react-native';
import {ProfilePreviewType} from '../../types';
import {ProfilePreview} from '..';
import {useNavigation} from '@react-navigation/native';
import {Button} from 'react-native-elements';

interface FollowersListProps {
  result: Array<ProfilePreviewType>;
  sectionTitle: string;
}

const Followers: React.FC<FollowersListProps> = ({result, sectionTitle}) => {
  const navigation = useNavigation();
  return (
    <>
      <View style={styles.header}>
        <Button
          title="X"
          buttonStyle={styles.button}
          titleStyle={styles.buttonText}
          onPress={() => {
            navigation.goBack();
          }}
        />
        <Text style={styles.title}>{sectionTitle}</Text>
      </View>
      {result.map((profilePreview) => (
        <ProfilePreview
          style={styles.follower}
          key={profilePreview.id}
          {...{profilePreview}}
          isComment={true}
        />
      ))}
    </>
  );
};

const styles = StyleSheet.create({
  header: {flexDirection: 'row'},
  follower: {
    marginVertical: 10,
  },
  title: {
    position: 'relative',
    fontSize: 17,
    fontWeight: 'bold',
    paddingBottom: 10,
    paddingTop: 10,
    flexGrow: 1,
    paddingLeft: '26%',
  },
  button: {
    backgroundColor: 'transparent',
  },
  buttonText: {
    color: 'black',
    fontSize: 18,
    fontWeight: '400',
  },
});

export default Followers;
