re-organizing

This commit is contained in:
Pfeil, Scott Robert 2020-01-22 09:11:56 -05:00
parent 045cfeb7f9
commit 00d1bf7be6
5 changed files with 24 additions and 41 deletions

View File

@ -658,7 +658,6 @@
children = (
011B58EE23A2AA850085F53C /* ModelProtocols */,
946EE1B5237B663A0036751F /* Extensions */,
01EB368723609801006832FA /* Molecules */,
);
path = Models;
sourceTree = "<group>";
@ -674,16 +673,6 @@
path = FormUIHelpers;
sourceTree = "<group>";
};
01EB368723609801006832FA /* Molecules */ = {
isa = PBXGroup;
children = (
012A88AE238C626E00FE3DA1 /* CarouselModel.swift */,
012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */,
012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */,
);
path = Molecules;
sourceTree = "<group>";
};
0A5D59C323AD488600EFD9E9 /* Protocols */ = {
isa = PBXGroup;
children = (
@ -859,6 +848,7 @@
D260105C23D0BCD400764D80 /* Stack.swift */,
01EB368B23609801006832FA /* MoleculeStackModel.swift */,
D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */,
012A88AE238C626E00FE3DA1 /* CarouselModel.swift */,
D2A6390022CBB1820052ED1F /* Carousel.swift */,
);
path = Organisms;
@ -870,6 +860,7 @@
D2755D7A23689C7500485468 /* TableViewCell.swift */,
01EB368923609801006832FA /* ListItemModel.swift */,
01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */,
012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */,
D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */,
D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */,
D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */,
@ -998,6 +989,7 @@
012A88EB238F084D00FE3DA1 /* FooterModel.swift */,
D274CA322236A78900B01B62 /* FooterView.swift */,
0116A4E4228B19640094F3ED /* RadioButtonModel.swift */,
012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */,
D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */,
D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */,
D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */,

View File

@ -15,14 +15,14 @@ import Foundation
public var peakingUI: Bool?
public var peakingArrowColor: Color?
enum CarouselItemCodingKeys: String, CodingKey {
private enum CodingKeys: String, CodingKey {
case backgroundColor
case peakingUI
case peakingArrowColor
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CarouselItemCodingKeys.self)
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI)
peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor)
@ -31,7 +31,7 @@ import Foundation
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CarouselItemCodingKeys.self)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(peakingUI, forKey: .peakingUI)
try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor)

View File

@ -13,7 +13,7 @@ open class ModuleMoleculeModel: MoleculeModelProtocol {
public static var identifier: String = "moduleMolecule"
public var moduleName: String
enum CodingKeys: String, CodingKey {
private enum CodingKeys: String, CodingKey {
case moduleName
}

View File

@ -8,7 +8,7 @@
import UIKit
open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
open class Carousel: View {
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
@ -47,6 +47,9 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
var loop = false
private var dragging = false
// For adding pager
private var bottomPin: NSLayoutConstraint?
// MARK: - MVMCoreViewProtocol
open override func setupView() {
super.setupView()
@ -60,7 +63,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
collectionView.backgroundColor = .clear
collectionView.isAccessibilityElement = false
addSubview(collectionView)
pinView(toSuperView: collectionView)
bottomPin = NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView)?[ConstraintBot] as? NSLayoutConstraint
collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300)
collectionViewHeight?.isActive = false
@ -81,40 +84,28 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
// MARK: - MVMCoreUIMoleculeViewProtocol
//TODO: Model, Change to model
public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let caroselModel = model as? CarouselModel else {
return
}
#warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.")
//TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.
setUpDefaultWithModel(model, delegateObject, additionalData)
public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let carouselModel = model as? CarouselModel else { return }
collectionView.backgroundColor = backgroundColor
collectionView.layer.borderColor = backgroundColor?.cgColor
collectionView.layer.borderWidth = (caroselModel.border ?? false) ? 1 : 0
collectionView.layer.borderWidth = (carouselModel.border ?? false) ? 1 : 0
backgroundColor = .white
registerCells(with: caroselModel, delegateObject: delegateObject)
setupLayout(with: caroselModel)
prepareMolecules(with: caroselModel)
itemWidthPercent = (caroselModel.itemWidthPercent ?? 100) / 100
setAlignment(with: caroselModel.itemAlignment)
registerCells(with: carouselModel, delegateObject: delegateObject)
setupLayout(with: carouselModel)
prepareMolecules(with: carouselModel)
itemWidthPercent = (carouselModel.itemWidthPercent ?? 100) / 100
setAlignment(with: carouselModel.itemAlignment)
if let height = caroselModel.height {
if let height = carouselModel.height {
collectionViewHeight?.constant = CGFloat(height)
collectionViewHeight?.isActive = true
}
setupPagingMolecule(caroselModel.pagingMolecule, delegateObject: delegateObject)
setupPagingMolecule(carouselModel.pagingMolecule, delegateObject: delegateObject)
collectionView.reloadData()
}
open override func shouldSetHorizontalMargins(_ shouldSet: Bool) {
super.shouldSetHorizontalMargins(shouldSet)
updateViewHorizontalDefaults = false
}
// MARK: - JSON Setters
/// Updates the layout being used

View File

@ -25,7 +25,7 @@ import UIKit
self.molecules = molecules
}
enum CodingKeys: String, CodingKey {
private enum CodingKeys: String, CodingKey {
case moleculeName
case backgroundColor
case molecules