re-organizing
This commit is contained in:
parent
045cfeb7f9
commit
00d1bf7be6
@ -658,7 +658,6 @@
|
|||||||
children = (
|
children = (
|
||||||
011B58EE23A2AA850085F53C /* ModelProtocols */,
|
011B58EE23A2AA850085F53C /* ModelProtocols */,
|
||||||
946EE1B5237B663A0036751F /* Extensions */,
|
946EE1B5237B663A0036751F /* Extensions */,
|
||||||
01EB368723609801006832FA /* Molecules */,
|
|
||||||
);
|
);
|
||||||
path = Models;
|
path = Models;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -674,16 +673,6 @@
|
|||||||
path = FormUIHelpers;
|
path = FormUIHelpers;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
01EB368723609801006832FA /* Molecules */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
012A88AE238C626E00FE3DA1 /* CarouselModel.swift */,
|
|
||||||
012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */,
|
|
||||||
012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */,
|
|
||||||
);
|
|
||||||
path = Molecules;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
0A5D59C323AD488600EFD9E9 /* Protocols */ = {
|
0A5D59C323AD488600EFD9E9 /* Protocols */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -859,6 +848,7 @@
|
|||||||
D260105C23D0BCD400764D80 /* Stack.swift */,
|
D260105C23D0BCD400764D80 /* Stack.swift */,
|
||||||
01EB368B23609801006832FA /* MoleculeStackModel.swift */,
|
01EB368B23609801006832FA /* MoleculeStackModel.swift */,
|
||||||
D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */,
|
D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */,
|
||||||
|
012A88AE238C626E00FE3DA1 /* CarouselModel.swift */,
|
||||||
D2A6390022CBB1820052ED1F /* Carousel.swift */,
|
D2A6390022CBB1820052ED1F /* Carousel.swift */,
|
||||||
);
|
);
|
||||||
path = Organisms;
|
path = Organisms;
|
||||||
@ -870,6 +860,7 @@
|
|||||||
D2755D7A23689C7500485468 /* TableViewCell.swift */,
|
D2755D7A23689C7500485468 /* TableViewCell.swift */,
|
||||||
01EB368923609801006832FA /* ListItemModel.swift */,
|
01EB368923609801006832FA /* ListItemModel.swift */,
|
||||||
01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */,
|
01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */,
|
||||||
|
012A88C1238D7BCA00FE3DA1 /* CarouselItemModel.swift */,
|
||||||
D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */,
|
D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */,
|
||||||
D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */,
|
D28A838023CCB0D800DFE4FC /* AccordionListItemModel.swift */,
|
||||||
D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */,
|
D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */,
|
||||||
@ -998,6 +989,7 @@
|
|||||||
012A88EB238F084D00FE3DA1 /* FooterModel.swift */,
|
012A88EB238F084D00FE3DA1 /* FooterModel.swift */,
|
||||||
D274CA322236A78900B01B62 /* FooterView.swift */,
|
D274CA322236A78900B01B62 /* FooterView.swift */,
|
||||||
0116A4E4228B19640094F3ED /* RadioButtonModel.swift */,
|
0116A4E4228B19640094F3ED /* RadioButtonModel.swift */,
|
||||||
|
012A88C5238DA34000FE3DA1 /* ModuleMoleculeModel.swift */,
|
||||||
D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */,
|
D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */,
|
||||||
D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */,
|
D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */,
|
||||||
D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */,
|
D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */,
|
||||||
|
|||||||
@ -15,14 +15,14 @@ import Foundation
|
|||||||
public var peakingUI: Bool?
|
public var peakingUI: Bool?
|
||||||
public var peakingArrowColor: Color?
|
public var peakingArrowColor: Color?
|
||||||
|
|
||||||
enum CarouselItemCodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case peakingUI
|
case peakingUI
|
||||||
case peakingArrowColor
|
case peakingArrowColor
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
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)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI)
|
peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI)
|
||||||
peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor)
|
peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor)
|
||||||
@ -31,7 +31,7 @@ import Foundation
|
|||||||
|
|
||||||
public override func encode(to encoder: Encoder) throws {
|
public override func encode(to encoder: Encoder) throws {
|
||||||
try super.encode(to: encoder)
|
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(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeIfPresent(peakingUI, forKey: .peakingUI)
|
try container.encodeIfPresent(peakingUI, forKey: .peakingUI)
|
||||||
try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor)
|
try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor)
|
||||||
|
|||||||
@ -13,7 +13,7 @@ open class ModuleMoleculeModel: MoleculeModelProtocol {
|
|||||||
public static var identifier: String = "moduleMolecule"
|
public static var identifier: String = "moduleMolecule"
|
||||||
public var moduleName: String
|
public var moduleName: String
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moduleName
|
case moduleName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
|
open class Carousel: View {
|
||||||
|
|
||||||
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
|
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
|
||||||
|
|
||||||
@ -47,6 +47,9 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
|
|||||||
var loop = false
|
var loop = false
|
||||||
private var dragging = false
|
private var dragging = false
|
||||||
|
|
||||||
|
// For adding pager
|
||||||
|
private var bottomPin: NSLayoutConstraint?
|
||||||
|
|
||||||
// MARK: - MVMCoreViewProtocol
|
// MARK: - MVMCoreViewProtocol
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
@ -60,7 +63,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
|
|||||||
collectionView.backgroundColor = .clear
|
collectionView.backgroundColor = .clear
|
||||||
collectionView.isAccessibilityElement = false
|
collectionView.isAccessibilityElement = false
|
||||||
addSubview(collectionView)
|
addSubview(collectionView)
|
||||||
pinView(toSuperView: collectionView)
|
bottomPin = NSLayoutConstraint.constraintPinSubview(toSuperview: collectionView)?[ConstraintBot] as? NSLayoutConstraint
|
||||||
|
|
||||||
collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300)
|
collectionViewHeight = collectionView.heightAnchor.constraint(equalToConstant: 300)
|
||||||
collectionViewHeight?.isActive = false
|
collectionViewHeight?.isActive = false
|
||||||
@ -81,40 +84,28 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
|
|||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
//TODO: Model, Change to model
|
//TODO: Model, Change to model
|
||||||
public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
guard let caroselModel = model as? CarouselModel else {
|
super.setWithModel(model, delegateObject, additionalData)
|
||||||
return
|
guard let carouselModel = 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)
|
|
||||||
|
|
||||||
collectionView.backgroundColor = backgroundColor
|
collectionView.backgroundColor = backgroundColor
|
||||||
collectionView.layer.borderColor = backgroundColor?.cgColor
|
collectionView.layer.borderColor = backgroundColor?.cgColor
|
||||||
collectionView.layer.borderWidth = (caroselModel.border ?? false) ? 1 : 0
|
collectionView.layer.borderWidth = (carouselModel.border ?? false) ? 1 : 0
|
||||||
backgroundColor = .white
|
backgroundColor = .white
|
||||||
|
|
||||||
registerCells(with: caroselModel, delegateObject: delegateObject)
|
registerCells(with: carouselModel, delegateObject: delegateObject)
|
||||||
setupLayout(with: caroselModel)
|
setupLayout(with: carouselModel)
|
||||||
prepareMolecules(with: caroselModel)
|
prepareMolecules(with: carouselModel)
|
||||||
itemWidthPercent = (caroselModel.itemWidthPercent ?? 100) / 100
|
itemWidthPercent = (carouselModel.itemWidthPercent ?? 100) / 100
|
||||||
setAlignment(with: caroselModel.itemAlignment)
|
setAlignment(with: carouselModel.itemAlignment)
|
||||||
|
|
||||||
if let height = caroselModel.height {
|
if let height = carouselModel.height {
|
||||||
collectionViewHeight?.constant = CGFloat(height)
|
collectionViewHeight?.constant = CGFloat(height)
|
||||||
collectionViewHeight?.isActive = true
|
collectionViewHeight?.isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPagingMolecule(caroselModel.pagingMolecule, delegateObject: delegateObject)
|
setupPagingMolecule(carouselModel.pagingMolecule, delegateObject: delegateObject)
|
||||||
collectionView.reloadData()
|
collectionView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
open override func shouldSetHorizontalMargins(_ shouldSet: Bool) {
|
|
||||||
super.shouldSetHorizontalMargins(shouldSet)
|
|
||||||
updateViewHorizontalDefaults = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - JSON Setters
|
// MARK: - JSON Setters
|
||||||
/// Updates the layout being used
|
/// Updates the layout being used
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import UIKit
|
|||||||
self.molecules = molecules
|
self.molecules = molecules
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case backgroundColor
|
case backgroundColor
|
||||||
case molecules
|
case molecules
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user