Skip to content

feat: optional anchor for iPadOS/macOS share popovers - #12

Merged
AbassHammed merged 2 commits into
sudosylabs:masterfrom
karlingen:fix/share-popover-anchor
Jul 31, 2026
Merged

feat: optional anchor for iPadOS/macOS share popovers#12
AbassHammed merged 2 commits into
sudosylabs:masterfrom
karlingen:fix/share-popover-anchor

Conversation

@karlingen

Copy link
Copy Markdown
Contributor

Implements the optional anchor field requested in #11 so that the share popover on iPadOS/macOS can anchor to a source rectangle instead of always centering on the window.

Changes

  • Added anchor?: { x, y, width, height } to ShareData (guest-js/index.ts) and ShareOptions (src/models.rs).
  • iOS/iPadOS (ios/Sources/SharePlugin.swift): caches the WKWebView from load(webview:), then sets popoverController.sourceView and popoverController.sourceRect from the anchor when provided, falling back to the previous centered behavior.
  • macOS (src/platform/macos.rs): converts the anchor rect from web-viewport (top-left origin) coordinates to AppKit (bottom-left origin) coordinates and passes it to showRelativeToRect_ofView_preferredEdge, falling back to the view center when no anchor is provided.
  • Android (android/src/main/java/SharePlugin.kt): added Anchor/ShareOptions.anchor models so deserialization stays compatible; the anchor is otherwise ignored.
  • Updated README with a button-anchor example and the Rust ShareOptions snippet.
  • Added a JS regression test verifying the anchor is forwarded to the Rust command.

Verification

  • cargo +1.89.0-aarch64-apple-darwin test — 11 passed
  • cargo +1.89.0-aarch64-apple-darwin fmt --check — clean
  • cd ios && VNIDROP_SHARE_USE_TAURI_STUB=1 swift test — 5 passed
  • npm run builddist-js and api-iife.js regenerated
  • npm run test — 8 passed
  • npm run test:types — clean

Closes #11

Add an `anchor` option to `ShareData`/`ShareOptions` containing a source rect in web-viewport coordinates. Use it on iPad and macOS to anchor the system share popover instead of centering it on the window.

Closes sudosylabs#11
@AbassHammed

Copy link
Copy Markdown
Contributor

This looks good, need to test this locally then i can merge. Thanks though @karlingen

@AbassHammed
AbassHammed merged commit b7b34ad into sudosylabs:master Jul 31, 2026
4 checks passed
@karlingen
karlingen deleted the fix/share-popover-anchor branch August 4, 2026 13:44
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.

Feature request: support an anchor option for iPadOS/macOS share popovers

2 participants