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:
commit
539f10ffbf
@ -39,6 +39,27 @@ public extension String {
|
||||
func isValid(range: NSRange) -> Bool {
|
||||
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 {
|
||||
|
||||
@ -140,6 +140,7 @@ open class PriceLockup: View, ParentViewProtocol {
|
||||
internal var delimiterIndex = 0
|
||||
internal var strikethroughLocation = 0
|
||||
internal var strikethroughLength = 0
|
||||
internal var strikethroughAccessibilityText: String = "price not offering anymore"
|
||||
|
||||
internal var textPosition:TextPosition = .preDelimiter
|
||||
enum TextPosition: String, CaseIterable {
|
||||
@ -217,6 +218,24 @@ open class PriceLockup: View, ParentViewProtocol {
|
||||
|
||||
open override func 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
|
||||
hideCurrency = false
|
||||
leadingText = nil
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
1.0.76
|
||||
----------------
|
||||
- CXTDT-630735 - PriceLockup - Accessibility
|
||||
- CXTDT-626164 - FootnoteGroup - Dark mode
|
||||
|
||||
1.0.75
|
||||
|
||||
Loading…
Reference in New Issue
Block a user