Merge branch 'develop' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/rightVariable_payments_list
This commit is contained in:
commit
a845c37f17
@ -8,12 +8,21 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
class LabelAttributeActionModel: LabelAttributeModel {
|
||||
open class LabelAttributeActionModel: LabelAttributeModel {
|
||||
override public class var identifier: String {
|
||||
return "action"
|
||||
}
|
||||
var action: ActionModelProtocol
|
||||
|
||||
public init(_ location: Int, _ length: Int, action: ActionModelProtocol) {
|
||||
self.action = action
|
||||
super.init(location, length)
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case action
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
||||
@ -25,8 +34,4 @@ class LabelAttributeActionModel: LabelAttributeModel {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeModel(action, forKey: .action)
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case action
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,12 +25,14 @@ import Foundation
|
||||
return ""
|
||||
}
|
||||
|
||||
var type: String
|
||||
var type: String {
|
||||
get { return Self.identifier }
|
||||
}
|
||||
|
||||
var location: Int
|
||||
var length: Int
|
||||
|
||||
init(_ type: String, _ location: Int, _ length: Int) {
|
||||
self.type = type
|
||||
init(_ location: Int, _ length: Int) {
|
||||
self.location = location
|
||||
self.length = length
|
||||
}
|
||||
@ -51,7 +53,6 @@ import Foundation
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
type = try typeContainer.decode(String.self, forKey: .type)
|
||||
location = try typeContainer.decode(Int.self, forKey: .location)
|
||||
length = try typeContainer.decode(Int.self, forKey: .length)
|
||||
}
|
||||
|
||||
@ -210,6 +210,9 @@ import UIKit
|
||||
}
|
||||
|
||||
public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
self.delegateObject = delegateObject
|
||||
// TODO: Temporary, should be moved to init once we have type erasure ready.
|
||||
setAsMolecule()
|
||||
guard let imageModel = model as? ImageViewModel else {
|
||||
return
|
||||
}
|
||||
@ -273,7 +276,9 @@ import UIKit
|
||||
}
|
||||
|
||||
// MARK: - load functions
|
||||
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? = nil, width: NSNumber? = nil, height: NSNumber? = nil, customFallbackImage: String? = nil, allowServerParameters: Bool = false, completionHandler: MVMCoreGetImageBlock? = nil) {
|
||||
|
||||
let completionBlock = completionHandler ?? defaultCompletionBlock()
|
||||
MVMCoreDispatchUtility.performBlock(onMainThread: { [unowned self] in
|
||||
self.currentImageName = imageName
|
||||
self.currentImageWidth = width?.cgfloat()
|
||||
@ -295,15 +300,15 @@ import UIKit
|
||||
if layoutWillChange {
|
||||
self?.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self!)
|
||||
}
|
||||
completionHandler(image,data,isFallbackImage)
|
||||
completionBlock(image,data,isFallbackImage)
|
||||
})}
|
||||
|
||||
let fallbackImageName = customFallbackImage ?? MVMCoreUIUtility.localizedImageName("fallback")
|
||||
if let format = format, format.lowercased().contains("gif") {
|
||||
// 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, completionHandler: finishedLoadingBlock)
|
||||
MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, completionHandler: finishedLoadingBlock)
|
||||
} else {
|
||||
MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, completionHandler: finishedLoadingBlock)
|
||||
MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, completionHandler: finishedLoadingBlock)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -333,6 +338,8 @@ import UIKit
|
||||
})
|
||||
}
|
||||
|
||||
// Note: Exposed for objective-c interfaces.
|
||||
|
||||
public func loadImage(withName imageName: String?) {
|
||||
loadImage(withName: imageName, format: nil, width: nil, height: nil, customFallbackImage: nil, completionHandler: defaultCompletionBlock())
|
||||
}
|
||||
@ -368,4 +375,8 @@ import UIKit
|
||||
public func loadImage(withName imageName: String?, format: String?, width: NSNumber?, height: NSNumber?, customFallbackImage: String?) {
|
||||
loadImage(withName: imageName, format: format, width: width, height: height, customFallbackImage: customFallbackImage, completionHandler: defaultCompletionBlock())
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +37,3 @@ extension MFViewController: MoleculeDelegateProtocol {
|
||||
|
||||
@objc public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { }
|
||||
}
|
||||
|
||||
public extension MFViewController {
|
||||
@objc func parsePageJSON() throws { }
|
||||
}
|
||||
|
||||
@ -96,6 +96,9 @@
|
||||
// This view controller should subclass this function and check the load to make sure it has all the needed data. Fills the error object if there are any errors. Returns if we should finish the load or not.
|
||||
- (BOOL)shouldFinishProcessingLoad:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error;
|
||||
|
||||
/// Called in newDataBuildScreen. Can override to parse the json into a model object.
|
||||
- (void)parsePageJSON:(NSError * _Nullable * _Nullable)error;
|
||||
|
||||
// Sets the screen to use the screen heading.
|
||||
// it is required in device flow, where we are showing greeting name as screen heading,
|
||||
// device details screen heading needs to be updated/refreshed again, if user has changed device nick name
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
self.loadObject = loadObject;
|
||||
|
||||
NSError *parseError = nil;
|
||||
[self parsePageJSONAndReturnError:&parseError];
|
||||
[self parsePageJSON:&parseError];
|
||||
if (parseError) {
|
||||
if (error) {
|
||||
MVMCoreErrorObject *errorObject = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]];
|
||||
@ -112,6 +112,10 @@
|
||||
return [MFViewController verifyRequiredModulesLoadedForLoadObject:loadObject error:error];
|
||||
}
|
||||
|
||||
- (void)parsePageJSON:(NSError * _Nullable * _Nullable)error {
|
||||
|
||||
}
|
||||
|
||||
// Sets the screen to use the screen heading.
|
||||
// it is required in device flow, where we are showing greeting name as screen heading,
|
||||
// device details screen heading needs to be updated/refreshed again, if user has changed device nick name
|
||||
@ -261,7 +265,7 @@
|
||||
- (BOOL)newPageLoaded:(nonnull NSDictionary *)page {
|
||||
self.loadObject.pageJSON = page;
|
||||
NSError *parseError = nil;
|
||||
[self parsePageJSONAndReturnError:&parseError];
|
||||
[self parsePageJSON:&parseError];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@ -23,8 +23,12 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
// MARK: - Computed Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
@objc public override func parsePageJSON() throws {
|
||||
try parseTemplateJSON()
|
||||
open override func parsePageJSON(_ error: NSErrorPointer) {
|
||||
do {
|
||||
try parseTemplateJSON()
|
||||
} catch let parseError {
|
||||
error?.pointee = parseError as NSError
|
||||
}
|
||||
}
|
||||
|
||||
open override var loadObject: MVMCoreLoadObject? {
|
||||
|
||||
@ -12,8 +12,12 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
|
||||
|
||||
var observer: NSKeyValueObservation?
|
||||
public var templateModel: StackPageTemplateModel?
|
||||
public override func parsePageJSON() throws {
|
||||
try parseTemplateJSON()
|
||||
open override func parsePageJSON(_ error: NSErrorPointer) {
|
||||
do {
|
||||
try parseTemplateJSON()
|
||||
} catch let parseError {
|
||||
error?.pointee = parseError as NSError
|
||||
}
|
||||
}
|
||||
|
||||
open override var loadObject: MVMCoreLoadObject? {
|
||||
|
||||
@ -11,8 +11,13 @@ import UIKit
|
||||
@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol {
|
||||
|
||||
public var templateModel: ThreeLayerPageTemplateModel?
|
||||
@objc public override func parsePageJSON() throws {
|
||||
try parseTemplateJSON()
|
||||
|
||||
open override func parsePageJSON(_ error: NSErrorPointer) {
|
||||
do {
|
||||
try parseTemplateJSON()
|
||||
} catch let parseError {
|
||||
error?.pointee = parseError as NSError
|
||||
}
|
||||
}
|
||||
|
||||
override open func viewDidLoad() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user