computeClosingPlatterRect static method
Computes the rect of the closing platter (Blob B) as native iOS 27 does:
a uniform scale of the resting menu rect by platterScale
(0.2 + 0.8·rawValue) about the trigger centre pivot, where the pivot
keeps its fractional position inside restingRect.
Verified against the _UIContextMenuView trace to 0.1 pt: its
anchorPoint is exactly the trigger centre expressed in platter-local
fractions (0.244, 0.088 for the traced menu), and
rect = pivot − anchor · size · scale. Because the pivot sits near the
platter's top for top-anchored menus, the top edge sweeps toward the
trigger centre while the platter shrinks, instead of staying glued to
the trigger top.
Implementation
static Rect computeClosingPlatterRect({
required Offset pivot,
required Rect restingRect,
required double platterScale,
double? maxHeight,
}) {
final s = platterScale.clamp(0.0, 1.0);
final fx = restingRect.width > 0.0
? (pivot.dx - restingRect.left) / restingRect.width
: 0.5;
final fy = restingRect.height > 0.0
? (pivot.dy - restingRect.top) / restingRect.height
: 0.5;
final w = restingRect.width * s;
final h = math.min(restingRect.height * s, maxHeight ?? double.infinity);
return Rect.fromLTWH(pivot.dx - fx * w, pivot.dy - fy * h, w, h);
}