diff options
author | Ivan Chen <ivan@tagg.id> | 2021-05-11 18:56:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-11 18:56:28 -0400 |
commit | 68d10064cf1dcd2a774a4b2299f3a64f8fb75c60 (patch) | |
tree | e8367c2a8cdb19e52c2a70b73ab2a89865efd54a /src/components/common/LikeButton.tsx | |
parent | 610b6c9ddd2414b3b0d5c4cc24c35ef6e9e68513 (diff) | |
parent | 51f397132d227edf5e07d48d673ee167d2aa5937 (diff) |
Merge pull request #409 from IvanIFChen/tma799-comment-likes
[TMA-799] Comments likes
Diffstat (limited to 'src/components/common/LikeButton.tsx')
-rw-r--r-- | src/components/common/LikeButton.tsx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/components/common/LikeButton.tsx b/src/components/common/LikeButton.tsx new file mode 100644 index 00000000..81383eca --- /dev/null +++ b/src/components/common/LikeButton.tsx @@ -0,0 +1,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; |