{"id":21374033,"url":"https://github.com/pikachu987/WebController","last_synced_at":"2025-07-13T08:32:14.867Z","repository":{"id":56927371,"uuid":"150578562","full_name":"pikachu987/WebController","owner":"pikachu987","description":"Quick WKWebView 😄","archived":false,"fork":false,"pushed_at":"2024-05-15T12:25:59.000Z","size":2816,"stargazers_count":24,"open_issues_count":0,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-31T04:20:37.019Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pikachu987.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-27T11:49:32.000Z","updated_at":"2024-05-15T12:26:03.000Z","dependencies_parsed_at":"2022-08-21T06:20:19.081Z","dependency_job_id":null,"html_url":"https://github.com/pikachu987/WebController","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pikachu987%2FWebController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pikachu987%2FWebController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pikachu987%2FWebController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pikachu987%2FWebController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pikachu987","download_url":"https://codeload.github.com/pikachu987/WebController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225868592,"owners_count":17537081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T08:29:38.880Z","updated_at":"2024-11-22T08:30:08.453Z","avatar_url":"https://github.com/pikachu987.png","language":"Swift","funding_links":[],"categories":["OOM-Leaks-Crash"],"sub_categories":["WebView-ProgressBar"],"readme":"# WebController\n\n[![CI Status](https://img.shields.io/travis/pikachu987/WebController.svg?style=flat)](https://travis-ci.org/pikachu987/WebController)\n[![Version](https://img.shields.io/cocoapods/v/WebController.svg?style=flat)](https://cocoapods.org/pods/WebController)\n[![License](https://img.shields.io/cocoapods/l/WebController.svg?style=flat)](https://cocoapods.org/pods/WebController)\n[![Platform](https://img.shields.io/cocoapods/p/WebController.svg?style=flat)](https://cocoapods.org/pods/WebController)\n![](https://img.shields.io/badge/Supported-iOS9%20%7C%20OSX%2010.9-4BC51D.svg?style=flat-square)\n![](https://img.shields.io/badge/Swift-5.0-orange.svg?style=flat)\n\n## Introduce\n\nA simple WKWebView library.\nYou can simply modify the bottom ToolBar.\nThere is a ProgressView so you can see the Load status of WebView.\nOnce you receive your app's schema from DeepLink or UniversalLink on your website, you can open the app.\n\n![demo](./Etc/gif1.gif)\n![demo2](./Etc/gif2.gif)\n\n\u003cbr\u003e\u003cbr\u003e\n\n![demo](./Etc/img_1.png)\n![demo2](./Etc/img_2.png)\n\n## Requirements\n\n`WebController` written in Swift 5. Compatible with iOS 9.0+\n\n## Installation\n\n### Cocoapods\n\nWebController is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'WebController'\n```\n\n## Usage\n\n```swift\nimport WebController\n```\n\n```swift\nlet webController = WebController()\nwebController.load(\"http://www.apple.com\")\nself.navigationController?.pushViewController(webController, animated: true)\n```\ndone!\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n\n### Property\n\nWebController\n\n```swift\n\n//WKWebView\nwebController.webView\n\n//The UIProgressView that appears above the WebView when the site loads\nwebController.progressView\n\n//The UIActivityIndicatorView that appears in the center of the webview when the site loads\nwebController.indicatorView\n\n//A UIView that wraps around the bottom UIToolbar.\nwebController.toolView\n\n//Paints the title color of the UINavigationBar.\nwebController.titleTintColor\n\n//Paints the background color of the UINavigationBar.\nwebController.barTintColor\n\n```\n\nToolView\n\n```swift\n\n//UIToolbar\nwebController.toolView.toolbar\n\n//Paints the colors of the UIToolbar's items.\nwebController.toolView.itemTintColor\n\n//Paints the background color of the UIToolbar.\nwebController.toolView.barTintColor\n\n//Hide the ToolBar's Refresh UIBarButtonItem, Stop UIBarButtonItem. Default is false.\nwebController.toolView.isHiddenRefresh\n\n//Hides the ToolBar at the bottom of the WebController. Default is false.\nwebController.toolView.isHiddenToolBar\n\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n### Method\n\nWebController load\n\n```swift\nwebController.load(\"http://www.apple.com\")\n```\n\nToolView UIBarButtonItem\n\n```swift\nwebController.toolView.setBackBarButtonItem(\"\u003c\")\nwebController.toolView.setBackBarButtonItem(UIImage(named: \"\"))\nwebController.toolView.setForwardBarButtonItem(\"\u003e\")\nwebController.toolView.setForwardBarButtonItem(UIImage(named: \"\"))\n```\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n### Delegate\n\n```swift\nclass ViewController: UIViewController {\n\n  override func viewDidLoad() {\n    super.viewDidLoad()\n\n    let webController = WebController()\n    webController.delegate = self\n  }\n\n}\n\nextension ViewController: WebControllerDelegate {\n\n/**\nCalled when title changes.\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- didChangeTitle: The title to change.\n*/\nfunc webController(_ webController: WebController, didChangeTitle: String?) {\n\n}\n\n/**\nCalled when url changes.\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- didChangeURL: The url to change.\n*/\nfunc webController(_ webController: WebController, didChangeURL: URL?) {\n\n}\n\n/**\nIt is called when the load starts or ends.\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- didLoading: load starts or ends.\n*/\nfunc webController(_ webController: WebController, didLoading: Bool) {\n\n}\n\n/**\nCalled when title changes.\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- title: will change based on the return value.\n- Returns: UINavigationTitle is changed. default is changed to title which is received as argument.\n*/\nfunc webController(_ webController: WebController, title: String?) -\u003e String? {\n\n}\n\n/**\nIt will be called when the site becomes an Alert.\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- alertController: This is an alert window that will appear on the screen.\n- didUrl: The website URL with the alert window.\n*/\nfunc webController(_ webController: WebController, alertController: UIAlertController, didUrl: URL?) {\n\n}\n\n/**\nIf the website fails to load, the Alert is called.\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- alertController: This is an alert window that will appear on the screen.\n- didUrl: The website URL with the alert window.\n*/\nfunc webController(_ webController: WebController, failAlertController: UIAlertController, didUrl: URL?) {\n\n}\n\n/**\nIf the scheme is not http or https, think of it as a deep link or universal link\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- openUrl: Url to use 'UIApplication.shared.openURL'.\n- Returns: Return true to use 'UIApplication.shared.openURL'. default is true.\n*/\nfunc webController(_ webController: WebController, openUrl: URL?) -\u003e Bool {\n\n}\n\n/**\nDecides whether to allow or cancel a navigation.\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- navigationAction: Descriptive information about the action triggering the navigation request.\n- decisionHandler: The decision handler to call to allow or cancel the navigation. The argument is one of the constants of the enumerated type WKNavigationActionPolicy.\n*/\nfunc webController(_ webController: WebController, navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -\u003e Void) {\n\n}\n\n/**\nDecides whether to allow or cancel a navigation after its response is known.\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- navigationResponse: Descriptive information about the navigation response.\n- decisionHandler: decisionHandler The decision handler to call to allow or cancel the navigation. The argument is one of the constants of the enumerated type WKNavigationResponsePolicy.\n*/\nfunc webController(_ webController: WebController, navigationResponse: WKNavigationResponse, decisionHandler: (WKNavigationResponsePolicy) -\u003e Void) {\n\n}\n\n/**\nInvoked when the web view needs to respond to an authentication challenge.\n- Parameters:\n- webController: WebControllerDelegate The UIViewController invoking the delegate method.\n- challenge: The authentication challenge.\n- completionHandler: The completion handler you must invoke to respond to the challenge. The disposition argument is one of the constants of the enumerated type NSURLSessionAuthChallengeDisposition. When disposition is NSURLSessionAuthChallengeUseCredential, the credential argument is the credential to use, or nil to indicate continuing without a credential.\n*/\nfunc webController(_ webController: WebController, challenge: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -\u003e Void) {\n\n}\n\n}\n\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n### Customize\n\nWebController Customize\n\n```swift\nlet webController = WebController()\nwebController.delegate = self\nwebController.toolView.setBackBarButtonItem(UIImage(named: \"icBack\"))\nwebController.toolView.setForwardBarButtonItem(UIImage(named: \"icFront\"))\nwebController.toolView.tintColor = .white\nwebController.toolView.barTintColor = UIColor.black\nwebController.toolView.toolbar.isTranslucent = false\nwebController.barTintColor = .black\nwebController.titleTintColor = .white\nwebController.progressView.trackTintColor = .white\nwebController.progressView.progressTintColor = .black\nwebController.indicatorView.color = .white\nwebController.load(\"https://www.google.com\")\nself.navigationController?.pushViewController(webController, animated: true)\n```\n\n```swift\nclass CustomWebController: WebController {\n    static func instance() -\u003e CustomWebController? {\n        let webController = CustomWebController()\n        webController.load(\"https://www.google.com\")\n        return webController\n    }\n\n    override func viewWillAppear(_ animated: Bool) {\n        super.viewWillAppear(animated)\n        self.webView.configuration.userContentController.add(self, name: \"myApp\")\n    }\n\n    override func viewWillDisappear(_ animated: Bool) {\n        super.viewWillDisappear(animated)\n        self.webView.configuration.userContentController.removeScriptMessageHandler(forName: \"myApp\")\n    }\n}\n\n// MARK: WKScriptMessageHandler\nextension CustomWebController: WKScriptMessageHandler {\n    func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {\n        print(message)\n    }\n}\n\n```\n\n## Author\n\npikachu987, pikachu77769@gmail.com\n\n## License\n\nWebController is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpikachu987%2FWebController","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpikachu987%2FWebController","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpikachu987%2FWebController/lists"}