Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
20 changes: 7 additions & 13 deletions Sources/TranslucentWindowStyle/TranslucentWindowStyle.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#if os(macOS)
import SwiftUI

import AppKit

public protocol WindowBackgroundStyle {
associatedtype Body : View
Expand All @@ -17,15 +18,12 @@ public struct TranslucentBackgroundStyle: WindowBackgroundStyle {
}

extension View {

@MainActor public func presentedWindowBackgroundStyle<S>(_ style: S) -> some View where S : WindowBackgroundStyle {
self.background(style.backgroud)
}

}

struct TranslucentWindowBackground: NSViewRepresentable {

enum ContentViewConfiguration {
case embed(NSView?)
case replace(NSView?)
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -107,12 +105,10 @@ struct TranslucentWindowBackground: NSViewRepresentable {
}
}


func makeCoordinator() -> Coordinator {
Coordinator()
}


class Coordinator: NSObject {
private var _originalWindowConfiguration: WindowConfiguration?

Expand Down Expand Up @@ -157,7 +153,6 @@ struct TranslucentWindowBackground: NSViewRepresentable {
}

func updateNSView(_ nsView: NSView, context: Context) {

}

static func dismantleNSView(_ nsView: NSView, coordinator: Coordinator) {
Expand All @@ -167,5 +162,4 @@ struct TranslucentWindowBackground: NSViewRepresentable {
coordinator.resetWindow(window: window)
}
}


#endif