Digital ACT191 story ONEAPP-6682 minor changes
This commit is contained in:
parent
72ef366eed
commit
f527ec5483
@ -42,7 +42,7 @@ open class TextArea: EntryFieldBase {
|
|||||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||||
$0.axis = .horizontal
|
$0.axis = .horizontal
|
||||||
$0.distribution = .fill
|
$0.distribution = .fill
|
||||||
$0.spacing = 12
|
$0.spacing = VDSLayout.Spacing.space3X.value
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -58,6 +58,7 @@ open class TextArea: EntryFieldBase {
|
|||||||
$0.axis = .horizontal
|
$0.axis = .horizontal
|
||||||
$0.distribution = .fill
|
$0.distribution = .fill
|
||||||
$0.alignment = .top
|
$0.alignment = .top
|
||||||
|
$0.spacing = VDSLayout.Spacing.space2X.value
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -128,6 +129,8 @@ open class TextArea: EntryFieldBase {
|
|||||||
borderColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessOnlight, VDSColor.feedbackSuccessOndark, forState: .success)
|
borderColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessOnlight, VDSColor.feedbackSuccessOndark, forState: .success)
|
||||||
borderColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .focused)
|
borderColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .focused)
|
||||||
textView.delegate = self
|
textView.delegate = self
|
||||||
|
characterCounterLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||||
|
bottomContainerStackView.spacing = VDSLayout.Spacing.space2X.value
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets to default settings.
|
/// Resets to default settings.
|
||||||
@ -161,10 +164,10 @@ open class TextArea: EntryFieldBase {
|
|||||||
minWidthConstraint?.isActive = true
|
minWidthConstraint?.isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((maxLength ?? 0) > 0) {
|
if let maxLength, maxLength > 0 {
|
||||||
// allow - 20% of character limit
|
// allow - 20% of character limit
|
||||||
let overflowLimit = Double(maxLength ?? 0) * 0.20
|
let overflowLimit = Double(maxLength) * 0.20
|
||||||
allowCharCount = Int(overflowLimit) + (maxLength ?? 0)
|
allowCharCount = Int(overflowLimit) + maxLength
|
||||||
characterCounterLabel.text = getCharacterCounterText()
|
characterCounterLabel.text = getCharacterCounterText()
|
||||||
} else {
|
} else {
|
||||||
characterCounterLabel.text = ""
|
characterCounterLabel.text = ""
|
||||||
@ -175,8 +178,9 @@ open class TextArea: EntryFieldBase {
|
|||||||
containerView.layer.borderColor = readOnly ? readOnlyBorderColorConfiguration.getColor(self).cgColor : borderColorConfiguration.getColor(self).cgColor
|
containerView.layer.borderColor = readOnly ? readOnlyBorderColorConfiguration.getColor(self).cgColor : borderColorConfiguration.getColor(self).cgColor
|
||||||
textView.isEditable = readOnly ? false : true
|
textView.isEditable = readOnly ? false : true
|
||||||
textView.backgroundColor = backgroundColorConfiguration.getColor(self)
|
textView.backgroundColor = backgroundColorConfiguration.getColor(self)
|
||||||
characterCounterLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
|
||||||
textView.tintColor = iconColorConfiguration.getColor(self)
|
textView.tintColor = iconColorConfiguration.getColor(self)
|
||||||
|
characterCounterLabel.surface = surface
|
||||||
|
highlightCharacterOverflow()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Container for the area showing helper text, error text, character count, maximum length value.
|
/// Container for the area showing helper text, error text, character count, maximum length value.
|
||||||
@ -221,9 +225,11 @@ open class TextArea: EntryFieldBase {
|
|||||||
|
|
||||||
open func highlightCharacterOverflow() {
|
open func highlightCharacterOverflow() {
|
||||||
let count = textView.text.count
|
let count = textView.text.count
|
||||||
guard let text = textView.attributedText?.mutableCopy() as? NSMutableAttributedString else { return }
|
guard let maxLength,
|
||||||
text.addAttribute(NSAttributedString.Key.backgroundColor, value: highlightBackgroundColor.getColor(self), range: NSRange(location:(maxLength ?? 0 ), length: (count - (maxLength ?? 0))))
|
count > maxLength,
|
||||||
text.addAttribute(NSAttributedString.Key.foregroundColor, value: highlightTextColor.getColor(self), range: NSRange(location:(maxLength ?? 0 ), length: (count - (maxLength ?? 0))))
|
let text = textView.attributedText?.mutableCopy() as? NSMutableAttributedString else { return }
|
||||||
|
text.addAttribute(NSAttributedString.Key.backgroundColor, value: highlightBackgroundColor.getColor(self), range: NSRange(location:maxLength, length: (count - maxLength)))
|
||||||
|
text.addAttribute(NSAttributedString.Key.foregroundColor, value: highlightTextColor.getColor(self), range: NSRange(location:maxLength, length: (count - maxLength)))
|
||||||
textView.attributedText = text.copy() as? NSAttributedString
|
textView.attributedText = text.copy() as? NSAttributedString
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user