GithubHelp home page GithubHelp logo

ios-webviewswiftui's Introduction

WebViewSwiftUI

WebViewSwiftUI is an innovative SwiftUI wrapper for WKWebView, designed to seamlessly integrate web content within your SwiftUI applications. This framework allows for easy webpage loading, sophisticated navigation controls, and enhanced web interactions, all within the SwiftUI paradigm.

Features

  • Simplified WebView Integration: Integrate web views into SwiftUI with minimal boilerplate code.
  • Navigation Control: Navigate forward and backward through web pages with easy-to-use SwiftUI views.
  • Progress Display: Visually represent page load progress within your app.
  • Dynamic Loading: Conditionally load or reload web pages based on app logic.
  • Custom Link Handling: Intercept link navigation to implement custom logic, such as opening links externally or showing alerts.

Usage

Here's a quick start guide to embed a web view into your SwiftUI view:

import Lux
import SwiftUI
import WebViewSwiftUI

struct ContentView: View {
    @StateObject var website = WebViewStore()
    let baseURL = URL(string: "https://www.google.com")!
    
    var body: some View {
        VStack {
            NavigatorNavBar(webViewStore: website)
            LoaderNavBar(webViewStore: website)
            BrowserView(webViewStore: website)
                .onAppear {
                    configWebsite()
                }
        }
    }
    
    func configWebsite() {
        website.setLinkHandler { url in
            let alert = UIAlertController(title: "Intercepted", message: "Allowed nav intent to:\(url)", preferredStyle: .alert)
            alert.addAction(UIAlertAction(title: "Ok", style: .default))
            UIApplication.shared.present(alert, animated: true)
            
            return .allow
        }
        DispatchQueue.main.async {
            self.website.loadIfNeeded(url: baseURL)
        }
    }
}

Advanced Customizations

The framework provides several SwiftUI views for specific purposes, such as BrowserBackView for a custom back navigation view, and LoaderNavBar for displaying loading progress. It also supports advanced web view manipulations like JavaScript injection and HTML content retrieval.

ios-webviewswiftui's People

Contributors

hassanvfx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.