Backport blur effect for iOS 14/macOS Big Sur

This commit is contained in:
Arkadiusz Fal
2022-01-06 15:58:16 +01:00
parent 4e88f2baf8
commit 520d69f37a
4 changed files with 197 additions and 20 deletions

View File

@@ -33,10 +33,10 @@ struct DetailBadge: View {
.background(.thinMaterial)
} else {
content
#if os(tvOS)
.background(Color.background(scheme: colorScheme))
#else
.background(Color.background.opacity(0.95))
#if os(macOS)
.background(VisualEffectBlur())
#elseif os(iOS)
.background(VisualEffectBlur(blurStyle: .systemThinMaterial))
#endif
}
}

View File

@@ -1,5 +1,6 @@
import Foundation
import SwiftUI
struct PlayerControlsView<Content: View>: View {
let content: Content
@@ -36,11 +37,13 @@ struct PlayerControlsView<Content: View>: View {
.foregroundColor(model.currentItem.isNil ? .secondary : .accentColor)
.lineLimit(1)
Text(model.currentVideo?.author ?? "Yattee v\(appVersion) (build \(appBuild))")
.fontWeight(model.currentItem.isNil ? .light : .bold)
.font(.system(size: 10))
.foregroundColor(.secondary)
.lineLimit(1)
if let video = model.currentVideo {
Text(video.author)
.fontWeight(.bold)
.font(.system(size: 10))
.foregroundColor(.secondary)
.lineLimit(1)
}
}
.contextMenu {
Button {
@@ -115,27 +118,21 @@ struct PlayerControlsView<Content: View>: View {
.background(Material.ultraThinMaterial)
} else {
controls
#if !os(tvOS)
.background(Color.secondaryBackground)
#if os(macOS)
.background(VisualEffectBlur())
#elseif os(iOS)
.background(VisualEffectBlur(blurStyle: .systemUltraThinMaterial))
#endif
}
}
}
private var appVersion: String {
Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "unknown"
}
private var appBuild: String {
Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "unknown"
}
private var progressViewValue: Double {
[model.time?.seconds, model.videoDuration].compactMap { $0 }.min() ?? 0
}
private var progressViewTotal: Double {
model.playerItemDuration?.seconds ?? model.currentVideo?.length ?? progressViewValue
model.playerItemDuration?.seconds ?? model.currentVideo?.length ?? 100
}
}