@@ -25,7 +25,9 @@ import {
2525 KeyboardEvents ,
2626 KeyboardStickyView ,
2727 useKeyboardState ,
28+ useReanimatedKeyboardAnimation ,
2829} from "react-native-keyboard-controller" ;
30+ import Animated , { useAnimatedStyle } from "react-native-reanimated" ;
2931
3032import {
3133 ComposerToolbarButton ,
@@ -585,39 +587,47 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
585587 height : state . height ,
586588 isVisible : state . isVisible ,
587589 } ) ) ;
588- const accessoryInsets = { left : insets . left , right : insets . right } ;
589- if (
590- Platform . OS === "ios" &&
591- nativeColumnMetrics ?. hasHinge &&
592- nativeColumnMetrics . verticalBarEdge !== "none" &&
593- // In short landscape columns, UIKit's floating tabs sit beside this row.
594- nativeColumnMetrics . width < nativeColumnMetrics . height
595- ) {
596- const edge = nativeColumnMetrics . verticalBarEdge ;
597- const top = nativeColumnMetrics . height - keyboardState . height - TERMINAL_ACCESSORY_HEIGHT ;
598- // UIKit reserves the whole rail in its safe area. At keyboard height, keep
599- // clearance only for occlusions that actually overlap the accessory row.
600- accessoryInsets [ edge ] = 0 ;
601- for ( const region of nativeColumnMetrics . reservedRegions ) {
602- if (
603- region . kind !== "occlusion" ||
604- region . y >= top + TERMINAL_ACCESSORY_HEIGHT ||
605- region . y + region . height <= top
606- )
607- continue ;
608- if ( edge === "left" && region . x < insets . left ) {
609- accessoryInsets . left = Math . max ( accessoryInsets . left , region . x + region . width ) ;
610- } else if (
611- edge === "right" &&
612- region . x + region . width > nativeColumnMetrics . width - insets . right
613- ) {
614- accessoryInsets . right = Math . max (
615- accessoryInsets . right ,
616- nativeColumnMetrics . width - region . x ,
617- ) ;
590+ const { height : keyboardTranslation } = useReanimatedKeyboardAnimation ( ) ;
591+ const isIos = Platform . OS === "ios" ;
592+ const accessoryStyle = useAnimatedStyle ( ( ) => {
593+ if ( ! isIos ) return { paddingLeft : 0 , paddingRight : 0 } ;
594+ const accessoryInsets = { left : insets . left , right : insets . right } ;
595+ if (
596+ nativeColumnMetrics ?. hasHinge &&
597+ nativeColumnMetrics . verticalBarEdge !== "none" &&
598+ // In short landscape columns, UIKit's floating tabs sit beside this row.
599+ nativeColumnMetrics . width < nativeColumnMetrics . height
600+ ) {
601+ const edge = nativeColumnMetrics . verticalBarEdge ;
602+ // Match KeyboardStickyView's live translation so this stays in column
603+ // coordinates when the keyboard or window changes without a show event.
604+ const top =
605+ nativeColumnMetrics . height + keyboardTranslation . value - TERMINAL_ACCESSORY_HEIGHT ;
606+ // UIKit reserves the whole rail in its safe area. At keyboard height, keep
607+ // clearance only for occlusions that actually overlap the accessory row.
608+ accessoryInsets [ edge ] = 0 ;
609+ for ( const region of nativeColumnMetrics . reservedRegions ) {
610+ if (
611+ region . kind !== "occlusion" ||
612+ region . y >= top + TERMINAL_ACCESSORY_HEIGHT ||
613+ region . y + region . height <= top
614+ )
615+ continue ;
616+ if ( edge === "left" && region . x < insets . left ) {
617+ accessoryInsets . left = Math . max ( accessoryInsets . left , region . x + region . width ) ;
618+ } else if (
619+ edge === "right" &&
620+ region . x + region . width > nativeColumnMetrics . width - insets . right
621+ ) {
622+ accessoryInsets . right = Math . max (
623+ accessoryInsets . right ,
624+ nativeColumnMetrics . width - region . x ,
625+ ) ;
626+ }
618627 }
619628 }
620- }
629+ return { paddingLeft : accessoryInsets . left , paddingRight : accessoryInsets . right } ;
630+ } ) ;
621631 const isAccessoryVisible = canOperateTerminal && keyboardState . isVisible && ! isAccessoryDismissed ;
622632 // Android's terminal owns an EditText; turning off autoFocus also clears its native focus.
623633 const terminalAutoFocus =
@@ -1331,27 +1341,18 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
13311341 style = { { position : "absolute" , bottom : 0 , left : 0 , right : 0 } }
13321342 offset = { { closed : 0 , opened : 0 } }
13331343 >
1334- < View
1344+ < Animated . View
13351345 className = "border-t"
1336- style = { {
1337- backgroundColor : terminalTheme . background ,
1338- borderTopColor : terminalTheme . border ,
1339- minHeight : TERMINAL_ACCESSORY_HEIGHT ,
1340- } }
1346+ style = { [
1347+ {
1348+ backgroundColor : terminalTheme . background ,
1349+ borderTopColor : terminalTheme . border ,
1350+ minHeight : TERMINAL_ACCESSORY_HEIGHT ,
1351+ } ,
1352+ accessoryStyle ,
1353+ ] }
13411354 >
1342- < ComposerToolbarRow
1343- paddingBottom = { 4 }
1344- paddingHorizontal = { 8 }
1345- paddingTop = { 4 }
1346- style = {
1347- Platform . OS === "ios"
1348- ? {
1349- paddingLeft : 8 + accessoryInsets . left ,
1350- paddingRight : 8 + accessoryInsets . right ,
1351- }
1352- : undefined
1353- }
1354- >
1355+ < ComposerToolbarRow paddingBottom = { 4 } paddingHorizontal = { 8 } paddingTop = { 4 } >
13551356 < ComposerToolbarScroller
13561357 contentPaddingRight = { 2 }
13571358 fadeOpaque = { terminalTheme . background }
@@ -1386,7 +1387,7 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
13861387 showChevron = { false }
13871388 />
13881389 </ ComposerToolbarRow >
1389- </ View >
1390+ </ Animated . View >
13901391 </ KeyboardStickyView >
13911392 ) : canOperateTerminal && ! keyboardState . isVisible && Platform . OS !== "android" ? (
13921393 < Pressable
0 commit comments