update based on Scott's comment
This commit is contained in:
parent
4abfeef11a
commit
0edc7a8f00
@ -60,8 +60,9 @@ import WebKit
|
|||||||
|
|
||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
self.delegateObject = delegateObject
|
self.delegateObject = delegateObject
|
||||||
|
var webViewHeightConstant: CGFloat = 44
|
||||||
if let height = webviewModel?.height {
|
if let height = webviewModel?.height {
|
||||||
|
webViewHeightConstant = height
|
||||||
webViewHeight?.constant = height
|
webViewHeight?.constant = height
|
||||||
dynamicHeight = false
|
dynamicHeight = false
|
||||||
}
|
}
|
||||||
@ -71,7 +72,7 @@ import WebKit
|
|||||||
} else {
|
} else {
|
||||||
webView?.stopLoading()
|
webView?.stopLoading()
|
||||||
webView?.load(URLRequest(url: url))
|
webView?.load(URLRequest(url: url))
|
||||||
webViewHeight?.constant = 44
|
webViewHeight?.constant = webViewHeightConstant
|
||||||
overLayer.isHidden = false
|
overLayer.isHidden = false
|
||||||
loadingSpinner.resumeSpinner()
|
loadingSpinner.resumeSpinner()
|
||||||
}
|
}
|
||||||
@ -80,7 +81,7 @@ import WebKit
|
|||||||
//dont load the new html since they are the same html string as preivous
|
//dont load the new html since they are the same html string as preivous
|
||||||
} else {
|
} else {
|
||||||
webView?.stopLoading()
|
webView?.stopLoading()
|
||||||
webViewHeight?.constant = 44
|
webViewHeight?.constant = webViewHeightConstant
|
||||||
webView?.loadHTMLString(htmlString, baseURL: nil)
|
webView?.loadHTMLString(htmlString, baseURL: nil)
|
||||||
overLayer.isHidden = false
|
overLayer.isHidden = false
|
||||||
loadingSpinner.resumeSpinner()
|
loadingSpinner.resumeSpinner()
|
||||||
@ -106,7 +107,6 @@ import WebKit
|
|||||||
loadingSpinner.widthAnchor.constraint(equalToConstant: 44.0).isActive = true
|
loadingSpinner.widthAnchor.constraint(equalToConstant: 44.0).isActive = true
|
||||||
loadingSpinner.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
|
loadingSpinner.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
|
||||||
loadingSpinner.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
loadingSpinner.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||||
loadingSpinner.resumeSpinner()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupOverLayer() {
|
func setupOverLayer() {
|
||||||
|
|||||||
@ -16,7 +16,6 @@ import Foundation
|
|||||||
public var htmlString: String?
|
public var htmlString: String?
|
||||||
public var height: CGFloat?
|
public var height: CGFloat?
|
||||||
public var borderColor: Color?
|
public var borderColor: Color?
|
||||||
public var buttonMap: [String: ButtonModel]?
|
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey{
|
private enum CodingKeys: String, CodingKey{
|
||||||
case moleculeName
|
case moleculeName
|
||||||
@ -24,7 +23,6 @@ import Foundation
|
|||||||
case url
|
case url
|
||||||
case htmlString
|
case htmlString
|
||||||
case height
|
case height
|
||||||
case buttonMap
|
|
||||||
case borderColor
|
case borderColor
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,8 +31,10 @@ import Foundation
|
|||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
url = try typeContainer.decodeIfPresent(URL.self, forKey: .url)
|
url = try typeContainer.decodeIfPresent(URL.self, forKey: .url)
|
||||||
htmlString = try typeContainer.decodeIfPresent(String.self, forKey: .htmlString)
|
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)
|
height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height)
|
||||||
buttonMap = try typeContainer.decodeIfPresent([String: ButtonModel].self, forKey: .buttonMap)
|
|
||||||
borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor)
|
borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user