From 43e1c33edf6fca78e366403f167cc01ea075a226 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 7 May 2021 15:12:13 -0400 Subject: added like button --- src/assets/images/heart-filled.png | Bin 0 -> 1208 bytes src/assets/images/heart-outlined.png | Bin 0 -> 1055 bytes src/components/comments/CommentTile.tsx | 22 +++++++++++++++++----- src/components/common/LikeButton.tsx | 32 ++++++++++++++++++++++++++++++++ src/components/common/index.ts | 1 + 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 src/assets/images/heart-filled.png create mode 100644 src/assets/images/heart-outlined.png create mode 100644 src/components/common/LikeButton.tsx (limited to 'src') diff --git a/src/assets/images/heart-filled.png b/src/assets/images/heart-filled.png new file mode 100644 index 00000000..59bf0ab1 Binary files /dev/null and b/src/assets/images/heart-filled.png differ diff --git a/src/assets/images/heart-outlined.png b/src/assets/images/heart-outlined.png new file mode 100644 index 00000000..aeb87a99 Binary files /dev/null and b/src/assets/images/heart-outlined.png differ diff --git a/src/components/comments/CommentTile.tsx b/src/components/comments/CommentTile.tsx index ecdb4c30..cf79b68c 100644 --- a/src/components/comments/CommentTile.tsx +++ b/src/components/comments/CommentTile.tsx @@ -26,6 +26,7 @@ import { SCREEN_WIDTH, } from '../../utils'; import {mentionPartTypes, renderTextWithMentions} from '../../utils/comments'; +import {LikeButton} from '../common'; import {ProfilePreview} from '../profile'; import CommentsContainer from './CommentsContainer'; @@ -143,11 +144,14 @@ const CommentTile: React.FC = ({ containerStyle={styles.swipableContainer}> - + + + {}} style={styles.likeButton} /> + {renderTextWithMentions({ value: commentObject.comment, @@ -215,6 +219,14 @@ const styles = StyleSheet.create({ moreMarginWithThread: { marginLeft: '14%', }, + commentHeaderContainer: { + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + }, + likeButton: { + marginRight: 10, + }, body: { marginLeft: 56, }, diff --git a/src/components/common/LikeButton.tsx b/src/components/common/LikeButton.tsx new file mode 100644 index 00000000..28eff768 --- /dev/null +++ b/src/components/common/LikeButton.tsx @@ -0,0 +1,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 = ({onPress, style}) => { + const [filled, setFilled] = useState(false); + const uri = filled + ? require('../../assets/images/heart-filled.png') + : require('../../assets/images/heart-outlined.png'); + return ( + { + setFilled(!filled); + onPress(); + }}> + + + ); +}; + +const styles = StyleSheet.create({ + image: { + width: normalize(18), + height: normalize(15), + }, +}); + +export default LikeButton; diff --git a/src/components/common/index.ts b/src/components/common/index.ts index b38056c6..48abb8b8 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -26,3 +26,4 @@ export {default as BasicButton} from './BasicButton'; export {default as Avatar} from './Avatar'; export {default as TaggTypeahead} from './TaggTypeahead'; export {default as TaggUserRowCell} from './TaggUserRowCell'; +export {default as LikeButton} from './LikeButton'; -- cgit v1.2.3-70-g09d2