Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Last active April 29, 2020 16:44
Show Gist options
  • Save prafullakumar/3684606b7bca3dc8ecd36df0f202dbd2 to your computer and use it in GitHub Desktop.
Save prafullakumar/3684606b7bca3dc8ecd36df0f202dbd2 to your computer and use it in GitHub Desktop.
struct ContentView: View {
@ObservedObject var webViewStateModel: WebViewStateModel = WebViewStateModel()
var body: some View {
NavigationView {
LoadingView(isShowing: .constant(webViewStateModel.loading)) { //loading logic taken from https://stackoverflow.com/a/56496896/9838937
//Add onNavigationAction if callback needed
WebView(url: URL.init(string: "https://www.google.com")!, webViewStateModel: self.webViewStateModel) // add
}
.navigationBarTitle(Text(webViewStateModel.pageTitle), displayMode: .inline)
.navigationBarItems(trailing:
Button("Last Page") {
self.webViewStateModel.goBack.toggle()
}.disabled(!webViewStateModel.canGoBack)
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment