@@ -8,6 +8,7 @@ import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area
88import { AdaptiveWorkspaceContext , useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context" ;
99import { threadSelectionDeferral } from "./deferred-navigation" ;
1010import { uuidv4 } from "../../lib/uuid" ;
11+ import { useToolbarLayout } from "../../components/ui/useToolbarLayout" ;
1112import { EnvironmentId , ThreadId , type SidebarProjectGroupingMode } from "@t3tools/contracts" ;
1213import { useAtomValue } from "@effect/atom-react" ;
1314import { NavigationContext , NavigationRouteContext , useNavigation } from "@react-navigation/native" ;
@@ -317,8 +318,9 @@ function AdaptiveWorkspaceLayoutContent(
317318 const enabledTabs = useEnabledNavigationTabs ( ) ;
318319 const { scale, fabSize } = useAndroidControlSizing ( ) ;
319320 const floatingTabs = floatingTabsMetrics ( enabledTabs . length + 1 , scale , fabSize ) ;
321+ // The rail stays while the keyboard sets the sidebar aside; only the list pane collapses.
320322 const navigationRailWidth =
321- shouldRenderNavigationRail && ( showPrimarySidebar || workspacePage )
323+ shouldRenderNavigationRail && ( sidebarWithoutKeyboard || workspacePage )
322324 ? ANDROID_WORKSPACE_RAIL_WIDTH
323325 : 0 ;
324326 const [ hinge , setHinge ] = useState < VerticalHinge | null > ( null ) ;
@@ -819,6 +821,9 @@ function AdaptiveWorkspaceLayoutContent(
819821 // Showing or hiding the sidebar clips a fixed-width list. A hinge resize instead tracks the
820822 // animated edge, so the header actions slide with it rather than jumping or being covered.
821823 const listPaneGap = layout . listPaneGap ?? 0 ;
824+ const keyboardSidebarRest = sidebarRestsOpen
825+ ? ( layout . listPaneWidth ?? 0 ) + ( layout . listPaneGap ?? 0 )
826+ : 0 ;
822827 const drawnSidebarWidth = useDerivedValue (
823828 ( ) => renderedSidebarWidth . value * ( keyboardHold . value ? 1 - keyboardProgress . value : 1 ) ,
824829 ) ;
@@ -827,15 +832,42 @@ function AdaptiveWorkspaceLayoutContent(
827832 listPaneCeiling ,
828833 Math . max ( listPaneFloor , drawnSidebarWidth . value - listPaneGap ) ,
829834 ) ,
830- // Following the keyboard, the list rides the sidebar's edge like the content beside it,
831- // instead of being uncovered in place.
832- transform : [ { translateX : drawnSidebarWidth . value - renderedSidebarWidth . value } ] ,
833835 } ) ) ;
834836 const sidebarAnimatedStyle = useAnimatedStyle ( ( ) => ( {
835837 // Fading a UIKit glass ancestor can leave remounted header effects missing.
836838 opacity :
837- Platform . OS === "ios" || floatingTabsEnabled ? 1 : Math . min ( 1 , drawnSidebarWidth . value / 80 ) ,
838- width : drawnSidebarWidth . value ,
839+ keyboardHold . value || Platform . OS === "ios" || floatingTabsEnabled
840+ ? 1
841+ : Math . min ( 1 , drawnSidebarWidth . value / 80 ) ,
842+ // Held by the keyboard, it keeps its resting width and slides, so nothing relays out.
843+ width : keyboardHold . value ? renderedSidebarWidth . value : drawnSidebarWidth . value ,
844+ transform : [
845+ {
846+ translateX : keyboardHold . value ? drawnSidebarWidth . value - renderedSidebarWidth . value : 0 ,
847+ } ,
848+ ] ,
849+ } ) ) ;
850+ // The content keeps the width React laid it out at and rides the sidebar's edge, so a keyboard
851+ // transition relays nothing out per frame, the way UIKit animates the iOS split view.
852+ // While the keyboard is moving, the detail card continues past its right edge, so the strip the
853+ // narrower settled column leaves on the way back shows the card instead of the row behind it.
854+ const contentOverhangStyle = useAnimatedStyle ( ( ) => ( {
855+ opacity : keyboardHold . value && keyboardProgress . value > 0 && keyboardProgress . value < 1 ? 1 : 0 ,
856+ transform : [
857+ {
858+ translateX : keyboardHold . value ? drawnSidebarWidth . value - renderedSidebarWidth . value : 0 ,
859+ } ,
860+ ] ,
861+ } ) ) ;
862+ const threadHeader = useToolbarLayout ( false , composerKeyboardActive ) ;
863+ const threadHeaderHeight =
864+ threadHeader . paddingTop + threadHeader . height + threadHeader . paddingBottom ;
865+ const contentKeyboardStyle = useAnimatedStyle ( ( ) => ( {
866+ transform : [
867+ {
868+ translateX : keyboardHold . value ? drawnSidebarWidth . value - renderedSidebarWidth . value : 0 ,
869+ } ,
870+ ] ,
839871 } ) ) ;
840872
841873 // Clip the navigator at its settled width so native headers and markdown reflow only once per pane toggle.
@@ -851,8 +883,13 @@ function AdaptiveWorkspaceLayoutContent(
851883 ) ;
852884 // Android can resize the native row before React removes its split panes on a fold.
853885 const androidSplit = Platform . OS === "android" && layout . usesSplitView ;
886+ // Held by the keyboard, the sidebar leaves the row, so the column spans its room too.
854887 const androidContentSlotStyle = useAnimatedStyle ( ( ) => ( {
855- width : androidSplit ? renderedContentWidth . value : ( "100%" as const ) ,
888+ width : ! androidSplit
889+ ? ( "100%" as const )
890+ : keyboardHoldsSidebar
891+ ? Math . max ( 0 , viewportWidth - renderedRailWidth . value - renderedInspectorWidth . value )
892+ : renderedContentWidth . value ,
856893 } ) ) ;
857894 // While the sidebar animates, clip the settled navigator instead of reflowing its text every frame.
858895 const androidNavigatorLimit = useAnimatedStyle ( ( ) => ( {
@@ -965,7 +1002,10 @@ function AdaptiveWorkspaceLayoutContent(
9651002 { position : "absolute" , top : 0 , bottom : 0 , zIndex : 2 , elevation : 8 } ,
9661003 floatingSidebarAnimatedStyle ,
9671004 ]
968- : null ,
1005+ : // Out of the row while the keyboard slides it.
1006+ keyboardHoldsSidebar
1007+ ? { position : "absolute" , top : 0 , bottom : 0 , left : navigationRailWidth }
1008+ : null ,
9691009 sidebarAnimatedStyle ,
9701010 ] }
9711011 >
@@ -996,9 +1036,13 @@ function AdaptiveWorkspaceLayoutContent(
9961036 </ Animated . View >
9971037 ) : null }
9981038 < Animated . View
1039+ // While the keyboard slides the sidebar beneath this column, the row's own background
1040+ // shows through instead; a zIndex change would reorder the views and drop focus.
9991041 className = {
10001042 Platform . OS === "android"
1001- ? "max-w-full shrink-0 overflow-hidden bg-header"
1043+ ? keyboardHoldsSidebar
1044+ ? "max-w-full shrink-0 overflow-hidden"
1045+ : "max-w-full shrink-0 overflow-hidden bg-header"
10021046 : "flex-1 overflow-hidden bg-screen"
10031047 }
10041048 style = { Platform . OS === "android" ? androidContentSlotStyle : undefined }
@@ -1008,11 +1052,17 @@ function AdaptiveWorkspaceLayoutContent(
10081052 >
10091053 < Animated . View
10101054 collapsable = { false }
1055+ // The animated style stays attached so its shift resets when the keyboard lets go.
10111056 style = { [
1012- // While the keyboard moves the sidebar, the content tracks its edge every frame so
1013- // the two land together; a settled width would jump when React commits mid-slide.
1014- keyboardHoldsSidebar
1015- ? { flex : 1 , marginRight : contentEndGap }
1057+ keyboardHoldsSidebar && contentTargetWidth !== null
1058+ ? {
1059+ position : "absolute" ,
1060+ top : 0 ,
1061+ bottom : 0 ,
1062+ // React places it at the sidebar's resting edge; only the keyboard's share moves.
1063+ left : keyboardSidebarRest ,
1064+ width : contentTargetWidth ,
1065+ }
10161066 : contentTargetWidth !== null
10171067 ? {
10181068 flex : 1 ,
@@ -1022,6 +1072,7 @@ function AdaptiveWorkspaceLayoutContent(
10221072 }
10231073 : { flex : 1 } ,
10241074 Platform . OS === "android" ? androidNavigatorLimit : undefined ,
1075+ contentKeyboardStyle ,
10251076 ] }
10261077 >
10271078 { /* Android holds the content still, so its floating controls keep its width. */ }
@@ -1068,6 +1119,35 @@ function AdaptiveWorkspaceLayoutContent(
10681119 </ WorkspaceSettledContentWidthContext >
10691120 </ WorkspaceContentWidthContext >
10701121 </ Animated . View >
1122+ { keyboardHoldsSidebar && contentTargetWidth !== null ? (
1123+ < >
1124+ < Animated . View
1125+ pointerEvents = "none"
1126+ className = "absolute top-0 bg-header"
1127+ style = { [
1128+ {
1129+ left : keyboardSidebarRest + contentTargetWidth ,
1130+ width : keyboardSidebarRest + contentEndGap ,
1131+ height : threadHeaderHeight ,
1132+ } ,
1133+ contentOverhangStyle ,
1134+ ] }
1135+ />
1136+ < Animated . View
1137+ pointerEvents = "none"
1138+ className = "absolute bottom-0 rounded-tr-[28px] bg-thread-canvas"
1139+ style = { [
1140+ {
1141+ // Starts under the card's rounded corner so the two read as one card.
1142+ left : keyboardSidebarRest + contentTargetWidth - 28 ,
1143+ width : keyboardSidebarRest + 28 ,
1144+ top : threadHeaderHeight ,
1145+ } ,
1146+ contentOverhangStyle ,
1147+ ] }
1148+ />
1149+ </ >
1150+ ) : null }
10711151 </ Animated . View >
10721152 { sidebarFloats ? (
10731153 < Animated . View
0 commit comments