Skip to content

Commit a994a97

Browse files
authored
Removed height constant
1 parent 673be3f commit a994a97

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

ExponeaSDK/ExponeaSDK/Classes/InAppContentBlocks/StaticInAppContentBlockView.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ public final class StaticInAppContentBlockView: UIView, WKNavigationDelegate {
7171
)
7272
return
7373
}
74-
self.replacePlaceholder(inputView: self, loadedInAppContentBlocksView: self.webview, height: height.height ) {
75-
self.heightCompletion?(Int(height.height))
74+
let usableHeight = height.height - calculator.defaultPadding
75+
self.replacePlaceholder(inputView: self, loadedInAppContentBlocksView: self.webview, height: usableHeight) {
76+
self.heightCompletion?(Int(usableHeight))
7677
self.prepareContentReadyState(true)
7778
guard let message = self.assignedMessage else {
7879
return
@@ -152,16 +153,16 @@ public final class StaticInAppContentBlockView: UIView, WKNavigationDelegate {
152153
}
153154
loadedInAppContentBlocksView.removeFromSuperview()
154155
inputView.addSubview(loadedInAppContentBlocksView)
155-
loadedInAppContentBlocksView.topAnchor.constraint(equalTo: inputView.topAnchor, constant: 5).isActive = true
156-
loadedInAppContentBlocksView.leadingAnchor.constraint(equalTo: inputView.leadingAnchor, constant: 5).isActive = true
157-
loadedInAppContentBlocksView.trailingAnchor.constraint(equalTo: inputView.trailingAnchor, constant: -5).isActive = true
156+
loadedInAppContentBlocksView.topAnchor.constraint(equalTo: inputView.topAnchor).isActive = true
157+
loadedInAppContentBlocksView.leadingAnchor.constraint(equalTo: inputView.leadingAnchor).isActive = true
158+
loadedInAppContentBlocksView.trailingAnchor.constraint(equalTo: inputView.trailingAnchor).isActive = true
158159
if self.height != nil {
159160
self.height?.constant = height
160161
} else {
161162
self.height = loadedInAppContentBlocksView.heightAnchor.constraint(equalToConstant: height)
162163
self.height?.isActive = true
163164
}
164-
loadedInAppContentBlocksView.bottomAnchor.constraint(equalTo: inputView.bottomAnchor, constant: -5).isActive = true
165+
loadedInAppContentBlocksView.bottomAnchor.constraint(equalTo: inputView.bottomAnchor).isActive = true
165166
loadedInAppContentBlocksView.sizeToFit()
166167
loadedInAppContentBlocksView.layoutIfNeeded()
167168
UIView.animate(withDuration: duration) {

ExponeaSDK/ExponeaSDK/Classes/InAppContentBlocks/WKWebViewHeightCalculator.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import UIKit
1313
public final class WKWebViewHeightCalculator: WKWebView, WKNavigationDelegate {
1414

1515
// MARK: - Properties
16+
var defaultPadding: CGFloat = 20
1617
var heightUpdate: TypeBlock<CalculatorData>?
1718
var height: CGFloat?
1819
var id: String = ""
@@ -32,7 +33,7 @@ public final class WKWebViewHeightCalculator: WKWebView, WKNavigationDelegate {
3233
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void
3334
) {
3435
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
35-
self.heightUpdate?(.init(height: webView.scrollView.contentSize.height + 25, placeholderId: self.id))
36+
self.heightUpdate?(.init(height: webView.scrollView.contentSize.height + self.defaultPadding, placeholderId: self.id))
3637
}
3738
decisionHandler(.allow)
3839
}

0 commit comments

Comments
 (0)