### NSScreen Extensions for Notch Detection Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Utilize `NSScreen` extensions to detect hardware notches, get their size and frame, and find the screen under the mouse cursor. `notchFrameWithMenubarAsBackup` provides a fallback frame. ```swift import AppKit import DynamicNotchKit let screen = NSScreen.screens[0] // Check whether a screen has a hardware notch if screen.hasNotch { print("Notch size: \(screen.notchSize!)") // Optional NSSize print("Notch frame: \(screen.notchFrame!)") // Optional NSRect, absolute coordinates } else { print("No notch — floating style will be used") } // Always returns a valid rect: uses actual notch frame or a 300pt fallback let safeNotchFrame = screen.notchFrameWithMenubarAsBackup print("Safe notch frame: \(safeNotchFrame)") // Height of the menu bar on this screen print("Menu bar height: \(screen.menubarHeight)") // Find the screen currently under the mouse cursor if let mouseScreen = NSScreen.screenWithMouse { print("Mouse is on: \(mouseScreen.localizedName)") } ``` -------------------------------- ### DynamicNotchInfo.Label: Custom Image Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Use a custom SwiftUI Image for the notch icon. This example uses the application's icon. ```swift let imageLabel = DynamicNotchInfo.Label( image: Image(nsImage: NSImage(named: NSImage.applicationIconName)!) ) ``` -------------------------------- ### DynamicNotchInfo.Label: Custom SwiftUI View Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Use any custom SwiftUI View as the notch icon. This example uses a linear gradient. ```swift let customLabel = DynamicNotchInfo.Label { LinearGradient( colors: [.indigo, .pink], startPoint: .topLeading, endPoint: .bottomTrailing ) .clipShape(.rect(cornerRadius: 4)) .aspectRatio(contentMode: .fit) } ``` -------------------------------- ### DynamicNotchInfo: Using a Label Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Demonstrates how to use a created label within a DynamicNotchInfo instance and control its visibility. ```swift Task { let notch = DynamicNotchInfo( icon: progressLabel, title: "Charging", description: "75% — about 30 min remaining" ) await notch.expand() try? await Task.sleep(for: .seconds(4)) await notch.hide() } ``` -------------------------------- ### Predefined Information Display with DynamicNotchInfo Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Utilize `DynamicNotchInfo` for a structured icon, title, and description display, with optional compact leading/trailing icons. Content can be updated live using `withAnimation`. ```swift import SwiftUI import DynamicNotchKit Task { let notch = DynamicNotchInfo( icon: .init(systemName: "arrow.down.circle.fill", color: .blue), title: "Downloading Update", description: "macOS Sequoia 15.2 — 1.4 GB", compactLeading: .init(systemName: "arrow.down", color: .blue), compactTrailing: .init(systemName: "externaldrive.fill", color: .gray), style: .auto ) await notch.expand() try? await Task.sleep(for: .seconds(3)) // Dynamically update content while visible withAnimation { notch.icon = .init(progress: .constant(0.6), color: .blue) notch.title = "60% Complete" notch.description = nil } try? await Task.sleep(for: .seconds(3)) // Transition to compact state await notch.compact() try? await Task.sleep(for: .seconds(2)) withAnimation { notch.compactLeading = .init(systemName: "checkmark.circle.fill", color: .green) notch.compactTrailing = nil } try? await Task.sleep(for: .seconds(1.5)) await notch.hide() } ``` -------------------------------- ### DynamicNotchHoverBehavior: Default (.all) Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Initialize a DynamicNotch with the default hover behavior, which includes keeping the notch visible, providing haptic feedback, and increasing the shadow on hover. ```swift let notch1 = DynamicNotch(hoverBehavior: .all) { Text("Hover over me") } ``` -------------------------------- ### Basic DynamicNotch Usage Source: https://github.com/mrkai77/dynamicnotchkit/blob/main/README.md Use this snippet to integrate your existing SwiftUI views directly into DynamicNotchKit. Ensure your `ContentView` conforms to the `View` protocol. ```swift let notch = DynamicNotch { ContentView() } await notch.expand() ``` -------------------------------- ### DynamicNotchInfo for General Information Source: https://github.com/mrkai77/dynamicnotchkit/blob/main/README.md Utilize DynamicNotchInfo for displaying general information. This version is tailored for information display and supports a floating style on Macs without a notch. ```swift let notch = DynamicNotchInfo( icon: .init(systemName: "figure"), title: "Figure", description: "Looks like a person" ) await notch.expand() ``` -------------------------------- ### Unified Control with DynamicNotchControllable Protocol Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Use the `DynamicNotchControllable` protocol for generic functions that work with both `DynamicNotch` and `DynamicNotchInfo`. The `expand(on:)` method allows targeting a specific screen. ```swift import AppKit import DynamicNotchKit // Generic helper: show a notch for a fixed duration, then hide @MainActor func present(_ notch: any DynamicNotchControllable, for duration: Duration) async { await notch.expand() try? await Task.sleep(for: duration) await notch.hide() } // Works with DynamicNotch let customNotch = DynamicNotch { Text("Hello from DynamicNotch") .foregroundStyle(.white) } Task { await present(customNotch, for: .seconds(3)) } // Also works with DynamicNotchInfo let infoNotch = DynamicNotchInfo( icon: .init(systemName: "bell.fill", color: .yellow), title: "Reminder", description: "Stand up and stretch!" ) Task { await present(infoNotch, for: .seconds(4)) } // Target a specific screen (e.g. screen under cursor) Task { let screen = NSScreen.screens[0] await infoNotch.expand(on: screen) try? await Task.sleep(for: .seconds(3)) await infoNotch.hide() } ``` -------------------------------- ### DynamicNotchStyle: Auto Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Initialize a DynamicNotch with the `.auto` style, which defaults to `.notch` on screens with a hardware notch and `.floating` on others. ```swift let autoNotch = DynamicNotch(style: .auto) { Text("Auto") } ``` -------------------------------- ### DynamicNotchStyle: Custom Notch Radii Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Force the notch style with custom top and bottom corner radii. Ensure Outer Radius = Inner Radius + Padding for consistent UI. ```swift let notchCustom = DynamicNotch( style: .notch(topCornerRadius: 10, bottomCornerRadius: 25) ) { Text("Custom notch radii") } ``` -------------------------------- ### DynamicNotchInfo: Force Floating Style Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Force a DynamicNotchInfo to always render as a floating pill, even on Macs with a hardware notch. Useful for debugging or specific UI requirements. ```swift Task { let notch = DynamicNotchInfo( icon: .init(systemName: "exclamationmark.triangle", color: .yellow), title: "Warning", description: "Disk space is low.", style: .floating // Always renders as a floating pill ) await notch.expand() try? await Task.sleep(for: .seconds(3)) await notch.hide() } ``` -------------------------------- ### DynamicNotch: Observing Hover State Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Create a DynamicNotch and observe its `isHovering` state, which is a `@Published` boolean that can be monitored using Combine or SwiftUI. ```swift Task { let notch = DynamicNotch(hoverBehavior: .all) { Text("Watching hover…") } await notch.expand() // notch.isHovering is a @Published Bool you can observe via Combine or SwiftUI try? await Task.sleep(for: .seconds(5)) await notch.hide() } ``` -------------------------------- ### Custom Notch Content with DynamicNotch Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Use `DynamicNotch` for fully custom SwiftUI content in the notch. It supports expanded, compact leading, and compact trailing views. State transitions are asynchronous and await completion. ```swift import SwiftUI import DynamicNotchKit // Full custom notch with expanded and compact content Task { let notch = DynamicNotch(style: .auto) { // Expanded content — shown below the notch VStack(spacing: 12) { Image(systemName: "music.note") .font(.largeTitle) .foregroundStyle(.white) Text("Now Playing") .font(.headline) .foregroundStyle(.white) Text("Clair de Lune – Debussy") .font(.subheadline) .foregroundStyle(.white.opacity(0.7)) } .padding() } compactLeading: { // Left side of notch in compact mode Image(systemName: "music.note") .foregroundStyle(.purple) } compactTrailing: { // Right side of notch in compact mode Capsule() .frame(width: 8, height: 8) .foregroundStyle(.green) } await notch.expand() // Animate to expanded state try? await Task.sleep(for: .seconds(3)) await notch.compact() // Shrink to compact state (notch screens only) try? await Task.sleep(for: .seconds(2)) await notch.hide() // Hide and deallocate the window } ``` -------------------------------- ### DynamicNotchInfo.Label: System Symbol Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Use a system symbol (SF Symbol) for the notch icon. Specify a color for the symbol. ```swift let sfSymbolLabel = DynamicNotchInfo.Label(systemName: "wifi", color: .green) ``` -------------------------------- ### Custom Animation Curves with DynamicNotchTransitionConfiguration Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Override default animation styles for opening, closing, and state-conversion transitions. Set `skipIntermediateHides` to `true` for faster compact ↔ expanded animations. ```swift import SwiftUI import DynamicNotchKit let notch = DynamicNotch(style: .notch) { Text("Custom animations") .foregroundStyle(.white) } // Override all three animation phases notch.transitionConfiguration = DynamicNotchTransitionConfiguration( openingAnimation: .spring(duration: 0.3, bounce: 0.4), closingAnimation: .easeIn(duration: 0.2), conversionAnimation: .snappy(duration: 0.25), skipIntermediateHides: true // Direct compact ↔ expanded without hide flash ) Task { await notch.expand() try? await Task.sleep(for: .seconds(2)) await notch.compact() try? await Task.sleep(for: .seconds(2)) await notch.hide() } ``` -------------------------------- ### DynamicNotchInfo.Label: Progress Ring Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Create a progress ring with an optional overlay symbol. The progress is controlled by a binding. ```swift @State var progress: CGFloat = 0.75 let progressLabel = DynamicNotchInfo.Label(progress: $progress, color: .orange) { Image(systemName: "bolt.fill") .foregroundStyle(.orange) .font(.system(size: 8, weight: .bold)) } ``` -------------------------------- ### DynamicNotchHoverBehavior: Custom Combination Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Configure specific hover behaviors, such as keeping the notch visible and providing haptic feedback, while disabling shadow enhancement. ```swift let notch2 = DynamicNotch(hoverBehavior: [.keepVisible, .hapticFeedback]) { Text("Haptic + keep visible") } ``` -------------------------------- ### DynamicNotchStyle: Custom Floating Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Force the floating style with a custom corner radius. This is useful for non-notch Macs or to override the default behavior. ```swift let floatingCustom = DynamicNotch( style: .floating(cornerRadius: 16) ) { Text("Floating window") } ``` -------------------------------- ### DynamicNotchHoverBehavior: None Source: https://context7.com/mrkai77/dynamicnotchkit/llms.txt Disable all hover behaviors, causing the notch to dismiss even when the mouse hovers over it. ```swift let notch3 = DynamicNotch(hoverBehavior: []) { Text("Dismisses even on hover") } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.