Skip to content

Add popover#67

Merged
colemancda merged 5 commits into
masterfrom
feature/popover
Jul 24, 2026
Merged

Add popover#67
colemancda merged 5 commits into
masterfrom
feature/popover

Conversation

@colemancda

Copy link
Copy Markdown
Member

.popover(isPresented:content:) — a small piece of content floated next to a view while a bound flag is true.

Shape

Unlike .sheet (screen-level, picked up by RenderSheetsAndAlerts), a popover is anchored to a specific view, so it uses the wrapper-node structure from contextMenu rather than the hidden-screen-child one: a Popover node whose children are [anchor…, body…], with anchorCount splitting them. The body is resolved only while presented. The interpreter renders the anchor and, when presented, a Compose Popup (focusable, elevated Surface bubble) offset just below it, whose onDismissRequest writes the bound flag back — so tapping off the bubble dismisses, and the popover's own buttons can dismiss by setting the binding false.

Verification

  • swift test — new test, 117 passing: collapsed emits the anchor only with no body resolved; presenting adds the body as a second child; and the dismiss callback flips isPresented back to false (dropping the body again).
  • Emulator (new "Popover" screen), screenshot-checked: tapping "Show details" floated an anchored card ("Quick details" + text + "Got it"). The second example round-trips a choice — tapping "Choose" opened only that popover (independent bindings), and picking "Option A" set "Picked: A" and dismissed the bubble.

Scope

The plain isPresented form; no popover(item:), no attachmentAnchor/arrowEdge positioning (the bubble anchors top-start below the view). On a phone SwiftUI itself often falls back to a sheet — this always shows the floating bubble.

@colemancda
colemancda merged commit 7760915 into master Jul 24, 2026
6 checks passed
@colemancda
colemancda deleted the feature/popover branch July 24, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant