This commit is contained in:
Max Goedjen 2022-03-20 16:25:31 -07:00
parent 9c5eceb4a2
commit 0bbf950216
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8
2 changed files with 46 additions and 41 deletions

View File

@ -75,6 +75,7 @@
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<BuildableProductRunnable <BuildableProductRunnable
runnableDebuggingMode = "0"> runnableDebuggingMode = "0">

View File

@ -118,29 +118,33 @@ extension ThumbnailPickerView {
} }
@MainActor class SystemBackground: ObservableObject {
static let shared = SystemBackground()
@Published var image: NSImage?
private init() {
if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) {
image = NSImage(contentsOf: imageURL)
} else {
image = nil
}
}
}
@available(macOS 12.0, *) @available(macOS 12.0, *)
struct SystemBackgroundView: View { struct SystemBackgroundView: View {
let anchor: UnitPoint let anchor: UnitPoint
var body: some View { var body: some View {
if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) { if let x = SystemBackground.shared.image {
AsyncImage(url: imageURL) { phase in Image(nsImage: x)
switch phase { .resizable()
case .empty, .failure: .scaleEffect(3, anchor: anchor)
Rectangle() .clipped()
.foregroundColor(Color(.systemPurple)) .allowsHitTesting(false)
case .success(let image):
image
.resizable()
.scaleEffect(3, anchor: anchor)
.clipped()
.allowsHitTesting(false)
@unknown default:
Rectangle()
.foregroundColor(Color(.systemPurple))
}
}
} else { } else {
Rectangle() Rectangle()
.foregroundColor(Color(.systemPurple)) .foregroundColor(Color(.systemPurple))
@ -222,11 +226,11 @@ struct NotificationView: View {
.foregroundColor(.primary) .foregroundColor(.primary)
} }
}.padding() }.padding()
.redacted(reason: .placeholder) .redacted(reason: .placeholder)
.background( .background(
RoundedRectangle(cornerRadius: 15) RoundedRectangle(cornerRadius: 15)
.foregroundStyle(.ultraThickMaterial) .foregroundStyle(.ultraThickMaterial)
) )
} }
Spacer() Spacer()
} }