diff --git a/apps/mobile/src/features/threads/PendingUserInputCard.tsx b/apps/mobile/src/features/threads/PendingUserInputCard.tsx index 4b5a93cd1f75..f35b72f0a88b 100644 --- a/apps/mobile/src/features/threads/PendingUserInputCard.tsx +++ b/apps/mobile/src/features/threads/PendingUserInputCard.tsx @@ -1,5 +1,5 @@ import type { ApprovalRequestId, UserInputQuestion } from "@t3tools/contracts"; -import { useCallback, useRef } from "react"; +import { useMemo, useCallback, useRef } from "react"; import { Platform, Pressable, ScrollView, View, type LayoutChangeEvent } from "react-native"; import Animated, { Easing, @@ -11,6 +11,7 @@ import Animated, { withTiming, type SharedValue, } from "react-native-reanimated"; +import { Markdown, type PartialMarkdownTheme } from "react-native-nitro-markdown"; import { USER_INPUT_TOGGLE_DURATION_MS } from "./pendingUserInputLayout"; @@ -19,6 +20,12 @@ import { AppText as Text, AppTextInput as TextInput } from "../../components/App import { ControlPill } from "../../components/ControlPill"; import { cn } from "../../lib/cn"; import { useThemeColor } from "../../lib/useThemeColor"; +import { useFontFamily } from "../../lib/useFontFamily"; +import { + resolveMarkdownFontSizes, + resolveNativeMarkdownTypography, +} from "../../lib/appearancePreferences"; +import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider"; import { isPendingUserInputOptionSelected, type PendingUserInput, @@ -90,6 +97,54 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) { const iconSubtle = useThemeColor("--color-icon-subtle"); const questionCount = props.pendingUserInput.questions.length; + const { appearance } = useAppearancePreferences(); + const markdownFontSizes = useMemo( + () => resolveMarkdownFontSizes(appearance.baseFontSize), + [appearance.baseFontSize], + ); + const regularFontFamily = useFontFamily("regular"); + const boldFontFamily = useFontFamily("bold"); + const markdownBodyColor = String(useThemeColor("--color-md-body")); + const markdownStrongColor = String(useThemeColor("--color-md-strong")); + const markdownLinkColor = String(useThemeColor("--color-md-link")); + const inlineMarkdownTheme = useMemo( + () => ({ + colors: { + text: markdownBodyColor, + heading: markdownStrongColor, + link: markdownLinkColor, + surface: "transparent", + }, + spacing: { xs: 0, s: 0, m: 0, l: 0, xl: 0 }, + fontSizes: { + s: markdownFontSizes.s, + m: markdownFontSizes.m, + h1: markdownFontSizes.h1, + h2: markdownFontSizes.h2, + h3: markdownFontSizes.h3, + h4: markdownFontSizes.h4, + h5: markdownFontSizes.h5, + h6: markdownFontSizes.h6, + }, + fontFamilies: { + regular: regularFontFamily, + heading: boldFontFamily, + mono: regularFontFamily, + }, + headingWeight: "700", + borderRadius: { s: 4, m: 8, l: 12 }, + showCodeLanguage: false, + }), + [ + markdownBodyColor, + markdownStrongColor, + markdownLinkColor, + markdownFontSizes, + regularFontFamily, + boldFontFamily, + ], + ); + const cardCoverage = props.cardCoverage; const barHeightRef = useRef(0); const cardHeightRef = useRef(0); @@ -254,9 +309,9 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) { {question.header} - + {question.question} - + {question.options.map((option) => { const selected = isPendingUserInputOptionSelected(draft, option.label); @@ -280,20 +335,13 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) { } > - + {option.label} - + {description ? ( - + {description} - + ) : null}