Skip to content

Commit 71960d1

Browse files
committed
fix(mobile): overlay Android FAB with undo notices
1 parent 3384d2f commit 71960d1

3 files changed

Lines changed: 7 additions & 17 deletions

File tree

‎apps/mobile/src/features/home/AndroidHomeFab.android.tsx‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
} from "react-native";
88
import { useSafeAreaInsets } from "react-native-safe-area-context";
99
import { NewThreadButton } from "../../components/NewThreadButton";
10-
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
1110
import {
1211
androidHomeFabPosition,
1312
type AndroidHomeFabLayout as SharedAndroidHomeFabLayout,
@@ -16,14 +15,12 @@ import { useWorkspaceState } from "../../state/workspace";
1615
import { FabScrollContext } from "./FabScrollContext";
1716
import { updateFabScroll } from "./fab-scroll";
1817
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
19-
import { ThreadUndoNoticeBottomContext } from "./thread-undo-notice-layout";
2018

2119
export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidHomeFabLayout>) {
2220
const insets = useSafeAreaInsets();
2321
const { appearance } = useAppearancePreferences();
2422
const { fontScale } = useWindowDimensions();
2523
const [layoutWidth, setLayoutWidth] = useState<number | null>(null);
26-
const { fabSize } = useAndroidControlSizing();
2724
const { state } = useWorkspaceState();
2825
const [expanded, setExpanded] = useState(true);
2926
const scrollState = useRef({ anchor: 0, expanded: true });
@@ -37,25 +34,21 @@ export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidH
3734
if (next.expanded !== scrollState.current.expanded) setExpanded(next.expanded);
3835
scrollState.current = next;
3936
}, []);
40-
const showFab = !props.disabled && !props.sidebar && state.hasConnections && layoutWidth !== null;
41-
const fabPosition = androidHomeFabPosition(insets.bottom, props.sidebar);
4237

4338
// Remount only the FAB when its font or pane changes to clear the cached expanded width.
4439
// The split-view sidebar has no FAB: the navigation rail carries New thread. On phones it
4540
// keeps Material's 16dp corner margin; the bottom bar already consumes the gesture inset.
4641
return (
4742
<View className="flex-1" onLayout={(event) => setLayoutWidth(event.nativeEvent.layout.width)}>
48-
<ThreadUndoNoticeBottomContext value={showFab ? fabPosition.bottom + fabSize + 12 : null}>
49-
<FabScrollContext value={onScroll}>{props.children}</FabScrollContext>
50-
</ThreadUndoNoticeBottomContext>
51-
{showFab ? (
43+
<FabScrollContext value={onScroll}>{props.children}</FabScrollContext>
44+
{!props.disabled && !props.sidebar && state.hasConnections && layoutWidth !== null ? (
5245
<NewThreadButton
5346
key={`${appearance.baseFontSize}:${fontScale}:${layoutWidth}`}
5447
extended
5548
expanded={expanded}
5649
onPress={props.onStartNewTask}
5750
className="absolute"
58-
style={fabPosition}
51+
style={androidHomeFabPosition(insets.bottom, props.sidebar)}
5952
/>
6053
) : null}
6154
</View>

‎apps/mobile/src/features/home/ThreadUndoNotice.android.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { use, useLayoutEffect, useState } from "react";
1+
import { useLayoutEffect, useState } from "react";
22
import { View } from "react-native";
33
import { GestureDetector, usePanGesture } from "react-native-gesture-handler";
44
import Animated, {
@@ -16,7 +16,6 @@ import {
1616
readThreadUndoNotice,
1717
useThreadUndoNotice,
1818
} from "./thread-undo-notice";
19-
import { ThreadUndoNoticeBottomContext } from "./thread-undo-notice-layout";
2019

2120
const SWIPE_TIMING = { duration: 160, reduceMotion: ReduceMotion.System };
2221

@@ -34,7 +33,6 @@ function SwipeableUndoNotice(props: {
3433
}) {
3534
const { notice } = props;
3635
const insets = useSafeAreaInsets();
37-
const bottom = use(ThreadUndoNoticeBottomContext);
3836
const translation = useSharedValue(0);
3937
const width = useSharedValue(0);
4038

@@ -79,7 +77,7 @@ function SwipeableUndoNotice(props: {
7977
return (
8078
<View
8179
className="absolute inset-x-3 z-[100]"
82-
style={{ bottom: bottom ?? insets.bottom + 12 }}
80+
style={{ bottom: insets.bottom + 12 }}
8381
pointerEvents="box-none"
8482
onLayout={(event) => {
8583
width.set(event.nativeEvent.layout.width);
@@ -89,6 +87,8 @@ function SwipeableUndoNotice(props: {
8987
<Animated.View
9088
collapsable={false}
9189
accessible
90+
accessibilityRole="alert"
91+
accessibilityLiveRegion="assertive"
9292
accessibilityLabel={`${notice.action} thread`}
9393
style={animatedStyle}
9494
accessibilityActions={[{ name: "dismiss", label: "Dismiss message" }]}

‎apps/mobile/src/features/home/thread-undo-notice-layout.ts‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)