Skip to content

ksugawara61/ProgressWebView

Repository files navigation

ProgressWebView

ProgressWebView library can use webview with progressbar for SwfitUI

Swift Version Github CocoaPods

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)
        }
    }
}