aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/LikeButton.tsx
blob: 81383eca4ec58645287ed47837fbf1d595932e83 (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
38
import React from 'react';
import {Image, ImageStyle, StyleSheet, TouchableOpacity} from 'react-native';
import {normalize} from '../../utils';

interface LikeButtonProps {
  onPress: () => void;
  style: ImageStyle;
  liked: boolean;
  setLiked: (liked: boolean) => void;
}
const LikeButton: React.FC<LikeButtonProps> = ({
  onPress,
  style,
  liked,
  setLiked,
}) => {
  const uri = liked
    ? require('../../assets/images/heart-filled.png')
    : require('../../assets/images/heart-outlined.png');
  return (
    <TouchableOpacity
      onPress={() => {
        setLiked(!liked);
        onPress();
      }}>
      <Image style={[styles.image, style]} source={uri} />
    </TouchableOpacity>
  );
};

const styles = StyleSheet.create({
  image: {
    width: normalize(18),
    height: normalize(15),
  },
});

export default LikeButton;