Improving accordion behavior. Not the +/- button responds to user interaction.
This commit is contained in:
parent
7c9be2e3de
commit
fa99ba6b42
@ -6,8 +6,6 @@
|
|||||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
|
|
||||||
@objcMembers public class AccordionMoleculeTableViewCell: MoleculeTableViewCell {
|
@objcMembers public class AccordionMoleculeTableViewCell: MoleculeTableViewCell {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -28,6 +26,8 @@ import UIKit
|
|||||||
return accordionButton
|
return accordionButton
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
var delegateObject: MVMCoreUIDelegateObject?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Setup
|
// MARK: - Setup
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -36,10 +36,27 @@ import UIKit
|
|||||||
customAccessoryView = true
|
customAccessoryView = true
|
||||||
super.setupView()
|
super.setupView()
|
||||||
accessoryView = accordionButton
|
accessoryView = accordionButton
|
||||||
|
|
||||||
|
accordionButton.addActionBlock(event: .touchUpInside) { _ in
|
||||||
|
guard let model = self.accordionListItemModel else { return }
|
||||||
|
|
||||||
|
if let indexPath = self.delegateObject?.moleculeDelegate?.getIndexPath(for: model) {
|
||||||
|
self.toggleAccordion(at: indexPath, delegateObject: self.delegateObject)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Methods
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
override public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
override public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
|
||||||
|
toggleAccordion(at: index, delegateObject: delegateObject)
|
||||||
|
}
|
||||||
|
|
||||||
|
func toggleAccordion(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
|
|
||||||
accordionButton.isSelected.toggle()
|
accordionButton.isSelected.toggle()
|
||||||
accordionButton.setTitle(accordionButton.isSelected ? "-" : "+", for: .normal)
|
accordionButton.setTitle(accordionButton.isSelected ? "-" : "+", for: .normal)
|
||||||
|
|
||||||
@ -57,4 +74,9 @@ import UIKit
|
|||||||
bottomSeparatorView?.isHidden = accordionButton.isSelected
|
bottomSeparatorView?.isHidden = accordionButton.isSelected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
self.delegateObject = delegateObject
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user