modal accessibility

This commit is contained in:
Kevin G Christiano 2020-05-19 09:42:35 -04:00
parent 07a66b17a7
commit 76326a1a34
4 changed files with 43 additions and 15 deletions

View File

@ -14,6 +14,7 @@ open class MoleculeCollectionViewCell: CollectionViewCell {
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData) super.set(with: model, delegateObject, additionalData)
guard let collectionModel = model as? MoleculeCollectionItemModel else { return } guard let collectionModel = model as? MoleculeCollectionItemModel else { return }
if molecule == nil { if molecule == nil {
if let moleculeView = MoleculeObjectMapping.shared()?.createMolecule(collectionModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { if let moleculeView = MoleculeObjectMapping.shared()?.createMolecule(collectionModel.molecule, delegateObject: delegateObject, additionalData: additionalData) {
addMolecule(moleculeView) addMolecule(moleculeView)
@ -24,13 +25,12 @@ open class MoleculeCollectionViewCell: CollectionViewCell {
guard let molecule = molecule as? (UIView & MVMCoreUIViewConstrainingProtocol) else { return } guard let molecule = molecule as? (UIView & MVMCoreUIViewConstrainingProtocol) else { return }
containerHelper.set(with: collectionModel, for: molecule) containerHelper.set(with: collectionModel, for: molecule)
accessibilityElements = molecule.subviews
} }
open override func reset() { open override func reset() {
super.reset() super.reset()
molecule?.reset() molecule?.reset()
backgroundColor = .white backgroundColor = .mvmWhite
} }
open class func nameForReuse(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { open class func nameForReuse(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {

View File

@ -8,6 +8,7 @@
import UIKit import UIKit
open class ModalMoleculeListTemplate: MoleculeListTemplate { open class ModalMoleculeListTemplate: MoleculeListTemplate {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
@ -15,13 +16,20 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate {
public var closeButton: Button? public var closeButton: Button?
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------
override open func handleNewData() { override open func handleNewData() {
super.handleNewData() super.handleNewData()
closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { _ in closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { _ in
MVMCoreNavigationHandler.shared()?.removeCurrentViewController() MVMCoreNavigationHandler.shared()?.removeCurrentViewController()
}) })
}
open override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
accessibilityElements = [closeButton as Any, tableView as Any] accessibilityElements = [closeButton as Any, tableView as Any]
UIAccessibility.post(notification: .layoutChanged, argument: closeButton)
} }
} }

View File

@ -8,6 +8,7 @@
import UIKit import UIKit
open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol { open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Stored Properties // MARK: - Stored Properties

View File

@ -8,8 +8,12 @@
import Foundation import Foundation
/// A base collection view cell with basic mvm functionality. /// A base collection view cell with basic mvm functionality.
open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCoreViewProtocol, CollectionTemplateItemProtocol { open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCoreViewProtocol, CollectionTemplateItemProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
// Convenience helpers // Convenience helpers
open var molecule: MoleculeViewProtocol? open var molecule: MoleculeViewProtocol?
@ -21,6 +25,10 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo
private var initialSetupPerformed = false private var initialSetupPerformed = false
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
// MARK: - Inits // MARK: - Inits
public override init(frame: CGRect) { public override init(frame: CGRect) {
super.init(frame: .zero) super.init(frame: .zero)
@ -39,6 +47,10 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo
} }
} }
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
// MARK: - MVMCoreViewProtocol // MARK: - MVMCoreViewProtocol
open func setupView() { open func setupView() {
isAccessibilityElement = false isAccessibilityElement = false
@ -58,10 +70,14 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo
open func reset() { open func reset() {
molecule?.reset() molecule?.reset()
backgroundColor = .white backgroundColor = .mvmWhite
width = nil width = nil
} }
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
// MARK: - MoleculeViewProtocol // MARK: - MoleculeViewProtocol
open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? CollectionItemModelProtocol else { return } guard let model = model as? CollectionItemModelProtocol else { return }
@ -85,7 +101,10 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo
self.molecule = molecule self.molecule = molecule
} }
//--------------------------------------------------
// MARK: - CollectionTemplateItemProtocol // MARK: - CollectionTemplateItemProtocol
//--------------------------------------------------
public func set(width: CGFloat) { public func set(width: CGFloat) {
self.width = width self.width = width
} }
@ -96,9 +115,9 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo
guard let width = width else { return autoLayoutAttributes } guard let width = width else { return autoLayoutAttributes }
let targetSize = CGSize(width: width, height: 0) let targetSize = CGSize(width: width, height: 0)
let newSize = contentView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: UILayoutPriority.required, verticalFittingPriority: UILayoutPriority.defaultLow) let newSize = contentView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .defaultLow)
let newFrame = CGRect(origin: autoLayoutAttributes.frame.origin, size: newSize) let newFrame = CGRect(origin: autoLayoutAttributes.frame.origin, size: newSize)
autoLayoutAttributes.frame = newFrame autoLayoutAttributes.frame = newFrame
return autoLayoutAttributes return autoLayoutAttributes
} }
} }