Merge branch 'bugfix/accordion_layout_fix' into 'develop'
getting the accordion accessory to work See merge request BPHV_MIPS/mvm_core_ui!585
This commit is contained in:
commit
dc8e580f87
@ -9,12 +9,21 @@
|
||||
import UIKit
|
||||
|
||||
class AccordionListItemModel: MoleculeListItemModel {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
override public class var identifier: String {
|
||||
return "accordionListItem"
|
||||
}
|
||||
}
|
||||
|
||||
public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]
|
||||
public var hideLineWhenExpanded: Bool = false
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Keys
|
||||
//--------------------------------------------------
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case molecules
|
||||
@ -22,11 +31,19 @@ class AccordionListItemModel: MoleculeListItemModel {
|
||||
case hideLineWhenExpanded
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Methods
|
||||
//--------------------------------------------------
|
||||
|
||||
public override func setDefaults() {
|
||||
super.setDefaults()
|
||||
hideArrow = true
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Codec
|
||||
//--------------------------------------------------
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
molecules = try typeContainer.decodeModels(codingKey: .molecules)
|
||||
|
||||
@ -8,20 +8,29 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
|
||||
@objcMembers public class AccordionMoleculeTableViewCell: MoleculeTableViewCell {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
var accordionListItemModel: AccordionListItemModel? {
|
||||
return listItemModel as? AccordionListItemModel
|
||||
}
|
||||
let accordionButton = createAccordionButton()
|
||||
|
||||
static func createAccordionButton() -> Button {
|
||||
let accordionButton: Button = {
|
||||
let accordionButton = Button(type: .custom)
|
||||
accordionButton.setTitle("+", for: .normal)
|
||||
accordionButton.setTitleColor(.black, for: .normal)
|
||||
accordionButton.titleLabel?.font = UIFont.systemFont(ofSize: 40, weight: .ultraLight)
|
||||
accordionButton.frame = CGRect(x: 0, y: 0, width: 20, height: 20)
|
||||
accordionButton.translatesAutoresizingMaskIntoConstraints = true
|
||||
return accordionButton
|
||||
}
|
||||
}()
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Setup
|
||||
//--------------------------------------------------
|
||||
|
||||
override public func setupView() {
|
||||
customAccessoryView = true
|
||||
@ -29,11 +38,13 @@ import UIKit
|
||||
accessoryView = accordionButton
|
||||
}
|
||||
|
||||
override public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
accordionButton.isSelected = !accordionButton.isSelected
|
||||
override public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
accordionButton.isSelected.toggle()
|
||||
accordionButton.setTitle(accordionButton.isSelected ? "-" : "+", for: .normal)
|
||||
|
||||
guard let model = accordionListItemModel else { return }
|
||||
|
||||
|
||||
if accordionButton.isSelected {
|
||||
if let indexPath = delegateObject?.moleculeDelegate?.getIndexPath(for: model) {
|
||||
delegateObject?.moleculeDelegate?.addMolecules(model.molecules, indexPath: indexPath, animation: .automatic)
|
||||
|
||||
@ -8,8 +8,12 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers open class TableViewCell: UITableViewCell, MoleculeViewProtocol, MoleculeListCellProtocol, MVMCoreViewProtocol, MFButtonProtocol {
|
||||
|
||||
@objcMembers open class TableViewCell: UITableViewCell, MoleculeViewProtocol, MoleculeListCellProtocol, MVMCoreViewProtocol, MFButtonProtocol {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
open var molecule: MoleculeViewProtocol?
|
||||
open var listItemModel: ListItemModelProtocol?
|
||||
public let containerHelper = ContainerHelper()
|
||||
@ -30,7 +34,10 @@ import UIKit
|
||||
|
||||
private var initialSetupPerformed = false
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Styling
|
||||
//--------------------------------------------------
|
||||
|
||||
open func styleLine(with style: ListItemStyle?) {
|
||||
switch style {
|
||||
case .standard?:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user