1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 06:40:32 +05:30
yattee/Shared/Player/Controls/OSD/Buffering.swift

48 lines
1.4 KiB
Swift
Raw Normal View History

import Defaults
import Foundation
import SwiftUI
struct Buffering: View {
2022-09-04 20:58:30 +05:30
var reason = "Buffering stream...".localized()
var state: String?
@ObservedObject private var player = PlayerModel.shared
@Default(.playerControlsLayout) private var regularPlayerControlsLayout
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
var playerControlsLayout: PlayerControlsLayout {
2022-09-02 04:35:31 +05:30
player.playingFullScreen ? fullScreenPlayerControlsLayout : regularPlayerControlsLayout
}
var body: some View {
VStack(spacing: 2) {
ProgressView()
#if os(macOS)
.scaleEffect(0.4)
#else
.scaleEffect(0.7)
#endif
.frame(maxHeight: 14)
.progressViewStyle(.circular)
Text(reason)
.font(.system(size: playerControlsLayout.timeFontSize))
2022-09-28 19:57:01 +05:30
if let state {
Text(state)
.font(.system(size: playerControlsLayout.bufferingStateFontSize).monospacedDigit())
}
}
.padding(8)
.modifier(ControlBackgroundModifier())
.clipShape(RoundedRectangle(cornerRadius: 4))
.foregroundColor(.secondary)
}
}
struct Buffering_Previews: PreviewProvider {
static var previews: some View {
Buffering(state: "100% (2.95s)")
}
}