Skip to content
GitHub

Examples

Every example under Examples/ is a host that builds on OpenNook’s public API only - no forking, no patched framework. All but the playground fit in a single main.swift. Each one is its own SPM target, so you run it straight from the repo with swift run <Name> and press the show/hide hotkey (the default is the option-command-semicolon combination) to expand the nook.

They are grouped here so you can jump to the one closest to what you are building. Each entry links to the guide that explains the concept in full.

The smallest hosts - one view, or one view plus a compact-slot glyph. Start here if you have never run an OpenNook app.

  • HelloNook - swift run HelloNook. The smallest possible app: hand NookApp.main one SwiftUI view and the top bar, Settings, hotkey, and compact pill all come for free. See Your first nook.
  • ClockNook - swift run ClockNook. A live-clock home surface plus a custom compact glyph, showing the setHome and setCompactTrailing registration knobs side by side. See Your first nook.

Reshaping the chrome - palette, lifecycle hooks, brand mark, layout - through NookConfiguration.

  • PlaygroundNook - swift run PlaygroundNook. A live customization playground: a controls window changes the running nook’s appearance, theme, size and shape, type and motion, top bar, companions, rim glow, scroll edge fade, and hover behavior, then exports the result as Swift that sets only what changed, or as a JSON preset. Start here to explore the other seams. See Playground.
  • ThemedNook - swift run ThemedNook. A host-supplied NookResolvedTheme that paints the chrome labels, plus the onExpand / onCompact lifecycle callbacks. See Theming.
  • ChromeNook - swift run ChromeNook. A tour of the deeper chrome seams: launch-preference defaults, hover and backdrop behavior, label and metric overrides, a custom brand mark, top-bar trailing actions, and the status banner. See Chrome customization.
  • LayoutNook - swift run LayoutNook. The recommended expanded-width and content-inset patterns - how a home view reads \.nookContentInsets instead of adding its own horizontal padding. See Layout and content insets.
  • CompanionNook - swift run CompanionNook. A media player with companion surfaces floating below it - a pill of section buttons and a round sleep-timer button, the same height through the shared companion size - plus the lock and gear moved into a capsule beside it, a speaker chip that a NookCompanionSource adds and removes while the app runs, a rim that glows blue while the timer runs, and lists that fade at the panel’s edges. See Companion surfaces and Rim glow and edge fade.

Drop-in surfaces from the NookComponents add-on. Each imports NookComponents alongside NookApp.

  • ShelfNook - swift run ShelfNook. A file shelf in the notch: drag files on to collect them, drag them back out to Finder, persisted across launches. See File shelf.
  • ActivityNook - swift run ActivityNook. A NookActivityQueue that collects transient activities and briefly takes over the expanded surface for each, one at a time. See Activity queue.
  • VolumeNook - swift run VolumeNook. An ambient volume glyph in the compact pill - a SystemVolumeObserver tracks the output level and NookVolumeIndicator renders it beside the notch. See Volume glyph.

Running more than one notch app in a single process.

  • MultiNook - swift run MultiNook. One host process with several interchangeable modules sharing one surface, switched through the menu bar, the cycle hotkey, or an in-surface switcher. See Multiple modules.
  • The Examples/ directory in the repository - the source for every app above.
  • Your first nook - the walkthrough HelloNook and ClockNook accompany.