height changes minor
This commit is contained in:
parent
10755d888f
commit
84ecaa9a81
@ -25,8 +25,8 @@ import UIKit
|
||||
var delegateObject: MVMCoreUIDelegateObject?
|
||||
|
||||
// For keeping track of current state.
|
||||
private var edges: UIRectEdge?
|
||||
private var spinnerHeight: CGFloat?
|
||||
private var edges = UIRectEdge(rawValue: 0)
|
||||
private var spinnerHeight: CGFloat = 0
|
||||
private var currentImageWidth: CGFloat?
|
||||
private var currentImageHeight: CGFloat?
|
||||
private var currentImageName: String?
|
||||
@ -39,7 +39,6 @@ import UIKit
|
||||
|
||||
// The default is an image that is centered with no edges pinned. So it will take the size of the content and fill as needed.
|
||||
public init() {
|
||||
edges = UIRectEdge(rawValue: 0)
|
||||
super.init(frame: .zero)
|
||||
}
|
||||
|
||||
@ -93,10 +92,7 @@ import UIKit
|
||||
pinView(toSuperView: imageView)
|
||||
|
||||
// Setup edges constraints
|
||||
if edges == nil {
|
||||
edges = UIRectEdge(rawValue: 0)
|
||||
}
|
||||
pinEdges(edges!)
|
||||
pinEdges(edges)
|
||||
|
||||
// Setup spinner.
|
||||
loadingSpinner.clipsToBounds = true
|
||||
@ -185,7 +181,8 @@ import UIKit
|
||||
let widthWillChange = !MVMCoreGetterUtility.cgfequal(widthConstraint?.constant ?? 0, width ?? 0)
|
||||
let heightWillChange = !MVMCoreGetterUtility.cgfequal(heightConstraint?.constant ?? 0, height ?? 0)
|
||||
let sizeWillChange = (width == nil || height == nil) && !(size?.equalTo(imageView.image?.size ?? CGSize.zero) ?? false)
|
||||
return widthWillChange || heightWillChange || sizeWillChange
|
||||
let heightChangeFromSpinner = ((height ?? size?.height) ?? 0) < loadingSpinnerHeightConstraint?.constant ?? CGFloat.leastNormalMagnitude
|
||||
return widthWillChange || heightWillChange || sizeWillChange || heightChangeFromSpinner
|
||||
}
|
||||
|
||||
// Constrains the image view to be the size provided. Used to size it to the image to fix aspect fit defect.
|
||||
@ -252,9 +249,9 @@ import UIKit
|
||||
self.currentImageName = imageName
|
||||
self.currentImageWidth = width?.cgfloat()
|
||||
self.currentImageHeight = height?.cgfloat()
|
||||
self.loadingSpinner.resumeSpinnerAfterDelay()
|
||||
if let height = self.spinnerHeight {
|
||||
self.loadingSpinnerHeightConstraint?.constant = height
|
||||
if MVMCoreCache.isHostedImage(imageName) {
|
||||
self.loadingSpinner.resumeSpinnerAfterDelay()
|
||||
self.loadingSpinnerHeightConstraint?.constant = self.spinnerHeight
|
||||
}
|
||||
|
||||
let finishedLoadingBlock: MVMCoreGetImageBlock = {[weak self] (image, data, isFallbackImage) in MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in
|
||||
@ -262,10 +259,10 @@ import UIKit
|
||||
return
|
||||
}
|
||||
self?.isFallbackImage = isFallbackImage
|
||||
self?.loadingSpinnerHeightConstraint?.constant = 0
|
||||
self?.loadingSpinner.pause()
|
||||
let layoutWillChange = self?.layoutWillChange(width: self?.currentImageWidth, height: self?.currentImageHeight, size: image?.size) ?? false
|
||||
self?.addConstraints(width: width, height: height, size: image?.size)
|
||||
self?.loadingSpinnerHeightConstraint?.constant = 0
|
||||
if layoutWillChange {
|
||||
self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated?(self!)
|
||||
}
|
||||
@ -287,9 +284,8 @@ import UIKit
|
||||
MVMCoreDispatchUtility.performBlock(onMainThread: { [unowned self] in
|
||||
self.currentImageName = imageName
|
||||
self.loadingSpinner.resumeSpinnerAfterDelay()
|
||||
if let height = self.spinnerHeight {
|
||||
self.loadingSpinnerHeightConstraint?.constant = height
|
||||
}
|
||||
self.loadingSpinnerHeightConstraint?.constant = self.spinnerHeight
|
||||
|
||||
MVMCoreCache.shared()?.getCroppedImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, finalRect: cropRect, flipImage: flipImage, localFallbackImageName: customFallbackImage ?? MVMCoreUIUtility.localizedImageName("fallback"), completionHandler: { [weak self] (image, data, isFallBackImage) in
|
||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||
guard let image = image, let loadingImageName = self?.currentImageName, loadingImageName == imageName else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user