DynamicNotchKit Documentation

repository·main·Indexed 19 days ago

https://github.com/mrkai77/dynamicnotchkit

A Swift framework for macOS 13+ that enables developers to integrate apps with the MacBook notch. It provides a 'Dynamic Island' style experience by managing custom windows, content insets, and safe areas to display SwiftUI views. Includes DynamicNotch for custom views and DynamicNotchInfo for pre-configured popover status updates, with automatic floating window fallbacks for Macs without a notch.

Tokens
473
Snippets
3
Records
4
Agent score
16%

What's inside DynamicNotchKit

  1. Overview of DynamicNotchKit

    main

    DynamicNotchKit is a framework designed to help macOS developers integrate their applications with the MacBook notch. It provides tools to display notifications and updates in a visually appealing way, mimicking the behavior of iOS's Dynamic Island.

    Key capabilities include:

    • Managing the complexities of the notch area.
    • Drawing custom windows specifically for notch interactions.
    • Handling content insets and safe areas automatically.
    • Providing a fallback 'floating window' style for devices that do not have a notch, ensuring a consistent experience across different MacBook models.
  2. Install DynamicNotchKit via Swift Package Manager

    main

    DynamicNotchKit requires macOS 13+. To install, add the following repository URL in the Swift Package Manager tab in Xcode:

    https://github.com/MrKai77/DynamicNotchKit

    https://github.com/MrKai77/DynamicNotchKit
  3. Use DynamicNotch with custom SwiftUI views

    main

    You can integrate any SwiftUI View into the notch area using DynamicNotch. This allows you to display custom content, notifications, or updates directly in the notch. Use the .expand() method to trigger the expansion animation.

    let notch = DynamicNotch {
        ContentView()
    }
    await notch.expand()
  4. Use DynamicNotchInfo for quick information displays

    main

    For displaying general information (like an icon, title, and description) in a pre-configured popover style, use DynamicNotchInfo. This is a fine-tuned version of DynamicNotch designed for quick status updates or info snippets.

    On Macs without a notch, DynamicNotchInfo automatically uses a .floating style to ensure compatibility.

    let notch = DynamicNotchInfo(
        icon: .init(systemName: "figure"),
        title: "Figure",
        description: "Looks like a person"
    )
    await notch.expand()