From b6f3a234da215a0c0f3967d04a921e82e4b5a259 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Sat, 5 Nov 2022 13:48:45 -0500 Subject: Replace likes with votes on post UIs --- src/view/com/post-thread/PostThreadItem.tsx | 89 +++++++--------------------- src/view/com/post/Post.tsx | 74 ++++-------------------- src/view/com/posts/FeedItem.tsx | 79 ++++--------------------- src/view/com/util/PostCtrls.tsx | 87 ++++++++++++++++++++++++++++ src/view/lib/icons.tsx | 90 +++++++++++++++++++++++++++++ 5 files changed, 220 insertions(+), 199 deletions(-) create mode 100644 src/view/com/util/PostCtrls.tsx (limited to 'src') diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 9fb145f15..7add92361 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -13,6 +13,7 @@ import {UserAvatar} from '../util/UserAvatar' import {s, colors} from '../../lib/styles' import {ago, pluralize} from '../../lib/strings' import {useStores} from '../../../state' +import {PostCtrls} from '../util/PostCtrls' const PARENT_REPLY_LINE_LENGTH = 8 @@ -64,50 +65,6 @@ export const PostThreadItem = observer(function PostThreadItem({ .catch(e => console.error('Failed to toggle like', record, e)) } - const Ctrls = () => ( - - - - {item.replyCount} - - - - - {item.repostCount} - - - - - - {item.likeCount} - - - onPressShare(item.uri)}> - - - - ) - if (item._isHighlightedPost) { return ( @@ -194,7 +151,16 @@ export const PostThreadItem = observer(function PostThreadItem({ <> )} - + @@ -291,7 +257,16 @@ export const PostThreadItem = observer(function PostThreadItem({ style={[styles.postText, s.f15, s['lh15-1.3']]} /> - + @@ -370,26 +345,4 @@ const styles = StyleSheet.create({ expandedInfoItem: { marginRight: 10, }, - ctrls: { - flexDirection: 'row', - }, - ctrl: { - flexDirection: 'row', - alignItems: 'center', - flex: 1, - paddingLeft: 4, - paddingRight: 4, - }, - ctrlIcon: { - marginRight: 5, - color: colors.gray5, - }, - ctrlIconReposted: { - marginRight: 5, - color: colors.green3, - }, - ctrlIconLiked: { - marginRight: 5, - color: colors.red3, - }, }) diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index 5f19e0d67..91088e21b 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -13,6 +13,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {PostThreadViewModel} from '../../../state/models/post-thread-view' import {Link} from '../util/Link' import {UserInfoText} from '../util/UserInfoText' +import {PostCtrls} from '../util/PostCtrls' import {RichText} from '../util/RichText' import {UserAvatar} from '../util/UserAvatar' import {useStores} from '../../../state' @@ -125,47 +126,16 @@ export const Post = observer(function Post({uri}: {uri: string}) { style={[s.f15, s['lh15-1.3']]} /> - - - - {item.replyCount} - - - - - {item.repostCount} - - - - - - {item.likeCount} - - - - - - + @@ -202,26 +172,4 @@ const styles = StyleSheet.create({ flexWrap: 'wrap', paddingBottom: 8, }, - ctrls: { - flexDirection: 'row', - }, - ctrl: { - flexDirection: 'row', - alignItems: 'center', - flex: 1, - paddingLeft: 4, - paddingRight: 4, - }, - ctrlIcon: { - marginRight: 5, - color: colors.gray5, - }, - ctrlIconReposted: { - marginRight: 5, - color: colors.green3, - }, - ctrlIconLiked: { - marginRight: 5, - color: colors.red3, - }, }) diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 5164ad12d..257690d05 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -9,6 +9,7 @@ import {SharePostModel} from '../../../state/models/shell' import {Link} from '../util/Link' import {PostDropdownBtn} from '../util/DropdownBtn' import {UserInfoText} from '../util/UserInfoText' +import {PostCtrls} from '../util/PostCtrls' import {RichText} from '../util/RichText' import {UserAvatar} from '../util/UserAvatar' import {s, colors} from '../../lib/styles' @@ -126,52 +127,16 @@ export const FeedItem = observer(function FeedItem({ style={[s.f15, s['lh15-1.3']]} /> - - - - {item.replyCount} - - - - - {item.repostCount} - - - - - - {item.likeCount} - - - onPressShare(item.uri)}> - - - + @@ -221,26 +186,4 @@ const styles = StyleSheet.create({ postText: { fontFamily: 'Helvetica Neue', }, - ctrls: { - flexDirection: 'row', - }, - ctrl: { - flexDirection: 'row', - alignItems: 'center', - flex: 1, - paddingLeft: 4, - paddingRight: 4, - }, - ctrlIcon: { - marginRight: 5, - color: colors.gray5, - }, - ctrlIconReposted: { - marginRight: 5, - color: colors.green3, - }, - ctrlIconLiked: { - marginRight: 5, - color: colors.red3, - }, }) diff --git a/src/view/com/util/PostCtrls.tsx b/src/view/com/util/PostCtrls.tsx new file mode 100644 index 000000000..3dd77eb30 --- /dev/null +++ b/src/view/com/util/PostCtrls.tsx @@ -0,0 +1,87 @@ +import React from 'react' +import {StyleSheet, Text, TouchableOpacity, View} from 'react-native' +import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' +import {UpIcon, UpIconSolid, DownIcon, DownIconSolid} from '../../lib/icons' +import {s, colors} from '../../lib/styles' + +interface PostCtrlsOpts { + replyCount: number + repostCount: number + likeCount: number + isReposted: boolean + isLiked: boolean + onPressReply: () => void + onPressToggleRepost: () => void + onPressToggleLike: () => void +} + +export function PostCtrls(opts: PostCtrlsOpts) { + return ( + + + + {opts.replyCount} + + + + + {opts.repostCount} + + + + {opts.isLiked ? ( + + ) : ( + + )} + + {opts.likeCount} + + + + {opts.isLiked ? ( + + ) : ( + + )} + + + ) +} + +const styles = StyleSheet.create({ + ctrls: { + flexDirection: 'row', + }, + ctrl: { + flexDirection: 'row', + alignItems: 'center', + flex: 1, + paddingLeft: 4, + paddingRight: 4, + }, + ctrlIcon: { + marginRight: 5, + color: colors.gray5, + }, + ctrlIconReposted: { + marginRight: 5, + color: colors.green3, + }, + ctrlIconUpvoted: { + marginRight: 5, + color: colors.blue3, + }, + ctrlIconDownvoted: { + marginRight: 5, + color: colors.red3, + }, +}) diff --git a/src/view/lib/icons.tsx b/src/view/lib/icons.tsx index 1a96a3aaa..8cc40a73e 100644 --- a/src/view/lib/icons.tsx +++ b/src/view/lib/icons.tsx @@ -91,3 +91,93 @@ export function UserGroupIcon({style}: {style?: StyleProp}) { ) } + +export function UpIcon({ + style, + size, +}: { + style?: StyleProp + size?: string | number +}) { + return ( + + + + ) +} + +export function UpIconSolid({ + style, + size, +}: { + style?: StyleProp + size?: string | number +}) { + return ( + + + + ) +} + +export function DownIcon({ + style, + size, +}: { + style?: StyleProp + size?: string | number +}) { + return ( + + + + ) +} + +export function DownIconSolid({ + style, + size, +}: { + style?: StyleProp + size?: string | number +}) { + return ( + + + + ) +} -- cgit 1.4.1