Molecular formatting updates

This commit is contained in:
Christiano, Kevin 2021-04-13 14:54:09 -04:00 committed by Pfeil, Scott Robert
parent e50fef3050
commit 30cd90dc17
80 changed files with 589 additions and 354 deletions

View File

@ -1239,6 +1239,18 @@
path = "Date Dropdown";
sourceTree = "<group>";
};
0A1C30972620F61A00B47F3B /* Protocols */ = {
isa = PBXGroup;
children = (
D23A8FF72612308D007E14CE /* PageBehaviorProtocolRequirer.swift */,
D23A8FFA26123189007E14CE /* PageBehaviorModelProtocol.swift */,
D23A8FFF2612347A007E14CE /* PageBehaviorHandlerModelProtocol.swift */,
D23A9003261234CE007E14CE /* PageBehaviorHandlerProtocol.swift */,
27F973522466074500CAB5C5 /* PageBehaviorProtocol.swift */,
);
path = Protocols;
sourceTree = "<group>";
};
0A5D59C323AD488600EFD9E9 /* Protocols */ = {
isa = PBXGroup;
children = (
@ -1296,11 +1308,7 @@
27F973512466071600CAB5C5 /* Behaviors */ = {
isa = PBXGroup;
children = (
D23A8FF72612308D007E14CE /* PageBehaviorProtocolRequirer.swift */,
D23A8FFA26123189007E14CE /* PageBehaviorModelProtocol.swift */,
D23A8FFF2612347A007E14CE /* PageBehaviorHandlerModelProtocol.swift */,
D23A9003261234CE007E14CE /* PageBehaviorHandlerProtocol.swift */,
27F973522466074500CAB5C5 /* PageBehaviorProtocol.swift */,
0A1C30972620F61A00B47F3B /* Protocols */,
27F97369246750BE00CAB5C5 /* ScreenBrightnessModifierBehavior.swift */,
D23A900826125FFB007E14CE /* GetContactBehavior.swift */,
);

View File

@ -16,9 +16,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat
// MARK: - Properties
//--------------------------------------------------
//Making static property as class property so that subclasses can override getter function of the property
open class var identifier: String {
"button"
}
open class var identifier: String { "button" }
public var backgroundColor: Color?
public var accessibilityIdentifier: String?
public var title: String

View File

@ -625,7 +625,7 @@ public typealias ActionBlock = () -> ()
font = font.updateSize(sizeObject.getValueBased(onSize: size))
}
}
@objc public func setFont(_ font: UIFont, scale: Bool) {
self.font = font
setScale(scale)
@ -829,6 +829,7 @@ extension Label {
private func addActionAttributes(range: NSRange, string: NSMutableAttributedString?) {
guard let string = string else { return }
string.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range)
}

View File

@ -7,18 +7,19 @@
//
@objcMembers open class ListStoreLocator: TableViewCell {
//--------------------------------------------------
// MARK: - Outlets
//--------------------------------------------------
public let heart = Heart()
public let leftHeadline = Label(fontStyle: .BoldBodySmall)
public let leftBody = Label(fontStyle: .RegularBodySmall)
public let leftSubBody = Label(fontStyle: .RegularBodySmall)
public let rightLabel = Label(fontStyle: .RegularBodySmall)
private lazy var rightLabelStackItem: StackItem = {
return StackItem(andContain: rightLabel)
StackItem(andContain: rightLabel)
}()
public lazy var horizontalStack: Stack<StackModel> = {
return Stack<StackModel>(with: StackModel(molecules: [StackItemModel(horizontalAlignment: .fill),
StackItemModel(horizontalAlignment: .fill),
@ -83,9 +84,7 @@
}
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 120
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 120 }
open override func reset() {
super.reset()
@ -98,6 +97,7 @@
//--------------------------------------------------
// MARK: - Accessibility
//--------------------------------------------------
func getAccessibilityMessage() -> String? {
var message = ""
heart.updateAccessibilityLabel()
@ -155,6 +155,6 @@
return .none
}
}
set {}
set { }
}
}

View File

@ -6,13 +6,9 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class FooterModel: MoleculeContainerModel {
public override class var identifier: String {
return "footer"
}
public override class var identifier: String { "footer" }
/// Defaults to set
public override func setDefaults() {

View File

@ -12,7 +12,7 @@ open class HeaderView: Container {
/// Convenience for doing some default setting
open var molecule: MoleculeViewProtocol?
var headerModel: HeaderModel? {
get { model as? HeaderModel }
}
@ -46,7 +46,7 @@ open class HeaderView: Container {
line.setStyle(.heavy)
molecule?.reset()
}
// MARK: - MoleculeViewProtocol
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)

View File

@ -6,7 +6,6 @@
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
//
import Foundation
@objcMembers public class HeaderModel: ContainerModel {
public var backgroundColor: Color?

View File

@ -6,12 +6,17 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class MoleculeSectionFooterModel: MoleculeContainerModel, SectionListHeaderFooterModel {
public class override var identifier: String {
return "sectionFooter"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public class override var identifier: String { "sectionFooter" }
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
/// Defaults to set
public override func setDefaults() {

View File

@ -6,19 +6,27 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class MoleculeSectionHeaderModel: MoleculeContainerModel, SectionListHeaderFooterModel {
public class override var identifier: String {
return "sectionHeader"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public class override var identifier: String { "sectionHeader" }
public var line: LineModel?
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case line
case backgroundColor
}
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
/// Defaults to set
public override func setDefaults() {
if useHorizontalMargins == nil {
@ -38,6 +46,10 @@ import Foundation
}
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)

View File

@ -13,13 +13,11 @@ class AccordionListItemModel: MoleculeListItemModel {
// MARK: - Properties
//--------------------------------------------------
override public class var identifier: String {
return "accordionListItem"
}
override public class var identifier: String { "accordionListItem" }
public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]
public var hideLineWhenExpanded: Bool = false
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
@ -39,7 +37,7 @@ class AccordionListItemModel: MoleculeListItemModel {
super.setDefaults()
hideArrow = true
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
@ -52,7 +50,7 @@ class AccordionListItemModel: MoleculeListItemModel {
}
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)

View File

@ -13,7 +13,7 @@
//--------------------------------------------------
var accordionListItemModel: AccordionListItemModel? {
return listItemModel as? AccordionListItemModel
listItemModel as? AccordionListItemModel
}
let accordionButton: Button = {

View File

@ -6,24 +6,20 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open override class var identifier: String {
return "carouselItem"
}
open override class var identifier: String { "carouselItem" }
public var peakingUI: Bool?
public var peakingArrowColor: Color?
public var analyticsData: JSONValueDictionary?
public var fieldValue: String?
public func formFieldValue() -> AnyHashable? { return fieldValue }
public func formFieldValue() -> AnyHashable? { fieldValue }
//--------------------------------------------------
// MARK: - Keys

View File

@ -7,11 +7,8 @@
//
// A base class that has common list item boilerplate model stuffs.
import Foundation
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------

View File

@ -6,21 +6,29 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
/// A model for a collection item that is a container for any molecule.
@objcMembers open class MoleculeCollectionItemModel: MoleculeContainerModel, CollectionItemModelProtocol {
open override class var identifier: String {
return "collectionItem"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open override class var identifier: String { "collectionItem" }
public var action: ActionModelProtocol?
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case action
}
/// Defaults to set
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
public override func setDefaults() {
if useHorizontalMargins == nil {
useHorizontalMargins = true
@ -36,9 +44,17 @@ import Foundation
}
}
//--------------------------------------------------
// MARK: - Initialization
//--------------------------------------------------
public override init(with moleculeModel: MoleculeModelProtocol) {
super.init(with: moleculeModel)
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)

View File

@ -6,7 +6,6 @@
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
//
import Foundation
import MVMCore
@ -15,12 +14,10 @@ import MVMCore
// MARK: - Properties
//--------------------------------------------------
public class var identifier: String {
return "listItem"
}
public class var identifier: String { "listItem" }
public var molecule: MoleculeModelProtocol
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
@ -42,13 +39,13 @@ import MVMCore
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
molecule = try typeContainer.decodeModel(codingKey: .molecule)
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)

View File

@ -11,6 +11,6 @@ import UIKit
open class MoleculeStackItem: MoleculeContainer {
var stackItemModel: StackItemModel? {
get { return model as? StackItemModel }
model as? StackItemModel
}
}

View File

@ -12,9 +12,7 @@
// MARK: - Properties
//--------------------------------------------------
public override class var identifier: String {
return "stackItem"
}
public override class var identifier: String { "stackItem" }
public var spacing: CGFloat?
public var percent: Int?
public var gone: Bool = false

View File

@ -30,16 +30,14 @@ import UIKit
}
public override class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return MoleculeContainer.nameForReuse(with: model, delegateObject)
MoleculeContainer.nameForReuse(with: model, delegateObject)
}
public override class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return MoleculeContainer.requiredModules(with: model, delegateObject, error: error)
MoleculeContainer.requiredModules(with: model, delegateObject, error: error)
}
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
guard let height = MoleculeContainer.estimatedHeight(with: model, delegateObject)
else { return 80 }
return height
MoleculeContainer.estimatedHeight(with: model, delegateObject) ?? 80
}
}

View File

@ -8,7 +8,11 @@
open class StackItem: Container {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
var stackItemModel: StackItemModel? {
get { return model as? StackItemModel }
model as? StackItemModel
}
}

View File

@ -6,7 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol {
//--------------------------------------------------

View File

@ -6,7 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol StackItemModelProtocol {
var spacing: CGFloat? { get set }

View File

@ -8,17 +8,30 @@
import UIKit
public class TabsListItemModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "tabsListItem"
var tabs: TabsModel
var molecules: [[ListItemModelProtocol & MoleculeModelProtocol]]
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case moleculeName
case tabs
case molecules
}
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
public override func setDefaults() {
super.setDefaults()
hideArrow = true
@ -28,19 +41,27 @@ public class TabsListItemModel: ListItemModel, MoleculeModelProtocol {
bottomPadding = 0
}
//--------------------------------------------------
// MARK: - Init
//--------------------------------------------------
public init(with tabs: TabsModel, molecules: [[ListItemModelProtocol & MoleculeModelProtocol]]) {
self.tabs = tabs
self.molecules = molecules
super.init()
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
tabs = try typeContainer.decode(TabsModel.self, forKey: .tabs)
molecules = try typeContainer.decodeModels2D(codingKey: .molecules)
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)

View File

@ -49,9 +49,7 @@ import UIKit
tabs.reset()
}
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 46
}
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 46 }
}
extension TabsTableViewCell: TabsDelegate {

View File

@ -6,14 +6,20 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
open class BGImageMoleculeModel: MoleculeContainerModel {
open override class var identifier: String {
return "bgImageContainer"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open override class var identifier: String { "bgImageContainer" }
public var image: ImageViewModel
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
open override func setDefaults() {
if useHorizontalMargins == nil {
useHorizontalMargins = true
@ -35,15 +41,27 @@ open class BGImageMoleculeModel: MoleculeContainerModel {
}
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case image
}
//--------------------------------------------------
// MARK: - Initialization
//--------------------------------------------------
public init(_ image: ImageViewModel, molecule: MoleculeModelProtocol) {
self.image = image
super.init(with: molecule)
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
image = try typeContainer.decode(ImageViewModel.self, forKey:.image)

View File

@ -12,7 +12,7 @@ open class ModuleMolecule: Container {
open var moduleMolecule: MoleculeViewProtocol?
var moduleMoleculeModel: ModuleMoleculeModel? {
get { return model as? ModuleMoleculeModel }
get { model as? ModuleMoleculeModel }
}
public override func setupView() {

View File

@ -6,12 +6,13 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
open class MoleculeContainerModel: ContainerModel, MoleculeContainerModelProtocol, MoleculeModelProtocol {
open class var identifier: String {
return "container"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open class var identifier: String { "container" }
public var backgroundColor: Color?
public var molecule: MoleculeModelProtocol
@ -19,6 +20,10 @@ open class MoleculeContainerModel: ContainerModel, MoleculeContainerModelProtoco
return [molecule]
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case moleculeName
case molecule

View File

@ -6,7 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol MoleculeContainerModelProtocol: ContainerModelProtocol, ParentMoleculeModelProtocol {
var molecule: MoleculeModelProtocol { get set }

View File

@ -9,8 +9,6 @@
import UIKit
public class ScrollerModel: MoleculeContainerModel {
public override class var identifier: String {
return "scroller"
}
public override class var identifier: String { "scroller" }
public var moleculeName: String = ScrollerModel.identifier
}

View File

@ -6,21 +6,32 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public class StringAndMoleculeModel: MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "stringAndMoleculeModel"
public var backgroundColor: Color?
public var string: String
public var molecule: MoleculeModelProtocol
public var stringColor: Color
//--------------------------------------------------
// MARK: - Init
//--------------------------------------------------
public init(string: String, molecule: MoleculeModelProtocol, stringColor: Color = Color(uiColor: .mvmBlack)) {
self.string = string
self.molecule = molecule
self.stringColor = stringColor
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case moleculeName
case backgroundColor
@ -29,6 +40,10 @@ public class StringAndMoleculeModel: MoleculeModelProtocol {
case stringColor
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
public required init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)

View File

@ -14,8 +14,8 @@ open class StringAndMoleculeStack: MoleculeStackView {
override open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? StackModelProtocol,
let molcules = model.molecules as? [MoleculeStackItemModel]
else { return }
let molcules = model.molecules as? [MoleculeStackItemModel]
else { return }
for stackItemModel in molcules {
guard let stringAndMoleculeModel = stackItemModel.molecule as? StringAndMoleculeModel,

View File

@ -8,6 +8,9 @@
open class StringAndMoleculeView: View {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
var label = Label(fontStyle: .RegularBodySmall)
var molecule: MoleculeViewProtocol
@ -25,7 +28,10 @@ open class StringAndMoleculeView: View {
}
}
//--------------------------------------------------
// MARK: - Inits
//--------------------------------------------------
public init(string: String, molecule: MoleculeViewProtocol) {
self.label.text = string
self.molecule = molecule
@ -43,6 +49,10 @@ open class StringAndMoleculeView: View {
super.init(model: model, delegateObject, additionalData)
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
override public func setupView() {
super.setupView()

View File

@ -16,7 +16,7 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
open var stackItems: [UIView] = []
open var stackModel: T? {
get { model as? T }
model as? T
}
//--------------------------------------------------

View File

@ -15,9 +15,7 @@
static let defaultSpacing: CGFloat = 16.0
public class var identifier: String {
return "stack"
}
public class var identifier: String { "stack" }
public var backgroundColor: Color?
public var molecules: [StackItemModelProtocol & MoleculeModelProtocol]

View File

@ -6,8 +6,6 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol CarouselItemModelProtocol: ContainerModelProtocol {
var analyticsData: JSONValueDictionary? { get set }
@ -17,8 +15,9 @@ public protocol CarouselItemModelProtocol: ContainerModelProtocol {
public extension CarouselItemModelProtocol {
var analyticsData: JSONValueDictionary? {
get { return nil }
get { nil }
set { analyticsData = newValue }
}
func formFieldValue() -> AnyHashable? { return nil }
func formFieldValue() -> AnyHashable? { nil }
}

View File

@ -6,7 +6,6 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
public enum ListItemStyle: String, Codable {
case standard
@ -27,12 +26,12 @@ public protocol ListItemModelProtocol: ContainerModelProtocol {
public extension ListItemModelProtocol {
var action: ActionModelProtocol? {
get { return nil }
get { nil }
set { }
}
var style: ListItemStyle? {
get { return nil }
get { nil }
set { }
}
}

View File

@ -1,5 +1,3 @@
import Foundation
public enum MolecularError: Swift.Error {
case error(String)

View File

@ -6,7 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol PageModelProtocol {
var pageType: String { get set }

View File

@ -6,8 +6,6 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol, MoleculeTreeTraversalProtocol {
var template: String { get }

View File

@ -6,7 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol ThreeLayerTemplateModelProtocol: TemplateModelProtocol {
var anchorHeader: Bool { get set }

View File

@ -9,14 +9,15 @@
import UIKit
import MVMCore.MVMCoreViewProtocol
public protocol MoleculeViewProtocol: UIView, ModelHandlerProtocol {
/// Initializes the view with the model
init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?)
/// Sets the view with the model.
func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?)
/// Resets to default state before set with json is called again.
func reset()
@ -40,19 +41,17 @@ extension MoleculeViewProtocol {
/// Uses moleculeName
public static func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model.moleculeName
model.moleculeName
}
// Do nothing, optionals.
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { }
public func reset() { }
public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil
}
public static func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return nil
}
public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { nil }
public static func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { nil }
/// Temporary convenience function for helping bridge the gap for legacy code.
public func setOptional<T: MoleculeModelProtocol>(with model: T?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {

View File

@ -31,7 +31,7 @@ public extension TemplateProtocol where Self: ViewController {
}
func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> TemplateModel {
return try decoder.decode(TemplateModel.self, from: data)
try decoder.decode(TemplateModel.self, from: data)
}
/// Traverses all models and adds any required behavior models.

View File

@ -6,16 +6,19 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objc open class CollectionTemplate: ThreeLayerCollectionViewController, TemplateProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public typealias TemplateModel = CollectionTemplateModel
public var templateModel: CollectionTemplateModel?
public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: (CollectionItemModelProtocol & MoleculeModelProtocol))]?
var observer: NSKeyValueObservation?
//--------------------------------------------------
// MARK: - Computed Properties
//--------------------------------------------------
@ -68,9 +71,9 @@ import Foundation
// This template requires atleast one of the three layers.
if templateModel?.header == nil,
templateModel?.molecules?.count ?? 0 == 0,
templateModel?.footer == nil,
let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), messageToLog: "Collection template requires atleast one of the following: header, footer, molecules", code: CoreUIErrorCode.ErrorCodeListMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) {
templateModel?.molecules?.count ?? 0 == 0,
templateModel?.footer == nil,
let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), messageToLog: "Collection template requires atleast one of the following: header, footer, molecules", code: CoreUIErrorCode.ErrorCodeListMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) {
error.pointee = errorObject
return false
}
@ -95,8 +98,8 @@ import Foundation
// Update the width for columns.
if let collectionView = collectionView,
let columns = templateModel?.columns, columns > 0,
let cell = cell as? CollectionTemplateItemProtocol {
let columns = templateModel?.columns, columns > 0,
let cell = cell as? CollectionTemplateItemProtocol {
let width = (size - collectionView.adjustedContentInset.left - collectionView.adjustedContentInset.right) / CGFloat(columns)
cell.set(width: width)
}
@ -110,18 +113,16 @@ import Foundation
collectionView?.register(moleculeInfo.class, forCellWithReuseIdentifier: moleculeInfo.identifier)
}
}
open override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return moleculesInfo?.count ?? 0
moleculesInfo?.count ?? 0
}
open override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
open override func numberOfSections(in collectionView: UICollectionView) -> Int { 1 }
open override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let moleculeInfo = moleculesInfo?[indexPath.row]
else { return UICollectionViewCell() }
guard let moleculeInfo = moleculesInfo?[indexPath.row] else { return UICollectionViewCell() }
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: moleculeInfo.identifier, for: indexPath)
(cell as? MoleculeViewProtocol)?.reset()
(cell as? MoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegateObjectIVar, nil)

View File

@ -6,7 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
/// A protocol that items of the CollectionTemplate must conform to.
public protocol CollectionTemplateItemProtocol: UICollectionViewCell {
@ -26,11 +25,10 @@ public protocol CollectionTemplateItemProtocol: UICollectionViewCell {
// Default implementation does nothing
extension CollectionTemplateItemProtocol {
public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {}
public func willDisplay() {}
public func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool {
return false
}
public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { }
public func willDisplay() { }
public func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool { false }
}

View File

@ -6,16 +6,13 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class CollectionTemplateModel: ThreeLayerModelBase {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public override class var identifier: String {
return "collection"
}
public override class var identifier: String { "collection" }
public var molecules: [CollectionItemModelProtocol & MoleculeModelProtocol]?
public var columns: Int?
@ -35,7 +32,7 @@ import Foundation
self.screenHeading = screenHeading
self.molecules = molecules
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
@ -44,7 +41,7 @@ import Foundation
case molecules
case columns
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
@ -55,7 +52,7 @@ import Foundation
columns = try typeContainer.decodeIfPresent(Int.self, forKey: .columns)
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
@ -63,4 +60,3 @@ import Foundation
try container.encodeIfPresent(columns, forKey: .columns)
}
}

View File

@ -6,19 +6,18 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class ListPageTemplateModel: ThreeLayerModelBase {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open override class var identifier: String {
return "list"
}
open override class var identifier: String { "list" }
public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]?
public var line: LineModel?
public var scrollToRowIndex: Int?
public var singleCellSelection: Bool = false
public override var rootMolecules: [MoleculeModelProtocol] {
if let molecules = molecules {
@ -30,12 +29,12 @@ import Foundation
/// This template requires content.
func validateModelHasContent() throws {
if header == nil,
molecules?.count ?? 0 == 0,
footer == nil {
molecules?.count ?? 0 == 0,
footer == nil {
throw ModelRegistry.Error.decoderOther(message: "List template requires atleast one of the following: header, footer, molecules")
}
}
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
@ -45,7 +44,7 @@ import Foundation
self.screenHeading = screenHeading
self.molecules = molecules
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
@ -54,8 +53,9 @@ import Foundation
case molecules
case line
case scrollToRowIndex
case singleCellSelection
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
@ -65,16 +65,19 @@ import Foundation
molecules = try typeContainer.decodeModelsIfPresent(codingKey: .molecules)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
scrollToRowIndex = try typeContainer.decodeIfPresent(Int.self, forKey: .scrollToRowIndex)
if let singleCellSelection = try typeContainer.decodeIfPresent(Bool.self, forKey: .singleCellSelection) {
self.singleCellSelection = singleCellSelection
}
try super.init(from: decoder)
try validateModelHasContent()
}
open override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeModelsIfPresent(molecules, forKey: .molecules)
try container.encode(line, forKey: .line)
try container.encode(singleCellSelection, forKey: .singleCellSelection)
try container.encodeIfPresent(scrollToRowIndex, forKey: .scrollToRowIndex)
}
}

View File

@ -6,19 +6,16 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class ModalListPageTemplateModel: ListPageTemplateModel {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open override class var identifier: String {
return "modalList"
}
open override class var identifier: String { "modalList" }
public var closeAction: ActionModelProtocol?
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
@ -26,21 +23,20 @@ import Foundation
private enum CodingKeys: String, CodingKey {
case closeAction
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
closeAction = try typeContainer.decodeModelIfPresent(codingKey: .closeAction)
try super.init(from: decoder)
}
open override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeModelIfPresent(closeAction, forKey: .closeAction)
}
}

View File

@ -15,14 +15,14 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate {
//--------------------------------------------------
public var closeButton: Button?
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
// For subclassing the model.
open override func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> ModalListPageTemplateModel {
return try decoder.decode(ModalListPageTemplateModel.self, from: data)
try decoder.decode(ModalListPageTemplateModel.self, from: data)
}
override open func handleNewData() {

View File

@ -9,15 +9,22 @@
import UIKit
open class ModalMoleculeStackTemplate: MoleculeStackTemplate {
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
// For subclassing the model.
open override func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> ModalStackPageTemplateModel {
return try decoder.decode(ModalStackPageTemplateModel.self, from: data)
try decoder.decode(ModalStackPageTemplateModel.self, from: data)
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
override open func handleNewData() {
super.handleNewData()
_ = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in
_ = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { [weak self] _ in
guard let self = self else { return }
let closeAction = (self.templateModel as? ModalStackPageTemplateModel)?.closeAction ??
ActionBackModel()

View File

@ -6,18 +6,24 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
open class ModalSectionListTemplate: SectionListTemplate {
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
// For subclassing the model.
open override func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> ModalSectionListTemplateModel {
return try decoder.decode(ModalSectionListTemplateModel.self, from: data)
try decoder.decode(ModalSectionListTemplateModel.self, from: data)
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
override open func handleNewData() {
super.handleNewData()
_ = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in
_ = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { [weak self] _ in
guard let self = self else { return }
let closeAction = (self.templateModel as? ModalSectionListTemplateModel)?.closeAction ??
ActionBackModel()

View File

@ -6,24 +6,37 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class ModalSectionListTemplateModel: SectionListTemplateModel {
public override class var identifier: String {
return "modalSectionList"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public override class var identifier: String { "modalSectionList" }
public var closeAction: ActionModelProtocol?
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case closeAction
}
//--------------------------------------------------
// MARK: - Init
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
closeAction = try typeContainer.decodeModelIfPresent(codingKey: .closeAction)
try super.init(from: decoder)
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)

View File

@ -6,24 +6,37 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class ModalStackPageTemplateModel: StackPageTemplateModel {
public override class var identifier: String {
return "modalStack"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public override class var identifier: String { "modalStack" }
public var closeAction: ActionModelProtocol?
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case closeAction
}
//--------------------------------------------------
// MARK: - Init
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
closeAction = try typeContainer.decodeModelIfPresent(codingKey: .closeAction)
try super.init(from: decoder)
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)

View File

@ -6,25 +6,34 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol MoleculeListCellProtocol: UITableViewCell {
/// Can set the separator according to what the moleculeList commands.
func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath)
/// Handle action when cell is pressed
func willSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool
/// Handle action when cell is pressed
func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?)
/// Handle action when cell is deselected.
func didDeselectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?)
/// Called by the list when the cell will display.
func willDisplay()
}
// Default implementation does nothing
extension MoleculeListCellProtocol {
public extension MoleculeListCellProtocol {
public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) { }
func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) { }
public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { }
func willSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool { true }
func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { }
func didDeselectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { }
func willDisplay() { }
}

View File

@ -8,13 +8,15 @@
import UIKit
public typealias MoleculeInfo = (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)
open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol {
//--------------------------------------------------
// MARK: - Stored Properties
//--------------------------------------------------
public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)]?
public var moleculesInfo: [MoleculeInfo]?
var observer: NSKeyValueObservation?
@ -38,6 +40,10 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
}
}
open var hasSingleCellSelection: Bool {
templateModel?.singleCellSelection ?? false
}
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
@ -49,7 +55,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
// For subclassing the model.
open func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> ListPageTemplateModel {
return try decoder.decode(ListPageTemplateModel.self, from: data)
try decoder.decode(ListPageTemplateModel.self, from: data)
}
open override func viewForTop() -> UIView {
@ -83,19 +89,20 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
open override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
//Handle scroll
handleScrollToSpecificRow()
}
//--------------------------------------------------
// MARK: - Handle scroll to spefic row
//--------------------------------------------------
func handleScrollToSpecificRow() {
guard let index = templateModel?.scrollToRowIndex,
loadObject?.pageDataFromCache == false,
let table = tableView,
index < tableView(table, numberOfRowsInSection:0) else { return }
index < tableView(table, numberOfRowsInSection:0)
else { return }
let indexPath = IndexPath(row: index, section: 0)
tableView?.scrollToRow(at: indexPath, at: .middle, animated: false)
//Reset for without refresh page not needed
@ -124,7 +131,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
}
open override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return moleculesInfo?.count ?? 0
moleculesInfo?.count ?? 0
}
open override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@ -146,10 +153,29 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
(cell as? MoleculeListCellProtocol)?.willDisplay()
}
open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let cell = tableView.cellForRow(at: indexPath) as? MoleculeListCellProtocol {
cell.didSelectCell(at: indexPath, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil)
}
open func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
guard let cell = tableView.cellForRow(at: indexPath) as? MoleculeListCellProtocol,
!cell.willSelectCell(at: indexPath, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil)
else { return indexPath }
return nil
}
open override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let cell = tableView.cellForRow(at: indexPath) as? MoleculeListCellProtocol else { return }
cell.didSelectCell(at: indexPath, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil)
}
open override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
guard let cell = tableView.cellForRow(at: indexPath) as? MoleculeListCellProtocol else { return }
cell.didDeselectCell(at: indexPath, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil)
}
func performTableViewUpdates() {
tableView.beginUpdates()
tableView.endUpdates()
}
//--------------------------------------------------
@ -157,13 +183,11 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
//--------------------------------------------------
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
guard let tableView = tableView else { return }
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()
}
let point = molecule.convert(molecule.bounds.origin, to: tableView)
if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
performTableViewUpdates()
}
}
@ -173,6 +197,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
let json = moleculeInfo.molecule.toJSON()
return json == molecule.toJSON()
}) else { return nil }
return IndexPath(row: index, section: 0)
}
@ -219,7 +244,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
//--------------------------------------------------
/// Returns the (identifier, class) of the molecule for the given model.
func createMoleculeInfo(with listItem: MoleculeModelProtocol?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? {
func createMoleculeInfo(with listItem: MoleculeModelProtocol?) -> MoleculeInfo? {
guard let listItem = listItem,
let moleculeClass = ModelRegistry.getMoleculeClass(listItem)
@ -231,14 +256,14 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
}
/// Returns the (identifier, class) of the molecule for the indexPath.
func getMoleculeInfo(for indexPath: IndexPath) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? {
return moleculesInfo?[indexPath.row]
func getMoleculeInfo(for indexPath: IndexPath) -> MoleculeInfo? {
moleculesInfo?[indexPath.row]
}
/// Sets up the molecule list and ensures no errors loading all content.
func getMoleculeInfoList() -> [(identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)]? {
func getMoleculeInfoList() -> [MoleculeInfo]? {
var moleculeList: [(identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)] = []
var moleculeList: [MoleculeInfo] = []
if let molecules = templateModel?.molecules {
for molecule in molecules {

View File

@ -8,8 +8,11 @@
import UIKit
public class MoleculeStackCenteredTemplate: MoleculeStackTemplate {
public override func spaceBetweenTopAndMiddle() -> CGFloat? {
return nil
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public override func spaceBetweenTopAndMiddle() -> CGFloat? { nil }
}

View File

@ -51,9 +51,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
}
}
open override func spaceBetweenTopAndMiddle() -> CGFloat? {
return 0
}
open override func spaceBetweenTopAndMiddle() -> CGFloat? { 0 }
open override func viewForTop() -> UIView? {
guard let headerModel = templateModel?.header,

View File

@ -6,11 +6,10 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
open class SectionListTemplate: MoleculeListTemplate {
public var sectionMoleculesInfo: [(header: (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)?, footer: (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)?, rows: [(identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)])]?
public var sectionMoleculesInfo: [(header: MoleculeInfo?, footer: MoleculeInfo?, rows: [MoleculeInfo])]?
open override func viewDidLoad() {
super.viewDidLoad()
@ -19,13 +18,13 @@ open class SectionListTemplate: MoleculeListTemplate {
override func setup() {
// Create quick reference
var sectionList: [(header: (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)?, footer: (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)?, rows: [(identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)])] = []
var sectionList: [(header: MoleculeInfo?, footer: MoleculeInfo?, rows: [MoleculeInfo])] = []
if let sections = (templateModel as? SectionListTemplateModel)?.sections {
for section in sections {
let header = createMoleculeInfo(with: section.header)
let footer = createMoleculeInfo(with: section.footer)
var rows: [(identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)] = []
var rows: [MoleculeInfo] = []
for row in section.rows {
if let rowInfo = createMoleculeInfo(with: row) {
rows.append(rowInfo)
@ -38,8 +37,8 @@ open class SectionListTemplate: MoleculeListTemplate {
sectionMoleculesInfo = sectionList.count > 0 ? sectionList : nil
}
override func getMoleculeInfo(for indexPath: IndexPath) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? {
return sectionMoleculesInfo?[indexPath.section].rows[indexPath.row]
override func getMoleculeInfo(for indexPath: IndexPath) -> MoleculeInfo? {
sectionMoleculesInfo?[indexPath.section].rows[indexPath.row]
}
open override func createTableView() -> TableView {
@ -54,7 +53,7 @@ open class SectionListTemplate: MoleculeListTemplate {
// For subclassing the model.
open override func decodeTemplate(using decoder: JSONDecoder, from data: Data) throws -> SectionListTemplateModel {
return try decoder.decode(SectionListTemplateModel.self, from: data)
try decoder.decode(SectionListTemplateModel.self, from: data)
}
open override func registerWithTable() {
@ -105,7 +104,9 @@ open class SectionListTemplate: MoleculeListTemplate {
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
guard let sectionInfo = sectionMoleculesInfo?[section],
let headerInfo = sectionInfo.header else { return nil }
let headerInfo = sectionInfo.header
else { return nil }
let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: headerInfo.identifier)
(header as? MoleculeViewProtocol)?.reset()
(header as? MoleculeViewProtocol)?.set(with: headerInfo.molecule, delegateObjectIVar, nil)
@ -117,7 +118,9 @@ open class SectionListTemplate: MoleculeListTemplate {
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
guard let sectionInfo = sectionMoleculesInfo?[section],
let footerInfo = sectionInfo.footer else { return nil }
let footerInfo = sectionInfo.footer
else { return nil }
let footer = tableView.dequeueReusableHeaderFooterView(withIdentifier: footerInfo.identifier)
(footer as? MoleculeViewProtocol)?.reset()
(footer as? MoleculeViewProtocol)?.set(with: footerInfo.molecule, delegateObjectIVar, nil)
@ -128,10 +131,10 @@ open class SectionListTemplate: MoleculeListTemplate {
}
open override func getNumberOfSections() -> Int {
return sectionMoleculesInfo?.count ?? 0
sectionMoleculesInfo?.count ?? 0
}
open override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return sectionMoleculesInfo?[section].rows.count ?? 0
sectionMoleculesInfo?[section].rows.count ?? 0
}
}

View File

@ -6,13 +6,15 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol SectionListHeaderFooterModel {
}
public protocol SectionListHeaderFooterModel { }
@objcMembers open class SectionModel: Codable {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var header: (SectionListHeaderFooterModel & MoleculeModelProtocol)?
public var footer: (SectionListHeaderFooterModel & MoleculeModelProtocol)?
public var rows: [ListItemModelProtocol & MoleculeModelProtocol]
@ -26,18 +28,18 @@ public protocol SectionListHeaderFooterModel {
case footer
case rows
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
header = try typeContainer.decodeModelIfPresent(codingKey: .header)
footer = try typeContainer.decodeModelIfPresent(codingKey: .footer)
rows = try typeContainer.decodeModels(codingKey: .rows)
}
open func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeModelIfPresent(header, forKey: .header)
@ -51,20 +53,18 @@ public protocol SectionListHeaderFooterModel {
// MARK: - Properties
//--------------------------------------------------
open override class var identifier: String {
return "sectionList"
}
open override class var identifier: String { "sectionList" }
public var sections: [SectionModel]
override func validateModelHasContent() throws {
if header == nil,
sections.count == 0,
footer == nil {
sections.count == 0,
footer == nil {
throw ModelRegistry.Error.decoderOther(message: "Section List template requires atleast one of the following: header, footer, sections")
}
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
@ -72,17 +72,17 @@ public protocol SectionListHeaderFooterModel {
private enum CodingKeys: String, CodingKey {
case sections
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
sections = try typeContainer.decode([SectionModel].self, forKey: .sections)
try super.init(from: decoder)
}
open override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)

View File

@ -6,10 +6,11 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class StackCenteredPageTemplateModel: StackPageTemplateModel {
public override class var identifier: String {
return "stackCenterTemplate"
}
//--------------------------------------------------
// MARK: - Property
//--------------------------------------------------
public override class var identifier: String { "stackCenterTemplate" }
}

View File

@ -6,34 +6,46 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class StackPageTemplateModel: ThreeLayerModelBase {
public override class var identifier: String {
return "stack"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public override class var identifier: String { "stack" }
public var moleculeStack: StackModel
public override var rootMolecules: [MoleculeModelProtocol] {
return [header, moleculeStack, footer].compactMap { $0 }
}
//--------------------------------------------------
// MARK: - Init
//--------------------------------------------------
public init(pageType: String, moleculeStack: StackModel) {
self.moleculeStack = moleculeStack
super.init(pageType: pageType)
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case stack
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
moleculeStack = try typeContainer.decode(StackModel.self, forKey: .stack)
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)

View File

@ -10,19 +10,16 @@ import Foundation
@objcMembers open class TemplateModel: MVMControllerModelProtocol, TabPageModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public class var identifier: String {
return ""
}
public class var identifier: String { "" }
public var pageType: String
public var template: String {
// Although this is done in the extension, it is needed for the encoding.
return Self.identifier
Self.identifier
}
public var backgroundColor: Color?

View File

@ -6,10 +6,11 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class ThreeLayerCenterTemplate: ThreeLayerTemplate<ThreeLayerCenterPageTemplateModel> {
open override func spaceBetweenTopAndMiddle() -> CGFloat? {
return nil
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
open override func spaceBetweenTopAndMiddle() -> CGFloat? { nil }
}

View File

@ -6,10 +6,11 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class ThreeLayerCenterPageTemplateModel: ThreeLayerPageTemplateModel {
public override class var identifier: String {
return "threeLayerCenter"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public override class var identifier: String { "threeLayerCenter" }
}

View File

@ -6,13 +6,17 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class ThreeLayerFillMiddleTemplate: ThreeLayerTemplate<ThreeLayerFillMiddleTemplateModel> {
open override func spaceBetweenMiddleAndBottom() -> CGFloat? {
return 0
}
//--------------------------------------------------
// MARK: - Spacing
//--------------------------------------------------
open override func spaceBetweenMiddleAndBottom() -> CGFloat? { 0 }
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
open override func loadView() {
super.loadView()

View File

@ -6,10 +6,11 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class ThreeLayerFillMiddleTemplateModel: ThreeLayerPageTemplateModel {
public override class var identifier: String {
return "threeLayerFillMiddle"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public override class var identifier: String { "threeLayerFillMiddle" }
}

View File

@ -6,9 +6,11 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class ThreeLayerModelBase: TemplateModel, ThreeLayerTemplateModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var anchorHeader: Bool = false
public var header: MoleculeModelProtocol?
@ -19,17 +21,29 @@ import Foundation
return [header, footer].compactMap { $0 }
}
//--------------------------------------------------
// MARK: - Init
//--------------------------------------------------
public override init(pageType: String) {
super.init(pageType: pageType)
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case anchorHeader
case header
case anchorFooter
case footer
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
if let anchor = try typeContainer.decodeIfPresent(Bool.self, forKey: .anchorHeader) {
@ -42,7 +56,7 @@ import Foundation
footer = try typeContainer.decodeModelIfPresent(codingKey: .footer)
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)

View File

@ -6,12 +6,13 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class ThreeLayerPageTemplateModel: ThreeLayerModelBase {
public override class var identifier: String {
return "threeLayer"
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public override class var identifier: String { "threeLayer" }
public var middle: MoleculeModelProtocol?
public override var rootMolecules: [MoleculeModelProtocol] {
@ -21,17 +22,29 @@ import Foundation
return super.rootMolecules
}
//--------------------------------------------------
// MARK: - Init
//--------------------------------------------------
public init(pageType: String, header: MoleculeModelProtocol?, middle: MoleculeModelProtocol?, footer: MoleculeModelProtocol?) {
super.init(pageType: pageType)
self.header = header
self.middle = middle
self.footer = footer
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case middle
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
middle = try typeContainer.decodeModelIfPresent(codingKey: .middle)

View File

@ -9,8 +9,16 @@
import UIKit
@objcMembers open class ThreeLayerTemplate<TemplateModel: ThreeLayerPageTemplateModel>: ThreeLayerViewController, TemplateProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var templateModel: TemplateModel?
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
open override func parsePageJSON() throws {
try parseTemplate(json: loadObject?.pageJSON)
try super.parsePageJSON()
@ -46,11 +54,11 @@ import UIKit
return molecule
}
open override func spaceBetweenTopAndMiddle() -> CGFloat? {
return 0
}
//--------------------------------------------------
// MARK: - Spacing
//--------------------------------------------------
open override func spaceBetweenMiddleAndBottom() -> CGFloat? {
return nil
}
open override func spaceBetweenTopAndMiddle() -> CGFloat? { 0 }
open override func spaceBetweenMiddleAndBottom() -> CGFloat? { nil }
}

View File

@ -174,17 +174,11 @@ import UIKit
// MARK: Overridables
// Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead.
open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model.moleculeName
}
open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { model.moleculeName }
open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil
}
open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { nil }
open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return nil
}
open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { nil }
// MARK: - Caret View
/// Adds the standard mvm style caret to the accessory view
@ -244,7 +238,7 @@ import UIKit
// MARK: - MoleculeListCellProtocol
/// For when the separator between cells shows using json and frequency. Default is type: standard, frequency: allExceptTop.
public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) {
open func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) {
addSeparatorsIfNeeded()
if let model = model {
topSeparatorView?.set(with: model, delegateObject, additionalData)
@ -256,12 +250,16 @@ import UIKit
setSeparatorFrequency(model?.frequency ?? .allExceptTop, indexPath: indexPath)
}
public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
open func willSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool { true }
open func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
guard let action = listItemModel?.action else { return }
Button.performButtonAction(with: action, button: self, delegateObject: delegateObject, additionalData: additionalData)
}
public func willDisplay() {
open func didDeselectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { }
open func willDisplay() {
_ = alignAccessoryToHero()
}

View File

@ -6,12 +6,19 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
open class ProgrammaticScrollViewController: ScrollingViewController {
//--------------------------------------------------
// MARK: - Constraints
//--------------------------------------------------
public var topConstraint: NSLayoutConstraint?
public var bottomConstraint: NSLayoutConstraint?
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public override init(with scrollView: UIScrollView) {
super.init(with: scrollView)
}
@ -24,6 +31,10 @@ open class ProgrammaticScrollViewController: ScrollingViewController {
super.init(coder: coder)
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
open override func loadView() {
let view = UIView()

View File

@ -6,11 +6,18 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UITableViewDelegate, UITableViewDataSource {
//--------------------------------------------------
// MARK: - Outlet
//--------------------------------------------------
@IBOutlet public var tableView: TableView!
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public init(with tableView: TableView) {
self.tableView = tableView
super.init(with: tableView)
@ -24,9 +31,13 @@ open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UI
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
open override func loadView() {
let view = UIView()
view.backgroundColor = .white
view.backgroundColor = .mvmWhite
let tableView = createTableView()
tableView.translatesAutoresizingMaskIntoConstraints = false
@ -47,19 +58,23 @@ open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UI
registerWithTable()
}
//--------------------------------------------------
// MARK: - Table View
//--------------------------------------------------
/// This class should create the table view that will be used here. Subclass this for different table styles.
open func createTableView() -> TableView {
let tableView = TableView(frame: .zero, style: .grouped)
tableView.backgroundColor = .clear
tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.insetsContentViewsToSafeArea = false
return tableView
}
// Registers classes and nibs. Can subclass for different nibs. Can call super and then add new ones after as well.
open func registerWithTable() {}
/// Registers classes and nibs. Can subclass for different nibs. Can call super and then add new ones after as well.
open func registerWithTable() { }
/// Sets the table to have no section headers or footers.
open func setNoSectionHeadersFooters() {
@ -73,19 +88,17 @@ open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UI
}
/// For subclassing, returns the number of sections for table. This function calls numberOfSectionsForTableview aftre ensuring the table is setup properly.
open func getNumberOfSections() -> Int {
return 1
}
open func getNumberOfSections() -> Int { 1 }
open func numberOfSections(in tableView: UITableView) -> Int {
return tableView.bounds.width > 1 ? getNumberOfSections() : 0
tableView.bounds.width > 1 ? getNumberOfSections() : 0
}
open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}
open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 0 }
open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return UITableViewCell()
}
open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { UITableViewCell() }
open func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) { }
open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { }
}

View File

@ -11,17 +11,33 @@ import MVMAnimationFramework
open class ThreeLayerTableViewController: ProgrammaticTableViewController {
// The three main views
//--------------------------------------------------
// MARK: - Main Views
//--------------------------------------------------
private var topView: UIView?
private var bottomView: UIView?
private var headerView: UIView?
private var footerView: UIView?
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var bottomViewOutsideOfScrollArea: Bool = false
public var topViewOutsideOfScrollArea: Bool = false
//--------------------------------------------------
// MARK: - Constraints
//--------------------------------------------------
private var topViewBottomConstraint: NSLayoutConstraint?
private var bottomViewTopConstraint: NSLayoutConstraint?
//MARK: - MFViewController
//--------------------------------------------------
// MARK: - MFViewController
//--------------------------------------------------
open override func updateViews() {
super.updateViews()
let width = view.bounds.width
@ -54,23 +70,20 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController {
self?.view.setNeedsUpdateConstraints()
}
}
//--------------------------------------------------
// MARK: - Spacing
//--------------------------------------------------
//MARK: - Spacing
// If both are subclassed to return a value, then the buttons will not be pinned towards the bottom because neither spacing would try to fill the screen.
/// Space between the top view and the table sections, nil to fill. 0 default
open func spaceBelowTopView() -> CGFloat? {
return 0
}
open func spaceBelowTopView() -> CGFloat? { 0 }
/// Space between the bottom view and the table sections, nil to fill. nil default
open func spaceAboveBottomView() -> CGFloat? {
return nil
}
open func spaceAboveBottomView() -> CGFloat? { nil }
/// can override to return a minimum fill space.
open func minimumFillSpace() -> CGFloat {
return 0
}
open func minimumFillSpace() -> CGFloat { 0 }
open override func updateViewConstraints() {
guard let tableView = tableView else {
@ -126,7 +139,10 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController {
super.updateViewConstraints()
}
//MARK: - Header Footer
//--------------------------------------------------
// MARK: - Header Footer
//--------------------------------------------------
/// Gets the top view and adds it to a spacing view, headerView, and then calls showHeader.
open func createViewForTableHeader() {
var topView = viewForTop()
@ -228,17 +244,20 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController {
tableView.tableFooterView = tableFooterView
}
//MARK: - Functions to subclass
//--------------------------------------------------
// MARK: - Functions to subclass
//--------------------------------------------------
/// Subclass for a top view.
open func viewForTop() -> UIView {
// Small height is needed to stop apple from adding padding for grouped tables when no header.
return MVMCoreUICommonViewsUtility.getView(with: 0.5)
MVMCoreUICommonViewsUtility.getView(with: 0.5)
}
/// Subclass for a bottom view.
open func viewForBottom() -> UIView {
// Default spacing is standard when no buttons.
return MVMCoreUICommonViewsUtility.getView(with: PaddingDefaultVerticalSpacing)
MVMCoreUICommonViewsUtility.getView(with: PaddingDefaultVerticalSpacing)
}
deinit {

View File

@ -653,7 +653,7 @@ import UIKit
// MARK: - Behavior Execution
//--------------------------------------------------
func executeBehaviors<T>(_ behaviorBlock:(_ behavior:T)->Void) {
func executeBehaviors<T>(_ behaviorBlock: (_ behavior: T) -> Void) {
behaviors?.compactMap { $0 as? T }.forEach { behaviorBlock($0) }
}
}

View File

@ -18,8 +18,8 @@ public extension PageBehaviorHandlerModelProtocol {
guard !behavior.shouldAllowMultipleInstances,
!newBehaviors.contains(where: { $0.behaviorName == behavior.behaviorName
}) else { return }
newBehaviors.append(behavior)
self.behaviors = newBehaviors
}
}

View File

@ -6,7 +6,6 @@
// Copyright © 2021 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol PageBehaviorHandlerProtocol {
var behaviors: [PageBehaviorProtocol]? { get set }
@ -19,7 +18,9 @@ public extension PageBehaviorHandlerProtocol {
behaviors = nil
return
}
var behaviors: [PageBehaviorProtocol] = []
for behaviorModel in behaviorModels {
do {
let handlerType = try ModelRegistry.getHandler(behaviorModel) as! PageBehaviorProtocol.Type

View File

@ -6,6 +6,7 @@
// Copyright © 2021 Verizon Wireless. All rights reserved.
//
public protocol PageBehaviorModelProtocol: ModelProtocol {
/// The type of rule
@ -18,11 +19,11 @@ public protocol PageBehaviorModelProtocol: ModelProtocol {
public extension PageBehaviorModelProtocol {
var behaviorName: String {
get { type(of:self).identifier }
type(of:self).identifier
}
static var shouldAllowMultipleInstances: Bool {
get { true }
true
}
static var categoryCodingKey: String {

View File

@ -6,7 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol PageBehaviorProtocol: ModelHandlerProtocol {
@ -46,9 +45,8 @@ public protocol PageCustomActionHandlerBehavior: PageBehaviorProtocol {
}
public extension MVMCoreUIDelegateObject {
weak var behaviorTemplateDelegate: (PageBehaviorHandlerProtocol & NSObjectProtocol)? {
get {
return (moleculeDelegate as? PageProtocol)?.pageModel as? (PageBehaviorHandlerProtocol & NSObjectProtocol)
}
(moleculeDelegate as? PageProtocol)?.pageModel as? (PageBehaviorHandlerProtocol & NSObjectProtocol)
}
}

View File

@ -18,7 +18,7 @@ open class Container: View, ContainerProtocol {
public let containerHelper = ContainerHelper()
public var containerModel: ContainerModelProtocol? {
get { return model as? ContainerModelProtocol }
get { model as? ContainerModelProtocol }
}
//--------------------------------------------------

View File

@ -6,7 +6,6 @@
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
open class ContainerModel: ContainerModelProtocol, Codable {
@ -44,7 +43,7 @@ open class ContainerModel: ContainerModelProtocol, Codable {
//--------------------------------------------------
/// Sets the default values. Should be called on init.
open func setDefaults() {}
open func setDefaults() { }
//--------------------------------------------------
// MARK: - Initializers

View File

@ -6,8 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public class RuleRegexModel: RulesProtocol {
//--------------------------------------------------