Improve translucency effect

This commit is contained in:
Arkadiusz Fal 2022-08-06 15:26:59 +02:00
parent f359b75d63
commit 5e1cb5a2fe
3 changed files with 18 additions and 26 deletions

View File

@ -7,14 +7,19 @@ struct ControlBackgroundModifier: ViewModifier {
func body(content: Content) -> some View { func body(content: Content) -> some View {
if enabled { if enabled {
content if #available(iOS 15, macOS 12, *) {
#if os(macOS) content
.background(VisualEffectBlur(material: .hudWindow)) .background(.thinMaterial)
#elseif os(iOS) } else {
.background(VisualEffectBlur(blurStyle: .systemThinMaterial).edgesIgnoringSafeArea(edgesIgnoringSafeArea)) content
#else #if os(macOS)
.background(.thinMaterial) .background(VisualEffectBlur(material: .hudWindow))
#endif #elseif os(iOS)
.background(VisualEffectBlur(blurStyle: .systemThinMaterial).edgesIgnoringSafeArea(edgesIgnoringSafeArea))
#else
.background(.thinMaterial)
#endif
}
} else { } else {
content content
} }

View File

@ -114,7 +114,7 @@ struct ControlsOverlay: View {
StreamControl() StreamControl()
.frame(width: 45, height: 30) .frame(width: 45, height: 30)
#if os(iOS) #if os(iOS)
.background(VisualEffectBlur(blurStyle: .systemThinMaterial)) .modifier(ControlBackgroundModifier())
#endif #endif
.mask(RoundedRectangle(cornerRadius: 3)) .mask(RoundedRectangle(cornerRadius: 3))
} label: { } label: {
@ -127,12 +127,8 @@ struct ControlsOverlay: View {
.buttonStyle(.plain) .buttonStyle(.plain)
.foregroundColor(.primary) .foregroundColor(.primary)
.frame(width: 140, height: 30) .frame(width: 140, height: 30)
#if os(macOS) .modifier(ControlBackgroundModifier())
.background(VisualEffectBlur(material: .hudWindow)) .mask(RoundedRectangle(cornerRadius: 3))
#elseif os(iOS)
.background(VisualEffectBlur(blurStyle: .systemThinMaterial))
#endif
.mask(RoundedRectangle(cornerRadius: 3))
#endif #endif
} }

View File

@ -29,17 +29,8 @@ struct DetailBadge: View {
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
func body(content: Content) -> some View { func body(content: Content) -> some View {
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) { content
content .modifier(ControlBackgroundModifier())
.background(.thinMaterial)
} else {
content
#if os(macOS)
.background(VisualEffectBlur(material: .hudWindow))
#elseif os(iOS)
.background(VisualEffectBlur(blurStyle: .systemThinMaterial))
#endif
}
} }
} }