From 86b0586829e69594fb6a138ef10ff0440bb95876 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Sun, 29 Sep 2024 15:52:58 -0400 Subject: [PATCH] linting fix --- .../AppKit/NSWindowDelegateContainer.swift | 32 +++++++++++++++---- .../AppKit/View+NSWindowDelegate.swift | 10 +++--- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Sources/RadiantKit/AppKit/NSWindowDelegateContainer.swift b/Sources/RadiantKit/AppKit/NSWindowDelegateContainer.swift index 613ac4a..bdeaee2 100644 --- a/Sources/RadiantKit/AppKit/NSWindowDelegateContainer.swift +++ b/Sources/RadiantKit/AppKit/NSWindowDelegateContainer.swift @@ -2,16 +2,34 @@ // NSWindowDelegateContainer.swift // RadiantKit // -// Created by Leo Dion on 9/27/24. +// Created by Leo Dion. +// Copyright © 2024 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. // #if canImport(AppKit) && canImport(SwiftUI) public import AppKit -@MainActor -public protocol NSWindowDelegateContainer : AnyObject { - var windowDelegate : (any NSWindowDelegate)? { - get - set + @MainActor public protocol NSWindowDelegateContainer: AnyObject { + var windowDelegate: (any NSWindowDelegate)? { get set } } -} #endif diff --git a/Sources/RadiantKit/AppKit/View+NSWindowDelegate.swift b/Sources/RadiantKit/AppKit/View+NSWindowDelegate.swift index 74001e0..922d1ba 100644 --- a/Sources/RadiantKit/AppKit/View+NSWindowDelegate.swift +++ b/Sources/RadiantKit/AppKit/View+NSWindowDelegate.swift @@ -31,19 +31,19 @@ import AppKit public import SwiftUI - fileprivate struct NSWindowDelegateAdaptorModifier: ViewModifier { - let container : any NSWindowDelegateContainer + let container: any NSWindowDelegateContainer let delegate: any NSWindowDelegate init( - container : any NSWindowDelegateContainer, + container: any NSWindowDelegateContainer, delegate: @autoclosure () -> any NSWindowDelegate ) { self.container = container if let windowDelegate = container.windowDelegate { self.delegate = windowDelegate - } else { + } + else { let newDelegate = delegate() print("Creating a New Window Delegate") self.delegate = newDelegate @@ -62,7 +62,7 @@ extension View { public func nsWindowDelegateAdaptor( - _ container : any NSWindowDelegateContainer, + _ container: any NSWindowDelegateContainer, _ delegate: @autoclosure () -> any NSWindowDelegate ) -> some View { self.modifier(NSWindowDelegateAdaptorModifier(container: container, delegate: delegate()))