merge main in
what are you doing there? go away fix recognizer to clear selected text on tap remove jank/hacks update readme remove android stuff (?) don't remove clipped subview on android for selection enable selection of alt text add numberOfLines properly apply container styles handle both selection and expand press events in alt text far better implementation revert link changes revert lightbox changes for now fix file name
This commit is contained in:
@@ -110,7 +110,8 @@ function LightboxFooter({imageIndex}: {imageIndex: number}) {
|
||||
accessibilityRole="button">
|
||||
<Text
|
||||
style={[s.gray3, styles.footerText]}
|
||||
numberOfLines={isAltExpanded ? undefined : 3}>
|
||||
numberOfLines={isAltExpanded ? undefined : 3}
|
||||
selectable>
|
||||
{altText}
|
||||
</Text>
|
||||
</Pressable>
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
usePreferencesQuery,
|
||||
} from '#/state/queries/preferences'
|
||||
import {useSession} from '#/state/session'
|
||||
import {isNative} from '#/platform/detection'
|
||||
import {isAndroid, isNative} from '#/platform/detection'
|
||||
import {logger} from '#/logger'
|
||||
|
||||
const MAINTAIN_VISIBLE_CONTENT_POSITION = {minIndexForVisible: 2}
|
||||
@@ -358,6 +358,7 @@ function PostThreadLoaded({
|
||||
style={s.hContentRegion}
|
||||
// @ts-ignore our .web version only -prf
|
||||
desktopFixedHeight
|
||||
removeClippedSubviews={isAndroid ? false : undefined}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -248,10 +248,9 @@ let PostThreadItemLoaded = ({
|
||||
</View>
|
||||
)}
|
||||
|
||||
<Link
|
||||
<View
|
||||
testID={`postThreadItem-by-${post.author.handle}`}
|
||||
style={[styles.outer, styles.outerHighlighted, pal.border, pal.view]}
|
||||
noFeedback
|
||||
accessible={false}>
|
||||
<PostSandboxWarning />
|
||||
<View style={styles.layout}>
|
||||
@@ -446,7 +445,7 @@ let PostThreadItemLoaded = ({
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</Link>
|
||||
</View>
|
||||
<WhoCanReply post={post} />
|
||||
</>
|
||||
)
|
||||
|
||||
+33
-57
@@ -70,14 +70,14 @@ export const Link = memo(function Link({
|
||||
const onPress = React.useCallback(
|
||||
(e?: Event) => {
|
||||
if (typeof href === 'string') {
|
||||
return onTextLinkPress({
|
||||
return onPressInner(
|
||||
closeModal,
|
||||
navigation,
|
||||
href: sanitizeUrl(href),
|
||||
sanitizeUrl(href),
|
||||
navigationAction,
|
||||
openLink,
|
||||
e,
|
||||
})
|
||||
)
|
||||
}
|
||||
},
|
||||
[closeModal, navigation, navigationAction, href, openLink],
|
||||
@@ -182,28 +182,40 @@ export const TextLink = memo(function TextLink({
|
||||
|
||||
props.onPress = React.useCallback(
|
||||
(e?: Event) => {
|
||||
onTextLinkPress({
|
||||
onPress,
|
||||
e,
|
||||
openModal,
|
||||
const requiresWarning =
|
||||
warnOnMismatchingLabel &&
|
||||
linkRequiresWarning(href, typeof text === 'string' ? text : '')
|
||||
if (requiresWarning) {
|
||||
e?.preventDefault?.()
|
||||
openModal({
|
||||
name: 'link-warning',
|
||||
text: typeof text === 'string' ? text : '',
|
||||
href,
|
||||
})
|
||||
}
|
||||
if (onPress) {
|
||||
e?.preventDefault?.()
|
||||
// @ts-ignore function signature differs by platform -prf
|
||||
return onPress()
|
||||
}
|
||||
return onPressInner(
|
||||
closeModal,
|
||||
navigation,
|
||||
href,
|
||||
text,
|
||||
sanitizeUrl(href),
|
||||
navigationAction,
|
||||
warnOnMismatchingLabel,
|
||||
openLink,
|
||||
})
|
||||
e,
|
||||
)
|
||||
},
|
||||
[
|
||||
onPress,
|
||||
openModal,
|
||||
closeModal,
|
||||
openModal,
|
||||
navigation,
|
||||
href,
|
||||
text,
|
||||
navigationAction,
|
||||
warnOnMismatchingLabel,
|
||||
navigationAction,
|
||||
openLink,
|
||||
],
|
||||
)
|
||||
@@ -294,9 +306,6 @@ export const TextLinkOnWebOnly = memo(function DesktopWebTextLink({
|
||||
)
|
||||
})
|
||||
|
||||
// Moving all of this logic into a separate function. Becuase we need to be able to use this function from
|
||||
// SelectableText, it's easier to move it outside the component instead of duplicating logic
|
||||
|
||||
// NOTE
|
||||
// we can't use the onPress given by useLinkProps because it will
|
||||
// match most paths to the HomeTab routes while we actually want to
|
||||
@@ -308,47 +317,14 @@ export const TextLinkOnWebOnly = memo(function DesktopWebTextLink({
|
||||
// this method copies from the onPress implementation but adds our
|
||||
// needed customizations
|
||||
// -prf
|
||||
export const onTextLinkPress = ({
|
||||
onPress,
|
||||
e,
|
||||
openModal,
|
||||
closeModal,
|
||||
navigation,
|
||||
href,
|
||||
text,
|
||||
navigationAction = 'push',
|
||||
warnOnMismatchingLabel,
|
||||
openLink,
|
||||
}: {
|
||||
onPress?: (e: GestureResponderEvent) => void
|
||||
e?: Event
|
||||
openModal?: any
|
||||
closeModal: any
|
||||
navigation: NavigationProp
|
||||
href: string
|
||||
text?: any
|
||||
navigationAction?: 'push' | 'replace' | 'navigate'
|
||||
warnOnMismatchingLabel?: boolean
|
||||
openLink: (href: string) => void
|
||||
}) => {
|
||||
const requiresWarning =
|
||||
warnOnMismatchingLabel &&
|
||||
linkRequiresWarning(href, typeof text === 'string' ? text : '')
|
||||
if (requiresWarning) {
|
||||
e?.preventDefault?.()
|
||||
openModal({
|
||||
name: 'link-warning',
|
||||
text: typeof text === 'string' ? text : '',
|
||||
href,
|
||||
})
|
||||
}
|
||||
if (onPress) {
|
||||
e?.preventDefault?.()
|
||||
// @ts-ignore function signature differs by platform -prf
|
||||
onPress()
|
||||
return
|
||||
}
|
||||
|
||||
function onPressInner(
|
||||
closeModal = () => {},
|
||||
navigation: NavigationProp,
|
||||
href: string,
|
||||
navigationAction: 'push' | 'replace' | 'navigate' = 'push',
|
||||
openLink: (href: string) => void,
|
||||
e?: Event,
|
||||
) {
|
||||
let shouldHandle = false
|
||||
const isLeftClick =
|
||||
// @ts-ignore Web only -prf
|
||||
|
||||
@@ -44,7 +44,11 @@ export function RichText({
|
||||
}
|
||||
return (
|
||||
// @ts-ignore web only -prf
|
||||
<Text testID={testID} style={[style, pal.text]} dataSet={WORD_WRAP}>
|
||||
<Text
|
||||
testID={testID}
|
||||
style={[style, pal.text]}
|
||||
dataSet={WORD_WRAP}
|
||||
selectable={selectable}>
|
||||
{text}
|
||||
</Text>
|
||||
)
|
||||
@@ -82,6 +86,7 @@ export function RichText({
|
||||
href={`/profile/${mention.did}`}
|
||||
style={[style, lineHeightStyle, pal.link, {pointerEvents: 'auto'}]}
|
||||
dataSet={WORD_WRAP}
|
||||
selectable={selectable}
|
||||
/>,
|
||||
)
|
||||
} else if (link && AppBskyRichtextFacet.validateLink(link).success) {
|
||||
@@ -94,6 +99,7 @@ export function RichText({
|
||||
style={[style, lineHeightStyle, pal.link, {pointerEvents: 'auto'}]}
|
||||
dataSet={WORD_WRAP}
|
||||
warnOnMismatchingLabel
|
||||
selectable={selectable}
|
||||
/>,
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React from 'react'
|
||||
import {StyleSheet, Text as RNText, TextProps} from 'react-native'
|
||||
import {Text as RNText, TextProps} from 'react-native'
|
||||
import {s, lh} from 'lib/styles'
|
||||
import {useTheme, TypographyVariant} from 'lib/ThemeContext'
|
||||
import {SelectableText} from '../../../../../modules/expo-selectable-text'
|
||||
import {isIOS} from 'platform/detection'
|
||||
import ExpoSelectableTextView from '../../../../../modules/expo-selectable-text/src/ExpoUITextView'
|
||||
|
||||
export type CustomTextProps = TextProps & {
|
||||
type?: TypographyVariant
|
||||
@@ -27,20 +27,13 @@ export function Text({
|
||||
const typography = theme.typography[type]
|
||||
const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
|
||||
|
||||
// if (false) {
|
||||
// TODO remove
|
||||
if (selectable && isIOS) {
|
||||
return (
|
||||
<SelectableText
|
||||
selectable
|
||||
style={StyleSheet.flatten([
|
||||
s.black,
|
||||
typography,
|
||||
lineHeightStyle,
|
||||
style,
|
||||
])}>
|
||||
<ExpoSelectableTextView
|
||||
style={[s.black, typography, lineHeightStyle, style]}
|
||||
{...props}>
|
||||
{children}
|
||||
</SelectableText>
|
||||
</ExpoSelectableTextView>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -49,6 +42,7 @@ export function Text({
|
||||
style={[s.black, typography, lineHeightStyle, style]}
|
||||
// @ts-ignore web only -esb
|
||||
dataSet={Object.assign({tooltip: title}, dataSet || {})}
|
||||
selectable={selectable}
|
||||
{...props}>
|
||||
{children}
|
||||
</RNText>
|
||||
|
||||
Reference in New Issue
Block a user