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"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
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, *)
struct SystemBackgroundView: View {
let anchor: UnitPoint
var body: some View {
if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) {
AsyncImage(url: imageURL) { phase in
switch phase {
case .empty, .failure:
Rectangle()
.foregroundColor(Color(.systemPurple))
case .success(let image):
image
.resizable()
.scaleEffect(3, anchor: anchor)
.clipped()
.allowsHitTesting(false)
@unknown default:
Rectangle()
.foregroundColor(Color(.systemPurple))
}
}
if let x = SystemBackground.shared.image {
Image(nsImage: x)
.resizable()
.scaleEffect(3, anchor: anchor)
.clipped()
.allowsHitTesting(false)
} else {
Rectangle()
.foregroundColor(Color(.systemPurple))
@ -222,11 +226,11 @@ struct NotificationView: View {
.foregroundColor(.primary)
}
}.padding()
.redacted(reason: .placeholder)
.background(
RoundedRectangle(cornerRadius: 15)
.foregroundStyle(.ultraThickMaterial)
)
.redacted(reason: .placeholder)
.background(
RoundedRectangle(cornerRadius: 15)
.foregroundStyle(.ultraThickMaterial)
)
}
Spacer()
}