Tusker/Tusker/Views/WrappedProgressView.swift

31 lines
742 B
Swift
Raw Normal View History

2020-08-31 23:28:50 +00:00
//
// WrappedProgressView.swift
// Tusker
//
// Created by Shadowfacts on 8/30/20.
// Copyright © 2020 Shadowfacts. All rights reserved.
//
import SwiftUI
struct WrappedProgressView: UIViewRepresentable {
typealias UIViewType = UIProgressView
let value: Int
let total: Int
2020-08-31 23:28:50 +00:00
func makeUIView(context: Context) -> UIProgressView {
return UIProgressView(progressViewStyle: .bar)
}
func updateUIView(_ uiView: UIProgressView, context: Context) {
if total > 0 {
let progress = Float(value) / Float(total)
print(progress)
uiView.setProgress(progress, animated: true)
2020-09-09 22:33:59 +00:00
} else {
uiView.setProgress(0, animated: true)
2020-08-31 23:28:50 +00:00
}
}
}