Flip value because it kept going true when nothing changed

This commit is contained in:
Kevin G Christiano 2020-03-24 11:01:08 -04:00
parent f0870bda5d
commit a1d43e338c
2 changed files with 9 additions and 8 deletions

View File

@ -27,7 +27,7 @@ import UIKit
public var formValidator: FormValidator? public var formValidator: FormValidator?
public var needsUpdateUI = true public var needsUpdateUI = false
private var observingForResponses = false private var observingForResponses = false
private var initialLoadFinished = false private var initialLoadFinished = false
private var previousScreenSize = CGSize.zero private var previousScreenSize = CGSize.zero
@ -36,7 +36,7 @@ import UIKit
/// Checks if the screen width has changed /// Checks if the screen width has changed
open func screenSizeChanged() -> Bool { open func screenSizeChanged() -> Bool {
return MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1) return !MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
} }
// MARK: - Response handling // MARK: - Response handling
@ -276,17 +276,18 @@ import UIKit
open override func viewDidLayoutSubviews() { open override func viewDidLayoutSubviews() {
// Add to fix a constraint bug where the width is zero and things get messed up. // Add to fix a constraint bug where the width is zero and things get messed up.
guard isViewLoaded, guard isViewLoaded, view.bounds.width > 1 else {
view.bounds.width > 1 else { super.viewDidLayoutSubviews()
super.viewDidLayoutSubviews() return
return
} }
if needsUpdateUI || screenSizeChanged() { if needsUpdateUI || screenSizeChanged() {
updateViews() updateViews()
needsUpdateUI = false needsUpdateUI = false
} }
previousScreenSize = view.bounds.size; previousScreenSize = view.bounds.size;
super.viewDidLayoutSubviews() super.viewDidLayoutSubviews()
} }

View File

@ -273,9 +273,9 @@ import UIKit
if moleculeLayoutUpdated || heightChanged { if moleculeLayoutUpdated || heightChanged {
delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self) delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
setNeedsDisplay()
} }
setNeedsDisplay()
layoutIfNeeded() layoutIfNeeded()
} }
} }