WIP inline link fix
This commit is contained in:
+40
-8
@@ -5,6 +5,7 @@ import {
|
|||||||
StyleProp,
|
StyleProp,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
import {TouchableWithoutFeedback} from 'react-native-gesture-handler'
|
||||||
import {sanitizeUrl} from '@braintree/sanitize-url'
|
import {sanitizeUrl} from '@braintree/sanitize-url'
|
||||||
import {StackActions, useLinkProps} from '@react-navigation/native'
|
import {StackActions, useLinkProps} from '@react-navigation/native'
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ import {useModalControls} from '#/state/modals'
|
|||||||
import {useOpenLink} from '#/state/preferences/in-app-browser'
|
import {useOpenLink} from '#/state/preferences/in-app-browser'
|
||||||
import {atoms as a, flatten, TextStyleProp, useTheme, web} from '#/alf'
|
import {atoms as a, flatten, TextStyleProp, useTheme, web} from '#/alf'
|
||||||
import {Button, ButtonProps} from '#/components/Button'
|
import {Button, ButtonProps} from '#/components/Button'
|
||||||
|
import {useDialogContext} from '#/components/Dialog'
|
||||||
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
||||||
import {Text, TextProps} from '#/components/Typography'
|
import {Text, TextProps} from '#/components/Typography'
|
||||||
import {router} from '#/routes'
|
import {router} from '#/routes'
|
||||||
@@ -285,13 +287,49 @@ export function InlineLinkText({
|
|||||||
onOut: onPressOut,
|
onOut: onPressOut,
|
||||||
} = useInteractionState()
|
} = useInteractionState()
|
||||||
const flattenedStyle = flatten(style) || {}
|
const flattenedStyle = flatten(style) || {}
|
||||||
|
const {isNativeDialog} = useDialogContext()
|
||||||
|
|
||||||
|
const pressableProps = {
|
||||||
|
accessibilityLabel: label,
|
||||||
|
accessibilityHint: '',
|
||||||
|
accessibilityRole: 'link',
|
||||||
|
role: 'link',
|
||||||
|
onPress: download ? undefined : onPress,
|
||||||
|
onLongPress: onLongPress,
|
||||||
|
onPressIn: onPressIn,
|
||||||
|
onPressOut: onPressOut,
|
||||||
|
} as const
|
||||||
|
|
||||||
|
if (isNativeDialog) {
|
||||||
|
/* eslint-disable-next-line bsky-internal/avoid-unwrapped-text */
|
||||||
|
return (
|
||||||
|
<TouchableWithoutFeedback {...pressableProps}>
|
||||||
|
<Text
|
||||||
|
{...rest}
|
||||||
|
selectable={selectable}
|
||||||
|
style={[
|
||||||
|
{color: t.palette.primary_500},
|
||||||
|
(hovered || focused || pressed) &&
|
||||||
|
!disableUnderline && {
|
||||||
|
...web({outline: 0}),
|
||||||
|
textDecorationLine: 'underline',
|
||||||
|
textDecorationColor:
|
||||||
|
flattenedStyle.color ?? t.palette.primary_500,
|
||||||
|
},
|
||||||
|
flattenedStyle,
|
||||||
|
{lineHeight: 20},
|
||||||
|
]}>
|
||||||
|
{children}
|
||||||
|
</Text>
|
||||||
|
</TouchableWithoutFeedback>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text
|
||||||
selectable={selectable}
|
selectable={selectable}
|
||||||
accessibilityHint=""
|
|
||||||
accessibilityLabel={label}
|
|
||||||
{...rest}
|
{...rest}
|
||||||
|
{...pressableProps}
|
||||||
style={[
|
style={[
|
||||||
{color: t.palette.primary_500},
|
{color: t.palette.primary_500},
|
||||||
(hovered || focused || pressed) &&
|
(hovered || focused || pressed) &&
|
||||||
@@ -302,16 +340,10 @@ export function InlineLinkText({
|
|||||||
},
|
},
|
||||||
flattenedStyle,
|
flattenedStyle,
|
||||||
]}
|
]}
|
||||||
role="link"
|
|
||||||
onPress={download ? undefined : onPress}
|
|
||||||
onLongPress={onLongPress}
|
|
||||||
onPressIn={onPressIn}
|
|
||||||
onPressOut={onPressOut}
|
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
onMouseEnter={onHoverIn}
|
onMouseEnter={onHoverIn}
|
||||||
onMouseLeave={onHoverOut}
|
onMouseLeave={onHoverOut}
|
||||||
accessibilityRole="link"
|
|
||||||
href={href}
|
href={href}
|
||||||
{...web({
|
{...web({
|
||||||
hrefAttrs: {
|
hrefAttrs: {
|
||||||
|
|||||||
Reference in New Issue
Block a user