From 7df4f0cdf96d4e2cb71087bec139188de456e234 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 18 Sep 2023 16:01:06 -0500 Subject: [PATCH 1/4] CXTDT-464973 - Button - Width percentage parameter missing. Signed-off-by: Matt Bruce --- VDS/Components/Buttons/Button/Button.swift | 63 ++++++++++++++++--- .../Buttons/ButtonGroup/ButtonGroup.swift | 2 +- VDS/SupportingFiles/ReleaseNotes.txt | 4 ++ 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/VDS/Components/Buttons/Button/Button.swift b/VDS/Components/Buttons/Button/Button.swift index 60d8d0fd..5aac3483 100644 --- a/VDS/Components/Buttons/Button/Button.swift +++ b/VDS/Components/Buttons/Button/Button.swift @@ -77,6 +77,12 @@ open class Button: ButtonBase, Useable { } } } + + /// Enum used to describe the width of a fixed value or percentage of parent's width. + public enum Width { + case percentage(CGFloat) + case value(CGFloat) + } //-------------------------------------------------- // MARK: - Private Properties @@ -92,21 +98,30 @@ open class Button: ButtonBase, Useable { /// The Use for this Button. open var use: Use = .primary { didSet { setNeedsUpdate() } } - private var _width: CGFloat? = nil + private var _width: Width? = nil /// If there is a width that is larger than this size's minmumWidth, the button will resize to this width. - open var width: CGFloat? { + open var width: Width? { get { _width } set { - if let newValue, newValue > size.minimumWidth { - _width = newValue + if let newValue { + switch newValue { + case .percentage(let percentage): + if percentage <= 100.0 { + _width = newValue + } + case .value(let value): + if value > 0 && value > size.minimumWidth { + _width = newValue + } + } } else { _width = nil } setNeedsUpdate() } } - + open override var textColor: UIColor { textColorConfiguration.getColor(self) } @@ -118,13 +133,35 @@ open class Button: ButtonBase, Useable { /// The natural size for the receiving view, considering only properties of the view itself. open override var intrinsicContentSize: CGSize { - guard let width, width > 0 else { - var superSize = super.intrinsicContentSize - superSize.height = size.height - return superSize + // get the intrinsic size + var defaultSize = super.intrinsicContentSize + // ensure the size height + defaultSize.height = size.height + + // take the max width either intrinsic or size's minimumWidth + defaultSize.width = max(defaultSize.width, size.minimumWidth) + + guard let width else { + return defaultSize } - return CGSize(width: width > size.minimumWidth ? width : size.minimumWidth, height: size.height) + switch width { + case .percentage(let percentage): + // test the superview's width against the percentage to ensure + // it is greater than the size's minimum width + guard let superWidth = superview?.frame.width else { + return defaultSize + } + + // if so set the width off percentage + defaultSize.width = max(superWidth * (percentage / 100), size.minimumWidth) + return defaultSize + + case .value(let value): + // test fixed value vs minimum width and take the greater value + defaultSize.width = max(value, size.minimumWidth) + return defaultSize + } } //-------------------------------------------------- @@ -216,6 +253,12 @@ open class Button: ButtonBase, Useable { invalidateIntrinsicContentSize() } + + open override func layoutSubviews() { + super.layoutSubviews() + + invalidateIntrinsicContentSize() + } } extension Use { diff --git a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift index a2ba0498..665813b9 100644 --- a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift +++ b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift @@ -149,7 +149,7 @@ open class ButtonGroup: View { case .percentage(let value): percentage = value } } - buttons.forEach { ($0 as? Button)?.width = width } + buttons.forEach { if let width { ($0 as? Button)?.width = .value(width) } } positionLayout.buttonPercentage = percentage collectionView.reloadData() diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 6dae1502..e33775b7 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,7 @@ +1.0.43 +======= +- CXTDT-464973 - Button - Width percentage parameter missing. + 1.0.42 ======= - CXTDT-462698 - Tabs - Incorrect letter spacing on Large tabs From 1319d19359f7d370c5c810af6254d810ac3b985a Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 19 Sep 2023 11:03:36 -0500 Subject: [PATCH 2/4] ONEAPP-5106 - Accessibility iOS Icon Signed-off-by: Matt Bruce --- VDS/Components/Icon/Icon.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Icon/Icon.swift b/VDS/Components/Icon/Icon.swift index e85dc751..5ac143f6 100644 --- a/VDS/Components/Icon/Icon.swift +++ b/VDS/Components/Icon/Icon.swift @@ -44,6 +44,7 @@ open class Icon: View { //-------------------------------------------------- /// UIImageView used to render the icon. open var imageView = UIImageView().with { + $0.isAccessibilityElement = false $0.translatesAutoresizingMaskIntoConstraints = false $0.contentMode = .scaleAspectFill $0.clipsToBounds = true @@ -78,7 +79,7 @@ open class Icon: View { /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() - + setContentCompressionResistancePriority(.required, for: .vertical) setContentHuggingPriority(.required, for: .vertical) setContentCompressionResistancePriority(.required, for: .horizontal) @@ -123,6 +124,11 @@ open class Icon: View { color = VDSColor.paletteBlack imageView.image = nil } + + open override func updateAccessibility() { + super.updateAccessibility() + accessibilityLabel = name?.rawValue ?? "icon" + } //-------------------------------------------------- // MARK: - Private Methods From 4922e06462101487ff85ecbad25c13e360ee28f8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 19 Sep 2023 11:40:17 -0500 Subject: [PATCH 3/4] updated comments Signed-off-by: Matt Bruce --- VDS/SupportingFiles/ReleaseNotes.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index e33775b7..9376c473 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,7 +1,8 @@ 1.0.43 ======= - CXTDT-464973 - Button - Width percentage parameter missing. - +- ONEAPP-5106 - Icon - Name not used in Voice over. +- CXTDT-464974 - Line - Needs vertical orientation added. 1.0.42 ======= - CXTDT-462698 - Tabs - Incorrect letter spacing on Large tabs From 5c15e4e010870358db10d0eb44cbc68697ad5357 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 19 Sep 2023 12:04:37 -0500 Subject: [PATCH 4/4] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- VDS/SupportingFiles/ReleaseNotes.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index e3948c92..4da82fd2 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 = 42; + CURRENT_PROJECT_VERSION = 43; 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 = 42; + CURRENT_PROJECT_VERSION = 43; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index 9376c473..d1a68aef 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -3,6 +3,7 @@ - CXTDT-464973 - Button - Width percentage parameter missing. - ONEAPP-5106 - Icon - Name not used in Voice over. - CXTDT-464974 - Line - Needs vertical orientation added. + 1.0.42 ======= - CXTDT-462698 - Tabs - Incorrect letter spacing on Large tabs