From 5e1cb5a2fedc1c006522fd6a8280905e09817963 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 6 Aug 2022 15:26:59 +0200 Subject: [PATCH] Improve translucency effect --- .../Controls/ControlBackgroundModifier.swift | 21 ++++++++++++------- Shared/Player/Controls/ControlsOverlay.swift | 10 +++------ Shared/Views/DetailBadge.swift | 13 ++---------- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/Shared/Player/Controls/ControlBackgroundModifier.swift b/Shared/Player/Controls/ControlBackgroundModifier.swift index 42dc8c23..e2bbd315 100644 --- a/Shared/Player/Controls/ControlBackgroundModifier.swift +++ b/Shared/Player/Controls/ControlBackgroundModifier.swift @@ -7,14 +7,19 @@ struct ControlBackgroundModifier: ViewModifier { func body(content: Content) -> some View { if enabled { - content - #if os(macOS) - .background(VisualEffectBlur(material: .hudWindow)) - #elseif os(iOS) - .background(VisualEffectBlur(blurStyle: .systemThinMaterial).edgesIgnoringSafeArea(edgesIgnoringSafeArea)) - #else - .background(.thinMaterial) - #endif + if #available(iOS 15, macOS 12, *) { + content + .background(.thinMaterial) + } else { + content + #if os(macOS) + .background(VisualEffectBlur(material: .hudWindow)) + #elseif os(iOS) + .background(VisualEffectBlur(blurStyle: .systemThinMaterial).edgesIgnoringSafeArea(edgesIgnoringSafeArea)) + #else + .background(.thinMaterial) + #endif + } } else { content } diff --git a/Shared/Player/Controls/ControlsOverlay.swift b/Shared/Player/Controls/ControlsOverlay.swift index d1202607..472b468b 100644 --- a/Shared/Player/Controls/ControlsOverlay.swift +++ b/Shared/Player/Controls/ControlsOverlay.swift @@ -114,7 +114,7 @@ struct ControlsOverlay: View { StreamControl() .frame(width: 45, height: 30) #if os(iOS) - .background(VisualEffectBlur(blurStyle: .systemThinMaterial)) + .modifier(ControlBackgroundModifier()) #endif .mask(RoundedRectangle(cornerRadius: 3)) } label: { @@ -127,12 +127,8 @@ struct ControlsOverlay: View { .buttonStyle(.plain) .foregroundColor(.primary) .frame(width: 140, height: 30) - #if os(macOS) - .background(VisualEffectBlur(material: .hudWindow)) - #elseif os(iOS) - .background(VisualEffectBlur(blurStyle: .systemThinMaterial)) - #endif - .mask(RoundedRectangle(cornerRadius: 3)) + .modifier(ControlBackgroundModifier()) + .mask(RoundedRectangle(cornerRadius: 3)) #endif } diff --git a/Shared/Views/DetailBadge.swift b/Shared/Views/DetailBadge.swift index 5cd0dfc6..175803c3 100644 --- a/Shared/Views/DetailBadge.swift +++ b/Shared/Views/DetailBadge.swift @@ -29,17 +29,8 @@ struct DetailBadge: View { @Environment(\.colorScheme) private var colorScheme func body(content: Content) -> some View { - if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) { - content - .background(.thinMaterial) - } else { - content - #if os(macOS) - .background(VisualEffectBlur(material: .hudWindow)) - #elseif os(iOS) - .background(VisualEffectBlur(blurStyle: .systemThinMaterial)) - #endif - } + content + .modifier(ControlBackgroundModifier()) } }