mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Add playing indicator
This commit is contained in:
43
Shared/Views/PlayingIndicatorView.swift
Normal file
43
Shared/Views/PlayingIndicatorView.swift
Normal file
@@ -0,0 +1,43 @@
|
||||
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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user