Fix post controls tap areas (#2627)

This commit is contained in:
dan 2024-01-25 22:06:28 +00:00 committed by GitHub
parent ef84f3a25e
commit 10b1d16c8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 87 additions and 67 deletions

View file

@ -118,37 +118,38 @@ let PostCtrls = ({
return ( return (
<View style={[styles.ctrls, style]}> <View style={[styles.ctrls, style]}>
<TouchableOpacity <View
testID="replyBtn"
style={[ style={[
styles.ctrl, styles.ctrl,
!big && styles.ctrlPad,
{paddingLeft: 0},
post.viewer?.replyDisabled ? {opacity: 0.5} : undefined, post.viewer?.replyDisabled ? {opacity: 0.5} : undefined,
]} ]}>
onPress={() => { <TouchableOpacity
if (!post.viewer?.replyDisabled) { testID="replyBtn"
requireAuth(() => onPressReply()) style={[styles.btn, !big && styles.btnPad, {paddingLeft: 0}]}
} onPress={() => {
}} if (!post.viewer?.replyDisabled) {
accessibilityRole="button" requireAuth(() => onPressReply())
accessibilityLabel={`Reply (${post.replyCount} ${ }
post.replyCount === 1 ? 'reply' : 'replies' }}
})`} accessibilityRole="button"
accessibilityHint="" accessibilityLabel={`Reply (${post.replyCount} ${
hitSlop={big ? HITSLOP_20 : HITSLOP_10}> post.replyCount === 1 ? 'reply' : 'replies'
<CommentBottomArrow })`}
style={[defaultCtrlColor, big ? s.mt2 : styles.mt1]} accessibilityHint=""
strokeWidth={3} hitSlop={big ? HITSLOP_20 : HITSLOP_10}>
size={big ? 20 : 15} <CommentBottomArrow
/> style={[defaultCtrlColor, big ? s.mt2 : styles.mt1]}
{typeof post.replyCount !== 'undefined' && post.replyCount > 0 ? ( strokeWidth={3}
<Text style={[defaultCtrlColor, s.ml5, s.f15]}> size={big ? 20 : 15}
{post.replyCount} />
</Text> {typeof post.replyCount !== 'undefined' && post.replyCount > 0 ? (
) : undefined} <Text style={[defaultCtrlColor, s.ml5, s.f15]}>
</TouchableOpacity> {post.replyCount}
<View style={[styles.ctrl, !big && styles.ctrlPad]}> </Text>
) : undefined}
</TouchableOpacity>
</View>
<View style={[styles.ctrl]}>
<RepostButton <RepostButton
big={big} big={big}
isReposted={!!post.viewer?.repost} isReposted={!!post.viewer?.repost}
@ -157,39 +158,41 @@ let PostCtrls = ({
onQuote={onQuote} onQuote={onQuote}
/> />
</View> </View>
<TouchableOpacity <View style={styles.ctrl}>
testID="likeBtn" <TouchableOpacity
style={[styles.ctrl, !big && styles.ctrlPad]} testID="likeBtn"
onPress={() => { style={[styles.btn, !big && styles.btnPad]}
requireAuth(() => onPressToggleLike()) onPress={() => {
}} requireAuth(() => onPressToggleLike())
accessibilityRole="button" }}
accessibilityLabel={`${ accessibilityRole="button"
post.viewer?.like ? _(msg`Unlike`) : _(msg`Like`) accessibilityLabel={`${
} (${post.likeCount} ${pluralize(post.likeCount || 0, 'like')})`} post.viewer?.like ? _(msg`Unlike`) : _(msg`Like`)
accessibilityHint="" } (${post.likeCount} ${pluralize(post.likeCount || 0, 'like')})`}
hitSlop={big ? HITSLOP_20 : HITSLOP_10}> accessibilityHint=""
{post.viewer?.like ? ( hitSlop={big ? HITSLOP_20 : HITSLOP_10}>
<HeartIconSolid style={s.likeColor} size={big ? 22 : 16} /> {post.viewer?.like ? (
) : ( <HeartIconSolid style={s.likeColor} size={big ? 22 : 16} />
<HeartIcon ) : (
style={[defaultCtrlColor, big ? styles.mt1 : undefined]} <HeartIcon
strokeWidth={3} style={[defaultCtrlColor, big ? styles.mt1 : undefined]}
size={big ? 20 : 16} strokeWidth={3}
/> size={big ? 20 : 16}
)} />
{typeof post.likeCount !== 'undefined' && post.likeCount > 0 ? ( )}
<Text {typeof post.likeCount !== 'undefined' && post.likeCount > 0 ? (
testID="likeCount" <Text
style={ testID="likeCount"
post.viewer?.like style={
? [s.bold, s.likeColor, s.f15, s.ml5] post.viewer?.like
: [defaultCtrlColor, s.f15, s.ml5] ? [s.bold, s.likeColor, s.f15, s.ml5]
}> : [defaultCtrlColor, s.f15, s.ml5]
{post.likeCount} }>
</Text> {post.likeCount}
) : undefined} </Text>
</TouchableOpacity> ) : undefined}
</TouchableOpacity>
</View>
{big ? undefined : ( {big ? undefined : (
<PostDropdownBtn <PostDropdownBtn
testID="postDropdownBtn" testID="postDropdownBtn"
@ -199,7 +202,7 @@ let PostCtrls = ({
record={record} record={record}
richText={richText} richText={richText}
showAppealLabelItem={showAppealLabelItem} showAppealLabelItem={showAppealLabelItem}
style={styles.ctrlPad} style={styles.btnPad}
/> />
)} )}
{/* used for adding pad to the right side */} {/* used for adding pad to the right side */}
@ -214,13 +217,17 @@ const styles = StyleSheet.create({
ctrls: { ctrls: {
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'space-between', justifyContent: 'space-between',
alignItems: 'center',
}, },
ctrl: { ctrl: {
flex: 1, flex: 1,
alignItems: 'flex-start',
},
btn: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
}, },
ctrlPad: { btnPad: {
paddingTop: 5, paddingTop: 5,
paddingBottom: 5, paddingBottom: 5,
paddingLeft: 5, paddingLeft: 5,

View file

@ -53,7 +53,7 @@ let RepostButton = ({
onPress={() => { onPress={() => {
requireAuth(() => onPressToggleRepostWrapper()) requireAuth(() => onPressToggleRepostWrapper())
}} }}
style={[styles.container]} style={[styles.btn, !big && styles.btnPad]}
accessibilityRole="button" accessibilityRole="button"
accessibilityLabel={`${ accessibilityLabel={`${
isReposted isReposted
@ -89,10 +89,16 @@ RepostButton = memo(RepostButton)
export {RepostButton} export {RepostButton}
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { btn: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
}, },
btnPad: {
paddingTop: 5,
paddingBottom: 5,
paddingLeft: 5,
paddingRight: 5,
},
reposted: { reposted: {
color: colors.green3, color: colors.green3,
}, },

View file

@ -69,7 +69,8 @@ export const RepostButton = ({
const inner = ( const inner = (
<View <View
style={[ style={[
styles.container, styles.btn,
!big && styles.btnPad,
(isReposted (isReposted
? styles.reposted ? styles.reposted
: defaultControlColor) as StyleProp<ViewStyle>, : defaultControlColor) as StyleProp<ViewStyle>,
@ -109,11 +110,17 @@ export const RepostButton = ({
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { btn: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
gap: 4, gap: 4,
}, },
btnPad: {
paddingTop: 5,
paddingBottom: 5,
paddingLeft: 5,
paddingRight: 5,
},
reposted: { reposted: {
color: colors.green3, color: colors.green3,
}, },