import { Host, TextField } from '@expo/ui/swift-ui'; import { background, cornerRadius, padding } from '@expo/ui/swift-ui/modifiers'; import { useState } from 'react'; import { ScrollView, StyleSheet, Text, View } from 'react-native'; import { CodeEditor, type Theme } from 'react-native-codepad'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { NestedBar } from '../chrome/NestedBar'; import { IOS, schemeFor, topInsetFor } from '../chrome/theme'; import { NESTED_SNIPPET } from './nestedSnippet'; type Props = { theme: Theme; onBack: () => void }; // Caret reveal inside a parent scroll view is the consumer's job: read getCursorRect and scroll the // parent to it. This screen shows the auto height loop and the sideways scroll. export function NestedScreen({ theme, onBack }: Props) { const scheme = schemeFor(theme); const palette = IOS[scheme]; const safe = useSafeAreaInsets(); const [height, setHeight] = useState(120); const [barHeight, setBarHeight] = useState(0); // The inset grouped field look: a rounded fill on the page, no border. const field = [ padding({ horizontal: 12, vertical: 11 }), background(palette.fieldBackground), cornerRadius(10), ]; return ( The editor below takes its height from onContentSizeChange and leaves vertical scrolling to this page. Long lines scroll sideways. setHeight(Math.ceil(e.height))} /> A tall footer, so the page itself has something to scroll. setBarHeight(e.nativeEvent.layout.height)} > ); } const styles = StyleSheet.create({ screen: { flex: 1 }, // The bar floats over the page like the editor's; the content starts below its measured height. chrome: { position: 'absolute', top: 0, left: 0, right: 0 }, scroll: { flex: 1 }, content: { padding: 16, gap: 16 }, host: { alignSelf: 'stretch' }, body: { fontSize: 17, lineHeight: 22 }, footer: { minHeight: 900 }, });