about summary refs log tree commit diff
path: root/src/view/com/util/text/RichText.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/com/util/text/RichText.tsx')
-rw-r--r--src/view/com/util/text/RichText.tsx21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/view/com/util/text/RichText.tsx b/src/view/com/util/text/RichText.tsx
index c9ed4b58e..830294d3a 100644
--- a/src/view/com/util/text/RichText.tsx
+++ b/src/view/com/util/text/RichText.tsx
@@ -2,9 +2,9 @@ import React from 'react'
 import {TextStyle, StyleProp} from 'react-native'
 import {TextLink} from '../Link'
 import {Text} from './Text'
-import {s} from '../../../lib/styles'
+import {lh} from '../../../lib/styles'
 import {toShortUrl} from '../../../../lib/strings'
-import {TypographyVariant} from '../../../lib/ThemeContext'
+import {useTheme, TypographyVariant} from '../../../lib/ThemeContext'
 import {usePalette} from '../../../lib/hooks/usePalette'
 
 type TextSlice = {start: number; end: number}
@@ -21,22 +21,24 @@ export function RichText({
   style,
   numberOfLines,
 }: {
-  type: TypographyVariant
+  type?: TypographyVariant
   text: string
   entities?: Entity[]
   style?: StyleProp<TextStyle>
   numberOfLines?: number
 }) {
+  const theme = useTheme()
   const pal = usePalette('default')
+  const lineHeightStyle = lh(theme, 'body1', 1.2)
   if (!entities?.length) {
     if (/^\p{Extended_Pictographic}+$/u.test(text) && text.length <= 5) {
       style = {
         fontSize: 26,
         lineHeight: 30,
       }
-      return <Text style={style}>{text}</Text>
+      return <Text style={[style, pal.text]}>{text}</Text>
     }
-    return <Text style={style}>{text}</Text>
+    return <Text style={[style, pal.text, lineHeightStyle]}>{text}</Text>
   }
   if (!style) style = []
   else if (!Array.isArray(style)) style = [style]
@@ -55,7 +57,7 @@ export function RichText({
             type={type}
             text={segment.text}
             href={`/profile/${segment.entity.value}`}
-            style={[style, pal.link]}
+            style={[style, lineHeightStyle, pal.link]}
           />,
         )
       } else if (segment.entity.type === 'link') {
@@ -65,7 +67,7 @@ export function RichText({
             type={type}
             text={toShortUrl(segment.text)}
             href={segment.entity.value}
-            style={[style, pal.link]}
+            style={[style, lineHeightStyle, pal.link]}
           />,
         )
       }
@@ -73,7 +75,10 @@ export function RichText({
     key++
   }
   return (
-    <Text type={type} style={[pal.text, style]} numberOfLines={numberOfLines}>
+    <Text
+      type={type}
+      style={[style, pal.text, lineHeightStyle]}
+      numberOfLines={numberOfLines}>
       {els}
     </Text>
   )