Ferrite-backup/Ferrite/Views/CommonViews/IndeterminateProgressView.swift
kingbri 1761f8dfb4 Debrid: Add loading indicator and fix iOS <14.5 issues
When a search result is selected, there is usually a delay due to
the debrid dance of API routes for grabbing a download link to stream.
Add a loading indicator and prevent any other tasks from loading
unless the user cancels it.

iOS 14.5 was a huge update which added many QoL SwiftUI changes that
are consistent to modern iOS versions.

However, Ferrite supports iOS versions less than 14.5, mainly 14.3.
More fixes had to be added to make sure UI is consistent across
all OS versions.

Signed-off-by: kingbri <bdashore3@gmail.com>
2022-08-31 18:47:02 -04:00

44 lines
1.3 KiB
Swift

//
// IndeterminateProgressView.swift
// Ferrite
//
// Created by Brian Dashore on 8/26/22.
//
// Inspired by https://daringsnowball.net/articles/indeterminate-linear-progress-view/
//
import SwiftUI
struct IndeterminateProgressView: View {
@State private var offset: CGFloat = 0
var body: some View {
GeometryReader { reader in
Rectangle()
.foregroundColor(.gray.opacity(0.15))
.overlay(
Rectangle()
.foregroundColor(Color.accentColor)
.frame(width: reader.size.width * 0.26, height: 6)
.clipShape(Capsule())
.offset(x: -reader.size.width * 0.6, y: 0)
.offset(x: reader.size.width * 1.2 * self.offset, y: 0)
.animation(.default.repeatForever().speed(0.5), value: self.offset)
.onAppear{
withAnimation {
self.offset = 1
}
}
)
.clipShape(Capsule())
}
.frame(height: 4, alignment: .center)
}
}
struct IndeterminateProgressView_Previews: PreviewProvider {
static var previews: some View {
IndeterminateProgressView()
}
}