1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 13:50:32 +05:30
yattee/Shared/Views/PlayingIndicatorView.swift

44 lines
1.2 KiB
Swift
Raw Normal View History

2022-12-17 03:43:16 +05:30
import SwiftUI
struct PlayingIndicatorView: View {
var video: Video?
var height = 65.0
@State private var drawingHeight = true
@ObservedObject private var player = PlayerModel.shared
var body: some View {
HStack(spacing: 2) {
bar(low: 0.4)
.animation(animation.speed(1.5), value: drawingHeight)
bar(low: 0.3)
.animation(animation.speed(1.2), value: drawingHeight)
bar(low: 0.5)
.animation(animation.speed(1.0), value: drawingHeight)
}
.opacity(player.currentVideo == video && player.isPlaying ? 1 : 0)
.onAppear {
drawingHeight.toggle()
}
}
func bar(low: Double = 0.0, high: Double = 1.0) -> some View {
RoundedRectangle(cornerRadius: 3)
.foregroundColor(.white)
.frame(height: (drawingHeight ? high : low) * height)
.frame(height: height, alignment: .bottom)
.shadow(radius: 3)
}
var animation: Animation {
.easeIn(duration: 0.5).repeatForever()
}
}
struct PlayingIndicatorView_Previews: PreviewProvider {
static var previews: some View {
PlayingIndicatorView(video: .fixture)
}
}