Merge branch 'mbruce/bugfixes' into 'develop'

ONEAPP-4683 - Accessibility - Tabs (Voice Over)

See merge request BPHV_MIPS/vds_ios!126
This commit is contained in:
Bruce, Matt R 2023-11-30 21:47:03 +00:00
commit 8ceaafb0a4
8 changed files with 71 additions and 30 deletions

View File

@ -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;

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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) }
}
}

View File

@ -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)
}
}

View File

@ -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"
}
}

View File

@ -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)

24
vds-docs.sh Normal file
View File

@ -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