From 8d3fb397f7943087ada0326ab4edf2ee37909ed6 Mon Sep 17 00:00:00 2001 From: Bryan Montz Date: Sun, 12 Feb 2023 21:59:17 -0600 Subject: [PATCH] Improved blur on images, especially in dark mode Changelog-Changed: Improved blur on images, especially in dark mode Closes: #583 --- damus/Views/NoteContentView.swift | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift index 773f726e..112fc130 100644 --- a/damus/Views/NoteContentView.swift +++ b/damus/Views/NoteContentView.swift @@ -9,6 +9,18 @@ import SwiftUI import LinkPresentation import NaturalLanguage +struct Blur: UIViewRepresentable { + var style: UIBlurEffect.Style = .systemUltraThinMaterial + + func makeUIView(context: Context) -> UIVisualEffectView { + return UIVisualEffectView(effect: UIBlurEffect(style: style)) + } + + func updateUIView(_ uiView: UIVisualEffectView, context: Context) { + uiView.effect = UIBlurEffect(style: style) + } +} + struct NoteContentView: View { let damus_state: DamusState let event: NostrEvent @@ -33,13 +45,12 @@ struct NoteContentView: View { if show_images && artifacts.images.count > 0 { ImageCarousel(urls: artifacts.images) } else if !show_images && artifacts.images.count > 0 { - ImageCarousel(urls: artifacts.images) - .blur(radius: 10) - .overlay { - Rectangle() - .opacity(0.50) - } - .cornerRadius(10) + ZStack { + ImageCarousel(urls: artifacts.images) + Blur() + .disabled(true) + } + .cornerRadius(10) } if artifacts.invoices.count > 0 { InvoicesView(our_pubkey: damus_state.keypair.pubkey, invoices: artifacts.invoices)