diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index c2fc5e62..8d622539 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1175,7 +1175,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1212,7 +1212,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/Components/Buttons/ButtonBase.swift b/VDS/Components/Buttons/ButtonBase.swift index 879588d1..255c6f64 100644 --- a/VDS/Components/Buttons/ButtonBase.swift +++ b/VDS/Components/Buttons/ButtonBase.swift @@ -158,26 +158,28 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable { //clear the arrays holding actions accessibilityCustomActions = [] - - //create the primary string - let mutableText = NSMutableAttributedString.mutableText(for: text ?? "No Text", - textStyle: textStyle, - useScaledFont: useScaledFont, - textColor: textColor, - alignment: titleLabel?.textAlignment ?? .center, - lineBreakMode: titleLabel?.lineBreakMode ?? .byTruncatingTail) - - if let attributes = textAttributes { - //loop through the models attributes - for attribute in attributes { - //add attribute on the string - attribute.setAttribute(on: mutableText) + if let text, !text.isEmpty { + //create the primary string + let mutableText = NSMutableAttributedString.mutableText(for: text, + textStyle: textStyle, + useScaledFont: useScaledFont, + textColor: textColor, + alignment: titleLabel?.textAlignment ?? .center, + lineBreakMode: titleLabel?.lineBreakMode ?? .byTruncatingTail) + + //apply any attributes + if let attributes = textAttributes { + mutableText.apply(attributes: attributes) } + + //set the attributed text + setAttributedTitle(mutableText, for: .normal) + setAttributedTitle(mutableText, for: .highlighted) + } else { + setAttributedTitle(nil, for: .normal) + setAttributedTitle(nil, for: .highlighted) + titleLabel?.text = nil } - - //set the attributed text - setAttributedTitle(mutableText, for: .normal) - setAttributedTitle(mutableText, for: .highlighted) } } diff --git a/VDS/Components/Label/Attributes/ColorLabelAttribute.swift b/VDS/Components/Label/Attributes/ColorLabelAttribute.swift index e266f15f..354fbc93 100644 --- a/VDS/Components/Label/Attributes/ColorLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/ColorLabelAttribute.swift @@ -23,7 +23,7 @@ public struct ColorLabelAttribute: LabelAttributeModel { //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(location: Int, length: Int, color: UIColor = .black, isForegroundColor: Bool = true) { + public init(location: Int = 0, length: Int = 0, color: UIColor = .black, isForegroundColor: Bool = true) { self.location = location self.length = length self.color = color @@ -31,8 +31,12 @@ public struct ColorLabelAttribute: LabelAttributeModel { } public func setAttribute(on attributedString: NSMutableAttributedString) { + var colorRange = range + if length == 0 && location == 0 { + colorRange = .init(location: location, length: attributedString.length) + } let attributeKey = isForegroundColor ? NSAttributedString.Key.foregroundColor : NSAttributedString.Key.backgroundColor - attributedString.removeAttribute(attributeKey, range: range) - attributedString.addAttribute(attributeKey, value: color, range: range) + attributedString.removeAttribute(attributeKey, range: colorRange) + attributedString.addAttribute(attributeKey, value: color, range: colorRange) } } diff --git a/VDS/Components/Label/Attributes/LabelAttributeModel.swift b/VDS/Components/Label/Attributes/LabelAttributeModel.swift index 84fdc005..62e1bbd8 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeModel.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeModel.swift @@ -54,3 +54,14 @@ public extension NSAttributedString { return TextStyleLabelAttribute(location: range.location, length: range.length, textStyle: style) } } + +extension NSMutableAttributedString { + public func apply(attribute: any LabelAttributeModel) { + attribute.setAttribute(on: self) + } + + public func apply(attributes: [any LabelAttributeModel]) { + attributes.forEach { apply(attribute: $0) } + } +} + diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 0e804b30..7ecb79cd 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -273,12 +273,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable { actions = [] if let attributes = attributes { - //loop through the models attributes - for attribute in attributes { - - //add attribute on the string - attribute.setAttribute(on: mutableAttributedString) - } + mutableAttributedString.apply(attributes: attributes) } } diff --git a/VDS/Components/Tabs/Tabs.swift b/VDS/Components/Tabs/Tabs.swift index 0fc447cd..41f70d4a 100644 --- a/VDS/Components/Tabs/Tabs.swift +++ b/VDS/Components/Tabs/Tabs.swift @@ -278,7 +278,7 @@ open class Tabs: View { tabItem.orientation = orientation tabItem.surface = surface tabItem.indicatorPosition = indicatorPosition - tabItem.accessibilityValue = "\(index+1) of \(tabViews.count) Tabs" + tabItem.accessibilityHint = "\(index+1) of \(tabViews.count) Tabs" } } diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 6fc26df1..cb769cc4 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,8 @@ +1.0.48 +======= +- ONEAPP-4683 - Accessibility - Tabs (Voice Over) +- Fix for Button/TextLink/TextLinkCaret for how empty text is dealt with + 1.0.47 ======= - ONEAPP-4684 - Acessibility - Tooltip (Header) diff --git a/vds-docs.sh b/vds-docs.sh new file mode 100644 index 00000000..8d5ebf6e --- /dev/null +++ b/vds-docs.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +rm -rf docsData + +echo "Building DocC documentation for VDS..." + +xcodebuild -project VDS.xcodeproj -derivedDataPath docsData -scheme VDS -destination 'platform=iOS Simulator,name=iPhone 15 Pro Max' -parallelizeTargets docbuild + +echo "Copying DocC archives to doc_archives..." + +mkdir doc_archives + +cp -R `find docsData -type d -name "*.doccarchive"` doc_archives + +mkdir docs + +for ARCHIVE in doc_archives/*.doccarchive; do + cmd() { + echo "$ARCHIVE" | awk -F'.' '{print $1}' | awk -F'/' '{print tolower($2)}' + } + ARCHIVE_NAME="$(cmd)" + echo "Processing Archive: $ARCHIVE" + $(xcrun --find docc) process-archive transform-for-static-hosting "$ARCHIVE" --hosting-base-path / --output-path docs/$ARCHIVE_NAME +done