77} from "react-native" ;
88import { useSafeAreaInsets } from "react-native-safe-area-context" ;
99import { NewThreadButton } from "../../components/NewThreadButton" ;
10+ import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing" ;
1011import {
1112 androidHomeFabPosition ,
1213 type AndroidHomeFabLayout as SharedAndroidHomeFabLayout ,
@@ -15,14 +16,14 @@ import { useWorkspaceState } from "../../state/workspace";
1516import { FabScrollContext } from "./FabScrollContext" ;
1617import { updateFabScroll } from "./fab-scroll" ;
1718import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider" ;
18- import { ThreadUndoNoticeHeightContext } from "./thread-undo-notice-layout" ;
19+ import { ThreadUndoNoticeBottomContext } from "./thread-undo-notice-layout" ;
1920
2021export function AndroidHomeFabLayout ( props : ComponentProps < typeof SharedAndroidHomeFabLayout > ) {
2122 const insets = useSafeAreaInsets ( ) ;
2223 const { appearance } = useAppearancePreferences ( ) ;
2324 const { fontScale } = useWindowDimensions ( ) ;
2425 const [ layoutWidth , setLayoutWidth ] = useState < number | null > ( null ) ;
25- const [ undoNoticeHeight , setUndoNoticeHeight ] = useState ( 0 ) ;
26+ const { fabSize } = useAndroidControlSizing ( ) ;
2627 const { state } = useWorkspaceState ( ) ;
2728 const [ expanded , setExpanded ] = useState ( true ) ;
2829 const scrollState = useRef ( { anchor : 0 , expanded : true } ) ;
@@ -36,26 +37,25 @@ export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidH
3637 if ( next . expanded !== scrollState . current . expanded ) setExpanded ( next . expanded ) ;
3738 scrollState . current = next ;
3839 } , [ ] ) ;
40+ const showFab = ! props . disabled && ! props . sidebar && state . hasConnections && layoutWidth !== null ;
41+ const fabPosition = androidHomeFabPosition ( insets . bottom , props . sidebar ) ;
3942
4043 // Remount only the FAB when its font or pane changes to clear the cached expanded width.
4144 // The split-view sidebar has no FAB: the navigation rail carries New thread. On phones it
4245 // keeps Material's 16dp corner margin; the bottom bar already consumes the gesture inset.
4346 return (
4447 < View className = "flex-1" onLayout = { ( event ) => setLayoutWidth ( event . nativeEvent . layout . width ) } >
45- < ThreadUndoNoticeHeightContext value = { setUndoNoticeHeight } >
48+ < ThreadUndoNoticeBottomContext value = { showFab ? fabPosition . bottom + fabSize + 12 : null } >
4649 < FabScrollContext value = { onScroll } > { props . children } </ FabScrollContext >
47- </ ThreadUndoNoticeHeightContext >
48- { ! props . disabled && ! props . sidebar && state . hasConnections && layoutWidth !== null ? (
50+ </ ThreadUndoNoticeBottomContext >
51+ { showFab ? (
4952 < NewThreadButton
5053 key = { `${ appearance . baseFontSize } :${ fontScale } :${ layoutWidth } ` }
5154 extended
5255 expanded = { expanded }
5356 onPress = { props . onStartNewTask }
5457 className = "absolute"
55- style = { [
56- androidHomeFabPosition ( insets . bottom , props . sidebar ) ,
57- undoNoticeHeight > 0 ? { bottom : insets . bottom + undoNoticeHeight + 24 } : null ,
58- ] }
58+ style = { fabPosition }
5959 />
6060 ) : null }
6161 </ View >
0 commit comments