Skip to content

Commit f05f8a5

Browse files
fix(mobile): the composer stays level with the Duo's rail after a fold
After a fold, react-native-keyboard-controller can settle at progress 1 with no keyboard. KeyboardStickyView then kept its open offset, so the composer sat its bottom spacing below the rail. A local sticky view applies the open offset only while the keyboard has height. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b76a110 commit f05f8a5

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { PropsWithChildren } from "react";
2+
import type { ViewProps } from "react-native";
3+
import { useReanimatedKeyboardAnimation } from "react-native-keyboard-controller";
4+
import Reanimated, { interpolate, useAnimatedStyle } from "react-native-reanimated";
5+
6+
type KeyboardStickyViewProps = PropsWithChildren<
7+
ViewProps & {
8+
readonly offset?: { readonly closed?: number; readonly opened?: number };
9+
readonly enabled?: boolean;
10+
}
11+
>;
12+
13+
/**
14+
* react-native-keyboard-controller's sticky view, with the open offset tied to the keyboard's
15+
* height. After a fold the controller can settle at progress 1 with no keyboard, which left the
16+
* view shifted by its open offset.
17+
*/
18+
export function KeyboardStickyView({
19+
offset: { closed = 0, opened = 0 } = {},
20+
enabled = true,
21+
style,
22+
...props
23+
}: KeyboardStickyViewProps) {
24+
const { height, progress } = useReanimatedKeyboardAnimation();
25+
const stickyStyle = useAnimatedStyle(() => {
26+
const open = height.value < 0 ? progress.value : 0;
27+
return {
28+
transform: [
29+
{
30+
translateY: enabled ? height.value + interpolate(open, [0, 1], [closed, opened]) : closed,
31+
},
32+
],
33+
};
34+
}, [closed, opened, enabled]);
35+
return <Reanimated.View style={[style, stickyStyle]} {...props} />;
36+
}

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ import {
100100
} from "react-native";
101101
import {
102102
KeyboardController,
103-
KeyboardStickyView,
104103
useKeyboardState,
105104
useReanimatedKeyboardAnimation,
106105
} from "react-native-keyboard-controller";
106+
import { KeyboardStickyView } from "../../components/KeyboardStickyView";
107107
import Animated, {
108108
Easing,
109109
FadeInDown,

‎apps/mobile/src/features/workspace/WorkspaceToolbar.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
useWindowDimensions,
1010
type TextInputInstance,
1111
} from "react-native";
12-
import { KeyboardStickyView, useKeyboardState } from "react-native-keyboard-controller";
12+
import { useKeyboardState } from "react-native-keyboard-controller";
13+
import { KeyboardStickyView } from "../../components/KeyboardStickyView";
1314
import { useSafeAreaInsets } from "react-native-safe-area-context";
1415

1516
import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";

0 commit comments

Comments
 (0)