@@ -30,7 +30,11 @@ import {
3030 useWindowDimensions ,
3131 View ,
3232} from "react-native" ;
33- import { KeyboardController , useKeyboardContext } from "react-native-keyboard-controller" ;
33+ import {
34+ KeyboardController ,
35+ useKeyboardContext ,
36+ useKeyboardState ,
37+ } from "react-native-keyboard-controller" ;
3438import Animated , {
3539 runOnJS ,
3640 useAnimatedStyle ,
@@ -313,16 +317,17 @@ function AdaptiveWorkspaceLayoutContent(
313317 ! sidebarFloats &&
314318 ( composerEditing || composerKeyboardActive ) ;
315319 const keyboardProgress = useKeyboardContext ( ) . reanimated . progress ;
320+ // From the moment the keyboard starts showing until it has fully hidden. The detail pane keeps
321+ // the sidebar's room for that whole span, so on the way back the sidebar pushes the wide pane
322+ // aside instead of arriving beside one that already shrank.
323+ const keyboardOnScreen = useKeyboardState ( ( state ) => state . isVisible ) ;
316324 const shouldRenderNavigationRail =
317325 Platform . OS === "android" && baseLayout . usesSplitView && ! floatingTabsEnabled ;
318326 const enabledTabs = useEnabledNavigationTabs ( ) ;
319327 const { scale, fabSize } = useAndroidControlSizing ( ) ;
320328 const floatingTabs = floatingTabsMetrics ( enabledTabs . length + 1 , scale , fabSize ) ;
321- // The rail stays while the keyboard sets the sidebar aside; only the list pane collapses.
322- const navigationRailWidth =
323- shouldRenderNavigationRail && ( sidebarWithoutKeyboard || workspacePage )
324- ? ANDROID_WORKSPACE_RAIL_WIDTH
325- : 0 ;
329+ // The rail stays whether or not the sidebar shows; only the list pane comes and goes.
330+ const navigationRailWidth = shouldRenderNavigationRail ? ANDROID_WORKSPACE_RAIL_WIDTH : 0 ;
326331 const [ hinge , setHinge ] = useState < VerticalHinge | null > ( null ) ;
327332 const [ windowHinge , setWindowHinge ] = useState < VerticalHinge | null > ( null ) ;
328333 const handleHingeChange = ( next : VerticalHinge | null , nextWindow : VerticalHinge | null ) => {
@@ -657,9 +662,46 @@ function AdaptiveWorkspaceLayoutContent(
657662 : 0 ;
658663 // Android's split content is a rounded card: keep it off the screen edge like the list card.
659664 const contentEndGap = Platform . OS === "android" && layout . usesSplitView ? 4 : 0 ;
660- const contentTargetWidth = layout . usesSplitView
661- ? Math . max ( 0 , panes . contentPaneWidth - inspectorColumnTargetWidth - contentEndGap )
662- : null ;
665+ // Android's split is one strip: a sidebar slot of fixed width, then the detail pane. The
666+ // sidebar never resizes; both slide by one offset, so together they always fill the width.
667+ // The pane spans the sidebar's room too unless the sidebar has finished arriving: a sidebar on
668+ // its way in pushes the wide pane past the edge, and one leaving uncovers it.
669+ const stripSidebar =
670+ Platform . OS === "android" &&
671+ layout . usesSplitView &&
672+ layout . listPaneWidth !== null &&
673+ ! workspacePage &&
674+ ! sidebarFloats ;
675+ const sidebarSlotWidth = ( layout . listPaneWidth ?? 0 ) + ( layout . listPaneGap ?? 0 ) ;
676+ const sidebarTargetOpen = keyboardHoldsSidebar ? sidebarRestsOpen : panes . primarySidebarVisible ;
677+ const [ sidebarMotion , setSidebarMotion ] = useState ( {
678+ strip : stripSidebar ,
679+ settledOpen : sidebarTargetOpen ,
680+ } ) ;
681+ if ( sidebarMotion . strip !== stripSidebar ) {
682+ // Entering or leaving the strip (a workspace page, a fold) snaps the sidebar into place.
683+ setSidebarMotion ( { strip : stripSidebar , settledOpen : sidebarTargetOpen } ) ;
684+ } else if ( sidebarMotion . settledOpen && ! sidebarTargetOpen ) {
685+ setSidebarMotion ( { strip : stripSidebar , settledOpen : false } ) ;
686+ }
687+ const sidebarSettledOpen =
688+ sidebarMotion . strip === stripSidebar ? sidebarMotion . settledOpen : sidebarTargetOpen ;
689+ const markSidebarSettled = ( open : boolean ) =>
690+ setSidebarMotion ( ( current ) =>
691+ current . settledOpen === open ? current : { ...current , settledOpen : open } ,
692+ ) ;
693+ // The keyboard covers the sidebar's share from the moment it starts showing until it is gone.
694+ const contentSpansSidebar =
695+ stripSidebar &&
696+ ( ! sidebarSettledOpen || ! sidebarTargetOpen || ( keyboardHoldsSidebar && keyboardOnScreen ) ) ;
697+ const contentTargetWidth = ! layout . usesSplitView
698+ ? null
699+ : Math . max (
700+ 0 ,
701+ ( contentSpansSidebar ? width : panes . contentPaneWidth ) -
702+ inspectorColumnTargetWidth -
703+ contentEndGap ,
704+ ) ;
663705 // A workspace page (Usage) lays out at this width even while hidden behind another tab, so
664706 // opening it widens nothing it measured.
665707 const workspacePageWidth = ! layout . usesSplitView
@@ -787,7 +829,10 @@ function AdaptiveWorkspaceLayoutContent(
787829 // The content beside it already took its final width when the page closed.
788830 renderedSidebarWidth . set (
789831 withTiming ( targetWidth , snap ? { duration : 0 } : WORKSPACE_PANE_TIMING , ( finished ) => {
790- if ( finished && Platform . OS === "android" ) runOnJS ( settleListPane ) ( listPaneRevision ) ;
832+ if ( finished && Platform . OS === "android" ) {
833+ runOnJS ( settleListPane ) ( listPaneRevision ) ;
834+ runOnJS ( markSidebarSettled ) ( targetWidth > 0 ) ;
835+ }
791836 } ) ,
792837 ) ;
793838 } , [
@@ -803,6 +848,7 @@ function AdaptiveWorkspaceLayoutContent(
803848 renderedSidebarWidth ,
804849 renderedRailWidth ,
805850 settleListPane ,
851+ markSidebarSettled ,
806852 listPaneRevision ,
807853 workspacePage ,
808854 ] ) ;
@@ -842,45 +888,36 @@ function AdaptiveWorkspaceLayoutContent(
842888 const listPaneAnimatedStyle = useAnimatedStyle ( ( ) => ( {
843889 width : Math . min (
844890 listPaneCeiling ,
845- Math . max ( listPaneFloor , drawnSidebarWidth . value - listPaneGap ) ,
891+ Math . max (
892+ listPaneFloor ,
893+ ( stripSidebar ? sidebarSlotWidth : drawnSidebarWidth . value ) - listPaneGap ,
894+ ) ,
846895 ) ,
847896 } ) ) ;
897+ // How far the strip has slid: 0 with the sidebar shown, minus its width with it gone.
898+ const stripOffset = useDerivedValue ( ( ) =>
899+ stripSidebar ? drawnSidebarWidth . value - sidebarSlotWidth : 0 ,
900+ ) ;
848901 const sidebarAnimatedStyle = useAnimatedStyle ( ( ) => ( {
849902 // Fading a UIKit glass ancestor can leave remounted header effects missing.
850903 opacity :
851- keyboardHold . value || Platform . OS === "ios" || floatingTabsEnabled
904+ stripSidebar || Platform . OS === "ios" || floatingTabsEnabled
852905 ? 1
853906 : Math . min ( 1 , drawnSidebarWidth . value / 80 ) ,
854- // Held by the keyboard, it keeps its resting width and slides, so nothing relays out.
855- width : keyboardHold . value ? renderedSidebarWidth . value : drawnSidebarWidth . value ,
856- transform : [
857- {
858- translateX : keyboardHold . value ? drawnSidebarWidth . value - renderedSidebarWidth . value : 0 ,
859- } ,
860- ] ,
907+ width : stripSidebar ? sidebarSlotWidth : drawnSidebarWidth . value ,
908+ flexShrink : stripSidebar ? 0 : 1 ,
909+ transform : [ { translateX : stripOffset . value } ] ,
861910 } ) ) ;
862911 // The content keeps the width React laid it out at and rides the sidebar's edge, so a keyboard
863912 // transition relays nothing out per frame, the way UIKit animates the iOS split view.
864913 // Until React commits the wider layout, the detail card continues past its right edge, so the
865914 // strip the narrower column leaves shows the card instead of the row behind it.
866915 const contentOverhangStyle = useAnimatedStyle ( ( ) => ( {
867916 opacity : keyboardHold . value && keyboardProgress . value > 0 ? 1 : 0 ,
868- transform : [
869- {
870- translateX : keyboardHold . value ? drawnSidebarWidth . value - renderedSidebarWidth . value : 0 ,
871- } ,
872- ] ,
873917 } ) ) ;
874918 const threadHeader = useToolbarLayout ( false , composerKeyboardActive ) ;
875919 const threadHeaderHeight =
876920 threadHeader . paddingTop + threadHeader . height + threadHeader . paddingBottom ;
877- const contentKeyboardStyle = useAnimatedStyle ( ( ) => ( {
878- transform : [
879- {
880- translateX : keyboardHold . value ? drawnSidebarWidth . value - renderedSidebarWidth . value : 0 ,
881- } ,
882- ] ,
883- } ) ) ;
884921
885922 // Clip the navigator at its settled width so native headers and markdown reflow only once per pane toggle.
886923 const renderedInspectorWidth = useSharedValue ( inspectorColumnTargetWidth ) ;
@@ -895,26 +932,29 @@ function AdaptiveWorkspaceLayoutContent(
895932 ) ;
896933 // Android can resize the native row before React removes its split panes on a fold.
897934 const androidSplit = Platform . OS === "android" && layout . usesSplitView ;
898- // Held by the keyboard, the column keeps its resting width and stops clipping, so nothing in
899- // the row relays out when the slide starts; the content slides out of it instead.
900- const androidContentSlotStyle = useAnimatedStyle ( ( ) => ( {
901- width : ! androidSplit
902- ? ( "100%" as const )
903- : keyboardHoldsSidebar
904- ? Math . max (
905- 0 ,
906- viewportWidth -
907- renderedRailWidth . value -
908- renderedSidebarWidth . value -
909- renderedInspectorWidth . value ,
910- )
911- : renderedContentWidth . value ,
912- } ) ) ;
935+ // In the strip the column itself slides with the sidebar: Android only delivers touches inside a
936+ // parent's bounds, so content may not slide out of its column.
937+ const androidContentSlotStyle = useAnimatedStyle ( ( ) =>
938+ ! androidSplit
939+ ? { width : "100%" as const }
940+ : stripSidebar
941+ ? {
942+ // Wide enough for the pane at either width; the margin gives the sidebar's share
943+ // back to the row, so a column after it stays put while the strip slides.
944+ width : Math . max (
945+ 0 ,
946+ viewportWidth - renderedRailWidth . value - renderedInspectorWidth . value ,
947+ ) ,
948+ marginRight : - sidebarSlotWidth ,
949+ transform : [ { translateX : stripOffset . value } ] ,
950+ }
951+ : { width : renderedContentWidth . value } ,
952+ ) ;
913953 // While the sidebar animates, clip the settled navigator instead of reflowing its text every frame.
914- // Held by the keyboard it lifts entirely: the content outgrows its column, and a cap that
915- // follows React's width would clip the wider layout for the frame it lands.
954+ // In the strip it lifts entirely: the content outgrows its column, and a cap that follows
955+ // React's width would clip the wider layout for the frame it lands.
916956 const androidNavigatorLimit = useAnimatedStyle ( ( ) => ( {
917- maxWidth : keyboardHold . value
957+ maxWidth : stripSidebar
918958 ? viewportWidth
919959 : androidSplit &&
920960 contentTargetWidth !== null &&
@@ -1058,13 +1098,9 @@ function AdaptiveWorkspaceLayoutContent(
10581098 </ Animated . View >
10591099 ) : null }
10601100 < Animated . View
1061- // While the keyboard slides the sidebar beneath this column, the row's own background
1062- // shows through instead; a zIndex change would reorder the views and drop focus.
10631101 className = {
10641102 Platform . OS === "android"
1065- ? keyboardHoldsSidebar
1066- ? "max-w-full shrink-0"
1067- : "max-w-full shrink-0 overflow-hidden bg-header"
1103+ ? "max-w-full shrink-0 overflow-hidden bg-header"
10681104 : "flex-1 overflow-hidden bg-screen"
10691105 }
10701106 style = { Platform . OS === "android" ? androidContentSlotStyle : undefined }
@@ -1074,20 +1110,17 @@ function AdaptiveWorkspaceLayoutContent(
10741110 >
10751111 < Animated . View
10761112 collapsable = { false }
1077- // The animated style stays attached so its shift resets when the keyboard lets go.
10781113 style = { [
10791114 contentTargetWidth !== null
10801115 ? {
10811116 flex : 1 ,
10821117 width : contentTargetWidth ,
1083- // Held by the keyboard, the content outgrows the column it slides out of from
1084- // its start edge; anchoring its end would push it off the other side.
1085- alignSelf : contentAnchor . end && ! keyboardHoldsSidebar ? "flex-end" : "flex-start" ,
1086- marginRight : contentAnchor . end && ! keyboardHoldsSidebar ? contentEndGap : 0 ,
1118+ // The strip's column is wider than the pane; the pane sits at its start.
1119+ alignSelf : contentAnchor . end && ! stripSidebar ? "flex-end" : "flex-start" ,
1120+ marginRight : contentAnchor . end && ! stripSidebar ? contentEndGap : 0 ,
10871121 }
10881122 : { flex : 1 } ,
10891123 Platform . OS === "android" ? androidNavigatorLimit : undefined ,
1090- contentKeyboardStyle ,
10911124 ] }
10921125 >
10931126 { /* Android holds the content still, so its floating controls keep its width. */ }
0 commit comments