image molecule protocol
This commit is contained in:
parent
680f8fc4aa
commit
3564d993e1
@ -191,6 +191,28 @@ import UIKit
|
|||||||
imageView.setContentHuggingPriority(UILayoutPriority.defaultLow, for: NSLayoutConstraint.Axis.vertical)
|
imageView.setContentHuggingPriority(UILayoutPriority.defaultLow, for: NSLayoutConstraint.Axis.vertical)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override func updateView(_ size: CGFloat) {
|
||||||
|
super.updateView(size)
|
||||||
|
let width = size.rounded()
|
||||||
|
if let imageName = json?.optionalStringForKey("image"), shouldLoadImage(withName: imageName, width: width) {
|
||||||
|
imageView.image = nil
|
||||||
|
imageView.animatedImage = nil
|
||||||
|
loadImage(withName: imageName, format: json?.optionalStringForKey("imageFormat"), width: NSNumber(value: Double(width)), height: nil)
|
||||||
|
loadImage(withName: imageName, format: json?.optionalStringForKey("imageFormat"), width: NSNumber(value: Double(width)), height: nil, customFallbackImage: json?.optionalStringForKey("fallbackImage"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - MVMCoreUIMoleculeViewProtocol functions
|
||||||
|
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegate: NSObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
|
super.setWithJSON(json, delegate: delegate, additionalData: additionalData)
|
||||||
|
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {
|
||||||
|
backgroundColor = UIColor.mfGet(forHex: backgroundColorString)
|
||||||
|
}
|
||||||
|
if let accessibilityString = json?.optionalStringForKey("accessibilityText") {
|
||||||
|
imageView.accessibilityLabel = accessibilityString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - load functions
|
// MARK: - load functions
|
||||||
@objc public func loadImage(withName imageName: String?, format: String?, width: NSNumber?, height: NSNumber?, customFallbackImage: String?, completionHandler: @escaping MVMCoreGetImageBlock) {
|
@objc public func loadImage(withName imageName: String?, format: String?, width: NSNumber?, height: NSNumber?, customFallbackImage: String?, completionHandler: @escaping MVMCoreGetImageBlock) {
|
||||||
MVMCoreDispatchUtility.performBlock(onMainThread: { [unowned self] in
|
MVMCoreDispatchUtility.performBlock(onMainThread: { [unowned self] in
|
||||||
|
|||||||
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
@interface MFView : UIView <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
@interface MFView : UIView <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||||
|
|
||||||
|
@property (nullable, nonatomic, strong) NSDictionary *json;
|
||||||
|
|
||||||
// Called in the initialization functions. Can setup ui here.
|
// Called in the initialization functions. Can setup ui here.
|
||||||
- (void)setupView;
|
- (void)setupView;
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,7 @@
|
|||||||
#pragma mark - MVMCoreUIMoleculeViewProtocol
|
#pragma mark - MVMCoreUIMoleculeViewProtocol
|
||||||
|
|
||||||
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
|
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
|
||||||
|
self.json = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user