Merge branch 'bugfix/update_after_load_image' into 'develop'

Bugfix/update after load image

See merge request BPHV_MIPS/mvm_core_ui!100
This commit is contained in:
Pfeil, Scott Robert 2019-07-24 12:50:48 -04:00
commit 9f3b6e5fe9
3 changed files with 19 additions and 0 deletions

View File

@ -22,6 +22,8 @@ import UIKit
var imageWidth: CGFloat?
var imageHeight: CGFloat?
var delegateObject: MVMCoreUIDelegateObject?
// For keeping track of current state.
private var edges: UIRectEdge?
private var spinnerHeight: CGFloat?
@ -190,6 +192,7 @@ import UIKit
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
self.delegateObject = delegateObject
if let accessibilityString = json?.optionalStringForKey("accessibilityText") {
imageView.accessibilityLabel = accessibilityString
imageView.accessibilityTraits = .staticText
@ -223,6 +226,7 @@ import UIKit
self?.loadingSpinnerHeightConstraint?.constant = 0
self?.loadingSpinner.pause()
self?.addConstraints(width: width, height: height, size: image?.size)
self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated?(self!)
completionHandler(image,data,isFallbackImage)
})}

View File

@ -12,4 +12,8 @@
/// returns a module for the corresponding module name.
- (nullable NSDictionary *)getModuleWithName:(nullable NSString *)name;
@optional
/// Notifies the delegate that the molecule layout update. Should be called when the layout may change due to an async method.
- (void)moleculeLayoutUpdated:(nonnull UIView <MVMCoreUIMoleculeViewProtocol>*)molecule;
@end

View File

@ -106,6 +106,17 @@ open class MoleculeListTemplate: ThreeLayerTableViewController {
return loadObject?.requestParameters?.modules
}
// MARK: - MoleculeDelegateProtocol
open override func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
if let tableView = tableView {
let point = molecule.convert(molecule.bounds.origin, to: tableView)
if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
tableView.beginUpdates()
tableView.endUpdates()
}
}
}
// MARK: - Convenience
/// Returns the (identifier, class) of the molecule for the given map.
func getMoleculeInfo(with molecule: [AnyHashable: Any]?) -> (identifier: String, class: AnyClass, molecule: [AnyHashable: Any])? {