blob: 28eff768c7b117ba163ee1cc4b7031ce5e155b32 (
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
|
import React, {useState} from 'react';
import {Image, ImageStyle, StyleSheet, TouchableOpacity} from 'react-native';
import {normalize} from '../../utils';
interface LikeButtonProps {
onPress: () => void;
style: ImageStyle;
}
const LikeButton: React.FC<LikeButtonProps> = ({onPress, style}) => {
const [filled, setFilled] = useState(false);
const uri = filled
? require('../../assets/images/heart-filled.png')
: require('../../assets/images/heart-outlined.png');
return (
<TouchableOpacity
onPress={() => {
setFilled(!filled);
onPress();
}}>
<Image style={[styles.image, style]} source={uri} />
</TouchableOpacity>
);
};
const styles = StyleSheet.create({
image: {
width: normalize(18),
height: normalize(15),
},
});
export default LikeButton;
|