Skip to content

SwiftUIOverlayContainer 3.0.0

Latest

Choose a tag to compare

@fatbobman fatbobman released this 28 Nov 00:08

SwiftUIOverlayContainer 3.0.0

English

SwiftUIOverlayContainer 3.0 is a breaking release for iOS and iPadOS 17 or later and macOS 14 or later. It requires Swift 6.2 or later and has no external dependencies. Projects targeting earlier OS versions, tvOS, or watchOS can stay on 2.4.3.

  • OverlayController and OverlayHandle let declarative bindings and imperative requests share a container's queue. Use a handle to replace a presentation atomically or await its entry and final removal separately.
  • Window scopes isolate queues even when windows use the same container ID. A temporarily detached host can reconnect to its retained queue. Observable snapshots expose host mounting, activity, and queue state.
  • Auto-dismiss starts when entry finishes and counts active window time. Waiting items can refill a slot once its outgoing views have been removed.

Migrating from 2.4.3

  • Move from ContainerManager and configuration protocols to OverlayController, .overlayPresentation, and value-based configuration.
  • The default animation is now .animated(.default). Use .disabled in the configuration when you want to turn off regular transition animations.
  • Within one controller, the first registered host owns its container ID until it detaches. Use .overlayContainerScope() to reuse the same IDs across independent windows.
  • Linear layouts default to .newestFirst. Use .oldestFirst to preserve the old visual order in centered linear layouts. Backdrops default to .passThrough. Use .block for a modal backdrop.

Migration guide (Chinese) · API reference (Chinese) · Demo

简体中文

SwiftUIOverlayContainer 3.0 是一次破坏性升级。支持 iOS 和 iPadOS 17 及以上、macOS 14 及以上,要求 Swift 6.2 或更新版本,零外部依赖。仍需支持更早系统、tvOS 或 watchOS 的项目可继续使用 2.4.3。

  • 声明式绑定与命令式调用共用同一容器队列。OverlayController 和 OverlayHandle 提供原位替换,可分别等待入场完成和最终移除。
  • 各窗口可复用相同的容器 ID 并保持队列隔离。宿主暂时卸载后可重连并恢复保留的队列。可观察快照提供宿主挂载、活跃和队列状态。
  • 自动退场从入场完成起算,只累计窗口活跃时间。旧画面完全移除后,等待条目才可递补该展示位。

从 2.4.3 迁移

  • 将 ContainerManager 和配置协议迁移至 OverlayController、.overlayPresentation 和值类型配置。
  • 默认动画改为 .animated(.default)。如需关闭常规转场动画,可在配置中使用 .disabled。
  • 同一控制器内,先注册的宿主持有容器 ID,直到它卸载。独立窗口可使用 .overlayContainerScope() 复用相同 ID。
  • 线性布局默认 .newestFirst。若要保留旧版居中线性布局的视觉顺序,可选 .oldestFirst。遮罩默认允许点击穿透,模态遮罩可显式使用 .block。

迁移指南 · 公开 API · 示例项目