import { Text as ComposeText, Host, OutlinedTextField, useNativeState, } from '@expo/ui/jetpack-compose'; import { fillMaxWidth } from '@expo/ui/jetpack-compose/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 { useAndroidColors } from '../chrome/material'; import { NestedBar } from '../chrome/NestedBar'; import { 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 colors = useAndroidColors(scheme); const safe = useSafeAreaInsets(); const [height, setHeight] = useState(120); const above = useNativeState(''); const below = useNativeState(''); return ( The editor below takes its height from onContentSizeChange and leaves vertical scrolling to this page. Long lines scroll sideways. A field above setHeight(Math.ceil(e.height))} /> A field below A tall footer, so the page itself has something to scroll. ); } const styles = StyleSheet.create({ screen: { flex: 1 }, scroll: { flex: 1 }, content: { padding: 16, gap: 16 }, host: { alignSelf: 'stretch' }, body: { fontSize: 16, lineHeight: 24 }, footer: { minHeight: 900 }, });