30 lines
714 B
Swift
30 lines
714 B
Swift
|
//
|
||
|
// 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
|
||
|
|
||
|
func makeUIView(context: Context) -> UIProgressView {
|
||
|
return UIProgressView(progressViewStyle: .bar)
|
||
|
}
|
||
|
|
||
|
func updateUIView(_ uiView: UIProgressView, context: Context) {
|
||
|
if total > 0 {
|
||
|
let progress = Float(value) / Float(total)
|
||
|
uiView.setProgress(progress, animated: true)
|
||
|
} else {
|
||
|
uiView.setProgress(0, animated: true)
|
||
|
}
|
||
|
}
|
||
|
}
|