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