Sample CodemacOSReviewed 2026-07-21View on Apple Developer

Customizing window styles and state-restoration behavior in macOS

At a glance

Item Summary
Purpose Configure how your app’s windows look and function in macOS to provide an engaging and more coherent experience.
App architecture A Swift sample with the source-visible chain DestinationVideoContentViewCoordinatorEnvironmentStateHandlerSwiftUI APIs.
Main patterns Delegate or data-source callbacks, Coordinator, Actor-isolated state
Project style 46 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.

Project structure

Source bundle/
└── DestinationVideo/
    ├── DestinationVideo.swift
    ├── Views/
    │   ├── VideoInfoView.swift
    │   ├── visionOS/
    │   │   ├── ProfileButton.swift
    │   │   └── ImmersiveEnvironmentPickerView.swift
    │   ├── VideoCardView.swift
    │   └── ViewModifiers.swift
    ├── Player/
    │   ├── InlinePlayerView.swift
    │   ├── PlayerModel.swift
    │   ├── SystemPlayerView.swift
    │   └── PlayerView.swift
    ├── Model/
    │   └── visionOS/
    │       └── EnvironmentStateHandler.swift
    └── SharePlay/
        └── WatchingCoordinator.swift

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: Swift.
  • The verified tree contains 6 project/configuration file(s) and 69 source declaration(s).

Overall architecture

Reference code

DestinationVideo/DestinationVideo.swift:13 — architecture anchor

@main
struct DestinationVideo: App {
    // ...
}

Interpretation

The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into SwiftUI.

Ownership and state

Ownership evidence

DestinationVideo/DestinationVideo.swift:16 — stored dependency or nearest verified ownership anchor

@main
struct DestinationVideo: App {
    // ...
    private let modelContainer: ModelContainer
    // ...
}
Owner Object or state Relationship Mutation authority
DestinationVideo ModelContainer (modelContainer) stores or receives Initialized by the owner; the binding is immutable
DestinationVideo PlayerModel (player) owns wrapper-managed state Owning lexical scope
DestinationVideo ImmersiveEnvironment (immersiveEnvironment) owns wrapper-managed state Owning lexical scope
DestinationVideo ImmersiveContentBrightness (contentBrightness) owns wrapper-managed state Owning lexical scope

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Class and protocol design

DestinationVideo/Views/VideoInfoView.swift:11 — representative type boundary

struct InfoView: View {
    // ...
}
Type Responsibility Depends on or conforms to
InfoView User-interface presentation and input forwarding View
GenreView User-interface presentation and input forwarding View
RoleView User-interface presentation and input forwarding View
InlinePlayerView User-interface presentation and input forwarding View
InlineControlsView User-interface presentation and input forwarding View
VideoContentView User-interface presentation and input forwarding UIViewControllerRepresentable
PlayerModel Feature data or observable state Concrete collaborators/imported frameworks
PlayerViewObserver Observes and relays feature changes NSObject, AVPlayerViewControllerDelegate
SystemPlayerView User-interface presentation and input forwarding Concrete collaborators/imported frameworks
Coordinator Cross-object flow or session coordination NSObject, AVPlayerViewDelegate

No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.

Access control

Symbol Access Verified effect Likely rationale
player (DestinationVideo/ContentView.swift:12) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
immersiveEnvironment (DestinationVideo/ContentView.swift:14) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
horizontalSizeClass (DestinationVideo/DestinationTabs.swift:17) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
videos (DestinationVideo/DestinationTabs.swift:20) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.

Reference code

DestinationVideo/ContentView.swift:12 — representative boundary

    @Environment(PlayerModel.self) private var player

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
Cross-object flow or session coordination Coordinator, WatchingCoordinator The source’s Coordinator suffix makes this role explicit.
Receives callback-driven events PlaybackCoordinatorDelegate The source’s Delegate suffix makes this role explicit.
Handles callbacks or feature events EnvironmentStateHandler The source’s Handler suffix makes this role explicit.
Feature data or observable state PlayerModel The source’s Model suffix makes this role explicit.
Observes and relays feature changes PlayerViewObserver The source’s Observer suffix makes this role explicit.
User-interface presentation and input forwarding CategoryListView, CategoryView, ContentView, DetailView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
Delegate or data-source callbacks DestinationVideo/Player/PlayerModel.swift:104 Callback protocols invert event delivery back into the sample’s owner.
Coordinator DestinationVideo/Player/SystemPlayerView.swift:25 A role-named coordinator centralizes cross-object flow.
Actor-isolated state DestinationVideo/Model/Data/Genre.swift:38 Actor annotations make the concurrency ownership boundary explicit.

Naming conventions

  • Types: Coordinator: Coordinator, WatchingCoordinator; Delegate: PlaybackCoordinatorDelegate; Handler: EnvironmentStateHandler; Model: PlayerModel; Observer: PlayerViewObserver; View: CategoryListView, CategoryView, ContentView, DetailView, GenreView.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: dismissAfterDelay, makeUIViewController, updateUIViewController, makePlayerUI, willEndFullScreenPresentation, playerViewController, observePlayback, configureAudioSession.
  • Files: DestinationVideo/DestinationVideo.swift, DestinationVideo/Player/InlinePlayerView.swift, DestinationVideo/Player/PlayerModel.swift, DestinationVideo/Player/SystemPlayerView.swift, DestinationVideo/Model/visionOS/EnvironmentStateHandler.swift, DestinationVideo/Player/PlayerView.swift.

Architecture takeaways

  • DestinationVideo is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches SwiftUI, SwiftData, AVKit, GroupActivities through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • The source does not justify labeling the design protocol-oriented.

Source map

Source file Relevant symbols
DestinationVideo/DestinationVideo.swift DestinationVideo
DestinationVideo/Views/VideoInfoView.swift InfoView, GenreView, RoleView, PosterCard
DestinationVideo/Player/InlinePlayerView.swift InlinePlayerView, InlineControlsView, VideoContentView
DestinationVideo/Player/PlayerModel.swift Presentation, PlayerModel, PlayerViewObserver
DestinationVideo/Player/SystemPlayerView.swift SystemPlayerView, Coordinator, SystemPlayerView
DestinationVideo/Views/visionOS/ProfileButton.swift ProfileButtonView, ProfileIconView, ProfileDetailView, ExpandingProfileButtonStyle, ExpandEffect, FadeEffect
DestinationVideo/Model/visionOS/EnvironmentStateHandler.swift EnvironmentStateType, EnvironmentStateHandler
DestinationVideo/Player/PlayerView.swift PlayerControlsStyle, PlayerView
DestinationVideo/SharePlay/WatchingCoordinator.swift WatchingCoordinator, PlaybackCoordinatorDelegate
DestinationVideo/Views/VideoCardView.swift VideoCardStyle, VideoCardView