create image model
This commit is contained in:
parent
dde5f1d1a4
commit
28a04218f9
@ -50,6 +50,7 @@
|
|||||||
9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */; };
|
9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */; };
|
||||||
9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */; };
|
9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */; };
|
||||||
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; };
|
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; };
|
||||||
|
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; };
|
||||||
9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; };
|
9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; };
|
||||||
946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; };
|
946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; };
|
||||||
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
|
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
|
||||||
@ -268,6 +269,7 @@
|
|||||||
9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgressModel.swift; sourceTree = "<group>"; };
|
9445890D2385C3F800DE9FD4 /* MultiProgressModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgressModel.swift; sourceTree = "<group>"; };
|
||||||
9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretViewModel.swift; sourceTree = "<group>"; };
|
9445891E2385D2E900DE9FD4 /* CaretViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaretViewModel.swift; sourceTree = "<group>"; };
|
||||||
944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = "<group>"; };
|
944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = "<group>"; };
|
||||||
|
944589222385DA9500DE9FD4 /* ImageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewModel.swift; sourceTree = "<group>"; };
|
||||||
9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = "<group>"; };
|
9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = "<group>"; };
|
||||||
946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = "<group>"; };
|
946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = "<group>"; };
|
||||||
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
|
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
|
||||||
@ -816,6 +818,7 @@
|
|||||||
D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */,
|
D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */,
|
||||||
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */,
|
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */,
|
||||||
D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */,
|
D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */,
|
||||||
|
944589222385DA9500DE9FD4 /* ImageViewModel.swift */,
|
||||||
D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */,
|
D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */,
|
||||||
D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */,
|
D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */,
|
||||||
D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */,
|
D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */,
|
||||||
@ -1177,6 +1180,7 @@
|
|||||||
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */,
|
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */,
|
||||||
D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */,
|
D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */,
|
||||||
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
||||||
|
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */,
|
||||||
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
||||||
01EB369023609801006832FA /* ListItemModel.swift in Sources */,
|
01EB369023609801006832FA /* ListItemModel.swift in Sources */,
|
||||||
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
||||||
|
|||||||
21
MVMCoreUI/Atoms/Views/ImageViewModel.swift
Normal file
21
MVMCoreUI/Atoms/Views/ImageViewModel.swift
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// ImageViewModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Ryan on 11/20/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers public class ImageViewModel: MoleculeProtocol {
|
||||||
|
public static var identifier: String = "imageView"
|
||||||
|
public var moleculeName: String
|
||||||
|
|
||||||
|
public var image: String
|
||||||
|
public var accessibilityText: String?
|
||||||
|
public var fallbackImage: String?
|
||||||
|
public var imageFormat: String?
|
||||||
|
public var width: CGFloat?
|
||||||
|
public var height: CGFloat?
|
||||||
|
}
|
||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers open class MFLoadImageView: ViewConstrainingView {
|
@objcMembers open class MFLoadImageView: ViewConstrainingView, ModelMoleculeViewProtocol {
|
||||||
public let loadingSpinner = MFLoadingSpinner(frame: .zero)
|
public let loadingSpinner = MFLoadingSpinner(frame: .zero)
|
||||||
public let imageView = MFTransparentGIFView(frame: .zero)
|
public let imageView = MFTransparentGIFView(frame: .zero)
|
||||||
public var addSizeConstraintsForAspectRatio = false
|
public var addSizeConstraintsForAspectRatio = false
|
||||||
@ -209,6 +209,31 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||||
|
guard let imageModel = model as? ImageViewModel else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if let accessibilityString = imageModel.accessibilityText {
|
||||||
|
imageView.accessibilityLabel = accessibilityString
|
||||||
|
imageView.accessibilityTraits = .staticText
|
||||||
|
imageView.isAccessibilityElement = true
|
||||||
|
}
|
||||||
|
let width = imageModel.width ?? imageWidth
|
||||||
|
let height = imageModel.height ?? imageHeight
|
||||||
|
// For smoother transitions, set constraints that we know immediately.
|
||||||
|
if let width = width, addSizeConstraintsForAspectRatio {
|
||||||
|
setWidth(width)
|
||||||
|
}
|
||||||
|
if let height = height, addSizeConstraintsForAspectRatio {
|
||||||
|
setHeight(height)
|
||||||
|
}
|
||||||
|
if shouldLoadImage(withName: imageModel.image, width: width, height: height) {
|
||||||
|
imageView.image = nil
|
||||||
|
imageView.animatedImage = nil
|
||||||
|
loadImage(withName: imageModel.image, format: imageModel.imageFormat, width: width as NSNumber?, height: height as NSNumber?, customFallbackImage: imageModel.fallbackImage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol functions
|
// MARK: - MVMCoreUIMoleculeViewProtocol functions
|
||||||
open override func setAsMolecule() {
|
open override func setAsMolecule() {
|
||||||
addSizeConstraintsForAspectRatio = true
|
addSizeConstraintsForAspectRatio = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user