remove readOnly from the Views and now using the isEnabled and model is controlling this based off enabled & readOnly
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
3fa1be0582
commit
143ebccb34
@ -90,14 +90,6 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
public override var isReadOnly: Bool {
|
||||
get { super.isReadOnly }
|
||||
set (readOnly){
|
||||
digitBoxes.forEach { $0.isReadOnly = readOnly }
|
||||
super.isReadOnly = readOnly
|
||||
}
|
||||
}
|
||||
|
||||
public override var showError: Bool {
|
||||
get { super.showError }
|
||||
set (error) {
|
||||
|
||||
@ -44,15 +44,7 @@ import UIKit
|
||||
super.isEnabled = enabled
|
||||
}
|
||||
}
|
||||
|
||||
@objc public override var isReadOnly: Bool {
|
||||
get { super.isReadOnly }
|
||||
set (readOnly) {
|
||||
dropDownCaretView.isEnabled = !readOnly
|
||||
super.isReadOnly = readOnly
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -90,18 +90,7 @@ import UIKit
|
||||
titleLabel.isRequired = isRequired
|
||||
}
|
||||
}
|
||||
|
||||
/// Toggles readOnly (original) or disabled UI.
|
||||
public var isReadOnly: Bool {
|
||||
get { entryFieldContainer.isReadOnly }
|
||||
set (readOnly) {
|
||||
if(entryFieldContainer.isReadOnly != readOnly){
|
||||
entryFieldContainer.isReadOnly = readOnly
|
||||
entryFieldModel?.readOnly = readOnly
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Toggles error or original UI.
|
||||
public var showError: Bool {
|
||||
get { entryFieldContainer.showError }
|
||||
@ -317,8 +306,7 @@ import UIKit
|
||||
titleLabel.setup(model: model.titleStateLabel, delegateObject, additionalData)
|
||||
feedbackLabel.setup(model: model.feedbackStateLabel, delegateObject, additionalData)
|
||||
|
||||
isEnabled = model.enabled
|
||||
isReadOnly = model.readOnly
|
||||
isEnabled = model.enabled && !model.readOnly
|
||||
isRequired = model.required
|
||||
model.updateUI = { [weak self] in
|
||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||
|
||||
@ -69,7 +69,7 @@ import UIKit
|
||||
guard let self = self else { return }
|
||||
|
||||
self.textField.isEnabled = enabled
|
||||
self.textField.textColor = enabled && !self.isReadOnly ? self.textEntryFieldModel?.enabledTextColor.uiColor : self.textEntryFieldModel?.disabledTextColor.uiColor
|
||||
self.textField.textColor = enabled ? self.textEntryFieldModel?.enabledTextColor.uiColor : self.textEntryFieldModel?.disabledTextColor.uiColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,25 +46,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
if self.textView.isShowingPlaceholder {
|
||||
self.textView.textColor = self.textView.placeholderTextColor
|
||||
} else {
|
||||
self.textView.textColor = (enabled && !self.isReadOnly ? self.textViewEntryFieldModel?.enabledTextColor : self.textViewEntryFieldModel?.disabledTextColor)?.uiColor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override var isReadOnly: Bool {
|
||||
get { super.isReadOnly }
|
||||
set (readOnly) {
|
||||
super.isReadOnly = readOnly
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
|
||||
self.textView.isEnabled = !readOnly
|
||||
if self.textView.isShowingPlaceholder {
|
||||
self.textView.textColor = self.textView.placeholderTextColor
|
||||
} else {
|
||||
self.textView.textColor = (!readOnly ? self.textViewEntryFieldModel?.enabledTextColor : self.textViewEntryFieldModel?.disabledTextColor)?.uiColor
|
||||
self.textView.textColor = (self.textView.isEnabled ? self.textViewEntryFieldModel?.enabledTextColor : self.textViewEntryFieldModel?.disabledTextColor)?.uiColor
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,8 +282,5 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele
|
||||
adjustMarginConstraints(constant: 0)
|
||||
}
|
||||
|
||||
if !model.enabled {
|
||||
isEnabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ import MVMCore
|
||||
|
||||
isUserInteractionEnabled = isEnabled
|
||||
|
||||
if isEnabled && !self.isReadOnly {
|
||||
if isEnabled {
|
||||
layer.borderColor = borderColor.cgColor
|
||||
backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor
|
||||
setShapeLayerStrokeColor(checkColor)
|
||||
@ -95,21 +95,7 @@ import MVMCore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override var isReadOnly: Bool {
|
||||
didSet{
|
||||
if isReadOnly {
|
||||
layer.borderColor = disabledBorderColor.cgColor
|
||||
backgroundColor = disabledBackgroundColor
|
||||
setShapeLayerStrokeColor(disabledCheckColor)
|
||||
} else {
|
||||
layer.borderColor = borderColor.cgColor
|
||||
backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor
|
||||
setShapeLayerStrokeColor(checkColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public var disabledBackgroundColor: UIColor = .clear
|
||||
public var disabledBorderColor: UIColor = .mvmCoolGray3
|
||||
public var disabledCheckColor: UIColor = .mvmCoolGray3
|
||||
@ -253,7 +239,7 @@ import MVMCore
|
||||
self.shapeLayer = shapeLayer
|
||||
shapeLayer.frame = bounds
|
||||
layer.addSublayer(shapeLayer)
|
||||
shapeLayer.strokeColor = isEnabled || !isReadOnly ? checkColor.cgColor : disabledCheckColor.cgColor
|
||||
shapeLayer.strokeColor = isEnabled ? checkColor.cgColor : disabledCheckColor.cgColor
|
||||
shapeLayer.fillColor = UIColor.clear.cgColor
|
||||
shapeLayer.path = checkMarkPath()
|
||||
shapeLayer.lineJoin = .miter
|
||||
@ -382,7 +368,6 @@ import MVMCore
|
||||
super.reset()
|
||||
|
||||
isEnabled = true
|
||||
isReadOnly = false
|
||||
shapeLayer?.removeAllAnimations()
|
||||
shapeLayer?.removeFromSuperlayer()
|
||||
shapeLayer = nil
|
||||
@ -445,8 +430,7 @@ import MVMCore
|
||||
})
|
||||
}
|
||||
|
||||
isEnabled = model.enabled
|
||||
isReadOnly = model.readOnly
|
||||
isEnabled = model.enabled && !model.readOnly
|
||||
|
||||
if (model.action != nil || model.offAction != nil) {
|
||||
actionBlock = { [weak self] in
|
||||
|
||||
@ -62,7 +62,7 @@ import UIKit
|
||||
heartPath.close()
|
||||
heart.path = heartPath.cgPath
|
||||
heart.fillColor = isSelected ? heartModel?.activeColor.cgColor : heartModel?.inActiveColor.cgColor
|
||||
heart.opacity = isEnabled || !isReadOnly ? 1.0 : 0.5
|
||||
heart.opacity = isEnabled ? 1.0 : 0.5
|
||||
heart.lineWidth = 1
|
||||
heart.strokeColor = isSelected ? UIColor.clear.cgColor : UIColor.mvmBlack.cgColor
|
||||
return heart
|
||||
@ -88,8 +88,7 @@ import UIKit
|
||||
self.additionalData = additionalData
|
||||
guard let model = model as? HeartModel else { return }
|
||||
isSelected = model.isActive
|
||||
isEnabled = model.enabled
|
||||
isReadOnly = model.readOnly
|
||||
isEnabled = model.enabled && !model.readOnly
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
@ -98,13 +97,13 @@ import UIKit
|
||||
//--------------------------------------------------
|
||||
/// Adjust accessibility label based on selection of Heart.
|
||||
func updateAccessibilityLabel() {
|
||||
accessibilityHint = isEnabled || !isReadOnly ? MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "heart_unfavorite_action_hint" : "heart_favorite_action_hint") : nil
|
||||
accessibilityTraits = isEnabled || !isReadOnly ? .button : .none
|
||||
accessibilityHint = isEnabled ? MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "heart_unfavorite_action_hint" : "heart_favorite_action_hint") : nil
|
||||
accessibilityTraits = isEnabled ? .button : .none
|
||||
accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "heart_selected_state" : "heart_not_selected_state")
|
||||
}
|
||||
|
||||
func tapAction() {
|
||||
guard isEnabled, !isReadOnly else { return }
|
||||
guard isEnabled else { return }
|
||||
isSelected = !isSelected
|
||||
if let heartModel = heartModel {
|
||||
Button.performButtonAction(with: heartModel.action, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: heartModel)
|
||||
|
||||
@ -39,11 +39,7 @@ open class RadioBox: Control, MFButtonProtocol {
|
||||
public override var isEnabled: Bool {
|
||||
didSet { updateAccessibility() }
|
||||
}
|
||||
|
||||
public override var isReadOnly: Bool {
|
||||
didSet { updateAccessibility() }
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
//--------------------------------------------------
|
||||
@ -93,8 +89,7 @@ open class RadioBox: Control, MFButtonProtocol {
|
||||
accentColor = color
|
||||
}
|
||||
isSelected = model.selected
|
||||
isEnabled = model.enabled
|
||||
isReadOnly = model.readOnly
|
||||
isEnabled = model.enabled && !model.readOnly
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
@ -129,7 +124,7 @@ open class RadioBox: Control, MFButtonProtocol {
|
||||
|
||||
// Handle Mask
|
||||
maskLayer?.removeFromSuperlayer()
|
||||
if !isEnabled || isReadOnly {
|
||||
if !isEnabled {
|
||||
let mask = getMaskLayer()
|
||||
layer.mask = mask
|
||||
maskLayer = mask
|
||||
@ -143,7 +138,7 @@ open class RadioBox: Control, MFButtonProtocol {
|
||||
}
|
||||
|
||||
@objc open func selectBox() {
|
||||
guard isEnabled, !isReadOnly, !isSelected else { return }
|
||||
guard isEnabled, !isSelected else { return }
|
||||
isSelected = true
|
||||
radioBoxModel?.selected = isSelected
|
||||
if let radioBoxModel = radioBoxModel, let actionModel = radioBoxModel.action {
|
||||
@ -242,7 +237,7 @@ open class RadioBox: Control, MFButtonProtocol {
|
||||
accessibilityTraits.insert(.selected)
|
||||
}
|
||||
|
||||
if !isEnabled || isReadOnly {
|
||||
if !isEnabled {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ import UIKit
|
||||
open override func draw(_ rect: CGRect) {
|
||||
guard let context = UIGraphicsGetCurrentContext() else { return }
|
||||
|
||||
let color = (isReadOnly == true || isEnabled == false) ? disabledColor.cgColor : enabledColor.cgColor
|
||||
let color = isEnabled == false ? disabledColor.cgColor : enabledColor.cgColor
|
||||
layer.cornerRadius = bounds.width * 0.5
|
||||
layer.borderColor = color
|
||||
layer.borderWidth = bounds.width * 0.0333
|
||||
@ -88,7 +88,7 @@ import UIKit
|
||||
|
||||
/// The action performed when tapped.
|
||||
func tapAction() {
|
||||
if !isEnabled || isReadOnly {
|
||||
if !isEnabled {
|
||||
return
|
||||
}
|
||||
|
||||
@ -163,8 +163,7 @@ import UIKit
|
||||
guard let model = model as? RadioButtonModel else { return }
|
||||
|
||||
isSelected = model.state
|
||||
isEnabled = model.enabled
|
||||
isReadOnly = model.readOnly
|
||||
isEnabled = model.enabled && !model.readOnly
|
||||
RadioButtonSelectionHelper.setupForRadioButtonGroup(model, self, delegateObject: delegateObject)
|
||||
}
|
||||
|
||||
|
||||
@ -38,13 +38,7 @@ open class RadioSwatch: Control, MFButtonProtocol {
|
||||
updateAccessibility()
|
||||
}
|
||||
}
|
||||
|
||||
public override var isReadOnly: Bool {
|
||||
didSet {
|
||||
updateAccessibility()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Lifecycle
|
||||
//--------------------------------------------------
|
||||
@ -70,8 +64,7 @@ open class RadioSwatch: Control, MFButtonProtocol {
|
||||
self.additionalData = additionalData
|
||||
bottomText.text = model.text
|
||||
isSelected = model.selected
|
||||
isEnabled = model.enabled
|
||||
isReadOnly = model.readOnly
|
||||
isEnabled = model.enabled && !model.readOnly
|
||||
}
|
||||
|
||||
public override func reset() {
|
||||
@ -79,7 +72,6 @@ open class RadioSwatch: Control, MFButtonProtocol {
|
||||
bottomText.text = nil
|
||||
isSelected = false
|
||||
isEnabled = true
|
||||
isReadOnly = false
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
@ -114,7 +106,7 @@ open class RadioSwatch: Control, MFButtonProtocol {
|
||||
|
||||
//Handle Mask
|
||||
maskLayer?.removeFromSuperlayer()
|
||||
if !isEnabled || isReadOnly {
|
||||
if !isEnabled {
|
||||
let mask = getMaskLayer()
|
||||
layer.mask = mask
|
||||
maskLayer = mask
|
||||
@ -128,7 +120,7 @@ open class RadioSwatch: Control, MFButtonProtocol {
|
||||
}
|
||||
|
||||
@objc open func selectSwatch() {
|
||||
guard isEnabled, !isReadOnly, !isSelected else { return }
|
||||
guard isEnabled, !isSelected else { return }
|
||||
isSelected = true
|
||||
radioSwatchModel?.selected = isSelected
|
||||
if let radioSwatchModel = radioSwatchModel, let actionModel = radioSwatchModel.action {
|
||||
@ -201,7 +193,7 @@ open class RadioSwatch: Control, MFButtonProtocol {
|
||||
if isSelected {
|
||||
accessibilityTraits.insert(.selected)
|
||||
}
|
||||
if !isEnabled || isReadOnly {
|
||||
if !isEnabled {
|
||||
accessibilityTraits.insert(.notEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,15 +66,7 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
||||
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: isEnabled ? "AccToggleHint" : "AccDisabled")
|
||||
}
|
||||
}
|
||||
|
||||
public override var isReadOnly: Bool {
|
||||
didSet{
|
||||
changeStateNoAnimation(!isReadOnly ? isOn : false)
|
||||
setToggleAppearanceFromState()
|
||||
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: !isReadOnly ? "AccToggleHint" : "AccDisabled")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Simple means to prevent user interaction with the toggle.
|
||||
public var isLocked: Bool = false {
|
||||
didSet { isUserInteractionEnabled = !isLocked }
|
||||
@ -358,8 +350,8 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
||||
|
||||
public func setToggleAppearanceFromState() {
|
||||
|
||||
backgroundColor = isEnabled || !isReadOnly ? isOn ? containerTintColor.on : containerTintColor.off : disabledTintColor.container
|
||||
knobView.backgroundColor = isEnabled || !isReadOnly ? isOn ? knobTintColor.on : knobTintColor.off : disabledTintColor.knob
|
||||
backgroundColor = isEnabled ? isOn ? containerTintColor.on : containerTintColor.off : disabledTintColor.container
|
||||
knobView.backgroundColor = isEnabled ? isOn ? knobTintColor.on : knobTintColor.off : disabledTintColor.knob
|
||||
}
|
||||
|
||||
public func knobReformAnimation() {
|
||||
@ -392,8 +384,7 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
||||
isOn = model.selected
|
||||
changeStateNoAnimation(isOn)
|
||||
isAnimated = model.animated
|
||||
isEnabled = model.enabled
|
||||
isReadOnly = model.readOnly
|
||||
isEnabled = model.enabled && !model.readOnly
|
||||
|
||||
if let accessibileString = model.accessibilityText {
|
||||
accessibilityLabel = accessibileString
|
||||
|
||||
@ -72,26 +72,14 @@ open class BarsIndicatorView: CarouselIndicator {
|
||||
didSet {
|
||||
for (i, indicatorBar) in barReferences.enumerated() {
|
||||
if i == currentIndex {
|
||||
indicatorBar.backgroundColor = isEnabled && !isReadOnly ? currentIndicatorColor : disabledIndicatorColor
|
||||
indicatorBar.backgroundColor = isEnabled ? currentIndicatorColor : disabledIndicatorColor
|
||||
} else {
|
||||
indicatorBar.backgroundColor = isEnabled && !isReadOnly ? indicatorColor : disabledIndicatorColor
|
||||
indicatorBar.backgroundColor = isEnabled ? indicatorColor : disabledIndicatorColor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open override var isReadOnly: Bool {
|
||||
didSet {
|
||||
for (i, indicatorBar) in barReferences.enumerated() {
|
||||
if i == currentIndex {
|
||||
indicatorBar.backgroundColor = !isReadOnly ? currentIndicatorColor : disabledIndicatorColor
|
||||
} else {
|
||||
indicatorBar.backgroundColor = !isReadOnly ? indicatorColor : disabledIndicatorColor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Colors the currently selected index, unique from other indicators
|
||||
public var currentIndicatorColor: UIColor {
|
||||
get { barsCarouselIndicatorModel?.currentIndicatorColor.uiColor ?? indicatorColor }
|
||||
|
||||
@ -42,13 +42,9 @@ open class NumericIndicatorView: CarouselIndicator {
|
||||
//--------------------------------------------------
|
||||
|
||||
open override var isEnabled: Bool {
|
||||
didSet { setViewColor(isEnabled && !isReadOnly ? indicatorColor : disabledIndicatorColor) }
|
||||
didSet { setViewColor(isEnabled ? indicatorColor : disabledIndicatorColor) }
|
||||
}
|
||||
|
||||
open override var isReadOnly: Bool {
|
||||
didSet { setViewColor(!isReadOnly ? indicatorColor : disabledIndicatorColor) }
|
||||
}
|
||||
|
||||
|
||||
/// Sets the color for pageCount text, left arrow and right arrow.
|
||||
public override var indicatorColor: UIColor {
|
||||
get { super.indicatorColor }
|
||||
|
||||
@ -13,14 +13,6 @@ import UIKit
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
public var isReadOnly: Bool = false{
|
||||
didSet{
|
||||
//don't allow touches
|
||||
isUserInteractionEnabled = !isReadOnly
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
open var model: MoleculeModelProtocol?
|
||||
|
||||
private var initialSetupPerformed = false
|
||||
|
||||
@ -55,7 +55,6 @@ import UIKit
|
||||
private var _showError: Bool = false
|
||||
private var _isLocked: Bool = false
|
||||
private var _isSelected: Bool = false
|
||||
private var _isReadOnly: Bool = false
|
||||
|
||||
public var isEnabled: Bool {
|
||||
get { return _isEnabled }
|
||||
@ -70,20 +69,6 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
public var isReadOnly: Bool {
|
||||
get { return _isReadOnly }
|
||||
set (readOnly) {
|
||||
|
||||
_isEnabled = true
|
||||
_isLocked = false
|
||||
_isSelected = false
|
||||
_showError = false
|
||||
_isReadOnly = readOnly
|
||||
|
||||
fieldState = readOnly ? .disabled : .original
|
||||
}
|
||||
}
|
||||
|
||||
public var showError: Bool {
|
||||
get { return _showError }
|
||||
set (error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user