2022-08-28 22:48:49 +05:30
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ProgressBar: View {
|
|
|
|
var value: Double
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
GeometryReader { geometry in
|
|
|
|
ZStack(alignment: .leading) {
|
|
|
|
Rectangle().frame(width: geometry.size.width, height: geometry.size.height)
|
|
|
|
.opacity(0.3)
|
|
|
|
.foregroundColor(Color.secondary)
|
|
|
|
|
2022-08-29 17:25:23 +05:30
|
|
|
Rectangle().frame(width: min(Double(self.value) * geometry.size.width, geometry.size.width), height: geometry.size.height)
|
2022-08-28 22:48:49 +05:30
|
|
|
.foregroundColor(Color.accentColor)
|
|
|
|
.animation(.linear)
|
|
|
|
}.cornerRadius(45.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ProgressBar_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
ProgressBar(value: 0.5)
|
|
|
|
.frame(maxHeight: 6)
|
|
|
|
}
|
|
|
|
}
|