-
-
Notifications
You must be signed in to change notification settings - Fork 538
Open
Description
Summary
Add a new initializer to FloatingPanelAdaptiveLayoutAnchor that pins the panel position using absolute inset + edge (same semantics as FloatingPanelLayoutAnchor(absoluteInset:edge:referenceGuide:)), while keeping adaptive sizing: the panel should still shrink to content when content is small and expand (capped by safe area / contentBoundingGuide) when content is large.
Motivation
FloatingPanelLayoutAnchor(absoluteInset:edge:referenceGuide:)gives fixed positioning (e.g. “panel top at 8pt from safe area top”) but the panel size is fixed (e.g. full height), not content-driven.FloatingPanelAdaptiveLayoutAnchor(absoluteOffset:contentLayout:referenceGuide:contentBoundingGuide:)gives adaptive sizing (shrink to content, cap by safe area) but the position is derived from the content dimension (offset from reference), not from a fixed inset + edge.
There is no way to get both:
- Position: Pin the panel from a specific edge with a fixed inset (e.g. “top of panel at safe area top + 8pt”).
- Size: Adaptive to content (shrink when content is small, grow up to safe area when content is large).
That combination is useful for panels that should always start at a consistent place (e.g. below a toast) but still size to their content.
Proposed API
Add an initializer on FloatingPanelAdaptiveLayoutAnchor:
/// Position is pinned from the given edge at a fixed inset (like FloatingPanelLayoutAnchor).
/// Size remains adaptive: panel shrinks to content and is capped by contentBoundingGuide.
init(
absoluteInset: CGFloat,
edge: FloatingPanelReferenceEdge,
contentLayout: UILayoutGuide,
referenceGuide: FloatingPanelLayoutReferenceGuide,
contentBoundingGuide: FloatingPanelLayoutContentBoundingGuide = .none
)Behavior:
- Position: Same as
FloatingPanelLayoutAnchor(absoluteInset:absoluteInset, edge: edge, referenceGuide: referenceGuide)— the panel’s leading edge (in the panel’s main axis) is placed atabsoluteInsetfrom the givenedgeof the reference guide (e.g. for a bottom panel withedge: .top, the panel’s top is atreferenceGuide.topAnchor + absoluteInset). - Size: Unchanged from current adaptive behavior — panel height/width follows
contentLayoutand is capped bycontentBoundingGuide(e.g..safeArea).
Example use case
A panel that should sit below a toast (fixed top inset) but still size to its content:
// Panel position: top pinned at safeArea.top + topAnchorInset
// Panel size: height = content, capped by safe area
.full: FloatingPanelAdaptiveLayoutAnchor(
absoluteInset: Self.topAnchorInset, // e.g. 8pt or below toast
edge: .top,
contentLayout: targetGuide,
referenceGuide: .safeArea,
contentBoundingGuide: .safeArea
)Thank you for considering this feature.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels