first versun

import SwiftUI
import WebKit

struct ContentView: View {
    private let urlString: String = "https://www.hlomart.com"
    
    var body: some View {
        ZStack {
            Color.black
                .ignoresSafeArea()
            
            VStack(spacing: 0) {
                // Fixed Header
                HeaderView()
                
                // WebView
                if let url = URL(string: urlString) {
                    WebView(url: url)
                        .frame(maxHeight: .infinity)
                        .cornerRadius(10)
                        .shadow(color: .black.opacity(0.3), radius: 20, x: 5, y: 5)
                } else {
                    Text("Invalid URL")
                }
            }
        }
        .edgesIgnoringSafeArea(.all)
    }
}

struct HeaderView: View {
    var body: some View {
        Text("Header")
            .frame(height: 0)
            .background(Color.blue)
            .foregroundColor(.white)
    }
}

// Rest of your WebView, WebViewRepresentable, and LoadingView structs


struct WebView: UIViewRepresentable {
    var url: URL
    @State private var isLoading = true

    func makeUIView(context: Context) -> WKWebView {
        let webView = WKWebView()
        webView.navigationDelegate = context.coordinator
        
        // Disable zooming
        webView.scrollView.maximumZoomScale = 1.0
        webView.scrollView.minimumZoomScale = 1.0
        
        return webView
    }

    func updateUIView(_ uiView: WKWebView, context: Context) {
        let request = URLRequest(url: url)
        uiView.load(request)
    }

    func makeCoordinator() -> Coordinator {
        Coordinator(self)
    }

    class Coordinator: NSObject, WKNavigationDelegate {
        var parent: WebView

        init(_ webView: WebView) {
            self.parent = webView
        }

        func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
            parent.isLoading = true
        }

        func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
            parent.isLoading = false
        }

        func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
            parent.isLoading = false
            // Handle the error appropriately.
        }
    }
}

struct LoadingView: View {
    var body: some View {
        ProgressView()
            .progressViewStyle(CircularProgressViewStyle(tint: .blue))
            .scaleEffect(1.5)
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

second

import SwiftUI
import WebKit

struct ContentView: View {
    private let urlString: String = "https://www.hlomart.com"
    
    var body: some View {
        ZStack {
            Color.black
                .ignoresSafeArea()
            
            VStack(spacing: 0) {
                // Fixed Header
                HeaderView()
                
                // WebView
                if let url = URL(string: urlString) {
                    WebView(url: url)
                        .frame(maxHeight: .infinity)
                        .cornerRadius(10)
                        .shadow(color: .black.opacity(0.3), radius: 20, x: 5, y: 5)
                } else {
                    Text("Invalid URL")
                }
            }
        }
        .edgesIgnoringSafeArea(.all)
    }
}

struct HeaderView: View {
    var body: some View {
        Text("Header")
            .frame(height: 0)
            .background(Color.blue)
            .foregroundColor(.white)
    }
}

// Rest of your WebView, WebViewRepresentable, and LoadingView structs


struct WebView: UIViewRepresentable {
    var url: URL
    @State private var isLoading = true

    func makeUIView(context: Context) -> WKWebView {
        let webView = WKWebView()
        webView.navigationDelegate = context.coordinator
        
        // Disable zooming
        webView.scrollView.maximumZoomScale = 1.0
        webView.scrollView.minimumZoomScale = 1.0
        
        return webView
    }

    func updateUIView(_ uiView: WKWebView, context: Context) {
        let request = URLRequest(url: url)
        uiView.load(request)
    }

    func makeCoordinator() -> Coordinator {
        Coordinator(self)
    }

    class Coordinator: NSObject, WKNavigationDelegate {
        var parent: WebView

        init(_ webView: WebView) {
            self.parent = webView
        }

        func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
            parent.isLoading = true
        }

        func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
            parent.isLoading = false
        }

        func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
            parent.isLoading = false
            // Handle the error appropriately.
        }
    }
}

struct LoadingView: View {
    var body: some View {
        ProgressView()
            .progressViewStyle(CircularProgressViewStyle(tint: .blue))
            .scaleEffect(1.5)
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Shopping Cart
🏠 Home 🛍️ Category 🧑🏻‍⚕️ Account 💝 0 Wishlist 🏦 Wallet
Custom Icon
0
0.00
Scroll to Top