Merge branch 'develop' into feature/designed_external_link
This commit is contained in:
commit
3bed045b5d
@ -129,6 +129,8 @@
|
|||||||
8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */; };
|
8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */; };
|
||||||
8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; };
|
8D24041123E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */; };
|
||||||
8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; };
|
8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */; };
|
||||||
|
8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */; };
|
||||||
|
8D3BA9BF2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D3BA9BE2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift */; };
|
||||||
8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; };
|
8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */; };
|
||||||
8D4687E2242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */; };
|
8D4687E2242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */; };
|
||||||
8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */; };
|
8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */; };
|
||||||
@ -139,6 +141,8 @@
|
|||||||
9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */; };
|
9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */; };
|
||||||
943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; };
|
943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; };
|
||||||
943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; };
|
943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; };
|
||||||
|
943820842432382400B43AF3 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943820832432382400B43AF3 /* WebView.swift */; };
|
||||||
|
94382086243238D100B43AF3 /* WebViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94382085243238D100B43AF3 /* WebViewModel.swift */; };
|
||||||
9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; };
|
9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */; };
|
||||||
9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */; };
|
9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */; };
|
||||||
9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */; };
|
9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */; };
|
||||||
@ -519,6 +523,8 @@
|
|||||||
8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextBodyText.swift; sourceTree = "<group>"; };
|
8D084AD12410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextBodyText.swift; sourceTree = "<group>"; };
|
||||||
8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = "<group>"; };
|
8D24041023E7FB9E009E23BE /* ListLeftVariableIconWithRightCaret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaret.swift; sourceTree = "<group>"; };
|
||||||
8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = "<group>"; };
|
8D24041423E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableIconWithRightCaretModel.swift; sourceTree = "<group>"; };
|
||||||
|
8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataDividerModel.swift; sourceTree = "<group>"; };
|
||||||
|
8D3BA9BE2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListThreeColumnInternationalDataDivider.swift; sourceTree = "<group>"; };
|
||||||
8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = "<group>"; };
|
8D448E5424050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextAllTextAndLinksModel.swift; sourceTree = "<group>"; };
|
||||||
8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageListItemModel.swift; sourceTree = "<group>"; };
|
8D4687E1242E2DE400802879 /* ListFourColumnDataUsageListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageListItemModel.swift; sourceTree = "<group>"; };
|
||||||
8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageListItem.swift; sourceTree = "<group>"; };
|
8D4687E3242E2DF300802879 /* ListFourColumnDataUsageListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageListItem.swift; sourceTree = "<group>"; };
|
||||||
@ -530,6 +536,8 @@
|
|||||||
9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = "<group>"; };
|
9432A79E23DB47BA00719041 /* EntryFieldContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = "<group>"; };
|
||||||
943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = "<group>"; };
|
943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = "<group>"; };
|
||||||
943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = "<group>"; };
|
943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = "<group>"; };
|
||||||
|
943820832432382400B43AF3 /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = "<group>"; };
|
||||||
|
94382085243238D100B43AF3 /* WebViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewModel.swift; sourceTree = "<group>"; };
|
||||||
9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = "<group>"; };
|
9445890B2385BCE300DE9FD4 /* ProgressBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressBarModel.swift; sourceTree = "<group>"; };
|
||||||
9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgressModel.swift; sourceTree = "<group>"; };
|
9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgressModel.swift; sourceTree = "<group>"; };
|
||||||
9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretViewModel.swift; sourceTree = "<group>"; };
|
9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretViewModel.swift; sourceTree = "<group>"; };
|
||||||
@ -1270,6 +1278,8 @@
|
|||||||
children = (
|
children = (
|
||||||
5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */,
|
5248BFEB23F12E350059236A /* ListThreeColumnPlanDataDividerModel.swift */,
|
||||||
5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */,
|
5248BFEA23F12E350059236A /* ListThreeColumnPlanDataDivider.swift */,
|
||||||
|
8D3BA9BC2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift */,
|
||||||
|
8D3BA9BE2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift */,
|
||||||
);
|
);
|
||||||
path = ThreeColumn;
|
path = ThreeColumn;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1552,6 +1562,8 @@
|
|||||||
0AA33B392398524F0067DD0F /* Toggle.swift */,
|
0AA33B392398524F0067DD0F /* Toggle.swift */,
|
||||||
0AE98BB623FF18E9004C5109 /* ArrowModel.swift */,
|
0AE98BB623FF18E9004C5109 /* ArrowModel.swift */,
|
||||||
0AE98BB423FF18D2004C5109 /* Arrow.swift */,
|
0AE98BB423FF18D2004C5109 /* Arrow.swift */,
|
||||||
|
94382085243238D100B43AF3 /* WebViewModel.swift */,
|
||||||
|
943820832432382400B43AF3 /* WebView.swift */,
|
||||||
);
|
);
|
||||||
path = Views;
|
path = Views;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1910,6 +1922,7 @@
|
|||||||
8D070BB0241B56530099AC56 /* ListRightVariableTotalDataModel.swift in Sources */,
|
8D070BB0241B56530099AC56 /* ListRightVariableTotalDataModel.swift in Sources */,
|
||||||
943784F5236B77BB006A1E82 /* GraphView.swift in Sources */,
|
943784F5236B77BB006A1E82 /* GraphView.swift in Sources */,
|
||||||
31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */,
|
31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */,
|
||||||
|
8D3BA9BF2433789900D341BA /* ListThreeColumnInternationalDataDivider.swift in Sources */,
|
||||||
94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */,
|
94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */,
|
||||||
D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */,
|
D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */,
|
||||||
D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */,
|
D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */,
|
||||||
@ -1928,6 +1941,7 @@
|
|||||||
0116A4E5228B19640094F3ED /* RadioButtonSelectionHelper.swift in Sources */,
|
0116A4E5228B19640094F3ED /* RadioButtonSelectionHelper.swift in Sources */,
|
||||||
017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */,
|
017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */,
|
||||||
D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */,
|
D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */,
|
||||||
|
94382086243238D100B43AF3 /* WebViewModel.swift in Sources */,
|
||||||
D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */,
|
D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */,
|
||||||
D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */,
|
D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */,
|
||||||
0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */,
|
0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */,
|
||||||
@ -1998,6 +2012,7 @@
|
|||||||
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,
|
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,
|
||||||
D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */,
|
D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */,
|
||||||
94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */,
|
94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */,
|
||||||
|
943820842432382400B43AF3 /* WebView.swift in Sources */,
|
||||||
0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */,
|
0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */,
|
||||||
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */,
|
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */,
|
||||||
0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */,
|
0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */,
|
||||||
@ -2213,6 +2228,7 @@
|
|||||||
01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */,
|
01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */,
|
||||||
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
|
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
|
||||||
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */,
|
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */,
|
||||||
|
8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */,
|
||||||
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
||||||
011D959F240453A1000E3791 /* RuleAllValueChangedModel.swift in Sources */,
|
011D959F240453A1000E3791 /* RuleAllValueChangedModel.swift in Sources */,
|
||||||
011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */,
|
011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */,
|
||||||
|
|||||||
196
MVMCoreUI/Atomic/Atoms/Views/WebView.swift
Normal file
196
MVMCoreUI/Atomic/Atoms/Views/WebView.swift
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
//
|
||||||
|
// MVMCoreUIWebView.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Ryan on 8/29/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import WebKit
|
||||||
|
|
||||||
|
@objcMembers open class WebView: View, MVMCoreUIViewConstrainingProtocol {
|
||||||
|
|
||||||
|
let mvmWebViewMessageHandler = "mvmWebViewMessageHandler"
|
||||||
|
|
||||||
|
var webviewModel: WebViewModel? {
|
||||||
|
return model as? WebViewModel
|
||||||
|
}
|
||||||
|
var webView: WKWebView?
|
||||||
|
var overLayer = MVMCoreUICommonViewsUtility.commonView()
|
||||||
|
public let loadingSpinner = MFLoadingSpinner(frame: .zero)
|
||||||
|
var delegateObject: MVMCoreUIDelegateObject?
|
||||||
|
var webViewHeight: NSLayoutConstraint?
|
||||||
|
var dynamicHeight: Bool = true
|
||||||
|
|
||||||
|
|
||||||
|
override open func setupView() {
|
||||||
|
super.setupView()
|
||||||
|
createWebView(messageHandler: mvmWebViewMessageHandler)
|
||||||
|
setupOverLayer()
|
||||||
|
pinSpinnerView()
|
||||||
|
|
||||||
|
//init height for loading spinner
|
||||||
|
webViewHeight = webView?.heightAnchor.constraint(equalToConstant: 44)
|
||||||
|
webViewHeight?.isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func createWebView(messageHandler: String?) {
|
||||||
|
let wkUserController = WKUserContentController()
|
||||||
|
if let messageHandlerName = messageHandler {
|
||||||
|
wkUserController.add(self, name: messageHandlerName)
|
||||||
|
}
|
||||||
|
let wkConfig = WKWebViewConfiguration()
|
||||||
|
wkConfig.userContentController = wkUserController
|
||||||
|
let webView = WKWebView(frame: .zero, configuration: wkConfig)
|
||||||
|
webView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
webView.uiDelegate = self
|
||||||
|
webView.navigationDelegate = self
|
||||||
|
self.webView = webView
|
||||||
|
addSubview(webView)
|
||||||
|
NSLayoutConstraint.constraintPinSubview(toSuperview: webView)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
|
override open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
|
|
||||||
|
//store the previous webview properties
|
||||||
|
let previousHtmlString = webviewModel?.htmlString
|
||||||
|
let previousURL = webView?.url
|
||||||
|
|
||||||
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
self.delegateObject = delegateObject
|
||||||
|
var webViewHeightConstant: CGFloat = 44
|
||||||
|
if let height = webviewModel?.height {
|
||||||
|
webViewHeightConstant = height
|
||||||
|
webViewHeight?.constant = height
|
||||||
|
dynamicHeight = false
|
||||||
|
}
|
||||||
|
if let url = webviewModel?.url {
|
||||||
|
if let previousUrl = previousURL, url == previousUrl {
|
||||||
|
//dont load the new
|
||||||
|
} else {
|
||||||
|
webView?.stopLoading()
|
||||||
|
webView?.load(URLRequest(url: url))
|
||||||
|
webViewHeight?.constant = webViewHeightConstant
|
||||||
|
overLayer.isHidden = false
|
||||||
|
loadingSpinner.resumeSpinner()
|
||||||
|
}
|
||||||
|
} else if let htmlString = webviewModel?.htmlString {
|
||||||
|
if let previousHTML = previousHtmlString, previousHTML == htmlString {
|
||||||
|
//dont load the new html since they are the same html string as preivous
|
||||||
|
} else {
|
||||||
|
webView?.stopLoading()
|
||||||
|
webViewHeight?.constant = webViewHeightConstant
|
||||||
|
webView?.loadHTMLString(htmlString, baseURL: nil)
|
||||||
|
overLayer.isHidden = false
|
||||||
|
loadingSpinner.resumeSpinner()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let borderColor = webviewModel?.borderColor?.cgColor {
|
||||||
|
webView?.layer.borderWidth = 1.0
|
||||||
|
webView?.layer.borderColor = borderColor
|
||||||
|
} else {
|
||||||
|
webView?.layer.borderWidth = 0.0
|
||||||
|
webView?.layer.borderColor = UIColor.clear.cgColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func pinSpinnerView() {
|
||||||
|
addSubview(loadingSpinner)
|
||||||
|
// Setup spinner.
|
||||||
|
loadingSpinner.clipsToBounds = true
|
||||||
|
loadingSpinner.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
|
loadingSpinner.heightAnchor.constraint(equalToConstant: 44.0).isActive = true
|
||||||
|
loadingSpinner.widthAnchor.constraint(equalToConstant: 44.0).isActive = true
|
||||||
|
loadingSpinner.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
|
||||||
|
loadingSpinner.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupOverLayer() {
|
||||||
|
addSubview(overLayer)
|
||||||
|
overLayer.backgroundColor = .white
|
||||||
|
NSLayoutConstraint.constraintPinSubview(toSuperview: overLayer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - WKUIDelegate
|
||||||
|
extension WebView : WKUIDelegate {
|
||||||
|
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||||
|
// hide loading
|
||||||
|
overLayer.isHidden = true
|
||||||
|
loadingSpinner.pause()
|
||||||
|
|
||||||
|
//update webview's heigth when webview is ready
|
||||||
|
if !dynamicHeight {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
/* was using "document.readyState" to check the state, while evaluateJavaScript "document.readyState",only works when webview contains userscrpt.otherwise, it would return WKErrorDomain Code=4 "A JavaScript exception occurred".
|
||||||
|
so webView.isLoading to check load finished state
|
||||||
|
*/
|
||||||
|
if !webView.isLoading {
|
||||||
|
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
|
||||||
|
guard let self = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if let height = result as? CGFloat {
|
||||||
|
self.webViewHeight?.constant = height
|
||||||
|
} else {
|
||||||
|
//if failed to get height from javascript, using scrollview.contensize's height
|
||||||
|
let scrollHeight = self.webView?.scrollView.contentSize.height
|
||||||
|
self.webViewHeight?.constant = scrollHeight ?? 44
|
||||||
|
}
|
||||||
|
self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
|
||||||
|
//actually no error handle page show in webview. We can handle the error display view by our self.
|
||||||
|
//or stop loading by default
|
||||||
|
overLayer.isHidden = true
|
||||||
|
loadingSpinner.pause()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - WKNavigationDelegate
|
||||||
|
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)
|
||||||
|
decisionHandler(.cancel)
|
||||||
|
} else {
|
||||||
|
decisionHandler(.allow)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - WKScriptMessageHandler
|
||||||
|
extension WebView: WKScriptMessageHandler {
|
||||||
|
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
|
||||||
|
if message.name == mvmWebViewMessageHandler, let text = message.body as? String {
|
||||||
|
/*
|
||||||
|
receiving JavaScript func webkit.messageHandlers.{callHandler}.postMessage(body);
|
||||||
|
if body is string, will decode to actionmodel.
|
||||||
|
use legacy MVMCoreActionHanlder handleAction method for now
|
||||||
|
*/
|
||||||
|
if let data = text.data(using: .utf8) {
|
||||||
|
do {
|
||||||
|
let actionMap = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
|
||||||
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: nil, delegateObject: self.delegateObject)
|
||||||
|
} catch {
|
||||||
|
//actionModel should report error when actionhandler is finshed with actionmodel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
50
MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift
Normal file
50
MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// WebviewModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Kruthika KP on 09/03/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers public class WebViewModel: MoleculeModelProtocol {
|
||||||
|
public static var identifier: String = "webview"
|
||||||
|
public var moleculeName: String = WebViewModel.identifier
|
||||||
|
public var backgroundColor: Color?
|
||||||
|
public var url: URL?
|
||||||
|
public var htmlString: String?
|
||||||
|
public var height: CGFloat?
|
||||||
|
public var borderColor: Color?
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey{
|
||||||
|
case moleculeName
|
||||||
|
case backgroundColor
|
||||||
|
case url
|
||||||
|
case htmlString
|
||||||
|
case height
|
||||||
|
case borderColor
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
url = try typeContainer.decodeIfPresent(URL.self, forKey: .url)
|
||||||
|
htmlString = try typeContainer.decodeIfPresent(String.self, forKey: .htmlString)
|
||||||
|
if url == nil, htmlString == nil {
|
||||||
|
throw ModelRegistry.Error.decoderErrorModelNotMapped
|
||||||
|
}
|
||||||
|
height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height)
|
||||||
|
borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
try container.encodeIfPresent(url, forKey: .url)
|
||||||
|
try container.encodeIfPresent(htmlString, forKey: .htmlString)
|
||||||
|
try container.encodeIfPresent(height, forKey: .height)
|
||||||
|
try container.encodeIfPresent(borderColor, forKey: .borderColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -80,6 +80,7 @@ import Foundation
|
|||||||
MoleculeObjectMapping.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self)
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self)
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self)
|
||||||
|
MoleculeObjectMapping.shared()?.register(viewClass: WebView.self, viewModelClass: WebViewModel.self)
|
||||||
|
|
||||||
// Horizontal Combination Molecules
|
// Horizontal Combination Molecules
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self)
|
||||||
@ -147,6 +148,7 @@ import Foundation
|
|||||||
MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerShort.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerShortModel.self)
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnTextWithWhitespaceDividerTall.self, viewModelClass: ListOneColumnTextWithWhitespaceDividerTallModel.self)
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextDividerSubsection.self, viewModelClass: ListOneColumnFullWidthTextDividerSubsectionModel.self)
|
||||||
|
MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnInternationalDataDivider.self, viewModelClass: ListThreeColumnInternationalDataDividerModel.self)
|
||||||
|
|
||||||
// Designed Headers
|
// Designed Headers
|
||||||
MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self)
|
MoleculeObjectMapping.shared()?.register(viewClass: HeadersH2NoButtonsBodyText.self, viewModelClass: HeadersH2NoButtonsBodyTextModel.self)
|
||||||
|
|||||||
@ -0,0 +1,66 @@
|
|||||||
|
//
|
||||||
|
// ListThreeColumnInternationalDataDivider.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Kruthika KP on 31/03/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers open class ListThreeColumnInternationalDataDivider: TableViewCell {
|
||||||
|
|
||||||
|
//-----------------------------------------------------
|
||||||
|
// MARK: - Outlets
|
||||||
|
//-----------------------------------------------------
|
||||||
|
let leftLabel = Label.createLabelBoldBodySmall(true)
|
||||||
|
let centerLabel = Label.createLabelBoldBodySmall(true)
|
||||||
|
let rightLabel = Label.createLabelBoldBodySmall(true)
|
||||||
|
var stack: Stack<StackModel>
|
||||||
|
|
||||||
|
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
|
stack = Stack<StackModel>.createStack(with: [(view: leftLabel, model: StackItemModel(percent: 30, horizontalAlignment: .leading)),
|
||||||
|
(view: centerLabel, model: StackItemModel(percent: 50, horizontalAlignment: .leading)),
|
||||||
|
(view: rightLabel, model: StackItemModel(percent: 20, horizontalAlignment: .leading))],
|
||||||
|
axis: .horizontal)
|
||||||
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
public required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------
|
||||||
|
// MARK: - MFViewProtocol
|
||||||
|
//-----------------------------------------------------
|
||||||
|
open override func setupView() {
|
||||||
|
super.setupView()
|
||||||
|
addMolecule(stack)
|
||||||
|
stack.restack()
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------
|
||||||
|
// MARK: - ModelMoleculeViewProtocol
|
||||||
|
//-----------------------------------------------------
|
||||||
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
guard let model = model as? ListThreeColumnInternationalDataDividerModel else { return }
|
||||||
|
leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
|
||||||
|
centerLabel.set(with: model.centerLabel, delegateObject, additionalData)
|
||||||
|
rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
|
||||||
|
}
|
||||||
|
|
||||||
|
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||||
|
return 121
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------
|
||||||
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
|
//-----------------------------------------------------
|
||||||
|
override open func reset() {
|
||||||
|
super.reset()
|
||||||
|
leftLabel.styleBoldBodySmall(true)
|
||||||
|
centerLabel.styleBoldBodySmall(true)
|
||||||
|
rightLabel.styleBoldBodySmall(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// ListThreeColumnInternationalDataDividerModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Kruthika KP on 31/03/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public class ListThreeColumnInternationalDataDividerModel: ListItemModel, MoleculeModelProtocol {
|
||||||
|
public static var identifier: String = "list3CIntDataDiv"
|
||||||
|
public var leftLabel: LabelModel
|
||||||
|
public var centerLabel: LabelModel
|
||||||
|
public var rightLabel: LabelModel
|
||||||
|
|
||||||
|
public init (leftLabel: LabelModel, centerLabel: LabelModel, rightLabel: LabelModel) {
|
||||||
|
self.leftLabel = leftLabel
|
||||||
|
self.centerLabel = centerLabel
|
||||||
|
self.rightLabel = rightLabel
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
override public func setDefaults() {
|
||||||
|
super.setDefaults()
|
||||||
|
style = "tallDivider"
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case moleculeName
|
||||||
|
case leftLabel
|
||||||
|
case centerLabel
|
||||||
|
case rightLabel
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel)
|
||||||
|
centerLabel = try typeContainer.decode(LabelModel.self, forKey: .centerLabel)
|
||||||
|
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
|
||||||
|
try super.init(from: decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func encode(to encoder: Encoder) throws {
|
||||||
|
try super.encode(to: encoder)
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
|
try container.encode(leftLabel, forKey: .leftLabel)
|
||||||
|
try container.encode(centerLabel, forKey: .centerLabel)
|
||||||
|
try container.encode(rightLabel, forKey: .rightLabel)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -48,6 +48,9 @@ import MVMCore
|
|||||||
if let validator = delegate?.formValidator {
|
if let validator = delegate?.formValidator {
|
||||||
validator.delegate = delegate
|
validator.delegate = delegate
|
||||||
validator.insert(item)
|
validator.insert(item)
|
||||||
|
|
||||||
|
// TODO: Temporary hacks, rewrite architecture to support this.
|
||||||
|
_ = validator.validate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import Foundation
|
|||||||
|
|
||||||
public class RuleRequiredModel: RulesProtocol {
|
public class RuleRequiredModel: RulesProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "required"
|
public static var identifier: String = "allRequired"
|
||||||
public var type: String = RuleRequiredModel.identifier
|
public var type: String = RuleRequiredModel.identifier
|
||||||
public var fields: [String]
|
public var fields: [String]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user