changes while establishing accessibility

This commit is contained in:
Kevin G Christiano 2020-06-04 13:44:00 -04:00
parent 39a12684a5
commit 7ba0e8ad67
3 changed files with 53 additions and 30 deletions

View File

@ -8,19 +8,21 @@
import UIKit
@objcMembers open class ListProgressBarData: TableViewCell {
//-----------------------------------------------------
// MARK: - Outlets
//-----------------------------------------------------
let progressBar = MultiProgress(frame: .zero)
let progressBar = MultiProgress()
let leftLabel = Label.createLabelBoldBodySmall(true)
let rightLabel = Label.createLabelBoldBodySmall(true)
let view = MVMCoreUICommonViewsUtility.commonView()
//-----------------------------------------------------
// MARK: - MFViewProtocol
// MARK: - Lifecycle
//-----------------------------------------------------
override open func setupView() {
super.setupView()
@ -30,7 +32,7 @@ import UIKit
view.addSubview(rightLabel)
contentView.addSubview(view)
containerHelper.constrainView(view)
NSLayoutConstraint.pinViews(leftView: leftLabel, rightView: rightLabel, alignTop: true, bottomAnchor: progressBar.topAnchor, constant: 8)
NSLayoutConstraint.pinViews(leftView: leftLabel, rightView: rightLabel, alignTop: true, bottomAnchor: progressBar.topAnchor, constant: Padding.Two)
progressBar.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
progressBar.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
view.bottomAnchor.constraint(equalTo: progressBar.bottomAnchor).isActive = true
@ -43,24 +45,6 @@ import UIKit
rightLabel.updateView(size)
}
//-----------------------------------------------------
// MARK: - MoleculeViewProtocol
//-----------------------------------------------------
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? ListProgressBarDataModel else { return}
progressBar.set(with: model.progressBar, delegateObject, additionalData)
leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 90
}
//-----------------------------------------------------
// MARK: - MoleculeViewProtocol
//-----------------------------------------------------
override open func reset() {
super.reset()
progressBar.reset()
@ -69,5 +53,22 @@ import UIKit
leftLabel.styleBoldBodySmall(true)
rightLabel.styleBoldBodySmall(true)
}
//-----------------------------------------------------
// MARK: - MoleculeViewProtocol
//-----------------------------------------------------
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
guard let model = model as? ListProgressBarDataModel else { return }
progressBar.set(with: model.progressBar, delegateObject, additionalData)
leftLabel.set(with: model.leftLabel, delegateObject, additionalData)
rightLabel.set(with: model.rightLabel, delegateObject, additionalData)
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 90
}
}

View File

@ -8,12 +8,21 @@
import Foundation
public class ListProgressBarDataModel : ListItemModel, MoleculeModelProtocol {
public class ListProgressBarDataModel: ListItemModel, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "listPrgBarData"
public var progressBar : MultiProgressBarModel
public var leftLabel: LabelModel
public var rightLabel: LabelModel
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init (progressBar: MultiProgressBarModel, leftLabel: LabelModel, rightLabel: LabelModel){
self.progressBar = progressBar
self.leftLabel = leftLabel
@ -21,6 +30,10 @@ public class ListProgressBarDataModel : ListItemModel, MoleculeModelProtocol {
super.init()
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey{
case moleculeName
case progressBar
@ -28,6 +41,10 @@ public class ListProgressBarDataModel : ListItemModel, MoleculeModelProtocol {
case rightLabel
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
progressBar = try typeContainer.decode(MultiProgressBarModel.self, forKey: .progressBar)

View File

@ -103,13 +103,13 @@ open class DoughnutChart: View {
heightConstraint?.isActive = true
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
labelContainerLeftConstraint = labelContainer.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor, constant: lineWidth())
labelContainerLeftConstraint = labelContainer.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor, constant: Padding.Three)
labelContainerLeftConstraint?.isActive = true
labelContainerTopConstraint = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: lineWidth())
labelContainerTopConstraint = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: Padding.Three)
labelContainerTopConstraint?.isActive = true
labelContainerRightConstraint = trailingAnchor.constraint(greaterThanOrEqualTo: labelContainer.trailingAnchor, constant: lineWidth())
labelContainerRightConstraint = trailingAnchor.constraint(greaterThanOrEqualTo: labelContainer.trailingAnchor, constant: Padding.Three)
labelContainerRightConstraint?.isActive = true
labelContainerBottomConstraint = bottomAnchor.constraint(greaterThanOrEqualTo: labelContainer.bottomAnchor, constant: lineWidth())
labelContainerBottomConstraint = bottomAnchor.constraint(greaterThanOrEqualTo: labelContainer.bottomAnchor, constant: Padding.Three)
labelContainerBottomConstraint?.isActive = true
labelContainer.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
labelContainer.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
@ -127,7 +127,9 @@ open class DoughnutChart: View {
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
clearLayers()
guard let doughnutChartModel = doughnutChartModel else { return }
titleLabel.setOptional(with: doughnutChartModel.title, delegateObject, additionalData)
@ -143,7 +145,9 @@ open class DoughnutChart: View {
//--------------------------------------------------
private func drawGraph() {
clearLayers()
let widthHeight = sizeObject.getValueBasedOnApplicationWidth()
doughnutLayer.frame = CGRect(x: 0, y: 0, width: widthHeight, height: widthHeight)
@ -178,11 +182,12 @@ open class DoughnutChart: View {
shapeLayer.path = circlePath.cgPath
doughnutLayer.addSublayer(shapeLayer)
return value
}
private func clearLayers() {
doughnutLayer.sublayers?.forEach{ $0.removeFromSuperlayer() }
doughnutLayer.sublayers?.forEach { $0.removeFromSuperlayer() }
}
public func updateContainer() {
@ -197,7 +202,7 @@ open class DoughnutChart: View {
}
public func lineGap() -> CGFloat {
//If array is having the single item then no space required
// If array is having the single item then no space required
return doughnutChartModel?.sections.count == 1 ? 0.0 : 0.05
}