base page type to template for old web overrides.

This commit is contained in:
Scott Pfeil 2022-01-07 16:08:15 -05:00
parent 8d55651a3e
commit 014a0dc988
2 changed files with 14 additions and 3 deletions

View File

@ -170,8 +170,13 @@ extension WebView : WKNavigationDelegate {
public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
//validate request url
//all validated link should be open in safari
if (navigationAction.navigationType == .linkActivated), let urlString = navigationAction.request.url?.absoluteString.removingPercentEncoding, !urlString.contains("#") {
MVMCoreActionHandler.shared()?.openURL(inWebView: navigationAction.request.url, actionInformation: nil, additionalData: nil, delegateObject: nil)
if (navigationAction.navigationType == .linkActivated),
let url = navigationAction.request.url,
let urlString = url.absoluteString.removingPercentEncoding,
!urlString.contains("#") {
MVMCoreDispatchUtility.performBlock(onMainThread: {
UIApplication.shared.open(navigationAction.request.url!, options: [:], completionHandler: nil)
})
decisionHandler(.cancel)
} else {
decisionHandler(.allow)

View File

@ -58,10 +58,16 @@ import Foundation
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
open class func defaultPageType() -> String? { return nil }
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
pageType = try typeContainer.decode(String.self, forKey: .pageType)
if let defaultPageType = Self.defaultPageType() {
pageType = try typeContainer.decodeIfPresent(String.self, forKey: .pageType) ?? defaultPageType
} else {
pageType = try typeContainer.decode(String.self, forKey: .pageType)
}
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules)