jellyflood/Swiftfin/Components/CircularProgressView.swift

41 lines
1016 B
Swift

//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
//
import SwiftUI
struct CircularProgressView: View {
@State
private var lineWidth: CGFloat = 1
let progress: Double
var body: some View {
ZStack {
Circle()
.stroke(
Color.green.opacity(0.5),
lineWidth: lineWidth
)
Circle()
.trim(from: 0, to: progress)
.stroke(
Color.green,
style: StrokeStyle(
lineWidth: lineWidth,
lineCap: .round
)
)
.rotationEffect(.degrees(-90))
}
.onSizeChanged { size in
lineWidth = size.width / 3.5
}
}
}