import React from 'react'; import { ScrollView, Text, View } from 'react-native'; import type { DiffLine } from '../toolWidgetUtils'; import { toolWidgetStyles } from './toolWidgetStyles'; const SIGNS: Record = { added: '+', context: ' ', removed: '-', }; // The essence of the web builder's diff modal, without its web-only dependencies. export function DiffView({ lines }: { lines: DiffLine[] }) { return ( {lines.map((line, index) => ( ))} ); } function DiffRow({ line }: { line: DiffLine }) { const rowStyle = line.type === 'added' ? toolWidgetStyles.diffLineAdded : line.type === 'removed' ? toolWidgetStyles.diffLineRemoved : null; const textStyle = line.type === 'added' ? toolWidgetStyles.diffTextAdded : line.type === 'removed' ? toolWidgetStyles.diffTextRemoved : toolWidgetStyles.diffTextContext; return ( {SIGNS[line.type]} {/* One line, sized to its full content — never wrap. This is what makes the row wider than the viewport so the horizontal ScrollView can scroll. */} {line.text || ' '} ); }