CardListLayoutCalculator
Pure, deterministic layout and visual state calculator for card lists.
This calculator is completely stateless and side-effect free. It translates layout configuration parameters (CardListLayoutParameters), viewport constraints, and active focus/drag identifiers into exact geometric coordinates, dimensions, and visual properties (CardVisualState) for every card in a list.
Responsibilities
Dimension & Aspect Ratio Calculation: Computes aspect-ratio preserved card dimensions and horizontal centering offsets based on viewport constraints (computeCardDimensions).
Total Height & Offsets: Computes total scrollable heights, top content offsets, and list margins (computeLayout).
Visual State Derivation: Computes the exact
y,scale,elevation,alpha, andzIndexfor any card at any point in time (computeCardVisualState).Drag Target Resolution: Determines target index insertion points during active drag gestures based on vertical overlap thresholds (findTargetIndexForDragY).
Used in conjunction with VerticalCardListModel across both Compose Multiplatform and SwiftUI.
Functions
Computes the rendered dimensions and horizontal centering offset for a card.
Computes the vertical step distance allocated to a card in standard list mode.
Computes the visual state for a card given its position and interaction state.
Computes the top offset for the detail view below a focused card.
Computes overall layout metadata for the card list container.
Finds the target index for a dragged card given its current Y position.