diff --git a/app/session/[id].tsx b/app/session/[id].tsx index 97f885f0..d43989c6 100644 --- a/app/session/[id].tsx +++ b/app/session/[id].tsx @@ -8,6 +8,7 @@ import { StyleSheet, useColorScheme, KeyboardAvoidingView, + Keyboard, Platform, ActivityIndicator, Alert, @@ -39,6 +40,7 @@ import { useConnections } from "../../src/stores/connections" import { useAuth } from "../../src/stores/auth" import { useCatalog } from "../../src/stores/catalog" import { useSpeech } from "../../src/lib/speech" +import { keyboardPadding, keyboardVerticalOffset } from "../../src/lib/keyboard-offset" // --- Builtin slash commands --- const BUILTIN_COMMANDS: SlashCommand[] = [ @@ -85,6 +87,20 @@ export default function SessionScreen() { const [input, setInput] = useState("") const [attachments, setAttachments] = useState([]) const [showInfo, setShowInfo] = useState(false) + const [keyboardHeight, setKeyboardHeight] = useState(() => Keyboard.metrics()?.height ?? 0) + + useEffect(() => { + if (Platform.OS !== "android") return + const show = Keyboard.addListener("keyboardDidShow", (event) => setKeyboardHeight(event.endCoordinates.height)) + const hide = Keyboard.addListener("keyboardDidHide", () => setKeyboardHeight(0)) + // Close the render-to-effect race: listeners are attached first, then the + // current native metrics become the source of truth. + setKeyboardHeight(Keyboard.metrics()?.height ?? 0) + return () => { + show.remove() + hide.remove() + } + }, []) const { currentSession, @@ -592,21 +608,25 @@ export default function SessionScreen() { />