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 @@ -70,7 +70,6 @@ const boundColors = useColors(); const messageStyle = {}; - const textStyle = {}; let darkColor; if (isViewer) { const threadColor = item.threadInfo.color; @@ -81,9 +80,6 @@ messageStyle.backgroundColor = boundColors.listChatBubble; darkColor = activeTheme === 'dark'; } - textStyle.color = darkColor - ? colors.dark.listForegroundLabel - : colors.light.listForegroundLabel; const cornerStyle = getRoundedContainerStyle(filterCorners(allCorners, item)); @@ -95,6 +91,19 @@ const rules = useTextMessageMarkdownRules(darkColor); + const textStyle = React.useMemo( + () => ({ + color: darkColor + ? colors.dark.listForegroundLabel + : colors.light.listForegroundLabel, + }), + [darkColor], + ); + + const markdownStyles = React.useMemo(() => [styles.text, textStyle], [ + textStyle, + ]); + const message = ( @@ -105,7 +114,11 @@ style={[styles.message, cornerStyle]} animatedStyle={messageStyle} > - + {text} diff --git a/native/markdown/markdown.react.js b/native/markdown/markdown.react.js --- a/native/markdown/markdown.react.js +++ b/native/markdown/markdown.react.js @@ -5,9 +5,11 @@ import { View, Text, StyleSheet } from 'react-native'; import type { TextStyle as FlattenedTextStyle } from 'react-native/Libraries/StyleSheet/StyleSheet'; import * as SimpleMarkdown from 'simple-markdown'; +import tinycolor from 'tinycolor2'; import { onlyEmojiRegex } from 'lib/shared/emojis'; +import { useColors } from '../themes/colors'; import type { TextStyle } from '../types/styles'; import type { MarkdownRules } from './rules.react'; @@ -15,11 +17,14 @@ +style: TextStyle, +children: string, +rules: MarkdownRules, + +threadColor?: string, }; function Markdown(props: Props): React.Node { - const { style, children, rules } = props; + const { style, children, rules, threadColor } = props; const { simpleMarkdownRules, emojiOnlyFactor, container } = rules; + const boundColors = useColors(); + const parser = React.useMemo( () => SimpleMarkdown.parserFor(simpleMarkdownRules), [simpleMarkdownRules], @@ -61,10 +66,20 @@ return { ...flattened, fontSize: fontSize * emojiOnlyFactor }; }, [emojiOnly, style, emojiOnlyFactor]); - const renderedOutput = React.useMemo( - () => output(ast, { textStyle, container }), - [ast, output, textStyle, container], - ); + const renderedOutput = React.useMemo(() => { + let color = boundColors.listChatBubble; + if (threadColor) { + color = tinycolor(threadColor).darken(20).toString(); + } + return output(ast, { textStyle, container, color }); + }, [ + ast, + output, + textStyle, + container, + threadColor, + boundColors.listChatBubble, + ]); if (container === 'Text') { return {renderedOutput}; 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 @@ -23,6 +23,7 @@ // View, and Views can't be nested inside Texts without explicit height and // width +container: 'View' | 'Text', + +color?: string, }; // Entry requires a seamless transition between Markdown and TextInput @@ -233,11 +234,16 @@ node: SharedMarkdown.SingleASTNode, output: SharedMarkdown.Output, state: SharedMarkdown.State, - ) => ( - - {output(node.content, state)} - - ), + ) => { + return ( + + {output(node.content, state)} + + ); + }, }, codeBlock: { ...SimpleMarkdown.defaultRules.codeBlock, diff --git a/native/markdown/styles.js b/native/markdown/styles.js --- a/native/markdown/styles.js +++ b/native/markdown/styles.js @@ -60,9 +60,7 @@ fontWeight: 'bold', }, blockQuote: { - backgroundColor: 'blockQuoteBackground', - borderLeftColor: 'blockQuoteBorder', - borderLeftWidth: 5, + borderRadius: 8, padding: 10, marginBottom: 6, marginVertical: 6,