Skip to content

Commit

Permalink
linting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed Sep 29, 2024
1 parent e0ccfe2 commit 86b0586
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
32 changes: 25 additions & 7 deletions Sources/RadiantKit/AppKit/NSWindowDelegateContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions Sources/RadiantKit/AppKit/View+NSWindowDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()))
Expand Down

0 comments on commit 86b0586

Please sign in to comment.