Merge branch 'feature/load_image_cleanup' into 'develop'
remove legacy number See merge request BPHV_MIPS/mvm_core_ui!661
This commit is contained in:
commit
89b8a47f71
@ -234,7 +234,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Constrains the image view to be the size provided. Used to size it to the image to fix aspect fit defect.
|
// Constrains the image view to be the size provided. Used to size it to the image to fix aspect fit defect.
|
||||||
func addConstraints(width: NSNumber?, height: NSNumber?, size: CGSize?) {
|
func addConstraints(width: CGFloat?, height: CGFloat?, size: CGSize?) {
|
||||||
|
|
||||||
widthConstraint?.isActive = false
|
widthConstraint?.isActive = false
|
||||||
heightConstraint?.isActive = false
|
heightConstraint?.isActive = false
|
||||||
@ -242,15 +242,15 @@
|
|||||||
guard addSizeConstraintsForAspectRatio else { return }
|
guard addSizeConstraintsForAspectRatio else { return }
|
||||||
|
|
||||||
if let width = width, let height = height {
|
if let width = width, let height = height {
|
||||||
setHeight(height.cgfloat())
|
setHeight(height)
|
||||||
setWidth(width.cgfloat())
|
setWidth(width)
|
||||||
} else if let width = width, let size = size {
|
} else if let width = width, let size = size {
|
||||||
setWidth(width.cgfloat())
|
setWidth(width)
|
||||||
heightConstraint = imageView.heightAnchor.constraint(equalTo: imageView.widthAnchor, multiplier: size.height/size.width)
|
heightConstraint = imageView.heightAnchor.constraint(equalTo: imageView.widthAnchor, multiplier: size.height/size.width)
|
||||||
heightConstraint?.priority = UILayoutPriority(rawValue: 900)
|
heightConstraint?.priority = UILayoutPriority(rawValue: 900)
|
||||||
heightConstraint?.isActive = true
|
heightConstraint?.isActive = true
|
||||||
} else if let height = height, let size = size {
|
} else if let height = height, let size = size {
|
||||||
setHeight(height.cgfloat())
|
setHeight(height)
|
||||||
widthConstraint = imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor, multiplier: size.width/size.height)
|
widthConstraint = imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor, multiplier: size.width/size.height)
|
||||||
widthConstraint?.priority = UILayoutPriority(rawValue: 900)
|
widthConstraint?.priority = UILayoutPriority(rawValue: 900)
|
||||||
widthConstraint?.isActive = true
|
widthConstraint?.isActive = true
|
||||||
@ -288,7 +288,7 @@
|
|||||||
if shouldLoadImage(withName: imageModel.image, width: width, height: height) {
|
if shouldLoadImage(withName: imageModel.image, width: width, height: height) {
|
||||||
imageView.image = nil
|
imageView.image = nil
|
||||||
imageView.animatedImage = nil
|
imageView.animatedImage = nil
|
||||||
loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: imageModel.fallbackImage, localBundle: imageModel.localBundle)
|
loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width, height: height, customFallbackImage: imageModel.fallbackImage, localBundle: imageModel.localBundle)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let contentMode = imageModel.contentMode {
|
if let contentMode = imageModel.contentMode {
|
||||||
@ -309,13 +309,13 @@
|
|||||||
// MARK: - Load Methods
|
// MARK: - Load Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public func loadImage(withName imageName: String?, format: String? = nil, width: NSNumber? = nil, height: NSNumber? = nil, customFallbackImage: String? = nil, allowServerParameters: Bool = false, localBundle: Bundle? = nil, completionHandler: MVMCoreGetImageBlock? = nil) {
|
public func loadImage(withName imageName: String?, format: String? = nil, width: CGFloat? = nil, height: CGFloat? = nil, customFallbackImage: String? = nil, allowServerParameters: Bool = false, localBundle: Bundle? = nil, completionHandler: MVMCoreGetImageBlock? = nil) {
|
||||||
|
|
||||||
let completionBlock = completionHandler ?? defaultCompletionBlock()
|
let completionBlock = completionHandler ?? defaultCompletionBlock()
|
||||||
MVMCoreDispatchUtility.performBlock(onMainThread: { [unowned self] in
|
MVMCoreDispatchUtility.performBlock(onMainThread: { [unowned self] in
|
||||||
self.currentImageName = imageName
|
self.currentImageName = imageName
|
||||||
self.currentImageWidth = width?.cgfloat()
|
self.currentImageWidth = width
|
||||||
self.currentImageHeight = height?.cgfloat()
|
self.currentImageHeight = height
|
||||||
if MVMCoreCache.isHostedImage(imageName) {
|
if MVMCoreCache.isHostedImage(imageName) {
|
||||||
self.loadingSpinner.resumeSpinnerAfterDelay()
|
self.loadingSpinner.resumeSpinnerAfterDelay()
|
||||||
self.loadingSpinnerHeightConstraint?.constant = self.spinnerHeight
|
self.loadingSpinnerHeightConstraint?.constant = self.spinnerHeight
|
||||||
@ -338,9 +338,9 @@
|
|||||||
let fallbackImageName = customFallbackImage ?? MVMCoreUIUtility.localizedImageName("fallback")
|
let fallbackImageName = customFallbackImage ?? MVMCoreUIUtility.localizedImageName("fallback")
|
||||||
if let format = format, format.lowercased().contains("gif") {
|
if let format = format, format.lowercased().contains("gif") {
|
||||||
// Gifs aren't supported by default and need special handling
|
// Gifs aren't supported by default and need special handling
|
||||||
MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock)
|
MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: Int(width ?? 0), useHeight: height != nil, heightForS7: Int(height ?? 0), format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock)
|
||||||
} else {
|
} else {
|
||||||
MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock)
|
MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: Int(width ?? 0), useHeight: height != nil, heightForS7: Int(height ?? 0), format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -409,6 +409,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func loadImage(withName imageName: String?, format: String?, width: NSNumber?, height: NSNumber?, customFallbackImage: String?, completionHandler: @escaping MVMCoreGetImageBlock) {
|
public func loadImage(withName imageName: String?, format: String?, width: NSNumber?, height: NSNumber?, customFallbackImage: String?, completionHandler: @escaping MVMCoreGetImageBlock) {
|
||||||
loadImage(withName: imageName, format: format, width: width, height: height, customFallbackImage: customFallbackImage, allowServerParameters: false, completionHandler: completionHandler)
|
loadImage(withName: imageName, format: format, width: width?.cgfloat(), height: height?.cgfloat(), customFallbackImage: customFallbackImage, allowServerParameters: false, completionHandler: completionHandler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user