Remove `FixedTouchableHighlight` , fix Android press issues (#3214)
* rm `FixedTouchableHighlight` * adjust delay for highlight * remove unnecessary background colors to support background ripplezio/stable
parent
6279c5cf31
commit
4f8381678d
|
@ -182,7 +182,6 @@ let FeedItem = ({
|
||||||
testID={`feedItem-by-${item.notification.author.handle}`}
|
testID={`feedItem-by-${item.notification.author.handle}`}
|
||||||
style={[
|
style={[
|
||||||
styles.outer,
|
styles.outer,
|
||||||
pal.view,
|
|
||||||
pal.border,
|
pal.border,
|
||||||
item.notification.isRead
|
item.notification.isRead
|
||||||
? undefined
|
? undefined
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
// FixedTouchableHighlight.tsx
|
|
||||||
import React, {ComponentProps, useRef} from 'react'
|
|
||||||
import {GestureResponderEvent, TouchableHighlight} from 'react-native'
|
|
||||||
|
|
||||||
type Position = {pageX: number; pageY: number}
|
|
||||||
|
|
||||||
export default function FixedTouchableHighlight({
|
|
||||||
onPress,
|
|
||||||
onPressIn,
|
|
||||||
...props
|
|
||||||
}: ComponentProps<typeof TouchableHighlight>) {
|
|
||||||
const _touchActivatePositionRef = useRef<Position | null>(null)
|
|
||||||
|
|
||||||
function _onPressIn(e: GestureResponderEvent) {
|
|
||||||
const {pageX, pageY} = e.nativeEvent
|
|
||||||
|
|
||||||
_touchActivatePositionRef.current = {
|
|
||||||
pageX,
|
|
||||||
pageY,
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressIn?.(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
function _onPress(e: GestureResponderEvent) {
|
|
||||||
const {pageX, pageY} = e.nativeEvent
|
|
||||||
|
|
||||||
const absX = Math.abs(_touchActivatePositionRef.current?.pageX! - pageX)
|
|
||||||
const absY = Math.abs(_touchActivatePositionRef.current?.pageY! - pageY)
|
|
||||||
|
|
||||||
const dragged = absX > 2 || absY > 2
|
|
||||||
if (!dragged) {
|
|
||||||
onPress?.(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TouchableHighlight onPressIn={_onPressIn} onPress={_onPress} {...props}>
|
|
||||||
{props.children}
|
|
||||||
</TouchableHighlight>
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -432,7 +432,6 @@ let PostThreadItemLoaded = ({
|
||||||
<PostHider
|
<PostHider
|
||||||
testID={`postThreadItem-by-${post.author.handle}`}
|
testID={`postThreadItem-by-${post.author.handle}`}
|
||||||
href={postHref}
|
href={postHref}
|
||||||
style={[pal.view]}
|
|
||||||
moderation={moderation.content}
|
moderation={moderation.content}
|
||||||
iconSize={isThreadedChild ? 26 : 38}
|
iconSize={isThreadedChild ? 26 : 38}
|
||||||
iconStyles={
|
iconStyles={
|
||||||
|
@ -622,7 +621,6 @@ function PostOuterWrapper({
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
pal.view,
|
|
||||||
pal.border,
|
pal.border,
|
||||||
styles.cursor,
|
styles.cursor,
|
||||||
{
|
{
|
||||||
|
@ -650,7 +648,6 @@ function PostOuterWrapper({
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
styles.outer,
|
styles.outer,
|
||||||
pal.view,
|
|
||||||
pal.border,
|
pal.border,
|
||||||
showParentReplyLine && hasPrecedingItem && styles.noTopBorder,
|
showParentReplyLine && hasPrecedingItem && styles.noTopBorder,
|
||||||
styles.cursor,
|
styles.cursor,
|
||||||
|
|
|
@ -133,7 +133,7 @@ function PostInner({
|
||||||
}, [setLimitLines])
|
}, [setLimitLines])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={itemHref} style={[styles.outer, pal.view, pal.border, style]}>
|
<Link href={itemHref} style={[styles.outer, pal.border, style]}>
|
||||||
{showReplyLine && <View style={styles.replyLine} />}
|
{showReplyLine && <View style={styles.replyLine} />}
|
||||||
<View style={styles.layout}>
|
<View style={styles.layout}>
|
||||||
<View style={styles.layoutAvi}>
|
<View style={styles.layoutAvi}>
|
||||||
|
|
|
@ -144,7 +144,6 @@ let FeedItemInner = ({
|
||||||
|
|
||||||
const outerStyles = [
|
const outerStyles = [
|
||||||
styles.outer,
|
styles.outer,
|
||||||
pal.view,
|
|
||||||
{
|
{
|
||||||
borderColor: pal.colors.border,
|
borderColor: pal.colors.border,
|
||||||
paddingBottom:
|
paddingBottom:
|
||||||
|
|
|
@ -78,11 +78,7 @@ function ViewFullThread({slice}: {slice: FeedPostSlice}) {
|
||||||
}, [slice.rootUri])
|
}, [slice.rootUri])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link style={[styles.viewFullThread]} href={itemHref} asAnchor noFeedback>
|
||||||
style={[pal.view, styles.viewFullThread]}
|
|
||||||
href={itemHref}
|
|
||||||
asAnchor
|
|
||||||
noFeedback>
|
|
||||||
<View style={styles.viewFullThreadDots}>
|
<View style={styles.viewFullThreadDots}>
|
||||||
<Svg width="4" height="40">
|
<Svg width="4" height="40">
|
||||||
<Line
|
<Line
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
View,
|
View,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
Pressable,
|
Pressable,
|
||||||
TouchableWithoutFeedback,
|
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {useLinkProps, StackActions} from '@react-navigation/native'
|
import {useLinkProps, StackActions} from '@react-navigation/native'
|
||||||
|
@ -23,7 +22,6 @@ import {
|
||||||
import {isAndroid, isWeb} from 'platform/detection'
|
import {isAndroid, isWeb} from 'platform/detection'
|
||||||
import {sanitizeUrl} from '@braintree/sanitize-url'
|
import {sanitizeUrl} from '@braintree/sanitize-url'
|
||||||
import {PressableWithHover} from './PressableWithHover'
|
import {PressableWithHover} from './PressableWithHover'
|
||||||
import FixedTouchableHighlight from '../pager/FixedTouchableHighlight'
|
|
||||||
import {useModalControls} from '#/state/modals'
|
import {useModalControls} from '#/state/modals'
|
||||||
import {useOpenLink} from '#/state/preferences/in-app-browser'
|
import {useOpenLink} from '#/state/preferences/in-app-browser'
|
||||||
import {WebAuxClickWrapper} from 'view/com/util/WebAuxClickWrapper'
|
import {WebAuxClickWrapper} from 'view/com/util/WebAuxClickWrapper'
|
||||||
|
@ -31,6 +29,7 @@ import {
|
||||||
DebouncedNavigationProp,
|
DebouncedNavigationProp,
|
||||||
useNavigationDeduped,
|
useNavigationDeduped,
|
||||||
} from 'lib/hooks/useNavigationDeduped'
|
} from 'lib/hooks/useNavigationDeduped'
|
||||||
|
import {useTheme} from '#/alf'
|
||||||
|
|
||||||
type Event =
|
type Event =
|
||||||
| React.MouseEvent<HTMLAnchorElement, MouseEvent>
|
| React.MouseEvent<HTMLAnchorElement, MouseEvent>
|
||||||
|
@ -63,6 +62,7 @@ export const Link = memo(function Link({
|
||||||
navigationAction,
|
navigationAction,
|
||||||
...props
|
...props
|
||||||
}: Props) {
|
}: Props) {
|
||||||
|
const t = useTheme()
|
||||||
const {closeModal} = useModalControls()
|
const {closeModal} = useModalControls()
|
||||||
const navigation = useNavigationDeduped()
|
const navigation = useNavigationDeduped()
|
||||||
const anchorHref = asAnchor ? sanitizeUrl(href) : undefined
|
const anchorHref = asAnchor ? sanitizeUrl(href) : undefined
|
||||||
|
@ -85,37 +85,23 @@ export const Link = memo(function Link({
|
||||||
)
|
)
|
||||||
|
|
||||||
if (noFeedback) {
|
if (noFeedback) {
|
||||||
if (isAndroid) {
|
|
||||||
// workaround for Android not working well with left/right swipe gestures and TouchableWithoutFeedback
|
|
||||||
// https://github.com/callstack/react-native-pager-view/issues/424
|
|
||||||
return (
|
|
||||||
<FixedTouchableHighlight
|
|
||||||
testID={testID}
|
|
||||||
onPress={onPress}
|
|
||||||
// @ts-ignore web only -prf
|
|
||||||
href={asAnchor ? sanitizeUrl(href) : undefined}
|
|
||||||
accessible={accessible}
|
|
||||||
accessibilityRole="link"
|
|
||||||
{...props}>
|
|
||||||
<View style={style}>
|
|
||||||
{children ? children : <Text>{title || 'link'}</Text>}
|
|
||||||
</View>
|
|
||||||
</FixedTouchableHighlight>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<WebAuxClickWrapper>
|
<WebAuxClickWrapper>
|
||||||
<TouchableWithoutFeedback
|
<Pressable
|
||||||
testID={testID}
|
testID={testID}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
accessible={accessible}
|
accessible={accessible}
|
||||||
accessibilityRole="link"
|
accessibilityRole="link"
|
||||||
{...props}>
|
{...props}
|
||||||
|
android_ripple={{
|
||||||
|
color: t.atoms.bg_contrast_25.backgroundColor,
|
||||||
|
}}
|
||||||
|
unstable_pressDelay={isAndroid ? 90 : undefined}>
|
||||||
{/* @ts-ignore web only -prf */}
|
{/* @ts-ignore web only -prf */}
|
||||||
<View style={style} href={anchorHref}>
|
<View style={style} href={anchorHref}>
|
||||||
{children ? children : <Text>{title || 'link'}</Text>}
|
{children ? children : <Text>{title || 'link'}</Text>}
|
||||||
</View>
|
</View>
|
||||||
</TouchableWithoutFeedback>
|
</Pressable>
|
||||||
</WebAuxClickWrapper>
|
</WebAuxClickWrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue