aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/Cover.tsx
blob: b7502cff5039dd0eed6f011fcefd232906ab8f80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from 'react';
import {Image, StyleSheet, View} from 'react-native';
import {useSelector} from 'react-redux';
import {COVER_HEIGHT, IMAGE_WIDTH} from '../../constants';
import {RootState} from '../../store/rootreducer';
import {ScreenType} from '../../types';

interface CoverProps {
  userXId: string | undefined;
  screenType: ScreenType;
}
const Cover: React.FC<CoverProps> = ({userXId, screenType}) => {
  const {cover} = userXId
    ? useSelector((state: RootState) => state.userX[screenType][userXId])
    : useSelector((state: RootState) => state.user);

  return (
    <View style={[styles.container]}>
      <Image
        style={styles.image}
        defaultSource={require('../../assets/images/cover-placeholder.png')}
        source={{uri: cover}}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    position: 'absolute',
  },
  image: {
    width: IMAGE_WIDTH,
    height: COVER_HEIGHT,
  },
});
export default Cover;