Molecule stack fix
This commit is contained in:
parent
b302d2ff61
commit
9e241e6d8e
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol StackItemModelProtocol: MoleculeModelProtocol {
|
||||
public protocol StackItemModelProtocol {
|
||||
var spacing: CGFloat? { get set }
|
||||
var percent: Int? { get set }
|
||||
var gone: Bool { get set }
|
||||
|
||||
@ -220,7 +220,7 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
|
||||
open func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
guard let stackItemModels = (model as? StackModelProtocol)?.molecules else { return }
|
||||
for model in stackItemModels {
|
||||
if let stackItem = MoleculeObjectMapping.shared()?.createMolecule(model, delegateObject: delegateObject, additionalData: additionalData) as? (MoleculeViewProtocol & StackModelProtocol) {
|
||||
if let stackItem = MoleculeObjectMapping.shared()?.createMolecule(model, delegateObject: delegateObject, additionalData: additionalData) {
|
||||
stackItems.append(stackItem)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,12 +15,12 @@ import Foundation
|
||||
return "stack"
|
||||
}
|
||||
public var backgroundColor: Color?
|
||||
public var molecules: [StackItemModelProtocol]
|
||||
public var molecules: [StackItemModelProtocol & MoleculeModelProtocol]
|
||||
public var axis: NSLayoutConstraint.Axis = .vertical
|
||||
public var spacing: CGFloat = StackModel.defaultSpacing
|
||||
public var useStackSpacingBeforeFirstItem = false
|
||||
|
||||
public init(molecules: [StackItemModelProtocol], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) {
|
||||
public init(molecules: [StackItemModelProtocol & MoleculeModelProtocol], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) {
|
||||
self.molecules = molecules
|
||||
if let axis = axis {
|
||||
self.axis = axis
|
||||
@ -41,7 +41,7 @@ import Foundation
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
molecules = try typeContainer.decodeModel(codingKey: .molecules)
|
||||
molecules = try typeContainer.decodeModels(codingKey: .molecules)
|
||||
if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) {
|
||||
axis = optionalAxis
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
public protocol StackModelProtocol {
|
||||
var molecules: [StackItemModelProtocol] { get set }
|
||||
var molecules: [StackItemModelProtocol & MoleculeModelProtocol] { get set }
|
||||
var axis: NSLayoutConstraint.Axis { get set }
|
||||
var spacing: CGFloat { get set }
|
||||
var useStackSpacingBeforeFirstItem: Bool { get set }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user