//
// DetailsView.swift
// SwiftUI WebView
//
// Created by Amoo .O. Faruk on 21/05/2022.
//
import SwiftUI
import WebKit
struct DetailsView: View {
let url: String
var body: some View {
WebView(urlPath: url)
}
}
struct WebView: UIViewRepresentable {
var urlPath: String?
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView : WKWebView , context : Context) {
if let response = urlPath {
if let url = URL(string: response){
let request = URLRequest(url: url)
uiView.load(request)
}
}
}
}
struct DetailsView_Previews: PreviewProvider {
static var previews: some View {
DetailsView(url: "https://google.com")
}
}