blob: f817bd989414f4aaff7301f4218265ad762a7f42 (
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, {useState} from 'react';
import {Image, ImageStyle, StyleSheet, TouchableOpacity} from 'react-native';
import {normalize} from '../../utils';
interface LikeButtonProps {
onPress: () => void;
filled: boolean;
style: ImageStyle;
}
const LikeButton: React.FC<LikeButtonProps> = ({
onPress,
filled: initialFillState,
style,
}) => {
const [filled, setFilled] = useState(initialFillState);
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;
|