ProgressWebView
ProgressWebView library can use webview with progressbar for SwfitUI
Install
CocoaPods
pod 'ProgressWebView'
Usage
import SwiftUI
import ProgressWebView
class SampleViewModel: WebViewModel {
init() {
super.init(urlString: "https://google.com")
}
func useVariables() {
print(self.urlString)
print(self.estimatedProgress)
}
}
struct ContentView: View {
@ObservedObject private var viewModel = SampleViewModel()
var updateButton: some View {
Button("Open github.com") {
self.viewModel.updateUrlString(urlString: "https://github.com", isForceUpdate: true)
}
}
var body: some View {
VStack {
updateButton
ProgressBarWebView(viewModel: self.viewModel)
}
}
}