diff --git a/apps/mobile/src/features/threads/PendingApprovalCard.tsx b/apps/mobile/src/features/threads/PendingApprovalCard.tsx index bd7f393f5314..3b581021f232 100644 --- a/apps/mobile/src/features/threads/PendingApprovalCard.tsx +++ b/apps/mobile/src/features/threads/PendingApprovalCard.tsx @@ -11,6 +11,11 @@ import { import { T, useGT, useMessages } from "gt-react-native"; import { useState } from "react"; import { Pressable, View } from "react-native"; +import Animated, { + useAnimatedStyle, + useSharedValue, + type DerivedValue, +} from "react-native-reanimated"; import { AppText as Text } from "../../components/ui/AppText"; import type { PendingApproval } from "../../lib/threadActivity"; @@ -19,12 +24,15 @@ export interface PendingApprovalCardProps { readonly canOperateThread: boolean; readonly approval: PendingApproval; readonly respondingApprovalId: RuntimeRequestId | null; + readonly maxHeight?: DerivedValue; readonly onRespond: ( requestId: RuntimeRequestId, decision: ProviderApprovalDecision, ) => Promise; } +const BODY_MIN_HEIGHT = 64; + export function PendingApprovalCard(props: PendingApprovalCardProps) { const gt = useGT(); const m = useMessages(); @@ -40,40 +48,71 @@ export function PendingApprovalCard(props: PendingApprovalCardProps) { const canRespond = props.approval.responseCapability === "live"; const disabled = !canRespond || props.respondingApprovalId === props.approval.requestId; const [explanationOpen, setExplanationOpen] = useState(false); + const { maxHeight } = props; + const cardHeight = useSharedValue(0); + const bodyHeight = useSharedValue(0); + // The body takes what the pinned rows leave. Below BODY_MIN_HEIGHT the caller's capped + // ScrollView scrolls the whole card instead, so the buttons stay reachable. + const bodyHeightStyle = useAnimatedStyle(() => + maxHeight === undefined + ? {} + : { + maxHeight: Math.max( + BODY_MIN_HEIGHT, + maxHeight.value - (cardHeight.value - bodyHeight.value), + ), + }, + ); return ( - - - Approval needed - - - {props.approval.appName ?? props.approval.requestKind} - - {props.approval.detail ? ( - - {props.approval.detail} + { + cardHeight.set(event.nativeEvent.layout.height); + }} + > + { + bodyHeight.set(event.nativeEvent.layout.height); + }} + style={bodyHeightStyle} + > + + Approval needed - ) : null} - {props.approval.reason ? ( - - {props.approval.reason} + + {props.approval.appName ?? props.approval.requestKind} - ) : null} - {props.approval.fullAccessOverride ? ( - setExplanationOpen((open) => !open)} - > - - {m(FULL_ACCESS_OVERRIDE_QUESTION)} + {props.approval.detail ? ( + + {props.approval.detail} + + ) : null} + {props.approval.reason ? ( + + {props.approval.reason} - {explanationOpen ? ( - - {fullAccessOverrideExplanation(props.approval.fullAccessOverride, m)} + ) : null} + {props.approval.fullAccessOverride ? ( + setExplanationOpen((open) => !open)} + > + + {m(FULL_ACCESS_OVERRIDE_QUESTION)} - ) : null} - - ) : null} + {explanationOpen ? ( + + {fullAccessOverrideExplanation(props.approval.fullAccessOverride, m)} + + ) : null} + + ) : null} + {!canRespond ? ( diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx index 2a627454b77c..ea3cad327e04 100644 --- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx @@ -1096,13 +1096,16 @@ function ThreadDetailBody( flexGrow: 0, })); // Questions overlay the composer on iOS; an approval sits above it, so it gives up its height. - const approvalHeightStyle = useAnimatedStyle(() => ({ - maxHeight: derivePendingUserInputMaxHeight({ + const pendingApprovalMaxHeight = useDerivedValue(() => + derivePendingUserInputMaxHeight({ windowHeight: screenAreaHeight, keyboardHeight: keyboardStickyEnabled ? -keyboardTranslation.value : 0, navigationHeaderHeight, composerOverlapHeight, }), + ); + const approvalHeightStyle = useAnimatedStyle(() => ({ + maxHeight: pendingApprovalMaxHeight.value, flexGrow: 0, })); // The usage panel stacks with the composer and any approval card, so it gets @@ -1833,6 +1836,7 @@ function ThreadDetailBody(