fayazara/macos-app-skills

macos-notch-ui

Add a Dynamic Island-style notch UI to a macOS app.

Voir la source

Mode d’emploi

  1. Copiez la commande et examinez le paquet avant de l’installer dans votre environnement agent.
  2. Consultez le document original pour les outils, identifiants et environnements requis.
  3. Décrivez les entrées et le livrable souhaité ; comparez la sortie aux sources.
npx skills add https://github.com/fayazara/macos-app-skills --skill macos-notch-ui

Avant de commencer

  • L’installation n’inclut ni abonnement au modèle, ni quota API, ni accès aux fichiers.
  • Étoiles et installations reflètent l’activité, pas un test indépendant de qualité ou de sécurité.
Document Skill original

Rendu depuis le dépôt source en conservant titres, exemples, code, tableaux, liens et images.

macOS Notch UI (Dynamic Island Style)

This skill creates a Dynamic Island-style overlay that extends from the MacBook's hardware notch. The overlay is a transparent floating panel positioned flush against the top of the screen, using a custom shape with concave "ear" curves that blend seamlessly with the physical notch cutout.

Architecture

The implementation has 3 parts:

  1. `NotchWindow` (NSPanel subclass) -- a borderless, transparent, click-through panel at CGShieldingWindowLevel that sits above everything, including the menu bar
  2. `NotchShape` (SwiftUI Shape) -- draws the Dynamic Island silhouette with concave quadratic Bezier curves at the top corners and convex rounded corners at the bottom
  3. Your content view -- whatever you want to show inside the notch (status indicators, waveforms, text, icons)

How It Works

The MacBook notch is a black rectangle at the top-center of the screen. By placing a black-filled NotchShape at that exact position at the highest window level, it visually extends the notch area. Content inside the shape appears to "emerge" from the hardware notch.

The key positioning math:

swift
// Use full screen frame (not visibleFrame) to include the menu bar / notch area
let screen = NSScreen.main!
let x = screen.frame.origin.x + (screen.frame.width - totalWidth) / 2
let y = screen.frame.origin.y + screen.frame.height - totalHeight

Using screen.frame (not screen.visibleFrame) is critical -- visibleFrame excludes the menu bar area where the notch lives.

Reference Files

  • references/NotchWindow.swift -- Drop-in NSPanel subclass with show/hide and positioning
  • references/NotchShape.swift -- The Dynamic Island shape with animatable corner radii

Step-by-Step Integration

1. Add the NotchShape

Copy references/NotchShape.swift. This is a SwiftUI Shape with two configurable corner radii:

  • topCornerRadius (default 10) -- the concave "ear" curves at the top that mimic the hardware notch's inverse corners
  • bottomCornerRadius (default 16) -- the standard convex rounded corners at the bottom

Both are animatable via animatableData, so SwiftUI can smoothly interpolate shape changes.

2. Create Your Content View

Build whatever you want to show inside the notch. The content should be clipped to NotchShape and filled with black background:

swift
struct NotchContentView: View {
    var isVisible: Bool

    var body: some View {
        HStack {
            Image(systemName: "mic.fill")
                .foregroundStyle(.red)
            Text("Recording")
                .font(.system(size: 13, weight: .medium))
                .foregroundStyle(.white)
        }
        .frame(width: isVisible ? 200 : 0)
        .frame(height: 32)
        .background(NotchShape().fill(.black))
        .clipShape(NotchShape())
        .animation(.spring(response: 0.35, dampingFraction: 0.75), value: isVisible)
        .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
    }
}

3. Add the NotchWindow

Copy references/NotchWindow.swift. This is a generic NSPanel that:

  • Creates a borderless, transparent, non-activating panel
  • Positions at CGShieldingWindowLevel (above everything)
  • Centers at the top of the screen, flush with the top edge
  • Ignores mouse events (fully click-through)
  • Joins all spaces and survives fullscreen

4. Show and Hide

swift
// Create once and reuse
let notchWindow = NotchWindow()

// Show with your content
let content = NotchContentView(isVisible: true)
notchWindow.showNotch(content: content)

// Hide with spring collapse animation
notchWindow.hideNotch()

Spring Animation Choreography

The Dynamic Island effect comes from a specific animation sequence:

Show:

  1. Window appears instantly (orderFront)
  2. On the next runloop tick, isVisible toggles to true
  3. The width animates from 0 to the target width with .spring(response: 0.35, dampingFraction: 0.75)

This two-step approach (instant window, then animated content) is necessary because SwiftUI needs the view to be in the hierarchy before it can animate.

Hide (3-step choreography):

  1. Clear any expanded content (text, details) -- collapses to compact shape
  2. After 0.25s, set isVisible = false -- triggers the spring width collapse to 0
  3. After 0.65s, remove the window (orderOut)

The delays are tuned so each animation completes before the next starts. This creates the smooth "shrink into the notch" effect.

swift
// Step 1: collapse content
state.isExpanded = false

// Step 2: shrink width
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
    state.isVisible = false
}

// Step 3: remove window
DispatchQueue.main.asyncAfter(deadline: .now() + 0.65) {
    window.orderOut(nil)
}

Screen Geometry Details

PropertyValueWhy
Window levelCGShieldingWindowLevel()Above everything including menu bar
Position originNSScreen.main.frame (not visibleFrame)Must include the notch/menu bar area
HorizontalCentered: (screen.width - totalWidth) / 2Aligned with the hardware notch
VerticalFlush top: screen.height - totalHeightTop edge touches the screen edge
Collection behavior.stationary, .canJoinAllSpaces, .fullScreenAuxiliary, .ignoresCycleDoesn't move with Spaces, survives fullscreen, hidden from Cmd+Tab

Fallback for Non-Notch Macs

Not all Macs have a notch (e.g., external displays, older MacBooks). You can detect this:

swift
var hasNotch: Bool {
    guard let screen = NSScreen.main else { return false }
    // Notch Macs have a safe area inset at the top
    return screen.safeAreaInsets.top > 0
}

For non-notch displays, fall back to a floating pill at the bottom of the screen using screen.visibleFrame and standard .floating window level.

Design Guidelines

  • Fill the shape with solid black -- this is what makes it blend with the hardware notch
  • Use white or colored text/icons on the black background for contrast
  • Keep content compact -- the notch area is small. A single row with an icon + short text works best
  • Use red for recording indicators -- matches iOS convention
  • Animate width, not opacity -- the Dynamic Island effect is about the shape growing/shrinking, not fading

Tâches connexes

du même dépôt

Autres Skills

Tous les Skills
fayazara
Communauté

macos-auto-update

Add Sparkle auto-update support to a native macOS app. Use this skill whenever the user wants to add auto-updates, implement Sparkle, set up an appcast feed, add "Check for Updates" to their app, or integrate automatic update checking. Also trigger when the user mentions Sparkle, appcast, SUFeedURL, EdDSA signing, or update notifications. This covers the full setup: adding the Sparkle SPM dependency, creating the UpdaterManager singleton, wiring it into the app delegate and UI, configuring Info.

installations
2
GitHub Stars
681
Mis à jour
27 mai
fayazara
Communauté

macos-build

Build a native macOS app using xcodebuild from the command line. Use this skill whenever the user asks to build, compile, or check if their macOS project compiles successfully. Also use it when the user asks to fix build errors, verify changes compile, or run a debug build. Trigger on phrases like "build the app", "does it compile", "run xcodebuild", "fix build errors", or even just "build".

installations
2
GitHub Stars
681
Mis à jour
27 mai
fayazara
Communauté

macos-patterns

Essential native macOS development patterns that web developers don't know about. Use this skill whenever the user is building a macOS app and needs guidance on native patterns, or when they ask about menu bar apps, floating panels, window levels, keyboard shortcuts, file pickers, clipboard, drag and drop, screen capture, activation policy, Quick Look, launch at login, or any macOS-specific API. Also trigger when the user seems to be applying web development patterns to macOS (e.g., using z-inde

installations
2
GitHub Stars
681
Mis à jour
27 mai
fayazara
Communauté

macos-release

Release a native macOS app to GitHub with DMG packaging and Sparkle appcast updates. Use this skill whenever the user wants to publish a new version, create a release, ship an update, push a release to GitHub, or update the appcast. Also trigger when the user mentions DMG creation, Sparkle signing, notarization, archiving, or anything related to distributing a new version of their macOS app. This covers the full release pipeline: archive, notarize, export, create DMG, sign with Sparkle EdDSA, up

installations
2
GitHub Stars
681
Mis à jour
27 mai