diff --git a/Package.swift b/Package.swift index 721e612..f87a845 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( name: "TranslucentWindowStyle", - platforms: [.macOS(.v13)], + platforms: [.macOS(.v12)], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( diff --git a/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift b/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift index 3686ec6..f93a397 100644 --- a/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift +++ b/Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift @@ -1,5 +1,6 @@ +#if os(macOS) import SwiftUI - +import AppKit public protocol WindowBackgroundStyle { associatedtype Body : View @@ -17,15 +18,12 @@ public struct TranslucentBackgroundStyle: WindowBackgroundStyle { } extension View { - @MainActor public func presentedWindowBackgroundStyle(_ style: S) -> some View where S : WindowBackgroundStyle { self.background(style.backgroud) } - } struct TranslucentWindowBackground: NSViewRepresentable { - enum ContentViewConfiguration { case embed(NSView?) case replace(NSView?) @@ -66,11 +64,11 @@ struct TranslucentWindowBackground: NSViewRepresentable { contentViewCofiguration: .embed(getTranlucentBackground()), styleMaskConfiguration: .insert(.titled), titlebarAppearsTransparent: true, - titleVisibility: .hidden, + titleVisibility: .visible, standardWindowButtonConfig: StandardWindowButtonConfiguration( - miniaturizeButtonIsHidden: true, - closeButtonIsHidden: true, - zoomButtonIsHidden: true + miniaturizeButtonIsHidden: false, + closeButtonIsHidden: false, + zoomButtonIsHidden: false ), isMovableByWindowBackground: true ) @@ -107,12 +105,10 @@ struct TranslucentWindowBackground: NSViewRepresentable { } } - func makeCoordinator() -> Coordinator { Coordinator() } - class Coordinator: NSObject { private var _originalWindowConfiguration: WindowConfiguration? @@ -157,7 +153,6 @@ struct TranslucentWindowBackground: NSViewRepresentable { } func updateNSView(_ nsView: NSView, context: Context) { - } static func dismantleNSView(_ nsView: NSView, coordinator: Coordinator) { @@ -167,5 +162,4 @@ struct TranslucentWindowBackground: NSViewRepresentable { coordinator.resetWindow(window: window) } } - - +#endif