Enlarge click targets for post controls and view header

zio/stable
Paul Frazee 2022-12-05 10:18:38 -06:00
parent 67c4dcff37
commit f3f3bfb335
3 changed files with 27 additions and 6 deletions

View File

@ -18,6 +18,8 @@ import {useStores} from '../../../state'
import {ConfirmModel} from '../../../state/models/shell-ui' import {ConfirmModel} from '../../../state/models/shell-ui'
import {TABS_ENABLED} from '../../../build-flags' import {TABS_ENABLED} from '../../../build-flags'
const HITSLOP = {left: 10, top: 10, right: 10, bottom: 10}
export interface DropdownItem { export interface DropdownItem {
icon?: IconProp icon?: IconProp
label: string label: string
@ -61,7 +63,11 @@ export function DropdownBtn({
} }
return ( return (
<TouchableOpacity style={style} onPress={onPress} ref={ref}> <TouchableOpacity
style={style}
onPress={onPress}
hitSlop={HITSLOP}
ref={ref}>
{children} {children}
</TouchableOpacity> </TouchableOpacity>
) )

View File

@ -25,6 +25,7 @@ interface PostCtrlsOpts {
const redgray = '#7A6161' const redgray = '#7A6161'
const sRedgray = {color: redgray} const sRedgray = {color: redgray}
const HITSLOP = {top: 10, left: 10, bottom: 10, right: 10}
export function PostCtrls(opts: PostCtrlsOpts) { export function PostCtrls(opts: PostCtrlsOpts) {
const interp1 = useSharedValue<number>(0) const interp1 = useSharedValue<number>(0)
@ -59,7 +60,10 @@ export function PostCtrls(opts: PostCtrlsOpts) {
return ( return (
<View style={styles.ctrls}> <View style={styles.ctrls}>
<View style={s.flex1}> <View style={s.flex1}>
<TouchableOpacity style={styles.ctrl} onPress={opts.onPressReply}> <TouchableOpacity
style={styles.ctrl}
hitSlop={HITSLOP}
onPress={opts.onPressReply}>
<FontAwesomeIcon <FontAwesomeIcon
style={styles.ctrlIcon} style={styles.ctrlIcon}
icon={['far', 'comment']} icon={['far', 'comment']}
@ -72,6 +76,7 @@ export function PostCtrls(opts: PostCtrlsOpts) {
</View> </View>
<View style={s.flex1}> <View style={s.flex1}>
<TouchableOpacity <TouchableOpacity
hitSlop={HITSLOP}
onPress={onPressToggleRepostWrapper} onPress={onPressToggleRepostWrapper}
style={styles.ctrl}> style={styles.ctrl}>
<Animated.View style={anim1Style}> <Animated.View style={anim1Style}>
@ -98,6 +103,7 @@ export function PostCtrls(opts: PostCtrlsOpts) {
<View style={s.flex1}> <View style={s.flex1}>
<TouchableOpacity <TouchableOpacity
style={styles.ctrl} style={styles.ctrl}
hitSlop={HITSLOP}
onPress={onPressToggleUpvoteWrapper}> onPress={onPressToggleUpvoteWrapper}>
<Animated.View style={anim2Style}> <Animated.View style={anim2Style}>
{opts.isUpvoted ? ( {opts.isUpvoted ? (
@ -137,7 +143,6 @@ const styles = StyleSheet.create({
ctrl: { ctrl: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
paddingRight: 4,
}, },
ctrlIcon: { ctrlIcon: {
color: redgray, color: redgray,

View File

@ -5,6 +5,9 @@ import {colors} from '../../lib/styles'
import {MagnifyingGlassIcon} from '../../lib/icons' import {MagnifyingGlassIcon} from '../../lib/icons'
import {useStores} from '../../../state' import {useStores} from '../../../state'
const HITSLOP = {left: 10, top: 10, right: 10, bottom: 10}
const BACK_HITSLOP = {left: 10, top: 10, right: 30, bottom: 10}
export function ViewHeader({ export function ViewHeader({
title, title,
subtitle, subtitle,
@ -27,11 +30,14 @@ export function ViewHeader({
return ( return (
<View style={styles.header}> <View style={styles.header}>
{store.nav.tab.canGoBack ? ( {store.nav.tab.canGoBack ? (
<TouchableOpacity onPress={onPressBack} style={styles.backIcon}> <TouchableOpacity
onPress={onPressBack}
hitSlop={BACK_HITSLOP}
style={styles.backIcon}>
<FontAwesomeIcon size={18} icon="angle-left" style={{marginTop: 6}} /> <FontAwesomeIcon size={18} icon="angle-left" style={{marginTop: 6}} />
</TouchableOpacity> </TouchableOpacity>
) : undefined} ) : undefined}
<View style={styles.titleContainer}> <View style={styles.titleContainer} pointerEvents="none">
<Text style={styles.title}>{title}</Text> <Text style={styles.title}>{title}</Text>
{subtitle ? ( {subtitle ? (
<Text style={styles.subtitle} numberOfLines={1}> <Text style={styles.subtitle} numberOfLines={1}>
@ -39,11 +45,15 @@ export function ViewHeader({
</Text> </Text>
) : undefined} ) : undefined}
</View> </View>
<TouchableOpacity onPress={onPressCompose} style={styles.btn}> <TouchableOpacity
onPress={onPressCompose}
hitSlop={HITSLOP}
style={styles.btn}>
<FontAwesomeIcon size={18} icon="plus" /> <FontAwesomeIcon size={18} icon="plus" />
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity <TouchableOpacity
onPress={onPressSearch} onPress={onPressSearch}
hitSlop={HITSLOP}
style={[styles.btn, {marginLeft: 8}]}> style={[styles.btn, {marginLeft: 8}]}>
<MagnifyingGlassIcon <MagnifyingGlassIcon
size={18} size={18}