confluence changes Updated
This commit is contained in:
parent
870658b4c1
commit
7cba93e9f5
@ -135,7 +135,6 @@ open class RadioBoxCollectionViewCell: UICollectionViewCell, MoleculeViewProtoco
|
||||
lineView.backgroundColor = collectionModel.selectedAccentColor?.uiColor
|
||||
bodyLabel.text = collectionModel.text
|
||||
subTextLabel.text = collectionModel.subText
|
||||
// isSelected = collectionModel.selected
|
||||
fieldValue = collectionModel.fieldValue
|
||||
isOutOfStock = collectionModel.strikethrough
|
||||
|
||||
|
||||
@ -17,6 +17,8 @@ import Foundation
|
||||
public var enabled: Bool = true
|
||||
public var strikethrough: Bool = false
|
||||
public var fieldValue: String?
|
||||
public var fieldKey: String?
|
||||
public var groupName: String?
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
@ -28,6 +30,9 @@ import Foundation
|
||||
case enabled
|
||||
case strikethrough
|
||||
case fieldValue
|
||||
case fieldKey
|
||||
case groupName
|
||||
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
@ -50,6 +55,9 @@ import Foundation
|
||||
strikethrough = isStrikeTrough
|
||||
}
|
||||
fieldValue = try typeContainer.decodeIfPresent(String.self, forKey: .fieldValue)
|
||||
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
||||
groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName)
|
||||
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -63,5 +71,8 @@ import Foundation
|
||||
try container.encodeIfPresent(enabled, forKey: .enabled)
|
||||
try container.encodeIfPresent(strikethrough, forKey: .strikethrough)
|
||||
try container.encodeIfPresent(fieldValue, forKey: .fieldValue)
|
||||
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,13 +14,18 @@ open class RadioBoxes: View {
|
||||
|
||||
/// The models for the molecules.
|
||||
var boxes: [RadioBoxModel]?
|
||||
public var fieldKey: String?
|
||||
public var groupName: String?
|
||||
public var collectionViewHeight: NSLayoutConstraint?
|
||||
private let boxWidth: Double = 151.0
|
||||
private let boxHeight: Double = 64.0
|
||||
private let itemSpacing: Double = 10.0
|
||||
private let leadingSpacing: Double = 0
|
||||
|
||||
public var selectedBox: RadioBoxModel? {
|
||||
get{
|
||||
guard let selectedItem = collectionView.indexPathsForSelectedItems?.first else {return nil}
|
||||
return boxes?[selectedItem.item]
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
open override func setupView() {
|
||||
@ -45,8 +50,6 @@ open class RadioBoxes: View {
|
||||
super.set(with: model, delegateObject, additionalData)
|
||||
guard let radioBoxesModel = model as? RadioBoxesModel else { return }
|
||||
backgroundColor = radioBoxesModel.backgroundColor?.uiColor
|
||||
fieldKey = radioBoxesModel.fieldKey
|
||||
groupName = radioBoxesModel.groupName
|
||||
registerCells()
|
||||
setupLayout(with: radioBoxesModel)
|
||||
prepareMolecules(with: radioBoxesModel)
|
||||
@ -119,3 +122,14 @@ extension RadioBoxes: UICollectionViewDataSource {
|
||||
return cell
|
||||
}
|
||||
}
|
||||
extension RadioBoxes: UICollectionViewDelegate {
|
||||
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
guard let boxItem = boxes?[indexPath.row] else { return }
|
||||
boxItem.selected = true
|
||||
}
|
||||
public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
|
||||
guard let boxItem = boxes?[indexPath.row] else { return }
|
||||
boxItem.selected = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,16 +12,13 @@ import Foundation
|
||||
public var backgroundColor: Color? = Color(uiColor: .white)
|
||||
public var selectedAccentColor: Color? = Color(uiColor: .red)
|
||||
public var boxes: [RadioBoxModel]
|
||||
public var fieldKey: String?
|
||||
public var groupName: String?
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case selectedAccentColor
|
||||
case backgroundColor
|
||||
case boxes
|
||||
case fieldKey
|
||||
case groupName
|
||||
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
@ -33,8 +30,6 @@ import Foundation
|
||||
backgroundColor = color
|
||||
}
|
||||
boxes = try typeContainer.decode([RadioBoxModel].self, forKey: .boxes)
|
||||
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
||||
groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -42,7 +37,5 @@ import Foundation
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(selectedAccentColor, forKey: .selectedAccentColor)
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user