1const PENDING_USER_INPUT_MAX_HEIGHT = 560;
2const PENDING_USER_INPUT_MIN_HEIGHT = 160;
3const PENDING_USER_INPUT_VERTICAL_GAP = 12;
4
5/**
6 * Reserve for a portrait iPhone keyboard with the QuickType bar until a real
7 * height has been observed. Overestimating only costs card height; an
8 * underestimate would let the card overshoot on the first keyboard open.
9 */
10export const ESTIMATED_KEYBOARD_HEIGHT = 336;
11
12/**
13 * One clock for the questionnaire expand/collapse choreography: the card's
14 * enter/exit and the feed-inset glide must share it or they visibly drift.
15 * Sized for the near-full-height slide (the card travels its own height),
16 * in the same class as the iOS keyboard's ~250ms.
17 */
18export const USER_INPUT_TOGGLE_DURATION_MS = 220;
19
20export function derivePendingUserInputMaxHeight(input: {
21 readonly windowHeight: number;
22 readonly keyboardHeight: number;
23 readonly navigationHeaderHeight: number;
24 readonly composerOverlapHeight: number;
25}): number {
26 const availableHeight =
27 input.windowHeight -
28 Math.max(0, input.keyboardHeight) -
29 Math.max(0, input.navigationHeaderHeight) -
30 Math.max(0, input.composerOverlapHeight) -
31 PENDING_USER_INPUT_VERTICAL_GAP;
32
33 return Math.min(
34 PENDING_USER_INPUT_MAX_HEIGHT,
35 Math.max(PENDING_USER_INPUT_MIN_HEIGHT, availableHeight),
36 );
37}