Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32400186
D5764.1765340294.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D5764.1765340294.diff
View Options
diff --git a/native/chat/inner-text-message.react.js b/native/chat/inner-text-message.react.js
--- a/native/chat/inner-text-message.react.js
+++ b/native/chat/inner-text-message.react.js
@@ -99,6 +99,30 @@
return [styles.text, textStyle];
}, [darkColor]);
+ // If we need to render a Text with an onPress prop inside, we're going to
+ // have an issue: the GestureTouchableOpacity below will trigger too when the
+ // the onPress is pressed. We have to use a GestureTouchableOpacity in order
+ // for the message touch gesture to play nice with the message swipe gesture,
+ // so we need to find a way to disable the GestureTouchableOpacity.
+ //
+ // Our solution is to keep using the GestureTouchableOpacity for the padding
+ // around the text, and to have the Texts inside ALL implement an onPress prop
+ // that will default to the message touch gesture. Luckily, Text with onPress
+ // plays nice with the message swipe gesture.
+ let secondMessage;
+ if (textMessageMarkdown.markdownHasPressable) {
+ secondMessage = (
+ <View
+ style={[StyleSheet.absoluteFill, styles.message]}
+ pointerEvents="box-none"
+ >
+ <Markdown style={markdownStyles} rules={rules}>
+ {text}
+ </Markdown>
+ </View>
+ );
+ }
+
const message = (
<TextMessageMarkdownContext.Provider value={textMessageMarkdown}>
<TouchableWithoutFeedback>
@@ -114,6 +138,7 @@
{text}
</Markdown>
</GestureTouchableOpacity>
+ {secondMessage}
</View>
</TouchableWithoutFeedback>
</TextMessageMarkdownContext.Provider>
diff --git a/native/markdown/markdown-paragraph.react.js b/native/markdown/markdown-paragraph.react.js
new file mode 100644
--- /dev/null
+++ b/native/markdown/markdown-paragraph.react.js
@@ -0,0 +1,29 @@
+// @flow
+
+import * as React from 'react';
+import { Text } from 'react-native';
+
+import { MessagePressResponderContext } from '../chat/message-press-responder-context';
+import type { TextStyle } from '../types/styles';
+
+type Props = {
+ +style?: ?TextStyle,
+ +children: React.Node,
+};
+function MarkdownParagraph(props: Props): React.Node {
+ const messagePressResponderContext = React.useContext(
+ MessagePressResponderContext,
+ );
+ const onPressMessage = messagePressResponderContext?.onPressMessage;
+ return (
+ <Text
+ style={props.style}
+ onPress={onPressMessage}
+ onLongPress={onPressMessage}
+ >
+ {props.children}
+ </Text>
+ );
+}
+
+export default MarkdownParagraph;
diff --git a/native/markdown/rules.react.js b/native/markdown/rules.react.js
--- a/native/markdown/rules.react.js
+++ b/native/markdown/rules.react.js
@@ -12,6 +12,7 @@
import { useSelector } from '../redux/redux-utils';
import MarkdownLink from './markdown-link.react';
+import MarkdownParagraph from './markdown-paragraph.react';
import { getMarkdownStyles } from './styles';
export type MarkdownRules = {
@@ -96,9 +97,9 @@
output: SharedMarkdown.Output<SharedMarkdown.ReactElement>,
state: SharedMarkdown.State,
) => (
- <Text key={state.key} style={state.textStyle}>
+ <MarkdownParagraph key={state.key} style={state.textStyle}>
{output(node.content, state)}
- </Text>
+ </MarkdownParagraph>
),
},
// This is the leaf node in the AST returned by the parse phase
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 10, 4:18 AM (18 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5860826
Default Alt Text
D5764.1765340294.diff (3 KB)
Attached To
Mode
D5764: [native] Render second TextMessage with all Texts pressable when markdownHasPressable
Attached
Detach File
Event Timeline
Log In to Comment