Merge branch 'bugfix/priceLockup' into 'develop'

Fixed the PriceLockup accessibility Issue - CXTDT-630735

See merge request BPHV_MIPS/vds_ios!318
This commit is contained in:
Bruce, Matt R 2024-10-21 14:30:23 +00:00
commit 539f10ffbf
3 changed files with 41 additions and 0 deletions

View File

@ -39,6 +39,27 @@ public extension String {
func isValid(range: NSRange) -> Bool { func isValid(range: NSRange) -> Bool {
range.location >= 0 && range.length > 0 && range.location + range.length <= count range.location >= 0 && range.length > 0 && range.location + range.length <= count
} }
func index(from: Int) -> Index {
return self.index(startIndex, offsetBy: from)
}
func substring(from: Int) -> String {
let fromIndex = index(from: from)
return String(self[fromIndex...])
}
func substring(to: Int) -> String {
let toIndex = index(from: to)
return String(self[..<toIndex])
}
func substring(with r: Range<Int>) -> String {
let startIndex = index(from: r.lowerBound)
let endIndex = index(from: r.upperBound)
return String(self[startIndex..<endIndex])
}
} }
public extension NSAttributedString { public extension NSAttributedString {

View File

@ -140,6 +140,7 @@ open class PriceLockup: View, ParentViewProtocol {
internal var delimiterIndex = 0 internal var delimiterIndex = 0
internal var strikethroughLocation = 0 internal var strikethroughLocation = 0
internal var strikethroughLength = 0 internal var strikethroughLength = 0
internal var strikethroughAccessibilityText: String = "price not offering anymore"
internal var textPosition:TextPosition = .preDelimiter internal var textPosition:TextPosition = .preDelimiter
enum TextPosition: String, CaseIterable { enum TextPosition: String, CaseIterable {
@ -217,6 +218,24 @@ open class PriceLockup: View, ParentViewProtocol {
open override func setDefaults() { open override func setDefaults() {
super.setDefaults() super.setDefaults()
priceLockupLabel.bridge_accessibilityLabelBlock = { [weak self] in
guard let self else { return "" }
var accessibilityLabels = [String]()
if let text = priceLockupLabel.text, !text.isEmpty {
if strikethrough, strikethroughLength > 0 {
let preText = text.substring(to: strikethroughLocation)
let postText = text.substring(from: strikethroughLocation)
accessibilityLabels.append(preText)
accessibilityLabels.append(strikethroughAccessibilityText)
accessibilityLabels.append(postText)
} else {
accessibilityLabels.append(text)
}
}
return accessibilityLabels.joined(separator: " ")
}
bold = false bold = false
hideCurrency = false hideCurrency = false
leadingText = nil leadingText = nil

View File

@ -1,5 +1,6 @@
1.0.76 1.0.76
---------------- ----------------
- CXTDT-630735 - PriceLockup - Accessibility
- CXTDT-626164 - FootnoteGroup - Dark mode - CXTDT-626164 - FootnoteGroup - Dark mode
1.0.75 1.0.75