62 lines
2.3 KiB
Swift
62 lines
2.3 KiB
Swift
//
|
|
// ViewController.swift
|
|
// MVMCoreUI
|
|
//
|
|
// Created by Scott Pfeil on 11/5/19.
|
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
@objcMembers open class ViewController: UIViewController, MVMCoreViewControllerProtocol {
|
|
public var pageType: String?
|
|
public var loadObject: MVMCoreLoadObject?
|
|
|
|
// MARK: - Response handling
|
|
public func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject>) -> Bool {
|
|
pageType = loadObject.pageType
|
|
self.loadObject = loadObject
|
|
|
|
// Verifies all modules needed are loaded.
|
|
return MFViewController.verifyRequiredModulesLoaded(for: loadObject, error: error)
|
|
}
|
|
|
|
public class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: inout MVMCoreErrorObject?) -> Bool {
|
|
guard let pageType = loadObject?.pageType, var modulesRequired = MVMCoreUIViewControllerMappingObject.shared()?.modulesRequired(forPageType: pageType) else { return true }
|
|
|
|
guard let loadedModules = loadObject?.modulesJSON else { return false }
|
|
|
|
for case let key as String in Array(loadedModules.keys) {
|
|
guard modulesRequired.count > 0 else { break }
|
|
if let index = modulesRequired.firstIndex(where: {($0 as? String) == key}), index != NSNotFound {
|
|
modulesRequired.remove(at: index)
|
|
}
|
|
}
|
|
|
|
guard modulesRequired.count == 0 else {
|
|
if error != nil {
|
|
error = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorCritical), messageToLog: modulesRequired.description, code: ErrorCode.requiredModuleNotPresent.rawValue, domain: ErrorDomainNative, location: MVMCoreLoadHandler.sharedGlobal()?.errorLocation(forRequest: loadObject!))
|
|
}
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
open func newDataBuildScreen() {
|
|
// TODO- tell navigation object to update with model
|
|
|
|
}
|
|
|
|
open func initialLoad() {
|
|
}
|
|
|
|
open func updateViews() {
|
|
}
|
|
|
|
override open func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
}
|