From cf4223b12761247f8e8c8b5bb8907f4bf4ddeb71 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 2 Aug 2023 14:58:59 -0500 Subject: [PATCH 01/19] udpated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 6c0e23ad..8621f0b9 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1163,7 +1163,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 34; + CURRENT_PROJECT_VERSION = 35; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1200,7 +1200,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 34; + CURRENT_PROJECT_VERSION = 35; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; From 8daae9088a3c757f0198881652adbe1668a96818 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 2 Aug 2023 15:08:16 -0500 Subject: [PATCH 02/19] updated notes Signed-off-by: Matt Bruce --- VDS/SupportingFiles/ReleaseNotes.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index b135fbc6..c6b192b5 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,10 +1,10 @@ 1.0.35 ======= -- ONEAPP-4684 - (Acessibility) Tooltip -- ONEAPP-4681 - (Acessibility) Checkbox -- ONEAPP-4825 - (Acessibility) Radiobutton -- ONEAPP-5104 - (Acessibility) Button -- ONEAPP-4115 - (Acessibility) Tabs +- ONEAPP-4684 - (Accessibility) Tooltip +- ONEAPP-4681 - (Accessibility) Checkbox +- ONEAPP-4825 - (Accessibility) Radiobutton +- ONEAPP-5104 - (Accessibility) Button +- ONEAPP-4115 - (Accessibility) Tabs - TitleLockup update for Janet release 1.0.34 From ce9e64da0fa9e8d12b507561a8c7b417513b0d96 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 4 Aug 2023 10:22:31 -0500 Subject: [PATCH 03/19] updated comments Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 12 +- VDS/Classes/Control.swift | 64 ++++---- VDS/Classes/SelectorBase.swift | 30 ++-- VDS/Classes/SelectorGroupHandlerBase.swift | 26 ++-- VDS/Classes/SelectorItemBase.swift | 144 ++++++++++-------- VDS/Classes/SelfSizingCollectionView.swift | 10 +- VDS/Classes/View.swift | 30 ++-- VDS/Components/Badge/Badge.swift | 90 ++++++----- .../BadgeIndicator/BadgeIndicator.swift | 46 +++--- VDS/Components/Buttons/Button/Button.swift | 2 +- .../Buttons/Button/ButtonBase.swift | 12 +- .../Buttons/ButtonGroup/ButtonGroup.swift | 3 +- .../Buttons/TextLink/TextLink.swift | 2 +- .../Buttons/TextLinkCaret/TextLinkCaret.swift | 4 +- VDS/Components/Checkbox/CheckboxGroup.swift | 1 + .../Icon/ButtonIcon/ButtonIcon.swift | 6 +- VDS/Components/Icon/Icon.swift | 5 +- .../Attributes/TooltipLabelAttribute.swift | 1 + VDS/Components/Label/Label.swift | 5 +- VDS/Components/Line/Line.swift | 25 ++- .../Loader/LoaderViewController.swift | 2 +- .../Notification/Notification.swift | 8 +- VDS/Components/RadioBox/RadioBoxGroup.swift | 1 + VDS/Components/RadioBox/RadioBoxItem.swift | 52 +++---- .../RadioButton/RadioButtonGroup.swift | 1 + VDS/Components/RadioSwatch/RadioSwatch.swift | 43 +++--- .../RadioSwatch/RadioSwatchGroup.swift | 2 +- .../TextFields/EntryField/EntryField.swift | 2 +- .../TextFields/InputField/InputField.swift | 2 +- .../TextFields/TextArea/TextArea.swift | 6 +- .../TileContainer/TileContainer.swift | 117 +++++++------- VDS/Components/Tilelet/Tilelet.swift | 7 +- .../Tilelet/TileletBadgeModel.swift | 1 + .../Tilelet/TileletIconModels.swift | 1 + VDS/Components/TitleLockup/TitleLockup.swift | 73 +++++---- VDS/Components/Toggle/Toggle.swift | 37 ++--- VDS/Components/Toggle/ToggleView.swift | 80 +++++----- VDS/Components/Tooltip/Tooltip.swift | 2 +- .../Tooltip/TooltipAlertViewController.swift | 10 +- .../Tooltip/TrailingTooltipLabel.swift | 3 +- VDS/Extensions/UIView+Accessibility.swift | 27 ++++ ....swift => UIView+NSLayoutConstraint.swift} | 0 VDS/Protocols/Changeable.swift | 1 + VDS/Protocols/Clickable.swift | 2 + VDS/Protocols/FormFieldable.swift | 6 +- VDS/Protocols/Handlerable.swift | 5 + VDS/Protocols/Primitive.swift | 1 + VDS/Protocols/Resetable.swift | 2 +- VDS/Protocols/ViewProtocol.swift | 14 +- 49 files changed, 540 insertions(+), 486 deletions(-) create mode 100644 VDS/Extensions/UIView+Accessibility.swift rename VDS/Extensions/{UIView.swift => UIView+NSLayoutConstraint.swift} (100%) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 8621f0b9..997fbe70 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -68,6 +68,7 @@ EA89200628B526D6006B9984 /* CheckboxGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200528B526D6006B9984 /* CheckboxGroup.swift */; }; EA89201328B568D8006B9984 /* RadioBoxItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201228B568D8006B9984 /* RadioBoxItem.swift */; }; EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */; }; + EA8E40912A7D3F6300934ED3 /* UIView+Accessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8E40902A7D3F6300934ED3 /* UIView+Accessibility.swift */; }; EA978EC5291D6AFE00ACC883 /* AnyLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA978EC4291D6AFE00ACC883 /* AnyLabelAttribute.swift */; }; EA985BE629688F6A00F2FF2E /* TileletBadgeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985BE529688F6A00F2FF2E /* TileletBadgeModel.swift */; }; EA985BE82968951C00F2FF2E /* TileletTitleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985BE72968951C00F2FF2E /* TileletTitleModel.swift */; }; @@ -99,7 +100,7 @@ EAB2376629E9952D00AABE9A /* UIApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376529E9952D00AABE9A /* UIApplication.swift */; }; EAB2376829E9992800AABE9A /* TooltipAlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */; }; EAB2376A29E9E59100AABE9A /* TooltipLaunchable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB2376929E9E59100AABE9A /* TooltipLaunchable.swift */; }; - EAB5FED429267EB300998C17 /* UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FED329267EB300998C17 /* UIView.swift */; }; + EAB5FED429267EB300998C17 /* UIView+NSLayoutConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FED329267EB300998C17 /* UIView+NSLayoutConstraint.swift */; }; EAB5FEED2927E1B200998C17 /* ButtonGroupPositionLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FEEC2927E1B200998C17 /* ButtonGroupPositionLayout.swift */; }; EAB5FEF12927F4AA00998C17 /* SelfSizingCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FEF02927F4AA00998C17 /* SelfSizingCollectionView.swift */; }; EAB5FEF5292D371F00998C17 /* ButtonBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB5FEF4292D371F00998C17 /* ButtonBase.swift */; }; @@ -213,6 +214,7 @@ EA89200528B526D6006B9984 /* CheckboxGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxGroup.swift; sourceTree = ""; }; EA89201228B568D8006B9984 /* RadioBoxItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxItem.swift; sourceTree = ""; }; EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroup.swift; sourceTree = ""; }; + EA8E40902A7D3F6300934ED3 /* UIView+Accessibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Accessibility.swift"; sourceTree = ""; }; EA978EC4291D6AFE00ACC883 /* AnyLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyLabelAttribute.swift; sourceTree = ""; }; EA985BE529688F6A00F2FF2E /* TileletBadgeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileletBadgeModel.swift; sourceTree = ""; }; EA985BE72968951C00F2FF2E /* TileletTitleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileletTitleModel.swift; sourceTree = ""; }; @@ -245,7 +247,7 @@ EAB2376529E9952D00AABE9A /* UIApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplication.swift; sourceTree = ""; }; EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipAlertViewController.swift; sourceTree = ""; }; EAB2376929E9E59100AABE9A /* TooltipLaunchable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipLaunchable.swift; sourceTree = ""; }; - EAB5FED329267EB300998C17 /* UIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIView.swift; sourceTree = ""; }; + EAB5FED329267EB300998C17 /* UIView+NSLayoutConstraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+NSLayoutConstraint.swift"; sourceTree = ""; }; EAB5FEEC2927E1B200998C17 /* ButtonGroupPositionLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonGroupPositionLayout.swift; sourceTree = ""; }; EAB5FEF02927F4AA00998C17 /* SelfSizingCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfSizingCollectionView.swift; sourceTree = ""; }; EAB5FEF4292D371F00998C17 /* ButtonBase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonBase.swift; sourceTree = ""; }; @@ -466,7 +468,8 @@ EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */, EA33623D2892EE950071C351 /* UIDevice.swift */, EAF7F0B6289C12A600B287F5 /* UITapGestureRecognizer.swift */, - EAB5FED329267EB300998C17 /* UIView.swift */, + EA8E40902A7D3F6300934ED3 /* UIView+Accessibility.swift */, + EAB5FED329267EB300998C17 /* UIView+NSLayoutConstraint.swift */, EAD062A62A3B67770015965D /* UIView+CALayer.swift */, EAB5FF0029424ACB00998C17 /* UIControl.swift */, EA985C662970C21600F2FF2E /* VDSLayout.swift */, @@ -965,6 +968,7 @@ EA0D1C3D2A6AD57600E5C127 /* Typography+Enums.swift in Sources */, EAF1FE9B29DB1A6000101452 /* Changeable.swift in Sources */, EAF7F0A2289AFB3900B287F5 /* Errorable.swift in Sources */, + EA8E40912A7D3F6300934ED3 /* UIView+Accessibility.swift in Sources */, EA985C7D297DAED300F2FF2E /* Primitive.swift in Sources */, EAF1FE9929D4850E00101452 /* Clickable.swift in Sources */, EAD0688E2A55F819002E3A2D /* Loader.swift in Sources */, @@ -995,7 +999,7 @@ EAF7F0B7289C12A600B287F5 /* UITapGestureRecognizer.swift in Sources */, EA0D1C392A6AD4DF00E5C127 /* Typography+SpacingConfig.swift in Sources */, EAB2376629E9952D00AABE9A /* UIApplication.swift in Sources */, - EAB5FED429267EB300998C17 /* UIView.swift in Sources */, + EAB5FED429267EB300998C17 /* UIView+NSLayoutConstraint.swift in Sources */, EAB2376829E9992800AABE9A /* TooltipAlertViewController.swift in Sources */, EA33623E2892EE950071C351 /* UIDevice.swift in Sources */, EA985C692971B90B00F2FF2E /* IconSize.swift in Sources */, diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 6920ac48..4f0f39bc 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -16,11 +16,9 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- - - /// Set of Subscribers for any Publishers for this Control + /// Set of Subscribers for any Publishers for this Control. public var subscribers = Set() - - /// Sets the primary Subscriber used for the TouchUpInside + public var onClickSubscriber: AnyCancellable? { willSet { if let onClickSubscriber { @@ -37,13 +35,11 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab /// Key of whether or not updateView() is called in setNeedsUpdate() open var shouldUpdateView: Bool = true - /// Dictionary for keeping information for this Control use only Primitives open var userInfo = [String: Primitive]() - /// Current Surface used within this Control and used to passdown to child views + /// Current Surface and this is used to pass down to child objects that implement Surfacable open var surface: Surface = .light { didSet { setNeedsUpdate() } } - /// Control is disabled or not open var disabled: Bool { get { !isEnabled } set { @@ -53,15 +49,14 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab } } - /// Override for isSelected to handle setNeedsUpdate() on changes + /// Override for isSelected to handle setNeedsUpdate() on changes. open override var isSelected: Bool { didSet { setNeedsUpdate() } } - /// Reference count use to be used in isHighlighted when a subscriber is listening for TouchUpInside. public var touchUpInsideCount: Int = 0 var isHighlightAnimating = false - /// Override to deal with only calling setNeedsUpdate() if needed + /// Override to deal with only calling setNeedsUpdate() if needed. open override var isHighlighted: Bool { didSet { if isHighlightAnimating == false && touchUpInsideCount > 0 { @@ -79,7 +74,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab } } - /// Override to deal with setNeedsUpdate() + /// Override to deal with setNeedsUpdate(). open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } } //-------------------------------------------------- @@ -101,10 +96,10 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab } //-------------------------------------------------- - // MARK: - Setup + // MARK: - Lifecycle //-------------------------------------------------- - /// Executed on initialization for this Control + /// Executed on initialization for this Control. open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true @@ -112,26 +107,18 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab setNeedsUpdate() } } - - ///Override to deal with sending actions for accessibility - /// - Returns: Based on whether the userInteraction is enabled - override open func accessibilityActivate() -> Bool { - // Hold state in case User wanted isAnimated to remain off. - guard isUserInteractionEnabled else { return false } - sendActions(for: .touchUpInside) - return true - } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - /// Update this view based off of property changes + open func setup() { + backgroundColor = .clear + translatesAutoresizingMaskIntoConstraints = false + insetsLayoutMarginsFromSafeArea = false + } + + /// Function used to make changes to the View based off a change events or from local properties. open func updateView() { updateAccessibility() } - /// Used to update any Accessibility properties open func updateAccessibility() { if isSelected { accessibilityTraits.insert(.selected) @@ -146,18 +133,25 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab } } - - /// Resets to the Controls default values + + /// Resets to default settings. open func reset() { backgroundColor = .clear surface = .light disabled = false } - /// Will be called only once and should be overridden in subclasses to setup UI or defaults - open func setup() { - backgroundColor = .clear - translatesAutoresizingMaskIntoConstraints = false - insetsLayoutMarginsFromSafeArea = false + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + + ///Override to deal with sending actions for accessibility. + /// - Returns: Based on whether the userInteraction is enabled. + override open func accessibilityActivate() -> Bool { + // Hold state in case User wanted isAnimated to remain off. + guard isUserInteractionEnabled else { return false } + sendActions(for: .touchUpInside) + return true } + } diff --git a/VDS/Classes/SelectorBase.swift b/VDS/Classes/SelectorBase.swift index 91935143..326c76bc 100644 --- a/VDS/Classes/SelectorBase.swift +++ b/VDS/Classes/SelectorBase.swift @@ -19,6 +19,7 @@ public protocol SelectorControlable: Control, Changeable { } open class SelectorBase: Control, SelectorControlable { + public var onChangeSubscriber: AnyCancellable? { willSet { if let onChangeSubscriber { @@ -26,9 +27,9 @@ open class SelectorBase: Control, SelectorControlable { } } } - + open var size = CGSize(width: 20, height: 20) { didSet { setNeedsUpdate() }} - + var _showError: Bool = false open var showError: Bool { get { _showError } @@ -51,18 +52,23 @@ open class SelectorBase: Control, SelectorControlable { return state } } - + open var backgroundColorConfiguration = ControlColorConfiguration() { didSet { setNeedsUpdate() }} - + open var borderColorConfiguration = ControlColorConfiguration() { didSet { setNeedsUpdate() }} - - open var selectorColorConfiguration = ControlColorConfiguration() { didSet { setNeedsUpdate() }} - + + open var selectorColorConfiguration = ControlColorConfiguration() { didSet { setNeedsUpdate() }} + private var selectorView = View() //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- internal var shapeLayer: CAShapeLayer? + + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override var intrinsicContentSize: CGSize { size } open override func initialSetup() { super.initialSetup() @@ -70,7 +76,7 @@ open class SelectorBase: Control, SelectorControlable { control.toggle() } } - + open override func setup() { super.setup() @@ -78,10 +84,7 @@ open class SelectorBase: Control, SelectorControlable { accessibilityTraits = .button } - open override var intrinsicContentSize: CGSize { size } - - open func toggle() { } - + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() setNeedsLayout() @@ -91,4 +94,7 @@ open class SelectorBase: Control, SelectorControlable { open override func updateAccessibility() { super.updateAccessibility() } + + open func toggle() { } + } diff --git a/VDS/Classes/SelectorGroupHandlerBase.swift b/VDS/Classes/SelectorGroupHandlerBase.swift index 2575ca2e..1418db50 100644 --- a/VDS/Classes/SelectorGroupHandlerBase.swift +++ b/VDS/Classes/SelectorGroupHandlerBase.swift @@ -9,14 +9,14 @@ import Foundation import UIKit import Combine -/// Base Class used for any Grouped Form Control of a Selector Type +/// Base Class used for any Grouped Form Control of a Selector Type. open class SelectorGroupHandlerBase: Control, Changeable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - /// Array of the HandlerType registered + /// Array of the HandlerType registered. public var selectorViews: [HandlerType] = [] /// The primary subscriber for onChange or the UIControl valueChanged event. @@ -27,12 +27,8 @@ open class SelectorGroupHandlerBase: Control, Changeable { } } } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - /// Override to update the child SelectorViews disabled property for this group + /// Override to update the child SelectorViews disabled property for this group. override public var disabled: Bool { didSet { selectorViews.forEach { handler in @@ -41,7 +37,7 @@ open class SelectorGroupHandlerBase: Control, Changeable { } } - /// Override to update the child SelectorViews surface property for this group + /// Current Surface and this is used to pass down to child objects that implement Surfacable. override public var surface: Surface { didSet { selectorViews.forEach { handler in @@ -49,21 +45,25 @@ open class SelectorGroupHandlerBase: Control, Changeable { } } } + + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- - /// Handler for the Group to override on a select event - /// - Parameter selectedControl: Selected Control the user interacted + /// Handler for the Group to override on a select event. + /// - Parameter selectedControl: Selected Control the user interacted. open func didSelect(_ selectedControl: HandlerType) { fatalError("Must override didSelect") } - /// Helper method to execute the valueChanged event + /// Helper method to execute the valueChanged event. public func valueChanged() { DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { [weak self] in self?.sendActions(for: .valueChanged) } } - /// Override to update the child SelectorViews reset method for this group + /// Resets to default settings as well as child views. open override func reset() { super.reset() selectorViews.forEach{ $0.reset() } @@ -77,7 +77,7 @@ open class SelectorGroupHandlerBase: Control, Changeable { open class SelectorGroupSelectedHandlerBase: SelectorGroupHandlerBase{ - /// Current Selected Control for this group + /// Current Selected Control for this group. public var selectedHandler: HandlerType? { return selectorViews.filter { $0.isSelected == true }.first } diff --git a/VDS/Classes/SelectorItemBase.swift b/VDS/Classes/SelectorItemBase.swift index de49b09a..b1b91985 100644 --- a/VDS/Classes/SelectorItemBase.swift +++ b/VDS/Classes/SelectorItemBase.swift @@ -11,7 +11,8 @@ import Combine import VDSColorTokens import VDSFormControlsTokens -open class SelectorItemBase: Control, Errorable, Changeable { +/// Generic Control used to build out a SelectorControlable control. +open class SelectorItemBase: Control, Errorable, Changeable, FormFieldable { //-------------------------------------------------- // MARK: - Initializers @@ -61,6 +62,7 @@ open class SelectorItemBase: Control, Errorable, //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + /// Subscriber that is set for the .valueChanged event. open var onChangeSubscriber: AnyCancellable? { willSet { if let onChangeSubscriber { @@ -69,32 +71,40 @@ open class SelectorItemBase: Control, Errorable, } } + /// Label used to render labelText. open var label = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .boldBodyLarge } + /// Label used to render childText. open var childLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .bodyLarge } + /// Label used to render errorText. open var errorLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .bodyMedium } - + + /// Generic Object used to allow the user to 'Select'. open var selectorView = Selector() - + + /// Whether or not ths Item is selected. open override var isSelected: Bool { didSet { setNeedsUpdate() }} - + + /// Text shown in the label. open var labelText: String? { didSet { setNeedsUpdate() }} - + + /// Array of LabelAttributeModel objects used in rendering the labelText. open var labelTextAttributes: [any LabelAttributeModel]? { didSet { setNeedsUpdate() }} + /// Instead of use labelText and labelTextAttirbutes, this is a fully baked NSAttributedString with both text and attributes. open var labelAttributedText: NSAttributedString? { didSet { label.useAttributedText = !(labelAttributedText?.string.isEmpty ?? true) @@ -103,10 +113,13 @@ open class SelectorItemBase: Control, Errorable, } } + /// Text shown in the childLabel. open var childText: String? { didSet { setNeedsUpdate() }} + /// Array of LabelAttributeModel objects used in rendering the childText. open var childTextAttributes: [any LabelAttributeModel]? { didSet { setNeedsUpdate() }} + /// Instead of use childText and childTextAttirbutes, this is a fully baked NSAttributedString with both text and attributes. open var childAttributedText: NSAttributedString? { didSet { childLabel.useAttributedText = !(childAttributedText?.string.isEmpty ?? true) @@ -114,18 +127,8 @@ open class SelectorItemBase: Control, Errorable, setNeedsUpdate() } } - - var _showError: Bool = false - open var showError: Bool { - get { _showError } - set { - if !isSelected && _showError != newValue { - _showError = newValue - setNeedsUpdate() - } - } - } + /// Override UIControl state to add the .error state if showError is true. open override var state: UIControl.State { get { var state = super.state @@ -136,13 +139,24 @@ open class SelectorItemBase: Control, Errorable, } } + var _showError: Bool = false + + open var showError: Bool { + get { _showError } + set { + if !isSelected && _showError != newValue { + _showError = newValue + setNeedsUpdate() + } + } + } + open var errorText: String? { didSet { setNeedsUpdate() }} open var inputId: String? { didSet { setNeedsUpdate() }} open var value: AnyHashable? { didSet { setNeedsUpdate() }} - //functions //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -169,7 +183,52 @@ open class SelectorItemBase: Control, Errorable, selectorLabelStackView.addArrangedSubview(childLabel) mainStackView.pinToSuperView() } + + /// Function used to make changes to the View based off a change events or from local properties. + open override func updateView() { + updateLabels() + selectorView.showError = showError + selectorView.isSelected = isSelected + selectorView.isHighlighted = isHighlighted + selectorView.disabled = disabled + selectorView.surface = surface + updateAccessibility() + } + + open override func updateAccessibility() { + super.updateAccessibility() + setAccessibilityLabel(for: [label, childLabel, errorLabel]) + } + + /// Resets to default settings. + open override func reset() { + super.reset() + shouldUpdateView = false + label.reset() + childLabel.reset() + errorLabel.reset() + + label.textStyle = .boldBodyLarge + childLabel.textStyle = .bodyLarge + errorLabel.textStyle = .bodyMedium + + labelText = nil + labelTextAttributes = nil + labelAttributedText = nil + childText = nil + childTextAttributes = nil + childAttributedText = nil + showError = false + errorText = nil + inputId = nil + value = nil + isSelected = false + + shouldUpdateView = true + setNeedsUpdate() + } + /// Update all labels with Text as well as adding and removing the labels. func updateLabels() { //deal with labels @@ -225,53 +284,8 @@ open class SelectorItemBase: Control, Errorable, errorLabel.isHidden = true } } - - /// Resets back to this objects default settings. - open override func reset() { - super.reset() - shouldUpdateView = false - label.reset() - childLabel.reset() - errorLabel.reset() - - label.textStyle = .boldBodyLarge - childLabel.textStyle = .bodyLarge - errorLabel.textStyle = .bodyMedium - - labelText = nil - labelTextAttributes = nil - labelAttributedText = nil - childText = nil - childTextAttributes = nil - childAttributedText = nil - showError = false - errorText = nil - inputId = nil - value = nil - isSelected = false - - shouldUpdateView = true - setNeedsUpdate() - } - - /// This will checkbox the state of the Selector and execute the actionBlock if provided. - open func toggle() {} - - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- - open override func updateView() { - updateLabels() - selectorView.showError = showError - selectorView.isSelected = isSelected - selectorView.isHighlighted = isHighlighted - selectorView.disabled = disabled - selectorView.surface = surface - updateAccessibility() - } - open override func updateAccessibility() { - super.updateAccessibility() - setAccessibilityLabel(for: [label, childLabel, errorLabel]) - } + /// This will change to state of the Selector. + open func toggle() {} + } diff --git a/VDS/Classes/SelfSizingCollectionView.swift b/VDS/Classes/SelfSizingCollectionView.swift index dbedd80e..d42e30f9 100644 --- a/VDS/Classes/SelfSizingCollectionView.swift +++ b/VDS/Classes/SelfSizingCollectionView.swift @@ -9,13 +9,13 @@ import Foundation import UIKit @objc(VDSSelfSizingCollectionView) -/// UICollectionView subclassed used to deal with Changing the size of itself based on its children and layout and changes of its contentSize +/// UICollectionView subclassed used to deal with Changing the size of itself based on its children and layout and changes of its contentSize. public final class SelfSizingCollectionView: UICollectionView { private var contentSizeObservation: NSKeyValueObservation? //-------------------------------------------------- - // MARK: - Lifecycle + // MARK: - Initialization //-------------------------------------------------- /// Initializer @@ -71,9 +71,9 @@ public final class SelfSizingCollectionView: UICollectionView { extension UITraitCollection { - /// Used within SelfSizingCollectionView to determine if there is an appearance change - /// - Parameter traitCollection: TraitCollection to compare - /// - Returns: True/False based on the trailCollection passed in + /// Used within SelfSizingCollectionView to determine if there is an appearance change. + /// - Parameter traitCollection: TraitCollection to compare. + /// - Returns: True/False based on the trailCollection passed in. public func hasDifferentTextAppearance(comparedTo traitCollection: UITraitCollection?) -> Bool { var result = self.preferredContentSizeCategory != traitCollection?.preferredContentSizeCategory result = result || self.legibilityWeight != traitCollection?.legibilityWeight diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index 199fadcb..ea470798 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -17,6 +17,7 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- + /// Set of Subscribers for any Publishers for this Control. public var subscribers = Set() //-------------------------------------------------- @@ -27,13 +28,13 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { /// Key of whether or not updateView() is called in setNeedsUpdate() open var shouldUpdateView: Bool = true - /// Dictionary for keeping information for this Control use only Primitives + /// Dictionary for keeping information for this Control use only Primitives. open var userInfo = [String: Primitive]() /// Current Surface and this is used to pass down to child objects that implement Surfacable open var surface: Surface = .light { didSet { setNeedsUpdate() } } - /// Whether this object is disabled or not + /// Whether this object is disabled or not. open var disabled: Bool { get { !isEnabled } set { @@ -64,10 +65,10 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { } //-------------------------------------------------- - // MARK: - Setup + // MARK: - Lifecycle //-------------------------------------------------- - /// Executed on initialization for this View + /// Executed on initialization for this View. open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true @@ -76,16 +77,19 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { } } - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- + /// Will be called only once and should be overridden in subclasses to setup UI or defaults. + open func setup() { + backgroundColor = .clear + translatesAutoresizingMaskIntoConstraints = false + insetsLayoutMarginsFromSafeArea = false + } - /// Update this view based off of property changes + /// Function used to make changes to the View based off a change events or from local properties.. open func updateView() { updateAccessibility() } - /// Used to update any Accessibility properties + /// Used to update any Accessibility properties. open func updateAccessibility() { if isEnabled { accessibilityTraits.remove(.notEnabled) @@ -94,17 +98,11 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { } } - /// Resets to the Views default values + /// Resets to default settings. open func reset() { backgroundColor = .clear surface = .light disabled = false } - /// Will be called only once and should be overridden in subclasses to setup UI or defaults - open func setup() { - backgroundColor = .clear - translatesAutoresizingMaskIntoConstraints = false - insetsLayoutMarginsFromSafeArea = false - } } diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index 321753f9..60b1cd33 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -41,7 +41,7 @@ open class Badge: View { /// The text that will be shown in the label. open var text: String = "" { didSet { setNeedsUpdate() }} - /// When applied, this property takes a px value that will restrict the width at that point + /// When applied, this property takes a px value that will restrict the width at that point. open var maxWidth: CGFloat? { didSet { setNeedsUpdate() }} /// This will restrict the badge height to a specific number of lines. If the text overflows the allowable space, ellipsis will show. @@ -53,6 +53,46 @@ open class Badge: View { private var maxWidthConstraint: NSLayoutConstraint? private var minWidthConstraint: NSLayoutConstraint? + //-------------------------------------------------- + // MARK: - Configuration + //-------------------------------------------------- + + /// ColorConfiguration that is mapped to the 'fillColor' for the surface. + private var backgroundColorConfiguration: AnyColorable = { + let config = KeyedColorConfiguration(keyPath: \.fillColor) + config.setSurfaceColors(VDSColor.backgroundBrandhighlight, VDSColor.backgroundBrandhighlight, forKey: .red) + config.setSurfaceColors(VDSColor.paletteYellow53, VDSColor.paletteYellow53, forKey: .yellow) + config.setSurfaceColors(VDSColor.paletteGreen26, VDSColor.paletteGreen36, forKey: .green) + config.setSurfaceColors(VDSColor.paletteOrange41, VDSColor.paletteOrange58, forKey: .orange) + config.setSurfaceColors(VDSColor.paletteBlue38, VDSColor.paletteBlue46, forKey: .blue) + config.setSurfaceColors(VDSColor.backgroundPrimaryDark, VDSColor.backgroundPrimaryDark, forKey: .black) + config.setSurfaceColors(VDSColor.backgroundPrimaryLight, VDSColor.backgroundPrimaryLight, forKey: .white) + return config.eraseToAnyColorable() + }() + + /// ColorConfiguration for the Text. + private var textColorConfiguration = ViewColorConfiguration() + + /// Updates the textColorConfiguration based on the fillColor. + public func updateTextColorConfig() { + textColorConfiguration.reset() + + switch fillColor { + + case .red, .black: + textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forDisabled: false) + textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forDisabled: true) + + case .yellow, .white: + textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forDisabled: false) + textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forDisabled: true) + + case .orange, .green, .blue: + textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOnlight, forDisabled: false) + textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOnlight, forDisabled: true) + } + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -75,9 +115,9 @@ open class Badge: View { } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { - super.reset() + super.reset() shouldUpdateView = false label.reset() label.lineBreakMode = .byTruncatingTail @@ -91,49 +131,7 @@ open class Badge: View { setNeedsUpdate() } - //-------------------------------------------------- - // MARK: - Configuration - //-------------------------------------------------- - - /// ColorConfiguration that is mapped to the 'fillColor' for the surface - private var backgroundColorConfiguration: AnyColorable = { - let config = KeyedColorConfiguration(keyPath: \.fillColor) - config.setSurfaceColors(VDSColor.backgroundBrandhighlight, VDSColor.backgroundBrandhighlight, forKey: .red) - config.setSurfaceColors(VDSColor.paletteYellow53, VDSColor.paletteYellow53, forKey: .yellow) - config.setSurfaceColors(VDSColor.paletteGreen26, VDSColor.paletteGreen36, forKey: .green) - config.setSurfaceColors(VDSColor.paletteOrange41, VDSColor.paletteOrange58, forKey: .orange) - config.setSurfaceColors(VDSColor.paletteBlue38, VDSColor.paletteBlue46, forKey: .blue) - config.setSurfaceColors(VDSColor.backgroundPrimaryDark, VDSColor.backgroundPrimaryDark, forKey: .black) - config.setSurfaceColors(VDSColor.backgroundPrimaryLight, VDSColor.backgroundPrimaryLight, forKey: .white) - return config.eraseToAnyColorable() - }() - - /// ColorConfiguration for the Text - private var textColorConfiguration = ViewColorConfiguration() - - /// Updates the textColorConfiguration based on the fillColor - public func updateTextColorConfig() { - textColorConfiguration.reset() - - switch fillColor { - - case .red, .black: - textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forDisabled: false) - textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forDisabled: true) - - case .yellow, .white: - textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forDisabled: false) - textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOnlight, forDisabled: true) - - case .orange, .green, .blue: - textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOnlight, forDisabled: false) - textColorConfiguration.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOnlight, forDisabled: true) - } - } - - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { updateTextColorConfig() diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index d35b7187..b9f72d46 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -19,17 +19,17 @@ open class BadgeIndicator: View { // MARK: - Enums //-------------------------------------------------- - /// Enum type for fill color + /// Enum type for fill color. public enum FillColor: String, CaseIterable { case red, yellow, green, orange, blue, gray, grayLowContrast, black, white } - /// Enum type for kind of BadgeIndicator + /// Enum type for kind of BadgeIndicator. public enum Kind: String, CaseIterable { case simple, numbered } - /// Enum type for maximum number of digits + /// Enum type for maximum number of digits. public enum MaximumDigits: String, CaseIterable { case one case two @@ -59,7 +59,7 @@ open class BadgeIndicator: View { } } - /// Enum type describing size of Badge Indicator + /// Enum type describing size of Badge Indicator. public enum Size: String, CaseIterable { case xxlarge = "2XLarge" case xlarge = "XLarge" @@ -67,7 +67,7 @@ open class BadgeIndicator: View { case medium = "Medium" case small = "Small" - /// Dynamic TextStyle for the size + /// Dynamic TextStyle for the size. public var textStyle: TextStyle { let style = TextStyle.bodySmall var pointSize: CGFloat = VDSTypography.fontSizeBody12 @@ -98,7 +98,7 @@ open class BadgeIndicator: View { letterSpacing: letterSpacing) } - //EdgeInsets for the label + //EdgeInsets for the label. public var edgeInset: UIEdgeInsets { var horizontalPadding: CGFloat = VDSLayout.Spacing.space1X.value let verticalPadding: CGFloat = 0 @@ -120,7 +120,7 @@ open class BadgeIndicator: View { // MARK: - Public Properties //-------------------------------------------------- - /// Label used for the numeric kind + /// Label used for the numeric kind. open var label = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.adjustsFontSizeToFitWidth = false @@ -129,7 +129,7 @@ open class BadgeIndicator: View { $0.numberOfLines = 1 } - /// BorderColor for Surface.light + /// BorderColor for Surface.light. open var borderColorLight: UIColor? { didSet { if let borderColorLight { @@ -140,8 +140,8 @@ open class BadgeIndicator: View { setNeedsUpdate() } } - - /// BorderColor for Surface.dark + + /// BorderColor for Surface.dark. open var borderColorDark: UIColor? { didSet { if let borderColorDark { @@ -157,40 +157,40 @@ open class BadgeIndicator: View { /// When used in conjunction with the surface prop, this fill color will change its tint automatically based on a light or dark surface. open var fillColor: FillColor = .red { didSet { setNeedsUpdate() }} - /// Badge Number that will be shown if you are using Kind.numbered + /// Badge Number that will be shown if you are using Kind.numbered. open var number: Int? { didSet { setNeedsUpdate() }} /// Type of Badge Indicator, simple is a dot, whereas numbered shows a number. open var kind: Kind = .simple { didSet { setNeedsUpdate() }} - /// Character that is always at the begging. Accepts any character and if unaffected by maximumDigits + /// Character that is always at the begging. Accepts any character and if unaffected by maximumDigits. open var leadingCharacter: String? { didSet { setNeedsUpdate() }} /// Determines the size of the Badge Indicator as well as the textStyle and padding used. open var size: Size = .xxlarge { didSet { setNeedsUpdate() }} - /// Pixel size of the dot when the kind is set to simple + /// Pixel size of the dot when the kind is set to simple. open var dotSize: CGFloat? { didSet { setNeedsUpdate() }} - /// Sets the padding at the top/bottom of the label + /// Sets the padding at the top/bottom of the label. open var verticalPadding: CGFloat? { didSet { setNeedsUpdate() }} - /// Sets the padding at the left/right of the label + /// Sets the padding at the left/right of the label. open var horitonalPadding: CGFloat? { didSet { setNeedsUpdate() }} /// Hides the dot when you are in Kind.simple mode. open var hideDot: Bool = false { didSet { setNeedsUpdate() }} - /// Will not show the border + /// Will not show the border. open var hideBorder: Bool = false { didSet { setNeedsUpdate() }} /// When in Kind.numbered this is the amount of digits that will show up when the user adds a number. open var maximumDigits: MaximumDigits = .two { didSet { setNeedsUpdate() }} - /// The Container's width + /// The Container's width. open var width: CGFloat? { didSet { setNeedsUpdate() }} - /// The Container's height + /// The Container's height. open var height: CGFloat? { didSet { setNeedsUpdate() }} //-------------------------------------------------- @@ -278,7 +278,7 @@ open class BadgeIndicator: View { } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false @@ -310,9 +310,7 @@ open class BadgeIndicator: View { } } - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { updateTextColorConfig() @@ -372,6 +370,10 @@ open class BadgeIndicator: View { return min(number, maxNumber) } + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override func layoutSubviews() { super.layoutSubviews() diff --git a/VDS/Components/Buttons/Button/Button.swift b/VDS/Components/Buttons/Button/Button.swift index be1a7cec..15c4a0ba 100644 --- a/VDS/Components/Buttons/Button/Button.swift +++ b/VDS/Components/Buttons/Button/Button.swift @@ -130,7 +130,7 @@ open class Button: ButtonBase, Useable { heightConstraint?.isActive = true } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index 637fceb3..d3b7c0d7 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -28,7 +28,9 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- + /// Set of Subscribers for any Publishers for this Control. public var subscribers = Set() + public var onClickSubscriber: AnyCancellable? { willSet { if let onClickSubscriber { @@ -45,16 +47,18 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + /// Key of whether or not updateView() is called in setNeedsUpdate() open var shouldUpdateView: Bool = true open var availableSizes: [ButtonSize] { [] } open var text: String? { didSet { setNeedsUpdate() } } - open var attributes: [any LabelAttributeModel]? { nil } + open var textAttributes: [any LabelAttributeModel]? { nil } open var useScaledFont: Bool = false { didSet { setNeedsUpdate() }} - + + /// Current Surface and this is used to pass down to child objects that implement Surfacable open var surface: Surface = .light { didSet { setNeedsUpdate() }} open var userInfo = [String: Primitive]() @@ -135,7 +139,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab } - /// Resets back to this objects default settings. + /// Resets to default settings. open func reset() { shouldUpdateView = false surface = .light @@ -185,7 +189,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab alignment: titleLabel?.textAlignment ?? .center, lineBreakMode: titleLabel?.lineBreakMode ?? .byTruncatingTail) - if let attributes = attributes { + if let attributes = textAttributes { //loop through the models attributes for attribute in attributes { //add attribute on the string diff --git a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift index 9f845f96..790f272f 100644 --- a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift +++ b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift @@ -101,7 +101,8 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega } } } - + + /// Current Surface and this is used to pass down to child objects that implement Surfacable override public var surface: Surface { didSet { buttons.forEach { button in diff --git a/VDS/Components/Buttons/TextLink/TextLink.swift b/VDS/Components/Buttons/TextLink/TextLink.swift index 573665e0..af844530 100644 --- a/VDS/Components/Buttons/TextLink/TextLink.swift +++ b/VDS/Components/Buttons/TextLink/TextLink.swift @@ -87,7 +87,7 @@ open class TextLink: ButtonBase { } } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift index c7c14e74..22cffb36 100644 --- a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift +++ b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift @@ -30,7 +30,7 @@ open class TextLinkCaret: ButtonBase { private var imageAttribute: CaretLabelAttribute? - open override var attributes: [any LabelAttributeModel]? { + open override var textAttributes: [any LabelAttributeModel]? { guard let imageAttribute else { return nil } return [imageAttribute] } @@ -79,7 +79,7 @@ open class TextLinkCaret: ButtonBase { accessibilityTraits = .link } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() iconPosition = .right diff --git a/VDS/Components/Checkbox/CheckboxGroup.swift b/VDS/Components/Checkbox/CheckboxGroup.swift index 03635d4d..8eb7f5fc 100644 --- a/VDS/Components/Checkbox/CheckboxGroup.swift +++ b/VDS/Components/Checkbox/CheckboxGroup.swift @@ -113,6 +113,7 @@ extension CheckboxGroup { public struct CheckboxModel : Surfaceable, Disabling, Initable, FormFieldable, Errorable { public var disabled: Bool + /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface public var inputId: String? public var value: AnyHashable? diff --git a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift index 5d7c63ba..baee9258 100644 --- a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift +++ b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift @@ -253,7 +253,7 @@ open class ButtonIcon: Control { iconLayoutGuide.trailingAnchor.constraint(equalTo: trailingAnchor)]) } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false @@ -284,6 +284,10 @@ open class ButtonIcon: Control { setNeedsLayout() } + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override func layoutSubviews() { super.layoutSubviews() diff --git a/VDS/Components/Icon/Icon.swift b/VDS/Components/Icon/Icon.swift index 58a712fb..9e884875 100644 --- a/VDS/Components/Icon/Icon.swift +++ b/VDS/Components/Icon/Icon.swift @@ -62,16 +62,13 @@ open class Icon: View { accessibilityTraits = .image } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() color = VDSColor.paletteBlack imageView.image = nil } - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- open override func updateView() { super.updateView() //get the color for the image diff --git a/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift b/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift index 2ea9f227..d77e03fe 100644 --- a/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/TooltipLabelAttribute.swift @@ -17,6 +17,7 @@ public class TooltipLabelAttribute: ActionLabelAttributeModel, TooltipLaunchable private var size: Tooltip.Size = .small public var location: Int = 0 public var length: Int = 3 + /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface = .light public var accessibleText: String? = "Tool Tip" public var closeButtonText: String = "Close" diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 092b48a2..13d25d42 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -16,6 +16,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- + /// Set of Subscribers for any Publishers for this Control. public var subscribers = Set() //-------------------------------------------------- @@ -23,12 +24,14 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- private var initialSetupPerformed = false + /// Key of whether or not updateView() is called in setNeedsUpdate() open var shouldUpdateView: Bool = true open var useAttributedText: Bool = false open var useScaledFont: Bool = false { didSet { setNeedsUpdate() }} + /// Current Surface and this is used to pass down to child objects that implement Surfacable open var surface: Surface = .light { didSet { setNeedsUpdate() }} open var attributes: [any LabelAttributeModel]? { didSet { setNeedsUpdate() }} @@ -111,7 +114,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { open func setup() {} - /// Resets back to this objects default settings. + /// Resets to default settings. open func reset() { shouldUpdateView = false surface = .light diff --git a/VDS/Components/Line/Line.swift b/VDS/Components/Line/Line.swift index 18bb485f..14ceacc8 100644 --- a/VDS/Components/Line/Line.swift +++ b/VDS/Components/Line/Line.swift @@ -28,6 +28,16 @@ open class Line: View { open var style: Style = .primary { didSet { setNeedsUpdate() } } + //-------------------------------------------------- + // MARK: - Configuration + //-------------------------------------------------- + public var lineViewColorConfiguration: AnyColorable = { + let config = KeyedColorConfiguration(keyPath: \.style) + config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forKey: .primary) + config.setSurfaceColors(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark, forKey: .secondary) + return config.eraseToAnyColorable() + }() + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -40,25 +50,12 @@ open class Line: View { lineView.pinToSuperView() } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() style = .primary } - //-------------------------------------------------- - // MARK: - Configuration - //-------------------------------------------------- - public var lineViewColorConfiguration: AnyColorable = { - let config = KeyedColorConfiguration(keyPath: \.style) - config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forKey: .primary) - config.setSurfaceColors(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark, forKey: .secondary) - return config.eraseToAnyColorable() - }() - - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- open override func updateView() { lineView.backgroundColor = lineViewColorConfiguration.getColor(self) } diff --git a/VDS/Components/Loader/LoaderViewController.swift b/VDS/Components/Loader/LoaderViewController.swift index 7e18c0c1..2b0fb944 100644 --- a/VDS/Components/Loader/LoaderViewController.swift +++ b/VDS/Components/Loader/LoaderViewController.swift @@ -20,7 +20,7 @@ open class LoaderViewController: UIViewController, Surfaceable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - /// Current Surface used within this Control and used to passdown to child views + /// Current Surface and this is used to pass down to child objects that implement Surfacable open var surface: Surface = .light { didSet { updateView() }} /// Size of the Height and Width of the Loader view. diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index de382de3..25308654 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -90,8 +90,9 @@ open class Notification: View { open var leadingConstraint: NSLayoutConstraint? open var trailingConstraint: NSLayoutConstraint? + //-------------------------------------------------- - // MARK: - View Properties + // MARK: - Public Properties //-------------------------------------------------- open var typeIcon = Icon().with { @@ -228,7 +229,7 @@ open class Notification: View { subTitleLabel.textColorConfiguration = textColorConfiguration.eraseToAnyColorable() } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() @@ -263,9 +264,6 @@ open class Notification: View { setNeedsUpdate() } - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- open override func updateView() { backgroundColor = backgroundColorConfiguration.getColor(self) updateIcons() diff --git a/VDS/Components/RadioBox/RadioBoxGroup.swift b/VDS/Components/RadioBox/RadioBoxGroup.swift index 0742459f..84065697 100644 --- a/VDS/Components/RadioBox/RadioBoxGroup.swift +++ b/VDS/Components/RadioBox/RadioBoxGroup.swift @@ -108,6 +108,7 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase { extension RadioBoxGroup { public struct RadioBoxModel: Surfaceable, Initable, Disabling, FormFieldable { public var disabled: Bool + /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface public var inputId: String? public var value: AnyHashable? diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index 9da920ef..6c0d8720 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -127,8 +127,29 @@ open class RadioBoxItem: Control, Changeable { open var inputId: String? { didSet { setNeedsUpdate() }} open var value: AnyHashable? { didSet { setNeedsUpdate() }} - - //functions + + //-------------------------------------------------- + // MARK: - Configuration Properties + //-------------------------------------------------- + private var strikeThroughLineThickness: CGFloat = VDSFormControls.widthBorder + private var selectorCornerRadius: CGFloat = VDSFormControls.borderradius + private var selectorBorderWidthSelected: CGFloat = VDSFormControls.widthBorder + VDSFormControls.widthBorder + private var selectorBorderWidth: CGFloat = VDSFormControls.widthBorder + + private var backgroundColorConfiguration = ControlColorConfiguration().with { + $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .normal) + $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .disabled) + $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .selected) + $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .highlighted) + } + + private var borderColorConfiguration = ControlColorConfiguration().with { + $0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: .normal) + $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled) + $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected) + $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .highlighted) + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -200,7 +221,7 @@ open class RadioBoxItem: Control, Changeable { } } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false @@ -238,9 +259,6 @@ open class RadioBoxItem: Control, Changeable { sendActions(for: .valueChanged) } - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- open override func updateView() { updateLabels() updateAccessibility() @@ -255,28 +273,6 @@ open class RadioBoxItem: Control, Changeable { } } - //-------------------------------------------------- - // MARK: - Configuration Properties - //-------------------------------------------------- - private var strikeThroughLineThickness: CGFloat = VDSFormControls.widthBorder - private var selectorCornerRadius: CGFloat = VDSFormControls.borderradius - private var selectorBorderWidthSelected: CGFloat = VDSFormControls.widthBorder + VDSFormControls.widthBorder - private var selectorBorderWidth: CGFloat = VDSFormControls.widthBorder - - private var backgroundColorConfiguration = ControlColorConfiguration().with { - $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .normal) - $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .disabled) - $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .selected) - $0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .highlighted) - } - - private var borderColorConfiguration = ControlColorConfiguration().with { - $0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: .normal) - $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled) - $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected) - $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .highlighted) - } - //-------------------------------------------------- // MARK: - RadioBox View Updates //-------------------------------------------------- diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index 1ffa55bb..5766d811 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -117,6 +117,7 @@ extension RadioButtonGroup { public struct RadioButtonModel: Surfaceable, Disabling, Initable, FormFieldable, Errorable { public var disabled: Bool + /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface public var inputId: String? public var value: AnyHashable? diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index f6651bdd..b9ec00c7 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -55,7 +55,22 @@ open class RadioSwatch: Control { open var value: AnyHashable? { didSet { setNeedsUpdate() }} - //functions + //-------------------------------------------------- + // MARK: - Configuration Properties + //-------------------------------------------------- + private var strikeThroughLineThickness: CGFloat = VDSFormControls.widthBorder + private var selectorBorderWidth: CGFloat = VDSFormControls.widthBorder + public let swatchSize = CGSize(width: 48, height: 48) + public let fillSize = CGSize(width: 36, height: 36) + public let disabledAlpha = 0.5 + + private var borderColorConfiguration = ControlColorConfiguration().with { + $0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: .normal) + $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled) + $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .highlighted) + $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected) + } + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -89,7 +104,7 @@ open class RadioSwatch: Control { } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false @@ -110,9 +125,6 @@ open class RadioSwatch: Control { sendActions(for: .valueChanged) } - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- open override func updateView() { layer.setNeedsDisplay() } @@ -121,22 +133,6 @@ open class RadioSwatch: Control { accessibilityLabel = text } - //-------------------------------------------------- - // MARK: - Configuration Properties - //-------------------------------------------------- - private var strikeThroughLineThickness: CGFloat = VDSFormControls.widthBorder - private var selectorBorderWidth: CGFloat = VDSFormControls.widthBorder - public let swatchSize = CGSize(width: 48, height: 48) - public let fillSize = CGSize(width: 36, height: 36) - public let disabledAlpha = 0.5 - - private var borderColorConfiguration = ControlColorConfiguration().with { - $0.setSurfaceColors(VDSFormControlsColor.borderOnlight, VDSFormControlsColor.borderOndark, forState: .normal) - $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled) - $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .highlighted) - $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forState: .selected) - } - //-------------------------------------------------- // MARK: - RadioBox View Updates //-------------------------------------------------- @@ -148,7 +144,10 @@ open class RadioSwatch: Control { open func getSelectorSize() -> CGSize { return swatchSize } - + + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- open override func layoutSubviews() { super.layoutSubviews() // Accounts for any size changes diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index e5211163..fc3fb801 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -79,7 +79,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo collectionView.reloadData() } } - + /// Current Surface and this is used to pass down to child objects that implement Surfacable override public var surface: Surface { didSet { for selector in selectorViews { diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index d485c007..8f14962e 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -228,7 +228,7 @@ open class EntryField: Control, Changeable { return containerView } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() titleLabel.reset() diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index 8ee35f0e..eec960ab 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -140,7 +140,7 @@ open class InputField: EntryField, UITextFieldDelegate { } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() textField.text = "" diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index 9064c9fc..c4d701d3 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -60,6 +60,7 @@ open class TextArea: EntryField { internal var minWidthConstraint: NSLayoutConstraint? internal var textViewHeightConstraint: NSLayoutConstraint? + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -79,7 +80,7 @@ open class TextArea: EntryField { textView.delegate = self } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() textView.text = "" @@ -90,9 +91,6 @@ open class TextArea: EntryField { return inputFieldStackView } - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- open override func updateView() { super.updateView() diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index 6b5eef20..87693dc9 100644 --- a/VDS/Components/TileContainer/TileContainer.swift +++ b/VDS/Components/TileContainer/TileContainer.swift @@ -145,7 +145,6 @@ open class TileContainer: Control { internal var containerLeadingConstraint: NSLayoutConstraint? internal var containerTrailingConstraint: NSLayoutConstraint? - //functions //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -189,7 +188,7 @@ open class TileContainer: Control { } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false @@ -205,64 +204,6 @@ open class TileContainer: Control { setNeedsUpdate() } - //-------------------------------------------------- - // MARK: - Configuration - //-------------------------------------------------- - private let cornerRadius = VDSFormControls.borderradius * 2 - - private var backgroundColorConfiguration = BackgroundColorConfiguration() - - private var borderColorConfiguration = SurfaceColorConfiguration().with { - $0.lightColor = VDSColor.elementsLowcontrastOnlight - $0.darkColor = VDSColor.elementsLowcontrastOndark - } - - private var imageFallbackColorConfiguration = SurfaceColorConfiguration().with { - $0.lightColor = VDSColor.backgroundPrimaryLight - $0.darkColor = VDSColor.backgroundPrimaryDark - } - - private var hightLightViewColorConfiguration = SurfaceColorConfiguration().with { - $0.lightColor = VDSColor.paletteWhite.withAlphaComponent(0.3) - $0.darkColor = VDSColor.paletteBlack.withAlphaComponent(0.3) - } - - //-------------------------------------------------- - // MARK: - Private Functions - //-------------------------------------------------- - private func ratioSize(for width: CGFloat) -> CGSize { - var height: CGFloat = width - - switch aspectRatio { - case .ratio1x1: - break; - case .ratio3x4: - height = (4 / 3) * width - case .ratio4x3: - height = (3 / 4) * width - case .ratio2x3: - height = (3 / 2) * width - case .ratio3x2: - height = (2 / 3) * width - case .ratio9x16: - height = (16 / 9) * width - case .ratio16x9: - height = (9 / 16) * width - case .ratio1x2: - height = (2 / 1) * width - case .ratio2x1: - height = (1 / 2) * width - - default: - break - } - - return CGSize(width: width, height: height) - } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- open override func updateView() { super.updateView() @@ -319,6 +260,62 @@ open class TileContainer: Control { view.pinToSuperView() } } + + //-------------------------------------------------- + // MARK: - Configuration + //-------------------------------------------------- + private let cornerRadius = VDSFormControls.borderradius * 2 + + private var backgroundColorConfiguration = BackgroundColorConfiguration() + + private var borderColorConfiguration = SurfaceColorConfiguration().with { + $0.lightColor = VDSColor.elementsLowcontrastOnlight + $0.darkColor = VDSColor.elementsLowcontrastOndark + } + + private var imageFallbackColorConfiguration = SurfaceColorConfiguration().with { + $0.lightColor = VDSColor.backgroundPrimaryLight + $0.darkColor = VDSColor.backgroundPrimaryDark + } + + private var hightLightViewColorConfiguration = SurfaceColorConfiguration().with { + $0.lightColor = VDSColor.paletteWhite.withAlphaComponent(0.3) + $0.darkColor = VDSColor.paletteBlack.withAlphaComponent(0.3) + } + + //-------------------------------------------------- + // MARK: - Private Functions + //-------------------------------------------------- + private func ratioSize(for width: CGFloat) -> CGSize { + var height: CGFloat = width + + switch aspectRatio { + case .ratio1x1: + break; + case .ratio3x4: + height = (4 / 3) * width + case .ratio4x3: + height = (3 / 4) * width + case .ratio2x3: + height = (3 / 2) * width + case .ratio3x2: + height = (2 / 3) * width + case .ratio9x16: + height = (16 / 9) * width + case .ratio16x9: + height = (9 / 16) * width + case .ratio1x2: + height = (2 / 1) * width + case .ratio2x1: + height = (1 / 2) * width + + default: + break + } + + return CGSize(width: width, height: height) + } + } extension TileContainer { diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 80c66ea0..32eb1dde 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -194,7 +194,7 @@ open class Tilelet: TileContainer { //-------------------------------------------------- internal var titleLockupWidthConstraint: NSLayoutConstraint? internal var titleLockupTrailingConstraint: NSLayoutConstraint? - //functions + //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- @@ -240,7 +240,7 @@ open class Tilelet: TileContainer { } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { shouldUpdateView = false aspectRatio = .none @@ -255,9 +255,6 @@ open class Tilelet: TileContainer { setNeedsUpdate() } - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- fileprivate func updateBadge() { if let badgeModel { badge.text = badgeModel.text diff --git a/VDS/Components/Tilelet/TileletBadgeModel.swift b/VDS/Components/Tilelet/TileletBadgeModel.swift index bd7efcac..a56d034a 100644 --- a/VDS/Components/Tilelet/TileletBadgeModel.swift +++ b/VDS/Components/Tilelet/TileletBadgeModel.swift @@ -11,6 +11,7 @@ extension Tilelet { public struct BadgeModel { public var text: String = "" public var fillColor: Badge.FillColor + /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface public var numberOfLines: Int public var maxWidth: CGFloat? diff --git a/VDS/Components/Tilelet/TileletIconModels.swift b/VDS/Components/Tilelet/TileletIconModels.swift index 22a5a148..eb9e444e 100644 --- a/VDS/Components/Tilelet/TileletIconModels.swift +++ b/VDS/Components/Tilelet/TileletIconModels.swift @@ -13,6 +13,7 @@ extension Tilelet { public struct DescriptiveIcon { public var name: Icon.Name public var size: Icon.Size + /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface public init(name: Icon.Name = .multipleDocuments, size: Icon.Size = .medium, surface: Surface = .dark) { diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index ab745a33..599b6364 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -46,11 +46,44 @@ open class TitleLockup: View { $0.distribution = .fill } + private var otherStandardStyle: OtherStandardStyle { + if let subTitleModel, !subTitleModel.text.isEmpty { + return subTitleModel.standardStyle + } else if let eyebrowModel, !eyebrowModel.text.isEmpty { + return eyebrowModel.standardStyle + } else { + return .bodyLarge + } + } + ///This logic applies when the type style and size used for the title and subtitle/eyebrow is exactly the same (not including the type weight). This should be automatically detected. private var isUniformSize: Bool { otherStandardStyle.value == titleModel?.standardStyle.value } + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }} + + //first row + open var eyebrowLabel = Label().with { + $0.setContentCompressionResistancePriority(.required, for: .vertical) + } + open var eyebrowModel: EyebrowModel? { didSet { setNeedsUpdate() }} + + //second row + open var titleLabel = Label().with { + $0.setContentCompressionResistancePriority(.required, for: .vertical) + } + open var titleModel: TitleModel? { didSet { setNeedsUpdate() }} + + //third row + open var subTitleLabel = Label().with { + $0.setContentCompressionResistancePriority(.required, for: .vertical) + } + open var subTitleModel: SubTitleModel? { didSet { setNeedsUpdate() }} + //-------------------------------------------------- // MARK: - Configuration Properties //-------------------------------------------------- @@ -217,29 +250,6 @@ open class TitleLockup: View { private var textColorSecondaryConfiguration = SurfaceColorConfiguration(VDSColor.elementsSecondaryOnlight , VDSColor.elementsSecondaryOnlight).eraseToAnyColorable() private var textColorPrimaryConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark).eraseToAnyColorable() - - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- - open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }} - - //first row - open var eyebrowLabel = Label().with { - $0.setContentCompressionResistancePriority(.required, for: .vertical) - } - open var eyebrowModel: EyebrowModel? { didSet { setNeedsUpdate() }} - - //second row - open var titleLabel = Label().with { - $0.setContentCompressionResistancePriority(.required, for: .vertical) - } - open var titleModel: TitleModel? { didSet { setNeedsUpdate() }} - - //third row - open var subTitleLabel = Label().with { - $0.setContentCompressionResistancePriority(.required, for: .vertical) - } - open var subTitleModel: SubTitleModel? { didSet { setNeedsUpdate() }} //-------------------------------------------------- // MARK: - Lifecycle @@ -263,7 +273,7 @@ open class TitleLockup: View { } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false @@ -275,19 +285,6 @@ open class TitleLockup: View { setNeedsUpdate() } - private var otherStandardStyle: OtherStandardStyle { - if let subTitleModel, !subTitleModel.text.isEmpty { - return subTitleModel.standardStyle - } else if let eyebrowModel, !eyebrowModel.text.isEmpty { - return eyebrowModel.standardStyle - } else { - return .bodyLarge - } - } - - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- open override func updateView() { super.updateView() @@ -378,5 +375,5 @@ open class TitleLockup: View { eyebrowLabel.isHidden = eyebrowTextIsEmpty titleLabel.isHidden = titleTextIsEmpty subTitleLabel.isHidden = subTitleTextIsEmpty - } + } } diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index e7b50206..e44c1b0f 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -172,7 +172,7 @@ open class Toggle: Control, Changeable { } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false @@ -191,6 +191,23 @@ open class Toggle: Control, Changeable { setNeedsUpdate() } + open override func updateView() { + updateLabel() + toggleView.surface = surface + toggleView.disabled = disabled + toggleView.isOn = isOn + updateAccessibility() + } + + open override func updateAccessibility() { + super.updateAccessibility() + if showText { + setAccessibilityLabel(for: [label]) + } else { + accessibilityLabel = "Toggle" + } + } + /// This will toggle the state of the Toggle open func toggle() { isOn.toggle() @@ -231,23 +248,7 @@ open class Toggle: Control, Changeable { //-------------------------------------------------- // MARK: - Overrides - //-------------------------------------------------- - open override func updateView() { - updateLabel() - toggleView.surface = surface - toggleView.disabled = disabled - toggleView.isOn = isOn - updateAccessibility() - } - - open override func updateAccessibility() { - super.updateAccessibility() - if showText { - setAccessibilityLabel(for: [label]) - } else { - accessibilityLabel = "Toggle" - } - } + //-------------------------------------------------- open override var intrinsicContentSize: CGSize { if showLabel { diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index b19afeed..55aaf044 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -34,7 +34,11 @@ open class ToggleView: Control, Changeable { public required init?(coder: NSCoder) { super.init(coder: coder) } - + + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + private var toggleView = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false $0.isUserInteractionEnabled = false @@ -46,27 +50,6 @@ open class ToggleView: Control, Changeable { $0.isUserInteractionEnabled = false } - //-------------------------------------------------- - // MARK: - Configuration Properties - //-------------------------------------------------- - // Sizes are from InVision design specs. - public let toggleSize = CGSize(width: 52, height: 28) - public let knobSize = CGSize(width: 24, height: 24) - - private var toggleColorConfiguration = ControlColorConfiguration().with { - $0.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.paletteGray44, forState: .normal) - $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled) - $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.selected, .disabled]) - $0.setSurfaceColors(VDSColor.paletteGreen26, VDSColor.paletteGreen36, forState: .selected) - } - - private var knobColorConfiguration = ControlColorConfiguration().with { - $0.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forState: .normal) - $0.setSurfaceColors(VDSColor.paletteGray95, VDSColor.paletteGray44, forState: .disabled) - $0.setSurfaceColors(VDSColor.paletteGray95, VDSColor.paletteGray44, forState: [.selected, .disabled]) - $0.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forState: .selected) - } - //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- @@ -88,6 +71,27 @@ open class ToggleView: Control, Changeable { open var value: AnyHashable? { didSet { setNeedsUpdate() }} + //-------------------------------------------------- + // MARK: - Configuration Properties + //-------------------------------------------------- + // Sizes are from InVision design specs. + public let toggleSize = CGSize(width: 52, height: 28) + public let knobSize = CGSize(width: 24, height: 24) + + private var toggleColorConfiguration = ControlColorConfiguration().with { + $0.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.paletteGray44, forState: .normal) + $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: .disabled) + $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forState: [.selected, .disabled]) + $0.setSurfaceColors(VDSColor.paletteGreen26, VDSColor.paletteGreen36, forState: .selected) + } + + private var knobColorConfiguration = ControlColorConfiguration().with { + $0.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forState: .normal) + $0.setSurfaceColors(VDSColor.paletteGray95, VDSColor.paletteGray44, forState: .disabled) + $0.setSurfaceColors(VDSColor.paletteGray95, VDSColor.paletteGray44, forState: [.selected, .disabled]) + $0.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forState: .selected) + } + //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -133,10 +137,8 @@ open class ToggleView: Control, Changeable { setContentHuggingPriority(.required, for: .horizontal) setContentHuggingPriority(.required, for: .vertical) } - - open override var intrinsicContentSize: CGSize { toggleSize } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false @@ -150,12 +152,27 @@ open class ToggleView: Control, Changeable { setNeedsUpdate() } + open override func updateView() { + updateToggle() + updateAccessibility() + } + + open override func updateAccessibility() { + super.updateAccessibility() + accessibilityLabel = "Toggle" + } + /// This will toggle the state of the Toggle and execute the actionBlock if provided. open func toggle() { isOn.toggle() sendActions(for: .valueChanged) } + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override var intrinsicContentSize: CGSize { toggleSize } + //-------------------------------------------------- // MARK: - Toggle //-------------------------------------------------- @@ -193,19 +210,6 @@ open class ToggleView: Control, Changeable { }, completion: nil) } } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - open override func updateView() { - updateToggle() - updateAccessibility() - } - - open override func updateAccessibility() { - super.updateAccessibility() - accessibilityLabel = "Toggle" - } } // MARK: AppleGuidlinesTouchable diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index 5df97beb..69b3964d 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -140,7 +140,7 @@ open class Tooltip: Control, TooltipLaunchable { }) } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false diff --git a/VDS/Components/Tooltip/TooltipAlertViewController.swift b/VDS/Components/Tooltip/TooltipAlertViewController.swift index 01aa8f09..5dc22d54 100644 --- a/VDS/Components/Tooltip/TooltipAlertViewController.swift +++ b/VDS/Components/Tooltip/TooltipAlertViewController.swift @@ -12,7 +12,7 @@ import VDSColorTokens open class TooltipAlertViewController: UIViewController, Surfaceable { - /// Set of Subscribers for any Publishers for this Control + /// Set of Subscribers for any Publishers for this Control. public var subscribers = Set() //-------------------------------------------------- @@ -31,12 +31,14 @@ open class TooltipAlertViewController: UIViewController, Surfaceable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + /// Current Surface and this is used to pass down to child objects that implement Surfacable open var surface: Surface = .light { didSet { updateView() }} open var titleText: String? { didSet { updateView() }} open var contentText: String? { didSet { updateView() }} open var contentView: UIView? { didSet { updateView() }} open var closeButtonText: String = "Close" { didSet { updateView() }} open var presenter: UIView? { didSet { updateView() }} + //-------------------------------------------------- // MARK: - Configuration //-------------------------------------------------- @@ -62,6 +64,9 @@ open class TooltipAlertViewController: UIViewController, Surfaceable { } } + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- open func setup() { view.accessibilityElements = [tooltipDialog] @@ -110,6 +115,9 @@ open class TooltipAlertViewController: UIViewController, Surfaceable { } open class TooltipDialog: View, UIScrollViewDelegate { + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- private var scrollView = UIScrollView().with { $0.translatesAutoresizingMaskIntoConstraints = false diff --git a/VDS/Components/Tooltip/TrailingTooltipLabel.swift b/VDS/Components/Tooltip/TrailingTooltipLabel.swift index 6986dd3a..e3f53436 100644 --- a/VDS/Components/Tooltip/TrailingTooltipLabel.swift +++ b/VDS/Components/Tooltip/TrailingTooltipLabel.swift @@ -78,7 +78,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { } } - /// Resets back to this objects default settings. + /// Resets to default settings. open override func reset() { super.reset() shouldUpdateView = false @@ -97,6 +97,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { extension Label { public struct TooltipModel { + /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface public var closeButtonText: String public var title: String? diff --git a/VDS/Extensions/UIView+Accessibility.swift b/VDS/Extensions/UIView+Accessibility.swift new file mode 100644 index 00000000..6c785c5e --- /dev/null +++ b/VDS/Extensions/UIView+Accessibility.swift @@ -0,0 +1,27 @@ +// +// UIView+Accessibility.swift +// VDS +// +// Created by Matt Bruce on 8/4/23. +// + +import Foundation +import UIKit + +extension UIView { + /// AccessibilityLabel helper for joining the accessibilityLabel property of all views passed in. + /// - Parameters: + /// - views: Array of Views that you want to join the accessibilityLabel. + /// - separator: Separator used between the accessibilityLabel for each UIView. + /// - Returns: Joined String. + public func combineAccessibilityLabel(for views: [UIView], separator: String = ", ") -> String? { + let labels = views.map({($0.accessibilityLabel?.isEmpty ?? true) ? nil : $0.accessibilityLabel}).compactMap({$0}) + return labels.joined(separator: separator) + } + + /// AccessibilityLabel helper for joining the accessibilityLabel property of all views passed in. + /// - Parameter views: Array of Views that you want to join the accessibilityLabel. + public func setAccessibilityLabel(for views: [UIView]) { + accessibilityLabel = combineAccessibilityLabel(for: views) + } +} diff --git a/VDS/Extensions/UIView.swift b/VDS/Extensions/UIView+NSLayoutConstraint.swift similarity index 100% rename from VDS/Extensions/UIView.swift rename to VDS/Extensions/UIView+NSLayoutConstraint.swift diff --git a/VDS/Protocols/Changeable.swift b/VDS/Protocols/Changeable.swift index d51c734b..308c6a00 100644 --- a/VDS/Protocols/Changeable.swift +++ b/VDS/Protocols/Changeable.swift @@ -10,6 +10,7 @@ import UIKit import Combine public protocol Changeable: Handlerable where Self: UIControl { + /// Sets the primary Subscriber used for the UIControl event .valueChanged. var onChangeSubscriber: AnyCancellable? { get set } } diff --git a/VDS/Protocols/Clickable.swift b/VDS/Protocols/Clickable.swift index f98dd1c7..e54e7db4 100644 --- a/VDS/Protocols/Clickable.swift +++ b/VDS/Protocols/Clickable.swift @@ -10,7 +10,9 @@ import UIKit import Combine public protocol Clickable: Handlerable where Self: UIControl { + /// Reference count used when a subscriber is listening for the UIControl event .touchUpInside. var touchUpInsideCount: Int { get set } + /// Sets the primary Subscriber used for the UIControl event .touchUpInside. var onClickSubscriber: AnyCancellable? { get set } } diff --git a/VDS/Protocols/FormFieldable.swift b/VDS/Protocols/FormFieldable.swift index 935b3d53..fe015120 100644 --- a/VDS/Protocols/FormFieldable.swift +++ b/VDS/Protocols/FormFieldable.swift @@ -7,12 +7,12 @@ import Foundation -/// Protocol used for a FormField object +/// Protocol used for a FormField object. public protocol FormFieldable { - /// Unique Id for the Form Field object within a Form + /// Unique Id for the Form Field object within a Form. var inputId: String? { get set } - /// Value for the Form Field + /// Value for the Form Field. var value: AnyHashable? { get set } } diff --git a/VDS/Protocols/Handlerable.swift b/VDS/Protocols/Handlerable.swift index 14246735..727f076e 100644 --- a/VDS/Protocols/Handlerable.swift +++ b/VDS/Protocols/Handlerable.swift @@ -10,12 +10,16 @@ import Combine import UIKit public protocol Handlerable: AnyObject, Initable, Disabling, Surfaceable { + /// Set of Subscribers for any Publishers for this Control. var subscribers: Set { get set } + /// Key of whether or not updateView() is called in setNeedsUpdate() var shouldUpdateView: Bool { get set } + /// Function used to make changes to the View based off a change events or from local properties. func updateView() } extension Handlerable { + /// Function called when there are changes in a View based off a change events or from local properties. public func setNeedsUpdate() { if shouldUpdateView { shouldUpdateView = false @@ -26,6 +30,7 @@ extension Handlerable { } extension Handlerable where Self: UIControl { + /// Helper function to assign a completion block to a specific UIControl Event using Combine and stored in the subscribers. public func addEvent(event: UIControl.Event, block: @escaping (Self)->()) { publisher(for: event) .sink(receiveValue: { c in diff --git a/VDS/Protocols/Primitive.swift b/VDS/Protocols/Primitive.swift index 30982c67..2e5a72e8 100644 --- a/VDS/Protocols/Primitive.swift +++ b/VDS/Protocols/Primitive.swift @@ -9,5 +9,6 @@ extension Array: Primitive where Element: Primitive {} extension Dictionary: Primitive where Key == String, Value: Primitive {} public protocol UserInfoable { + /// Dictionary for keeping information for the implementing object using only Primitives. var userInfo: [String: Primitive] { get set } } diff --git a/VDS/Protocols/Resetable.swift b/VDS/Protocols/Resetable.swift index 528cba1d..ff180c45 100644 --- a/VDS/Protocols/Resetable.swift +++ b/VDS/Protocols/Resetable.swift @@ -8,6 +8,6 @@ import Foundation public protocol Resettable { - /// Called to reset back an objects default settings. + /// Resets to default settings. func reset() } diff --git a/VDS/Protocols/ViewProtocol.swift b/VDS/Protocols/ViewProtocol.swift index 63517b35..69c13286 100644 --- a/VDS/Protocols/ViewProtocol.swift +++ b/VDS/Protocols/ViewProtocol.swift @@ -10,25 +10,19 @@ import UIKit public protocol ViewProtocol { - // Can setup ui here. Should be called in the initialization functions. + /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. func setup() + + /// Used to update any Accessibility properties. func updateAccessibility() } extension ViewProtocol where Self: UIView { + /// Helper method for removing a superview and updating Self. public func removeFromSuperview(_ view: UIView){ if view.superview != nil { view.removeFromSuperview() setNeedsDisplay() } } - - public func combineAccessibilityLabel(for views: [UIView]) -> String? { - let labels = views.map({($0.accessibilityLabel?.isEmpty ?? true) ? nil : $0.accessibilityLabel}).compactMap({$0}) - return labels.joined(separator: ", ") - } - - public func setAccessibilityLabel(for views: [UIView]) { - accessibilityLabel = combineAccessibilityLabel(for: views) - } } From 3f2fb8897f39f47eb0375a29da664c63a867c403 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 4 Aug 2023 15:03:36 -0500 Subject: [PATCH 04/19] refactored Font and fixed Styles to match Figma Signed-off-by: Matt Bruce --- VDS/Fonts/Font.swift | 16 +-- VDS/Typography/Typogprahy+Styles.swift | 188 +++++++++++-------------- 2 files changed, 94 insertions(+), 110 deletions(-) diff --git a/VDS/Fonts/Font.swift b/VDS/Fonts/Font.swift index ecd692de..c5caaa32 100644 --- a/VDS/Fonts/Font.swift +++ b/VDS/Fonts/Font.swift @@ -9,23 +9,23 @@ import Foundation /// Enum that is matched up for the Verizon fonts. public enum Font: String, FontProtocol { - case dsBold - case dsRegular + case edsBold + case edsRegular case dsLight - case txBold - case txRegular + case etxBold + case etxRegular public var fontName: String { switch self { - case .dsBold: + case .edsBold: return "VerizonNHGeDS-Bold" - case .dsRegular: + case .edsRegular: return "VerizonNHGeDS-Regular" case .dsLight: return "VerizonNHGDS-Light" - case .txBold: + case .etxBold: return "VerizonNHGeTX-Bold" - case .txRegular: + case .etxRegular: return "VerizonNHGeTX-Regular" } } diff --git a/VDS/Typography/Typogprahy+Styles.swift b/VDS/Typography/Typogprahy+Styles.swift index b593f33b..c3874bb2 100644 --- a/VDS/Typography/Typogprahy+Styles.swift +++ b/VDS/Typography/Typogprahy+Styles.swift @@ -12,34 +12,38 @@ import VDSTypographyTokens extension TextStyle { // Static properties for different text styles + + public static let boldFeatureXLarge = TextStyle(rawValue: "boldFeatureXLarge", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, + edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -4)) + public static let featureXLarge = TextStyle(rawValue: "featureXLarge", fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, letterSpacing: VDSTypography.letterSpacingSemiWide, edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -4)) - - public static let boldFeatureXLarge = TextStyle(rawValue: "boldFeatureXLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88, - letterSpacing: 0, - edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -4)) + public static let boldFeatureLarge = TextStyle(rawValue: "boldFeatureLarge", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, + edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -2)) + public static let featureLarge = TextStyle(rawValue: "featureLarge", fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, letterSpacing: VDSTypography.letterSpacingSemiWide, edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -2)) - - public static let boldFeatureLarge = TextStyle(rawValue: "boldFeatureLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76, - letterSpacing: 0, - edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -2)) + public static let boldFeatureMedium = TextStyle(rawValue: "boldFeatureMedium", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, + edgeInsets: .init(bottom: UIDevice.isIPad ? -4: -2)) public static let featureMedium = TextStyle(rawValue: "featureMedium", fontFace: .dsLight, @@ -47,13 +51,12 @@ extension TextStyle { lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, letterSpacing: VDSTypography.letterSpacingSemiWide, edgeInsets: .init(bottom: UIDevice.isIPad ? -4: -2)) - - public static let boldFeatureMedium = TextStyle(rawValue: "boldFeatureMedium", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64, - letterSpacing: 0, - edgeInsets: .init(bottom: UIDevice.isIPad ? -4: -2)) + + public static let boldFeatureSmall = TextStyle(rawValue: "boldFeatureSmall", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, + edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) public static let featureSmall = TextStyle(rawValue: "featureSmall", fontFace: .dsLight, @@ -61,27 +64,25 @@ extension TextStyle { lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, letterSpacing: VDSTypography.letterSpacingSemiWide, edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) - - public static let boldFeatureSmall = TextStyle(rawValue: "boldFeatureSmall", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48, - letterSpacing: 0, - edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) - + + public static let boldFeatureXSmall = TextStyle(rawValue: "boldFeatureXSmall", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, + edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) + public static let featureXSmall = TextStyle(rawValue: "featureXSmall", fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, letterSpacing: VDSTypography.letterSpacingSemiWide, edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) - - public static let boldFeatureXSmall = TextStyle(rawValue: "boldFeatureXSmall", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40, - letterSpacing: 0, - edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) + + public static let boldTitle2XLarge = TextStyle(rawValue: "boldTitle2XLarge", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40, + edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) public static let title2XLarge = TextStyle(rawValue: "title2XLarge", fontFace: .dsLight, @@ -90,24 +91,21 @@ extension TextStyle { letterSpacing: VDSTypography.letterSpacingSemiWide, edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) - public static let boldTitle2XLarge = TextStyle(rawValue: "boldTitle2XLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40, - letterSpacing: 0, - edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0)) + public static let boldTitleXLarge = TextStyle(rawValue: "boldTitleXLarge", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36) public static let titleXLarge = TextStyle(rawValue: "titleXLarge", fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36, letterSpacing: VDSTypography.letterSpacingSemiWide) - - public static let boldTitleXLarge = TextStyle(rawValue: "boldTitleXLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36, - letterSpacing: 0) + + public static let boldTitleLarge = TextStyle(rawValue: "boldTitleLarge", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28) public static let titleLarge = TextStyle(rawValue: "titleLarge", fontFace: .dsLight, @@ -115,84 +113,70 @@ extension TextStyle { lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28, letterSpacing: VDSTypography.letterSpacingSemiWide) - public static let boldTitleLarge = TextStyle(rawValue: "boldTitleLarge", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28, - letterSpacing: 0) + public static let boldTitleMedium = TextStyle(rawValue: "boldTitleMedium", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24) public static let titleMedium = TextStyle(rawValue: "titleMedium", - fontFace: .dsLight, + fontFace: .edsRegular, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24, - letterSpacing: 0) - - public static let boldTitleMedium = TextStyle(rawValue: "boldTitleMedium", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24, - letterSpacing: 0) + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24) + + public static let boldTitleSmall = TextStyle(rawValue: "boldTitleSmall", + fontFace: .edsBold, + pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16, + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20) public static let titleSmall = TextStyle(rawValue: "titleSmall", - fontFace: .dsLight, + fontFace: .edsRegular, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20, - letterSpacing: 0) - - public static let boldTitleSmall = TextStyle(rawValue: "boldTitleSmall", - fontFace: .dsBold, - pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16, - lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20, - letterSpacing: 0) + lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20) + public static let boldBodyLarge = TextStyle(rawValue: "boldBodyLarge", + fontFace: .edsBold, + pointSize: VDSTypography.fontSizeBody16, + lineHeight: VDSTypography.lineHeightBody20, + letterSpacing: VDSTypography.letterSpacingWide) + public static let bodyLarge = TextStyle(rawValue: "bodyLarge", - fontFace: .dsRegular, + fontFace: .edsRegular, pointSize: VDSTypography.fontSizeBody16, lineHeight: VDSTypography.lineHeightBody20, letterSpacing:VDSTypography.letterSpacingWide) - public static let boldBodyLarge = TextStyle(rawValue: "boldBodyLarge", - fontFace: .dsBold, - pointSize: VDSTypography.fontSizeBody16, - lineHeight: VDSTypography.lineHeightBody20, - letterSpacing: VDSTypography.letterSpacingWide) - - public static let bodyMedium = TextStyle(rawValue: "bodyMedium", - fontFace: .dsRegular, - pointSize: VDSTypography.fontSizeBody14, - lineHeight: VDSTypography.lineHeightBody18, - letterSpacing: VDSTypography.letterSpacingWide) - public static let boldBodyMedium = TextStyle(rawValue: "boldBodyMedium", - fontFace: .dsBold, + fontFace: .edsBold, pointSize: VDSTypography.fontSizeBody14, lineHeight: VDSTypography.lineHeightBody18, letterSpacing: VDSTypography.letterSpacingWide) - public static let bodySmall = TextStyle(rawValue: "bodySmall", - fontFace: .dsRegular, - pointSize: VDSTypography.fontSizeBody12, - lineHeight: VDSTypography.lineHeightBody16, - letterSpacing: 0) - + public static let bodyMedium = TextStyle(rawValue: "bodyMedium", + fontFace: .edsRegular, + pointSize: VDSTypography.fontSizeBody14, + lineHeight: VDSTypography.lineHeightBody18, + letterSpacing: VDSTypography.letterSpacingWide) + public static let boldBodySmall = TextStyle(rawValue: "boldBodySmall", - fontFace: .dsBold, + fontFace: .etxBold, pointSize: VDSTypography.fontSizeBody12, - lineHeight: VDSTypography.lineHeightBody16, - letterSpacing: 0) + lineHeight: VDSTypography.lineHeightBody16) - public static let micro = TextStyle(rawValue: "micro", - fontFace: .dsRegular, - pointSize: VDSTypography.fontSizeMicro11, - lineHeight: VDSTypography.lineHeightMicro16, - letterSpacing: 0) + public static let bodySmall = TextStyle(rawValue: "bodySmall", + fontFace: .etxRegular, + pointSize: VDSTypography.fontSizeBody12, + lineHeight: VDSTypography.lineHeightBody16) public static let boldMicro = TextStyle(rawValue: "boldMicro", - fontFace: .dsBold, + fontFace: .etxBold, pointSize: VDSTypography.fontSizeMicro11, - lineHeight: VDSTypography.lineHeightMicro16, - letterSpacing: 0) + lineHeight: VDSTypography.lineHeightMicro16) + public static let micro = TextStyle(rawValue: "micro", + fontFace: .etxRegular, + pointSize: VDSTypography.fontSizeMicro11, + lineHeight: VDSTypography.lineHeightMicro16) + public static var allCases: [TextStyle] { return [ featureXLarge, From 4aa2e0d929bcae3ee3c9e9288ddbc3067f3e5c78 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 4 Aug 2023 15:07:12 -0500 Subject: [PATCH 05/19] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- VDS/SupportingFiles/ReleaseNotes.txt | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 997fbe70..aa2ade8b 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1167,7 +1167,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 36; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1204,7 +1204,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 36; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index c6b192b5..c46e1b09 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,7 @@ +1.0.36 +======= +- Fixed bugs in Typography Definitions + 1.0.35 ======= - ONEAPP-4684 - (Accessibility) Tooltip From 56c2217b0cd9b7297b91a5b888b1a85cbe8b89a8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 4 Aug 2023 16:01:38 -0500 Subject: [PATCH 06/19] public to open Signed-off-by: Matt Bruce --- VDS/Classes/ColorConfiguration.swift | 4 ++-- VDS/Classes/Control.swift | 7 +++--- VDS/Classes/SelectorBase.swift | 2 +- VDS/Classes/SelectorGroupHandlerBase.swift | 12 +++++----- VDS/Classes/View.swift | 2 +- VDS/Components/Buttons/Button/Button.swift | 1 + .../Buttons/Button/ButtonBase.swift | 7 +++--- .../Buttons/ButtonGroup/ButtonGroup.swift | 8 ++++--- .../Buttons/TextLink/TextLink.swift | 1 + .../Buttons/TextLinkCaret/TextLinkCaret.swift | 1 + VDS/Components/Checkbox/CheckboxGroup.swift | 9 ++++---- VDS/Components/Checkbox/CheckboxItem.swift | 1 + .../Icon/ButtonIcon/ButtonIcon.swift | 1 + VDS/Components/Icon/Icon.swift | 1 + VDS/Components/Label/Label.swift | 7 +++--- VDS/Components/Line/Line.swift | 3 ++- VDS/Components/Loader/Loader.swift | 5 ++-- .../Loader/LoaderViewController.swift | 2 +- .../Notification/Notification.swift | 1 + VDS/Components/RadioBox/RadioBoxGroup.swift | 3 ++- VDS/Components/RadioBox/RadioBoxItem.swift | 5 ++-- .../RadioButton/RadioButtonGroup.swift | 5 ++-- VDS/Components/RadioSwatch/RadioSwatch.swift | 5 ++-- .../RadioSwatch/RadioSwatchGroup.swift | 8 +++++-- VDS/Components/Tabs/Tab.swift | 1 + VDS/Components/Tabs/Tabs.swift | 1 + VDS/Components/Tabs/TabsContainer.swift | 1 + .../TextFields/EntryField/EntryField.swift | 6 ++--- .../TextFields/InputField/InputField.swift | 3 ++- .../TextFields/TextArea/TextArea.swift | 5 ++-- .../TileContainer/TileContainer.swift | 23 ++++++++++--------- VDS/Components/Tilelet/Tilelet.swift | 11 +++++---- VDS/Components/TitleLockup/TitleLockup.swift | 1 + VDS/Components/Toggle/Toggle.swift | 1 + VDS/Components/Toggle/ToggleView.swift | 3 ++- VDS/Components/Tooltip/Tooltip.swift | 1 + .../Tooltip/TooltipAlertViewController.swift | 4 +++- .../Tooltip/TrailingTooltipLabel.swift | 1 + 38 files changed, 99 insertions(+), 64 deletions(-) diff --git a/VDS/Classes/ColorConfiguration.swift b/VDS/Classes/ColorConfiguration.swift index a1474610..a7cf2673 100644 --- a/VDS/Classes/ColorConfiguration.swift +++ b/VDS/Classes/ColorConfiguration.swift @@ -26,8 +26,8 @@ public typealias ObjectColorable = Colorable & Initable & ObjectWithable /// You can pass in a Surfaceable object and this will return the corresponding Color based on the object's surface property. open class SurfaceColorConfiguration: ObjectColorable { public typealias ObjectType = Surfaceable - public var lightColor: UIColor = .clear - public var darkColor: UIColor = .clear + open var lightColor: UIColor = .clear + open var darkColor: UIColor = .clear required public init(){} diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 4f0f39bc..00f13c57 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -17,9 +17,9 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab // MARK: - Combine Properties //-------------------------------------------------- /// Set of Subscribers for any Publishers for this Control. - public var subscribers = Set() + open var subscribers = Set() - public var onClickSubscriber: AnyCancellable? { + open var onClickSubscriber: AnyCancellable? { willSet { if let onClickSubscriber { onClickSubscriber.cancel() @@ -40,6 +40,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab /// Current Surface and this is used to pass down to child objects that implement Surfacable open var surface: Surface = .light { didSet { setNeedsUpdate() } } + /// Whether this object is disabled or not open var disabled: Bool { get { !isEnabled } set { @@ -52,7 +53,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab /// Override for isSelected to handle setNeedsUpdate() on changes. open override var isSelected: Bool { didSet { setNeedsUpdate() } } - public var touchUpInsideCount: Int = 0 + open var touchUpInsideCount: Int = 0 var isHighlightAnimating = false diff --git a/VDS/Classes/SelectorBase.swift b/VDS/Classes/SelectorBase.swift index 326c76bc..cb520876 100644 --- a/VDS/Classes/SelectorBase.swift +++ b/VDS/Classes/SelectorBase.swift @@ -20,7 +20,7 @@ public protocol SelectorControlable: Control, Changeable { open class SelectorBase: Control, SelectorControlable { - public var onChangeSubscriber: AnyCancellable? { + open var onChangeSubscriber: AnyCancellable? { willSet { if let onChangeSubscriber { onChangeSubscriber.cancel() diff --git a/VDS/Classes/SelectorGroupHandlerBase.swift b/VDS/Classes/SelectorGroupHandlerBase.swift index 1418db50..868276ba 100644 --- a/VDS/Classes/SelectorGroupHandlerBase.swift +++ b/VDS/Classes/SelectorGroupHandlerBase.swift @@ -17,10 +17,10 @@ open class SelectorGroupHandlerBase: Control, Changeable { //-------------------------------------------------- /// Array of the HandlerType registered. - public var selectorViews: [HandlerType] = [] + open var selectorViews: [HandlerType] = [] /// The primary subscriber for onChange or the UIControl valueChanged event. - public var onChangeSubscriber: AnyCancellable? { + open var onChangeSubscriber: AnyCancellable? { willSet { if let onChangeSubscriber { onChangeSubscriber.cancel() @@ -28,8 +28,8 @@ open class SelectorGroupHandlerBase: Control, Changeable { } } - /// Override to update the child SelectorViews disabled property for this group. - override public var disabled: Bool { + /// Whether this object is disabled or not + override open var disabled: Bool { didSet { selectorViews.forEach { handler in handler.disabled = disabled @@ -38,7 +38,7 @@ open class SelectorGroupHandlerBase: Control, Changeable { } /// Current Surface and this is used to pass down to child objects that implement Surfacable. - override public var surface: Surface { + override open var surface: Surface { didSet { selectorViews.forEach { handler in handler.surface = surface @@ -57,7 +57,7 @@ open class SelectorGroupHandlerBase: Control, Changeable { } /// Helper method to execute the valueChanged event. - public func valueChanged() { + open func valueChanged() { DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { [weak self] in self?.sendActions(for: .valueChanged) } diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index ea470798..9566b79a 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -18,7 +18,7 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { // MARK: - Combine Properties //-------------------------------------------------- /// Set of Subscribers for any Publishers for this Control. - public var subscribers = Set() + open var subscribers = Set() //-------------------------------------------------- // MARK: - Properties diff --git a/VDS/Components/Buttons/Button/Button.swift b/VDS/Components/Buttons/Button/Button.swift index 15c4a0ba..42b3150d 100644 --- a/VDS/Components/Buttons/Button/Button.swift +++ b/VDS/Components/Buttons/Button/Button.swift @@ -149,6 +149,7 @@ open class Button: ButtonBase, Useable { return CGSize(width: width > size.minimumWidth ? width : size.minimumWidth, height: size.height) } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() let bgColor = backgroundColorConfiguration.getColor(self) diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index d3b7c0d7..6672a320 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -29,9 +29,9 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab // MARK: - Combine Properties //-------------------------------------------------- /// Set of Subscribers for any Publishers for this Control. - public var subscribers = Set() + open var subscribers = Set() - public var onClickSubscriber: AnyCancellable? { + open var onClickSubscriber: AnyCancellable? { willSet { if let onClickSubscriber { onClickSubscriber.cancel() @@ -63,7 +63,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab open var userInfo = [String: Primitive]() - public var touchUpInsideCount: Int = 0 + open var touchUpInsideCount: Int = 0 internal var isHighlightAnimating = false @@ -160,6 +160,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab return CGSize(width: adjustedWidth, height: adjustedHeight) } + /// Function used to make changes to the View based off a change events or from local properties. open func updateView() { updateLabel() updateAccessibility() diff --git a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift index 790f272f..99aef7f5 100644 --- a/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift +++ b/VDS/Components/Buttons/ButtonGroup/ButtonGroup.swift @@ -29,7 +29,7 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega open var rowQuantityTablet: Int = 0 { didSet { setNeedsUpdate() } } - public var rowQuantity: Int { UIDevice.isIPad ? rowQuantityTablet : rowQuantityPhone } + open var rowQuantity: Int { UIDevice.isIPad ? rowQuantityTablet : rowQuantityPhone } //If provided, aligns TextLink/TextLinkCaret alignment when rowQuantity is set one. open var buttonPosition: ButtonPosition = .center { didSet { setNeedsUpdate() }} @@ -93,7 +93,8 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - override public var disabled: Bool { + /// Whether this object is disabled or not + override open var disabled: Bool { didSet { buttons.forEach { button in var b = button @@ -103,7 +104,7 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega } /// Current Surface and this is used to pass down to child objects that implement Surfacable - override public var surface: Surface { + override open var surface: Surface { didSet { buttons.forEach { button in var b = button @@ -138,6 +139,7 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() positionLayout.position = buttonPosition diff --git a/VDS/Components/Buttons/TextLink/TextLink.swift b/VDS/Components/Buttons/TextLink/TextLink.swift index af844530..ca7aac1d 100644 --- a/VDS/Components/Buttons/TextLink/TextLink.swift +++ b/VDS/Components/Buttons/TextLink/TextLink.swift @@ -107,6 +107,7 @@ open class TextLink: ButtonBase { return titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { //need to set the properties so the super class //can render out the label correctly diff --git a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift index 22cffb36..a41ebfb0 100644 --- a/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift +++ b/VDS/Components/Buttons/TextLinkCaret/TextLinkCaret.swift @@ -94,6 +94,7 @@ open class TextLinkCaret: ButtonBase { return titleLabel?.intrinsicContentSize ?? super.intrinsicContentSize } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { imageAttribute = CaretLabelAttribute(tintColor: textColor, position: iconPosition) super.updateView() diff --git a/VDS/Components/Checkbox/CheckboxGroup.swift b/VDS/Components/Checkbox/CheckboxGroup.swift index 8eb7f5fc..763a18ab 100644 --- a/VDS/Components/Checkbox/CheckboxGroup.swift +++ b/VDS/Components/Checkbox/CheckboxGroup.swift @@ -14,13 +14,13 @@ open class CheckboxGroup: SelectorGroupHandlerBase { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public var selectedHandlers: [CheckboxItem]? { + open var selectedHandlers: [CheckboxItem]? { let selected = selectorViews.filter{ $0.isSelected == true } guard selected.count > 0 else { return nil } return selected } - public override var selectorViews: [CheckboxItem] { + open override var selectorViews: [CheckboxItem] { willSet { mainStackView.arrangedSubviews.forEach { $0.removeFromSuperview() } } @@ -35,7 +35,7 @@ open class CheckboxGroup: SelectorGroupHandlerBase { } } - public var selectorModels: [CheckboxModel]? { + open var selectorModels: [CheckboxModel]? { didSet { if let selectorModels { selectorViews = selectorModels.enumerated().map { index, model in @@ -61,7 +61,7 @@ open class CheckboxGroup: SelectorGroupHandlerBase { } private var _showError: Bool = false - public var showError: Bool { + open var showError: Bool { get { _showError } set { var newShowError = newValue @@ -112,6 +112,7 @@ open class CheckboxGroup: SelectorGroupHandlerBase { extension CheckboxGroup { public struct CheckboxModel : Surfaceable, Disabling, Initable, FormFieldable, Errorable { + /// Whether this object is disabled or not public var disabled: Bool /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface diff --git a/VDS/Components/Checkbox/CheckboxItem.swift b/VDS/Components/Checkbox/CheckboxItem.swift index 675aa7cc..994eca5e 100644 --- a/VDS/Components/Checkbox/CheckboxItem.swift +++ b/VDS/Components/Checkbox/CheckboxItem.swift @@ -44,6 +44,7 @@ open class CheckboxItem: SelectorItemBase { sendActions(for: .valueChanged) } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { selectorView.isAnimated = isAnimated super.updateView() diff --git a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift index baee9258..00efaca1 100644 --- a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift +++ b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift @@ -268,6 +268,7 @@ open class ButtonIcon: Control { setNeedsUpdate() } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/Icon/Icon.swift b/VDS/Components/Icon/Icon.swift index 9e884875..0c496793 100644 --- a/VDS/Components/Icon/Icon.swift +++ b/VDS/Components/Icon/Icon.swift @@ -69,6 +69,7 @@ open class Icon: View { imageView.image = nil } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() //get the color for the image diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 13d25d42..1701311f 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -17,7 +17,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { // MARK: - Combine Properties //-------------------------------------------------- /// Set of Subscribers for any Publishers for this Control. - public var subscribers = Set() + open var subscribers = Set() //-------------------------------------------------- // MARK: - Properties @@ -66,7 +66,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Configuration Properties //-------------------------------------------------- - public var textColorConfiguration: AnyColorable = ViewColorConfiguration().with { + open var textColorConfiguration: AnyColorable = ViewColorConfiguration().with { $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true) $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false) }.eraseToAnyColorable(){ didSet { setNeedsUpdate() }} @@ -139,7 +139,8 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Overrides - //-------------------------------------------------- + //-------------------------------------------------- + /// Function used to make changes to the View based off a change events or from local properties. open func updateView() { if !useAttributedText { if let text = text { diff --git a/VDS/Components/Line/Line.swift b/VDS/Components/Line/Line.swift index 14ceacc8..070b3768 100644 --- a/VDS/Components/Line/Line.swift +++ b/VDS/Components/Line/Line.swift @@ -31,7 +31,7 @@ open class Line: View { //-------------------------------------------------- // MARK: - Configuration //-------------------------------------------------- - public var lineViewColorConfiguration: AnyColorable = { + open var lineViewColorConfiguration: AnyColorable = { let config = KeyedColorConfiguration(keyPath: \.style) config.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forKey: .primary) config.setSurfaceColors(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark, forKey: .secondary) @@ -56,6 +56,7 @@ open class Line: View { style = .primary } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { lineView.backgroundColor = lineViewColorConfiguration.getColor(self) } diff --git a/VDS/Components/Loader/Loader.swift b/VDS/Components/Loader/Loader.swift index 582eaf2b..9c67b6e2 100644 --- a/VDS/Components/Loader/Loader.swift +++ b/VDS/Components/Loader/Loader.swift @@ -24,10 +24,10 @@ open class Loader: View { // MARK: - Public Properties //-------------------------------------------------- /// Loader will be active if 'active' prop is passed. - public var isActive: Bool = true { didSet { setNeedsUpdate() } } + open var isActive: Bool = true { didSet { setNeedsUpdate() } } /// The Int used to determine the height and width of the Loader - public var size: Int = 40 { didSet { setNeedsUpdate() } } + open var size: Int = 40 { didSet { setNeedsUpdate() } } //-------------------------------------------------- // MARK: - Lifecycle @@ -46,6 +46,7 @@ open class Loader: View { ]) } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() icon.color = iconColorConfiguration.getColor(self) diff --git a/VDS/Components/Loader/LoaderViewController.swift b/VDS/Components/Loader/LoaderViewController.swift index 2b0fb944..d64e7a74 100644 --- a/VDS/Components/Loader/LoaderViewController.swift +++ b/VDS/Components/Loader/LoaderViewController.swift @@ -43,7 +43,7 @@ open class LoaderViewController: UIViewController, Surfaceable { updateView() } - /// Update this view based off of property chang + /// Function used to make changes to the View based off a change events or from local properties. open func updateView() { view.backgroundColor = backgroundColorConfiguration.getColor(self).withAlphaComponent(0.8) if let size { diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 25308654..9d6e0e34 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -264,6 +264,7 @@ open class Notification: View { setNeedsUpdate() } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { backgroundColor = backgroundColorConfiguration.getColor(self) updateIcons() diff --git a/VDS/Components/RadioBox/RadioBoxGroup.swift b/VDS/Components/RadioBox/RadioBoxGroup.swift index 84065697..209a5769 100644 --- a/VDS/Components/RadioBox/RadioBoxGroup.swift +++ b/VDS/Components/RadioBox/RadioBoxGroup.swift @@ -30,7 +30,7 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase { } } - public var selectorModels: [RadioBoxModel]? { + open var selectorModels: [RadioBoxModel]? { didSet { if let selectorModels { selectorViews = selectorModels.enumerated().map { index, model in @@ -107,6 +107,7 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase { extension RadioBoxGroup { public struct RadioBoxModel: Surfaceable, Initable, Disabling, FormFieldable { + /// Whether this object is disabled or not public var disabled: Bool /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index 6c0d8720..d7c9d1bd 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -56,7 +56,7 @@ open class RadioBoxItem: Control, Changeable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public var onChangeSubscriber: AnyCancellable? { + open var onChangeSubscriber: AnyCancellable? { willSet { if let onChangeSubscriber { onChangeSubscriber.cancel() @@ -82,7 +82,7 @@ open class RadioBoxItem: Control, Changeable { $0.textStyle = .bodyLarge } - public var selectorView = UIView().with { + open var selectorView = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false } @@ -259,6 +259,7 @@ open class RadioBoxItem: Control, Changeable { sendActions(for: .valueChanged) } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { updateLabels() updateAccessibility() diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index 5766d811..4298f827 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -30,7 +30,7 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase { } } - public var selectorModels: [RadioButtonModel]? { + open var selectorModels: [RadioButtonModel]? { didSet { if let selectorModels { selectorViews = selectorModels.enumerated().map { index, model in @@ -56,7 +56,7 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase { } private var _showError: Bool = false - public var showError: Bool { + open var showError: Bool { get { _showError } set { var newShowError = newValue @@ -116,6 +116,7 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase { extension RadioButtonGroup { public struct RadioButtonModel: Surfaceable, Disabling, Initable, FormFieldable, Errorable { + /// Whether this object is disabled or not public var disabled: Bool /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index b9ec00c7..f2898f13 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -32,11 +32,11 @@ open class RadioSwatch: Control { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public var selectorView = UIView().with { + open var selectorView = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false } - public var fillView = UIImageView().with { + open var fillView = UIImageView().with { $0.translatesAutoresizingMaskIntoConstraints = false $0.contentMode = .scaleAspectFit } @@ -125,6 +125,7 @@ open class RadioSwatch: Control { sendActions(for: .valueChanged) } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { layer.setNeedsDisplay() } diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index fc3fb801..e7b29b65 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -21,7 +21,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo } } - public var selectorModels: [RadioSwatchModel]? { + open var selectorModels: [RadioSwatchModel]? { didSet { if let selectorModels { selectorViews = selectorModels.map { model in @@ -46,7 +46,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- - public var label = Label() + open var label = Label() private let cellSize: CGFloat = 48.0 private let labelSpacing: CGFloat = 24.0 private let labelHeight: CGFloat = 16.0 @@ -71,6 +71,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- + /// Whether this object is disabled or not override public var disabled: Bool { didSet { for selector in selectorViews { @@ -123,6 +124,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo collectionView.dataSource = self } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { label.textPosition = .left label.textStyle = .bodySmall @@ -190,7 +192,9 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo extension RadioSwatchGroup { public struct RadioSwatchModel: Surfaceable, Disabling, Initable { + /// Whether this object is disabled or not public var disabled: Bool = false + /// Current Surface and this is used to pass down to child objects that implement Surfacable public var surface: Surface public var inputId: String? public var value: AnyHashable? diff --git a/VDS/Components/Tabs/Tab.swift b/VDS/Components/Tabs/Tab.swift index 4720fabe..ded6aa62 100644 --- a/VDS/Components/Tabs/Tab.swift +++ b/VDS/Components/Tabs/Tab.swift @@ -146,6 +146,7 @@ extension Tabs { layoutGuide.trailingAnchor.constraint(equalTo: trailingAnchor)]) } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/Tabs/Tabs.swift b/VDS/Components/Tabs/Tabs.swift index 59cfda95..fd7327fe 100644 --- a/VDS/Components/Tabs/Tabs.swift +++ b/VDS/Components/Tabs/Tabs.swift @@ -232,6 +232,7 @@ open class Tabs: View { } } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/Tabs/TabsContainer.swift b/VDS/Components/Tabs/TabsContainer.swift index ccb01c1c..50eab591 100644 --- a/VDS/Components/Tabs/TabsContainer.swift +++ b/VDS/Components/Tabs/TabsContainer.swift @@ -140,6 +140,7 @@ open class TabsContainer: View { ]) } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index 8f14962e..794b2fa1 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -98,7 +98,7 @@ open class EntryField: Control, Changeable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public var onChangeSubscriber: AnyCancellable? { + open var onChangeSubscriber: AnyCancellable? { willSet { if let onChangeSubscriber { onChangeSubscriber.cancel() @@ -258,9 +258,7 @@ open class EntryField: Control, Changeable { readOnly = false } - //-------------------------------------------------- - // MARK: - State - //-------------------------------------------------- + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { containerView.backgroundColor = backgroundColorConfiguration.getColor(self) diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index eec960ab..f6df3da8 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -103,7 +103,7 @@ open class InputField: EntryField, UITextFieldDelegate { $0.font = TextStyle.bodyLarge.font } - public var textFieldTextColorConfiguration: AnyColorable = ViewColorConfiguration().with { + open var textFieldTextColorConfiguration: AnyColorable = ViewColorConfiguration().with { $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true) $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false) }.eraseToAnyColorable() @@ -161,6 +161,7 @@ open class InputField: EntryField, UITextFieldDelegate { return inputFieldStackView } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index c4d701d3..eb7e45e0 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -53,10 +53,10 @@ open class TextArea: EntryField { $0.isScrollEnabled = false } - public var textViewTextColorConfiguration: AnyColorable = ViewColorConfiguration().with { + open var textViewTextColorConfiguration: AnyColorable = ViewColorConfiguration().with { $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true) $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false) - }.eraseToAnyColorable() + }.eraseToAnyColorable() { didSet { setNeedsUpdate() }} internal var minWidthConstraint: NSLayoutConstraint? internal var textViewHeightConstraint: NSLayoutConstraint? @@ -91,6 +91,7 @@ open class TextArea: EntryField { return inputFieldStackView } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index 87693dc9..e96f9f04 100644 --- a/VDS/Components/TileContainer/TileContainer.swift +++ b/VDS/Components/TileContainer/TileContainer.swift @@ -77,26 +77,26 @@ open class TileContainer: Control { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public var backgroundImage: UIImage? { didSet{ setNeedsUpdate() } } + open var backgroundImage: UIImage? { didSet{ setNeedsUpdate() } } - public var containerView = View().with { + open var containerView = View().with { $0.isUserInteractionEnabled = false } - public var highlightView = View().with { + open var highlightView = View().with { $0.isUserInteractionEnabled = false } - public var color: BackgroundColor = .white { didSet{ setNeedsUpdate() } } + open var color: BackgroundColor = .white { didSet{ setNeedsUpdate() } } - public var padding: Padding = .padding4X { didSet{ setNeedsUpdate() } } + open var padding: Padding = .padding4X { didSet{ setNeedsUpdate() } } - public var aspectRatio: AspectRatio = .ratio1x1 { didSet{ setNeedsUpdate() } } + open var aspectRatio: AspectRatio = .ratio1x1 { didSet{ setNeedsUpdate() } } - public var imageFallbackColor: Surface = .light { didSet{ setNeedsUpdate() } } + open var imageFallbackColor: Surface = .light { didSet{ setNeedsUpdate() } } private var _width: CGFloat? - public var width: CGFloat? { + open var width: CGFloat? { get { return _width } set { if let newValue, newValue > 100 { @@ -109,7 +109,7 @@ open class TileContainer: Control { } private var _height: CGFloat? - public var height: CGFloat? { + open var height: CGFloat? { get { return _height } set { if let newValue, newValue > 44 { @@ -121,9 +121,9 @@ open class TileContainer: Control { } } - public var showBorder: Bool = false { didSet{ setNeedsUpdate() } } + open var showBorder: Bool = false { didSet{ setNeedsUpdate() } } - public var showDropShadows: Bool = false { didSet{ setNeedsUpdate() } } + open var showDropShadows: Bool = false { didSet{ setNeedsUpdate() } } //-------------------------------------------------- // MARK: - Private Properties @@ -204,6 +204,7 @@ open class TileContainer: Control { setNeedsUpdate() } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 32eb1dde..7c19a3fa 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -162,13 +162,13 @@ open class Tilelet: TileContainer { open var textPostion: TextPosition = .top { didSet { setNeedsUpdate() }} //models - public var badgeModel: BadgeModel? { didSet { setNeedsUpdate() }} - public var titleModel: TitleModel? { didSet { setNeedsUpdate() }} - public var subTitleModel: SubTitleModel? { didSet { setNeedsUpdate() }} + open var badgeModel: BadgeModel? { didSet { setNeedsUpdate() }} + open var titleModel: TitleModel? { didSet { setNeedsUpdate() }} + open var subTitleModel: SubTitleModel? { didSet { setNeedsUpdate() }} //only 1 Icon can be active private var _descriptiveIconModel: DescriptiveIcon? - public var descriptiveIconModel: DescriptiveIcon? { + open var descriptiveIconModel: DescriptiveIcon? { get { _descriptiveIconModel } set { _descriptiveIconModel = newValue; @@ -178,7 +178,7 @@ open class Tilelet: TileContainer { } private var _directionalIconModel: DirectionalIcon? - public var directionalIconModel: DirectionalIcon? { + open var directionalIconModel: DirectionalIcon? { get { _directionalIconModel } set { _directionalIconModel = newValue; @@ -365,6 +365,7 @@ open class Tilelet: TileContainer { } } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index 599b6364..bf3ea8f0 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -285,6 +285,7 @@ open class TitleLockup: View { setNeedsUpdate() } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index e44c1b0f..f96d534a 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -191,6 +191,7 @@ open class Toggle: Control, Changeable { setNeedsUpdate() } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { updateLabel() toggleView.surface = surface diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index 55aaf044..8729fb72 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -53,7 +53,7 @@ open class ToggleView: Control, Changeable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public var onChangeSubscriber: AnyCancellable? + open var onChangeSubscriber: AnyCancellable? open var isOn: Bool { get { isSelected } @@ -152,6 +152,7 @@ open class ToggleView: Control, Changeable { setNeedsUpdate() } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { updateToggle() updateAccessibility() diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index 69b3964d..9fe2501c 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -154,6 +154,7 @@ open class Tooltip: Control, TooltipLaunchable { setNeedsUpdate() } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/Tooltip/TooltipAlertViewController.swift b/VDS/Components/Tooltip/TooltipAlertViewController.swift index 5dc22d54..7da2c581 100644 --- a/VDS/Components/Tooltip/TooltipAlertViewController.swift +++ b/VDS/Components/Tooltip/TooltipAlertViewController.swift @@ -13,7 +13,7 @@ import VDSColorTokens open class TooltipAlertViewController: UIViewController, Surfaceable { /// Set of Subscribers for any Publishers for this Control. - public var subscribers = Set() + open var subscribers = Set() //-------------------------------------------------- // MARK: - Private Properties @@ -105,6 +105,7 @@ open class TooltipAlertViewController: UIViewController, Surfaceable { ]) } + /// Function used to make changes to the View based off a change events or from local properties. open func updateView() { view.backgroundColor = backgroundColorConfiguration.getColor(self).withAlphaComponent(0.3) tooltipDialog.surface = surface @@ -222,6 +223,7 @@ open class TooltipDialog: View, UIScrollViewDelegate { heightConstraint?.activate() } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() diff --git a/VDS/Components/Tooltip/TrailingTooltipLabel.swift b/VDS/Components/Tooltip/TrailingTooltipLabel.swift index e3f53436..4a1be607 100644 --- a/VDS/Components/Tooltip/TrailingTooltipLabel.swift +++ b/VDS/Components/Tooltip/TrailingTooltipLabel.swift @@ -62,6 +62,7 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { }.store(in: &subscribers) } + /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() From 0ad630e4c5e2ee5b65f8acba445191cf50bdf2d0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 4 Aug 2023 16:09:20 -0500 Subject: [PATCH 07/19] bug in titleLarge phone doesn't have letter spacing Signed-off-by: Matt Bruce --- VDS/Typography/Typogprahy+Styles.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Typography/Typogprahy+Styles.swift b/VDS/Typography/Typogprahy+Styles.swift index c3874bb2..e2d906fe 100644 --- a/VDS/Typography/Typogprahy+Styles.swift +++ b/VDS/Typography/Typogprahy+Styles.swift @@ -111,7 +111,7 @@ extension TextStyle { fontFace: .dsLight, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28, - letterSpacing: VDSTypography.letterSpacingSemiWide) + letterSpacing: UIDevice.isIPad ? VDSTypography.letterSpacingSemiWide : 0) public static let boldTitleMedium = TextStyle(rawValue: "boldTitleMedium", fontFace: .edsBold, From d4f5c37629b72a60dc1704dc0ea93cc880061106 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 7 Aug 2023 18:56:49 -0500 Subject: [PATCH 08/19] fixed to be a button instead of link Signed-off-by: Matt Bruce --- VDS/Components/Tooltip/Tooltip.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index 9fe2501c..f983cfb7 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -126,7 +126,7 @@ open class Tooltip: Control, TooltipLaunchable { backgroundColor = .clear isAccessibilityElement = true - accessibilityTraits = .link + accessibilityTraits = .button onClickSubscriber = publisher(for: .touchUpInside) .sink(receiveValue: { [weak self] tooltip in From dec1a00bb5dd8c1c87c7ba2eba44e18a82809b10 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 09:46:52 -0500 Subject: [PATCH 09/19] refactored out Handlerable Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 8 +- VDS/Classes/Control.swift | 14 +- VDS/Classes/View.swift | 5 +- .../Buttons/Button/ButtonBase.swift | 8 +- VDS/Components/Label/Label.swift | 8 +- VDS/Components/Tooltip/TooltipDialog.swift | 231 ++++++++++++++++++ VDS/Protocols/Handlerable.swift | 40 --- VDS/Protocols/ViewProtocol.swift | 36 ++- 8 files changed, 284 insertions(+), 66 deletions(-) create mode 100644 VDS/Components/Tooltip/TooltipDialog.swift delete mode 100644 VDS/Protocols/Handlerable.swift diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index aa2ade8b..8de483a9 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -36,7 +36,6 @@ EA3361B6288B2A410071C351 /* Control.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B5288B2A410071C351 /* Control.swift */; }; EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */; }; EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BC288B2C760071C351 /* TypeAlias.swift */; }; - EA3361BF288B2EA60071C351 /* Handlerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BE288B2EA60071C351 /* Handlerable.swift */; }; EA3361C328902D960071C351 /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C228902D960071C351 /* Toggle.swift */; }; EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C8289054C50071C351 /* Surfaceable.swift */; }; EA3362042891E14D0071C351 /* VerizonNHGeTX-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = EA3362002891E14C0071C351 /* VerizonNHGeTX-Bold.otf */; }; @@ -69,6 +68,7 @@ EA89201328B568D8006B9984 /* RadioBoxItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201228B568D8006B9984 /* RadioBoxItem.swift */; }; EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */; }; EA8E40912A7D3F6300934ED3 /* UIView+Accessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8E40902A7D3F6300934ED3 /* UIView+Accessibility.swift */; }; + EA8E40932A82889500934ED3 /* TooltipDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8E40922A82889500934ED3 /* TooltipDialog.swift */; }; EA978EC5291D6AFE00ACC883 /* AnyLabelAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA978EC4291D6AFE00ACC883 /* AnyLabelAttribute.swift */; }; EA985BE629688F6A00F2FF2E /* TileletBadgeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985BE529688F6A00F2FF2E /* TileletBadgeModel.swift */; }; EA985BE82968951C00F2FF2E /* TileletTitleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985BE72968951C00F2FF2E /* TileletTitleModel.swift */; }; @@ -182,7 +182,6 @@ EA3361B5288B2A410071C351 /* Control.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Control.swift; sourceTree = ""; }; EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewProtocol.swift; sourceTree = ""; }; EA3361BC288B2C760071C351 /* TypeAlias.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypeAlias.swift; sourceTree = ""; }; - EA3361BE288B2EA60071C351 /* Handlerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Handlerable.swift; sourceTree = ""; }; EA3361C228902D960071C351 /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; EA3361C8289054C50071C351 /* Surfaceable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Surfaceable.swift; sourceTree = ""; }; EA3362002891E14C0071C351 /* VerizonNHGeTX-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeTX-Bold.otf"; sourceTree = ""; }; @@ -215,6 +214,7 @@ EA89201228B568D8006B9984 /* RadioBoxItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxItem.swift; sourceTree = ""; }; EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroup.swift; sourceTree = ""; }; EA8E40902A7D3F6300934ED3 /* UIView+Accessibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Accessibility.swift"; sourceTree = ""; }; + EA8E40922A82889500934ED3 /* TooltipDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipDialog.swift; sourceTree = ""; }; EA978EC4291D6AFE00ACC883 /* AnyLabelAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyLabelAttribute.swift; sourceTree = ""; }; EA985BE529688F6A00F2FF2E /* TileletBadgeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileletBadgeModel.swift; sourceTree = ""; }; EA985BE72968951C00F2FF2E /* TileletTitleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileletTitleModel.swift; sourceTree = ""; }; @@ -490,7 +490,6 @@ EA5E305929510F8B0082B959 /* EnumSubset.swift */, EAF7F0A1289AFB3900B287F5 /* Errorable.swift */, EA3361AE288B26310071C351 /* FormFieldable.swift */, - EA3361BE288B2EA60071C351 /* Handlerable.swift */, EA33624628931B050071C351 /* Initable.swift */, EA985C7C297DAED300F2FF2E /* Primitive.swift */, EAF7F0A5289B0CE000B287F5 /* Resetable.swift */, @@ -680,6 +679,7 @@ isa = PBXGroup; children = ( EAB2375C29E8789100AABE9A /* Tooltip.swift */, + EA8E40922A82889500934ED3 /* TooltipDialog.swift */, EAB2376729E9992800AABE9A /* TooltipAlertViewController.swift */, EAB2376929E9E59100AABE9A /* TooltipLaunchable.swift */, EAB2376129E9880400AABE9A /* TrailingTooltipLabel.swift */, @@ -957,6 +957,7 @@ EAF7F13328A2A16500B287F5 /* AttachmentLabelAttributeModel.swift in Sources */, EA0FC2C62914222900DF80B4 /* ButtonGroup.swift in Sources */, EA89200628B526D6006B9984 /* CheckboxGroup.swift in Sources */, + EA8E40932A82889500934ED3 /* TooltipDialog.swift in Sources */, 44604AD429CE186A00E62B51 /* NotificationButtonModel.swift in Sources */, EAD8D2C128BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift in Sources */, EA0D1C372A681CCE00E5C127 /* ToggleView.swift in Sources */, @@ -1008,7 +1009,6 @@ EAF7F0AD289B142900B287F5 /* StrikeThroughLabelAttribute.swift in Sources */, EAB5FEF12927F4AA00998C17 /* SelfSizingCollectionView.swift in Sources */, EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */, - EA3361BF288B2EA60071C351 /* Handlerable.swift in Sources */, EA3361A8288B23300071C351 /* UIColor.swift in Sources */, EA1DA1CB2A2E36DC001C51D2 /* SelectorBase.swift in Sources */, EAC9257D29119B5400091998 /* TextLink.swift in Sources */, diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 00f13c57..10eb8ef9 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -11,7 +11,7 @@ import Combine @objc(VDSControl) /// Base Class use to build Controls. -open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoable, Clickable { +open class Control: UIControl, ViewProtocol, UserInfoable, Clickable { //-------------------------------------------------- // MARK: - Combine Properties @@ -50,14 +50,14 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab } } - /// Override for isSelected to handle setNeedsUpdate() on changes. + /// Whether the Control is selected or not. open override var isSelected: Bool { didSet { setNeedsUpdate() } } open var touchUpInsideCount: Int = 0 var isHighlightAnimating = false - /// Override to deal with only calling setNeedsUpdate() if needed. + /// Whether the Control is highlighted or not.. open override var isHighlighted: Bool { didSet { if isHighlightAnimating == false && touchUpInsideCount > 0 { @@ -75,7 +75,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab } } - /// Override to deal with setNeedsUpdate(). + /// Whether the Control is enabled or not. open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } } //-------------------------------------------------- @@ -116,9 +116,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab } /// Function used to make changes to the View based off a change events or from local properties. - open func updateView() { - updateAccessibility() - } + open func updateView() { } open func updateAccessibility() { if isSelected { @@ -146,7 +144,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab // MARK: - Overrides //-------------------------------------------------- - ///Override to deal with sending actions for accessibility. + /// Implement accessibilityActivate on an element in order to handle the default action. /// - Returns: Based on whether the userInteraction is enabled. override open func accessibilityActivate() -> Bool { // Hold state in case User wanted isAnimated to remain off. diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index 9566b79a..8f1e40a3 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -9,10 +9,9 @@ import Foundation import UIKit import Combine - @objc(VDSView) /// Base Class used to build Views. -open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { +open class View: UIView, ViewProtocol, UserInfoable { //-------------------------------------------------- // MARK: - Combine Properties @@ -44,6 +43,7 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { } } + /// Whether the View is enabled or not. open var isEnabled: Bool = true { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } } //-------------------------------------------------- @@ -86,7 +86,6 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { /// Function used to make changes to the View based off a change events or from local properties.. open func updateView() { - updateAccessibility() } /// Used to update any Accessibility properties. diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index 6672a320..2f1e23b5 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -18,7 +18,7 @@ public protocol Buttonable: UIControl, Surfaceable, Disabling { } @objc(VDSButtonBase) -open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettable, UserInfoable, Clickable { +open class ButtonBase: UIButton, Buttonable, ViewProtocol, UserInfoable, Clickable { //-------------------------------------------------- // MARK: - Configuration Properties @@ -72,11 +72,11 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab if isHighlightAnimating == false && touchUpInsideCount > 0 { isHighlightAnimating = true UIView.animate(withDuration: 0.1, animations: { [weak self] in - self?.updateView() + self?.setNeedsUpdate() }) { [weak self] _ in //you update the view since this is typically a quick change UIView.animate(withDuration: 0.1, animations: { [weak self] in - self?.updateView() + self?.setNeedsUpdate() self?.isHighlightAnimating = false }) } @@ -94,6 +94,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab } } + /// Whether the Control is enabled or not. open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } } open var textStyle: TextStyle { .defaultStyle } @@ -163,7 +164,6 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab /// Function used to make changes to the View based off a change events or from local properties. open func updateView() { updateLabel() - updateAccessibility() } open func updateAccessibility() { diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 1701311f..27f3fd79 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -11,7 +11,7 @@ import VDSColorTokens import Combine @objc(VDSLabel) -open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { +open class Label: UILabel, ViewProtocol, UserInfoable { //-------------------------------------------------- // MARK: - Combine Properties @@ -61,6 +61,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { } } + /// Whether the View is enabled or not. open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } } //-------------------------------------------------- @@ -158,10 +159,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //set the attributed text attributedText = mutableText - - //get accessibility - updateAccessibility() - + //force a drawText setNeedsDisplay() } diff --git a/VDS/Components/Tooltip/TooltipDialog.swift b/VDS/Components/Tooltip/TooltipDialog.swift new file mode 100644 index 00000000..3a8826b3 --- /dev/null +++ b/VDS/Components/Tooltip/TooltipDialog.swift @@ -0,0 +1,231 @@ +// +// TooltipDialog.swift +// VDS +// +// Created by Matt Bruce on 8/8/23. +// + +import Foundation +import UIKit +import VDSColorTokens + +open class TooltipDialog: View, UIScrollViewDelegate { + //-------------------------------------------------- + // MARK: - Private Properties + //-------------------------------------------------- + + private var scrollView = UIScrollView().with { + $0.isAccessibilityElement = false + $0.translatesAutoresizingMaskIntoConstraints = false + $0.backgroundColor = .clear + } + + private let contentStackView = UIStackView().with { + $0.isAccessibilityElement = false + $0.translatesAutoresizingMaskIntoConstraints = false + $0.axis = .vertical + $0.distribution = .fillProportionally + $0.spacing = 0 + } + + private var line = Line().with { instance in + instance.lineViewColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark).eraseToAnyColorable() + } + + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + open var titleText: String? { didSet { setNeedsUpdate() }} + open var titleLabel = Label().with { label in + label.isAccessibilityElement = true + label.textStyle = .boldTitleMedium + } + + open var contentText: String? { didSet { setNeedsUpdate() }} + open var contentLabel = Label().with { label in + label.isAccessibilityElement = true + label.textStyle = .bodyLarge + } + + open var contentView: UIView? = nil + + open var closeButtonText: String = "Close" { didSet { setNeedsUpdate() }} + + open lazy var closeButton: UIButton = { + let button = UIButton(type: .system) + button.isAccessibilityElement = true + button.backgroundColor = .clear + button.setTitle("Close", for: .normal) + button.titleLabel?.font = TextStyle.bodyLarge.font + button.translatesAutoresizingMaskIntoConstraints = false + return button + }() + + //-------------------------------------------------- + // MARK: - Configuration + //-------------------------------------------------- + private var closeButtonHeight: CGFloat = 44.0 + private var fullWidth: CGFloat = 296 + private var minHeight: CGFloat = 96.0 + private var maxHeight: CGFloat = 312.0 + private let containerViewInset = VDSLayout.Spacing.space4X.value + + private let backgroundColorConfiguration = SurfaceColorConfiguration(VDSColor.backgroundPrimaryLight, VDSColor.backgroundPrimaryDark) + private let closeButtonTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark) + + private var contentStackViewBottomConstraint: NSLayoutConstraint? + private var heightConstraint: NSLayoutConstraint? + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + open override func setup() { + super.setup() + layer.cornerRadius = 8 + contentStackView.addArrangedSubview(titleLabel) + contentStackView.addArrangedSubview(contentLabel) + scrollView.addSubview(contentStackView) + addSubview(scrollView) + addSubview(line) + addSubview(closeButton) + + // Activate constraints + NSLayoutConstraint.activate([ + widthAnchor.constraint(equalToConstant: fullWidth), + + // Constraints for the scroll view + scrollView.topAnchor.constraint(equalTo: topAnchor, constant: VDSLayout.Spacing.space4X.value), + scrollView.leadingAnchor.constraint(equalTo: leadingAnchor), + scrollView.trailingAnchor.constraint(equalTo: trailingAnchor), + scrollView.bottomAnchor.constraint(equalTo: line.topAnchor), + + line.leadingAnchor.constraint(equalTo: leadingAnchor), + line.trailingAnchor.constraint(equalTo: trailingAnchor), + + closeButton.topAnchor.constraint(equalTo: line.bottomAnchor), + closeButton.leadingAnchor.constraint(equalTo: leadingAnchor), + closeButton.trailingAnchor.constraint(equalTo: trailingAnchor), + closeButton.bottomAnchor.constraint(equalTo: bottomAnchor), + closeButton.heightAnchor.constraint(equalToConstant: closeButtonHeight), + + contentStackView.topAnchor.constraint(equalTo: scrollView.topAnchor), + contentStackView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor, constant: containerViewInset), + contentStackView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor, constant: -containerViewInset), + contentStackView.widthAnchor.constraint(equalTo: scrollView.widthAnchor, constant: -(containerViewInset * 2)), + + ]) + contentStackViewBottomConstraint = contentStackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor) + contentStackViewBottomConstraint?.activate() + + heightConstraint = heightAnchor.constraint(equalToConstant: minHeight) + heightConstraint?.activate() + } + + /// Function used to make changes to the View based off a change events or from local properties. + open override func updateView() { + super.updateView() + + backgroundColor = backgroundColorConfiguration.getColor(self) + scrollView.indicatorStyle = surface == .light ? .black : .white + + titleLabel.removeFromSuperview() + contentLabel.removeFromSuperview() + contentView?.removeFromSuperview() + + titleLabel.surface = surface + contentLabel.surface = surface + line.surface = surface + + titleLabel.text = titleText + contentLabel.text = contentText + + titleLabel.sizeToFit() + contentLabel.sizeToFit() + + var addedTitle = false + + if let titleText, !titleText.isEmpty { + contentStackView.addArrangedSubview(titleLabel) + addedTitle = true + } + + var addedContent = false + if let contentText, !contentText.isEmpty { + contentStackView.addArrangedSubview(contentLabel) + addedContent = true + } else if let contentView { + contentView.translatesAutoresizingMaskIntoConstraints = false + if var surfaceable = contentView as? Surfaceable { + surfaceable.surface = surface + } + let wrapper = View() + wrapper.addSubview(contentView) + contentView.pinTop() + contentView.pinLeading() + contentView.pinBottom() + contentView.pinTrailingLessThanOrEqualTo() + contentView.setNeedsLayout() + contentStackView.addArrangedSubview(wrapper) + addedContent = true + } + + if addedTitle && addedContent { + contentStackView.setCustomSpacing(VDSLayout.Spacing.space1X.value, after: titleLabel) + } + + let closeButtonTextColor = closeButtonTextColorConfiguration.getColor(self) + closeButton.setTitleColor(closeButtonTextColor, for: .normal) + closeButton.setTitleColor(closeButtonTextColor, for: .highlighted) + closeButton.setTitle(closeButtonText, for: .normal) + closeButton.accessibilityLabel = closeButtonText + + contentStackView.setNeedsLayout() + contentStackView.layoutIfNeeded() + + scrollView.setNeedsLayout() + scrollView.layoutIfNeeded() + + //dealing with height + //we can't really use the minMax height and set constraints for + //greaterThan or lessThan on the heightAnchor due to scrollView/stackView intrinsic size + //therefore we can do a little math and manually set the height based off all of the content + var contentHeight = closeButtonHeight + scrollView.contentSize.height + (containerViewInset * 2) + + //reset the bottomConstraint + contentStackViewBottomConstraint?.constant = 0 + + if contentHeight < minHeight { + contentHeight = minHeight + + } else if contentHeight > maxHeight { + contentHeight = maxHeight + //since we are now scrolling, add padding to the bottom of the + //stackView between the bottom of the scrollView + contentStackViewBottomConstraint?.constant = -containerViewInset + } + + heightConstraint?.constant = contentHeight + } + + lazy var primaryAccessibilityElement = UIAccessibilityElement(accessibilityContainer: self).with { + $0.accessibilityLabel = "Tooltip" + $0.accessibilityValue = "expanded" + } + + open override func updateAccessibility() { + super.updateAccessibility() + + primaryAccessibilityElement.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: bounds.width, height: VDSLayout.Spacing.space1X.value)) + primaryAccessibilityElement.accessibilityHint = "Click on the \(closeButtonText) button to close." + } + + override public var accessibilityElements: [Any]? { + get { + var elements: [Any] = []//[primaryAccessibilityElement] + contentStackView.arrangedSubviews.forEach{ elements.append($0) } + elements.append(closeButton) + return elements + } + set {} + } +} diff --git a/VDS/Protocols/Handlerable.swift b/VDS/Protocols/Handlerable.swift deleted file mode 100644 index 727f076e..00000000 --- a/VDS/Protocols/Handlerable.swift +++ /dev/null @@ -1,40 +0,0 @@ -// -// Handlerable.swift -// VDS -// -// Created by Matt Bruce on 7/22/22. -// - -import Foundation -import Combine -import UIKit - -public protocol Handlerable: AnyObject, Initable, Disabling, Surfaceable { - /// Set of Subscribers for any Publishers for this Control. - var subscribers: Set { get set } - /// Key of whether or not updateView() is called in setNeedsUpdate() - var shouldUpdateView: Bool { get set } - /// Function used to make changes to the View based off a change events or from local properties. - func updateView() -} - -extension Handlerable { - /// Function called when there are changes in a View based off a change events or from local properties. - public func setNeedsUpdate() { - if shouldUpdateView { - shouldUpdateView = false - updateView() - shouldUpdateView = true - } - } -} - -extension Handlerable where Self: UIControl { - /// Helper function to assign a completion block to a specific UIControl Event using Combine and stored in the subscribers. - public func addEvent(event: UIControl.Event, block: @escaping (Self)->()) { - publisher(for: event) - .sink(receiveValue: { c in - block(c) - }).store(in: &subscribers) - } -} diff --git a/VDS/Protocols/ViewProtocol.swift b/VDS/Protocols/ViewProtocol.swift index 69c13286..47b9f9b0 100644 --- a/VDS/Protocols/ViewProtocol.swift +++ b/VDS/Protocols/ViewProtocol.swift @@ -7,17 +7,39 @@ import Foundation import UIKit +import Combine + +public protocol ViewProtocol: AnyObject, Initable, Resettable, Disabling, Surfaceable { + /// Set of Subscribers for any Publishers for this Control. + var subscribers: Set { get set } + + /// Key of whether or not updateView() is called in setNeedsUpdate() + var shouldUpdateView: Bool { get set } -public protocol ViewProtocol { - /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. func setup() + /// Function used to make changes to the View based off a change events or from local properties. + func updateView() + /// Used to update any Accessibility properties. func updateAccessibility() } +extension ViewProtocol { + /// Function called when there are changes in a View based off a change events or from local properties. + public func setNeedsUpdate() { + if shouldUpdateView { + shouldUpdateView = false + updateView() + updateAccessibility() + shouldUpdateView = true + } + } +} + extension ViewProtocol where Self: UIView { + /// Helper method for removing a superview and updating Self. public func removeFromSuperview(_ view: UIView){ if view.superview != nil { @@ -26,3 +48,13 @@ extension ViewProtocol where Self: UIView { } } } + +extension ViewProtocol where Self: UIControl { + /// Helper function to assign a completion block to a specific UIControl Event using Combine and stored in the subscribers. + public func addEvent(event: UIControl.Event, block: @escaping (Self)->()) { + publisher(for: event) + .sink(receiveValue: { c in + block(c) + }).store(in: &subscribers) + } +} From 1e8027d2ec2bc0d09c98bc29ec0dee87cab81cb2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 09:47:57 -0500 Subject: [PATCH 10/19] added super method calls in overrides Signed-off-by: Matt Bruce --- VDS/Classes/SelectorItemBase.swift | 2 +- VDS/Components/Badge/Badge.swift | 2 ++ VDS/Components/BadgeIndicator/BadgeIndicator.swift | 2 ++ VDS/Components/Buttons/Button/Button.swift | 1 + VDS/Components/Line/Line.swift | 2 ++ VDS/Components/Notification/Notification.swift | 2 ++ VDS/Components/RadioBox/RadioBoxItem.swift | 3 ++- VDS/Components/RadioSwatch/RadioSwatch.swift | 4 ++++ VDS/Components/RadioSwatch/RadioSwatchGroup.swift | 2 ++ VDS/Components/TextFields/EntryField/EntryField.swift | 1 + VDS/Components/Tilelet/Tilelet.swift | 3 ++- VDS/Components/Toggle/Toggle.swift | 4 +++- VDS/Components/Toggle/ToggleView.swift | 4 +++- 13 files changed, 27 insertions(+), 5 deletions(-) diff --git a/VDS/Classes/SelectorItemBase.swift b/VDS/Classes/SelectorItemBase.swift index b1b91985..b7c916b2 100644 --- a/VDS/Classes/SelectorItemBase.swift +++ b/VDS/Classes/SelectorItemBase.swift @@ -186,13 +186,13 @@ open class SelectorItemBase: Control, Errorable, /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() updateLabels() selectorView.showError = showError selectorView.isSelected = isSelected selectorView.isHighlighted = isHighlighted selectorView.disabled = disabled selectorView.surface = surface - updateAccessibility() } open override func updateAccessibility() { diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index 60b1cd33..bf2ff583 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -133,6 +133,8 @@ open class Badge: View { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() + updateTextColorConfig() backgroundColor = backgroundColorConfiguration.getColor(self) diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index b9f72d46..1a00abfc 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -312,6 +312,8 @@ open class BadgeIndicator: View { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() + updateTextColorConfig() badgeView.backgroundColor = backgroundColorConfiguration.getColor(self) diff --git a/VDS/Components/Buttons/Button/Button.swift b/VDS/Components/Buttons/Button/Button.swift index 42b3150d..f81e3b40 100644 --- a/VDS/Components/Buttons/Button/Button.swift +++ b/VDS/Components/Buttons/Button/Button.swift @@ -152,6 +152,7 @@ open class Button: ButtonBase, Useable { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { super.updateView() + let bgColor = backgroundColorConfiguration.getColor(self) let borderColor = borderColorConfiguration.getColor(self) let borderWidth = use == .secondary ? VDSFormControls.widthBorder : 0.0 diff --git a/VDS/Components/Line/Line.swift b/VDS/Components/Line/Line.swift index 070b3768..c9c33aba 100644 --- a/VDS/Components/Line/Line.swift +++ b/VDS/Components/Line/Line.swift @@ -58,6 +58,8 @@ open class Line: View { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() + lineView.backgroundColor = lineViewColorConfiguration.getColor(self) } } diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 9d6e0e34..3e704b5e 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -266,6 +266,8 @@ open class Notification: View { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() + backgroundColor = backgroundColorConfiguration.getColor(self) updateIcons() updateLabels() diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index d7c9d1bd..e789785e 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -261,8 +261,9 @@ open class RadioBoxItem: Control, Changeable { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() + updateLabels() - updateAccessibility() setNeedsLayout() layoutIfNeeded() } diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index f2898f13..1658482d 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -127,10 +127,14 @@ open class RadioSwatch: Control { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() + layer.setNeedsDisplay() } public override func updateAccessibility() { + super.updateAccessibility() + accessibilityLabel = text } diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index e7b29b65..25827392 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -126,6 +126,8 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase, UICo /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() + label.textPosition = .left label.textStyle = .bodySmall label.text = selectedHandler?.text ?? " " diff --git a/VDS/Components/TextFields/EntryField/EntryField.swift b/VDS/Components/TextFields/EntryField/EntryField.swift index 794b2fa1..819e805e 100644 --- a/VDS/Components/TextFields/EntryField/EntryField.swift +++ b/VDS/Components/TextFields/EntryField/EntryField.swift @@ -260,6 +260,7 @@ open class EntryField: Control, Changeable { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() containerView.backgroundColor = backgroundColorConfiguration.getColor(self) containerView.layer.borderColor = borderColorConfiguration.getColor(self).cgColor diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 7c19a3fa..0de18f58 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -374,10 +374,11 @@ open class Tilelet: TileContainer { updateIcons() layoutIfNeeded() - updateAccessibility() } open override func updateAccessibility() { + super.updateAccessibility() + setAccessibilityLabel(for: [badge.label, titleLockup.eyebrowLabel, titleLockup.titleLabel, titleLockup.subTitleLabel]) } } diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index f96d534a..82a602b2 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -193,15 +193,17 @@ open class Toggle: Control, Changeable { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() + updateLabel() toggleView.surface = surface toggleView.disabled = disabled toggleView.isOn = isOn - updateAccessibility() } open override func updateAccessibility() { super.updateAccessibility() + if showText { setAccessibilityLabel(for: [label]) } else { diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index 8729fb72..672c7305 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -154,12 +154,14 @@ open class ToggleView: Control, Changeable { /// Function used to make changes to the View based off a change events or from local properties. open override func updateView() { + super.updateView() + updateToggle() - updateAccessibility() } open override func updateAccessibility() { super.updateAccessibility() + accessibilityLabel = "Toggle" } From 366143a9ad4586783a1af33be166c499c73b05c6 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 09:48:19 -0500 Subject: [PATCH 11/19] refactored out Tooltipdialog Signed-off-by: Matt Bruce --- .../Tooltip/TooltipAlertViewController.swift | 208 +----------------- 1 file changed, 1 insertion(+), 207 deletions(-) diff --git a/VDS/Components/Tooltip/TooltipAlertViewController.swift b/VDS/Components/Tooltip/TooltipAlertViewController.swift index 7da2c581..2be0d921 100644 --- a/VDS/Components/Tooltip/TooltipAlertViewController.swift +++ b/VDS/Components/Tooltip/TooltipAlertViewController.swift @@ -112,212 +112,6 @@ open class TooltipAlertViewController: UIViewController, Surfaceable { tooltipDialog.titleText = titleText tooltipDialog.contentText = contentText tooltipDialog.contentView = contentView - } -} - -open class TooltipDialog: View, UIScrollViewDelegate { - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - - private var scrollView = UIScrollView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.backgroundColor = .clear - } - - private let contentStackView = UIStackView().with { - $0.translatesAutoresizingMaskIntoConstraints = false - $0.axis = .vertical - $0.distribution = .fillProportionally - $0.spacing = 0 - } - - private var line = Line().with { instance in - instance.lineViewColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsLowcontrastOnlight, VDSColor.elementsLowcontrastOndark).eraseToAnyColorable() - } - - //-------------------------------------------------- - // MARK: - Public Properties - //-------------------------------------------------- - open var titleText: String? { didSet { setNeedsUpdate() }} - open var titleLabel = Label().with { label in - label.textStyle = .boldTitleMedium - } - - open var contentText: String? { didSet { setNeedsUpdate() }} - open var contentLabel = Label().with { label in - label.textStyle = .bodyLarge - } - - open var contentView: UIView? = nil - - open var closeButtonText: String = "Close" { didSet { setNeedsUpdate() }} - - open lazy var closeButton: UIButton = { - let button = UIButton(type: .system) - button.backgroundColor = .clear - button.setTitle("Close", for: .normal) - button.titleLabel?.font = TextStyle.bodyLarge.font - button.translatesAutoresizingMaskIntoConstraints = false - return button - }() - - //-------------------------------------------------- - // MARK: - Configuration - //-------------------------------------------------- - private var closeButtonHeight: CGFloat = 44.0 - private var fullWidth: CGFloat = 296 - private var minHeight: CGFloat = 96.0 - private var maxHeight: CGFloat = 312.0 - private let containerViewInset = VDSLayout.Spacing.space4X.value - - private let backgroundColorConfiguration = SurfaceColorConfiguration(VDSColor.backgroundPrimaryLight, VDSColor.backgroundPrimaryDark) - private let closeButtonTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark) - - private var contentStackViewBottomConstraint: NSLayoutConstraint? - private var heightConstraint: NSLayoutConstraint? - - //-------------------------------------------------- - // MARK: - Lifecycle - //-------------------------------------------------- - open override func setup() { - super.setup() - layer.cornerRadius = 8 - contentStackView.isAccessibilityElement = true - contentStackView.addArrangedSubview(titleLabel) - contentStackView.addArrangedSubview(contentLabel) - scrollView.addSubview(contentStackView) - addSubview(scrollView) - addSubview(line) - addSubview(closeButton) - - // Activate constraints - NSLayoutConstraint.activate([ - widthAnchor.constraint(equalToConstant: fullWidth), - - // Constraints for the scroll view - scrollView.topAnchor.constraint(equalTo: topAnchor, constant: VDSLayout.Spacing.space4X.value), - scrollView.leadingAnchor.constraint(equalTo: leadingAnchor), - scrollView.trailingAnchor.constraint(equalTo: trailingAnchor), - scrollView.bottomAnchor.constraint(equalTo: line.topAnchor), - - line.leadingAnchor.constraint(equalTo: leadingAnchor), - line.trailingAnchor.constraint(equalTo: trailingAnchor), - - closeButton.topAnchor.constraint(equalTo: line.bottomAnchor), - closeButton.leadingAnchor.constraint(equalTo: leadingAnchor), - closeButton.trailingAnchor.constraint(equalTo: trailingAnchor), - closeButton.bottomAnchor.constraint(equalTo: bottomAnchor), - closeButton.heightAnchor.constraint(equalToConstant: closeButtonHeight), - - contentStackView.topAnchor.constraint(equalTo: scrollView.topAnchor), - contentStackView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor, constant: containerViewInset), - contentStackView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor, constant: -containerViewInset), - contentStackView.widthAnchor.constraint(equalTo: scrollView.widthAnchor, constant: -(containerViewInset * 2)), - - ]) - contentStackViewBottomConstraint = contentStackView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor) - contentStackViewBottomConstraint?.activate() - - heightConstraint = heightAnchor.constraint(equalToConstant: minHeight) - heightConstraint?.activate() - } - - /// Function used to make changes to the View based off a change events or from local properties. - open override func updateView() { - super.updateView() - - backgroundColor = backgroundColorConfiguration.getColor(self) - scrollView.indicatorStyle = surface == .light ? .black : .white - - titleLabel.removeFromSuperview() - contentLabel.removeFromSuperview() - contentView?.removeFromSuperview() - - titleLabel.surface = surface - contentLabel.surface = surface - line.surface = surface - - titleLabel.text = titleText - contentLabel.text = contentText - - titleLabel.sizeToFit() - contentLabel.sizeToFit() - - var addedTitle = false - - if let titleText, !titleText.isEmpty { - contentStackView.addArrangedSubview(titleLabel) - addedTitle = true - } - - var addedContent = false - if let contentText, !contentText.isEmpty { - contentStackView.addArrangedSubview(contentLabel) - addedContent = true - } else if let contentView { - contentView.translatesAutoresizingMaskIntoConstraints = false - if var surfaceable = contentView as? Surfaceable { - surfaceable.surface = surface - } - let wrapper = View() - wrapper.addSubview(contentView) - contentView.pinTop() - contentView.pinLeading() - contentView.pinBottom() - contentView.pinTrailingLessThanOrEqualTo() - contentView.setNeedsLayout() - contentStackView.addArrangedSubview(wrapper) - addedContent = true - } - - if addedTitle && addedContent { - contentStackView.setCustomSpacing(VDSLayout.Spacing.space1X.value, after: titleLabel) - } - - let closeButtonTextColor = closeButtonTextColorConfiguration.getColor(self) - closeButton.setTitleColor(closeButtonTextColor, for: .normal) - closeButton.setTitleColor(closeButtonTextColor, for: .highlighted) - closeButton.setTitle(closeButtonText, for: .normal) - closeButton.accessibilityLabel = closeButtonText - - contentStackView.setNeedsLayout() - contentStackView.layoutIfNeeded() - - scrollView.setNeedsLayout() - scrollView.layoutIfNeeded() - - //dealing with height - //we can't really use the minMax height and set constraints for - //greaterThan or lessThan on the heightAnchor due to scrollView/stackView intrinsic size - //therefore we can do a little math and manually set the height based off all of the content - var contentHeight = closeButtonHeight + scrollView.contentSize.height + (containerViewInset * 2) - - //reset the bottomConstraint - contentStackViewBottomConstraint?.constant = 0 - - if contentHeight < minHeight { - contentHeight = minHeight - - } else if contentHeight > maxHeight { - contentHeight = maxHeight - //since we are now scrolling, add padding to the bottom of the - //stackView between the bottom of the scrollView - contentStackViewBottomConstraint?.constant = -containerViewInset - } - - heightConstraint?.constant = contentHeight - } - - open override func updateAccessibility() { - var label = Tooltip.accessibleText(for: titleText, content: contentText, closeButtonText: closeButtonText) - if !label.isEmpty { - label += "," - } - - contentStackView.accessibilityLabel = label - contentStackView.accessibilityHint = "Click on the \(closeButtonText) button to close." - contentStackView.accessibilityValue = "expanded" - accessibilityElements = [contentStackView, closeButton] + tooltipDialog.closeButtonText = closeButtonText } } From 05fd22d2eb069d93ea8bbbc5f1e61d9c0a49d01d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 09:48:39 -0500 Subject: [PATCH 12/19] fixed protocol changes after handlerable removal Signed-off-by: Matt Bruce --- VDS/Extensions/UIView+CALayer.swift | 2 +- VDS/Protocols/Changeable.swift | 2 +- VDS/Protocols/Clickable.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VDS/Extensions/UIView+CALayer.swift b/VDS/Extensions/UIView+CALayer.swift index 05e60113..f8d9f25e 100644 --- a/VDS/Extensions/UIView+CALayer.swift +++ b/VDS/Extensions/UIView+CALayer.swift @@ -62,7 +62,7 @@ extension UIView { } else { removeDebugBorder() } - if let view = self as? Handlerable { + if let view = self as? ViewProtocol { view.updateView() } } diff --git a/VDS/Protocols/Changeable.swift b/VDS/Protocols/Changeable.swift index 308c6a00..6ef3eb8e 100644 --- a/VDS/Protocols/Changeable.swift +++ b/VDS/Protocols/Changeable.swift @@ -9,7 +9,7 @@ import Foundation import UIKit import Combine -public protocol Changeable: Handlerable where Self: UIControl { +public protocol Changeable: ViewProtocol where Self: UIControl { /// Sets the primary Subscriber used for the UIControl event .valueChanged. var onChangeSubscriber: AnyCancellable? { get set } } diff --git a/VDS/Protocols/Clickable.swift b/VDS/Protocols/Clickable.swift index e54e7db4..50445dc0 100644 --- a/VDS/Protocols/Clickable.swift +++ b/VDS/Protocols/Clickable.swift @@ -9,7 +9,7 @@ import Foundation import UIKit import Combine -public protocol Clickable: Handlerable where Self: UIControl { +public protocol Clickable: ViewProtocol where Self: UIControl { /// Reference count used when a subscriber is listening for the UIControl event .touchUpInside. var touchUpInsideCount: Int { get set } /// Sets the primary Subscriber used for the UIControl event .touchUpInside. From f04c7875d1c3ae3c4821d66c9fd60968b4fdda5e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 09:50:52 -0500 Subject: [PATCH 13/19] updated comment Signed-off-by: Matt Bruce --- VDS/Classes/ColorConfiguration.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VDS/Classes/ColorConfiguration.swift b/VDS/Classes/ColorConfiguration.swift index a7cf2673..317a16d3 100644 --- a/VDS/Classes/ColorConfiguration.swift +++ b/VDS/Classes/ColorConfiguration.swift @@ -72,11 +72,11 @@ public protocol KeyColorConfigurable: ObjectColorable { extension KeyColorConfigurable { - /// Generic Method to set a KeyColorConfiguration with the parameters given + /// Generic Method to set a KeyColorConfiguration with the parameters given. /// - Parameters: - /// - lightColor: Color used for a light - /// - darkColor: Color used for a dark - /// - key: <#key description#> + /// - lightColor: Color used for a light. + /// - darkColor: Color used for a dark. + /// - key: The key that you want to filter off of. public func setSurfaceColors(_ lightColor: UIColor, _ darkColor: UIColor, forKey key: KeyType) { keyColors.append(.init(key: key, surfaceConfig: .init(lightColor, darkColor))) } From da75a3831948fac343dc428ae2e4dc3216a02e33 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 10:03:23 -0500 Subject: [PATCH 14/19] fixed issue #5 on ONEAPP-4684 Signed-off-by: Matt Bruce --- VDS/Components/Tooltip/TooltipDialog.swift | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/VDS/Components/Tooltip/TooltipDialog.swift b/VDS/Components/Tooltip/TooltipDialog.swift index 3a8826b3..d04a173b 100644 --- a/VDS/Components/Tooltip/TooltipDialog.swift +++ b/VDS/Components/Tooltip/TooltipDialog.swift @@ -210,22 +210,18 @@ open class TooltipDialog: View, UIScrollViewDelegate { lazy var primaryAccessibilityElement = UIAccessibilityElement(accessibilityContainer: self).with { $0.accessibilityLabel = "Tooltip" $0.accessibilityValue = "expanded" + $0.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: fullWidth, height: VDSLayout.Spacing.space1X.value)) } open override func updateAccessibility() { super.updateAccessibility() - primaryAccessibilityElement.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: bounds.width, height: VDSLayout.Spacing.space1X.value)) primaryAccessibilityElement.accessibilityHint = "Click on the \(closeButtonText) button to close." + + var elements: [Any] = [primaryAccessibilityElement] + contentStackView.arrangedSubviews.forEach{ elements.append($0) } + elements.append(closeButton) + accessibilityElements = elements } - override public var accessibilityElements: [Any]? { - get { - var elements: [Any] = []//[primaryAccessibilityElement] - contentStackView.arrangedSubviews.forEach{ elements.append($0) } - elements.append(closeButton) - return elements - } - set {} - } } From 1fe325c16851391f231b2420977a05f7fe80f3cc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 11:06:08 -0500 Subject: [PATCH 15/19] removed logic Signed-off-by: Matt Bruce --- VDS/Components/Tooltip/TooltipDialog.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/VDS/Components/Tooltip/TooltipDialog.swift b/VDS/Components/Tooltip/TooltipDialog.swift index d04a173b..77806e86 100644 --- a/VDS/Components/Tooltip/TooltipDialog.swift +++ b/VDS/Components/Tooltip/TooltipDialog.swift @@ -15,13 +15,11 @@ open class TooltipDialog: View, UIScrollViewDelegate { //-------------------------------------------------- private var scrollView = UIScrollView().with { - $0.isAccessibilityElement = false $0.translatesAutoresizingMaskIntoConstraints = false $0.backgroundColor = .clear } private let contentStackView = UIStackView().with { - $0.isAccessibilityElement = false $0.translatesAutoresizingMaskIntoConstraints = false $0.axis = .vertical $0.distribution = .fillProportionally @@ -210,7 +208,7 @@ open class TooltipDialog: View, UIScrollViewDelegate { lazy var primaryAccessibilityElement = UIAccessibilityElement(accessibilityContainer: self).with { $0.accessibilityLabel = "Tooltip" $0.accessibilityValue = "expanded" - $0.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: fullWidth, height: VDSLayout.Spacing.space1X.value)) + $0.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: fullWidth, height: 2)) } open override func updateAccessibility() { @@ -221,6 +219,7 @@ open class TooltipDialog: View, UIScrollViewDelegate { var elements: [Any] = [primaryAccessibilityElement] contentStackView.arrangedSubviews.forEach{ elements.append($0) } elements.append(closeButton) + accessibilityElements = elements } From 07268c106669d91de11909df98e1ae40e8ccbc68 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 12:52:03 -0500 Subject: [PATCH 16/19] updated rect Signed-off-by: Matt Bruce --- VDS/Components/Tooltip/TooltipDialog.swift | 5 +++-- VDS/SupportingFiles/ReleaseNotes.txt | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/VDS/Components/Tooltip/TooltipDialog.swift b/VDS/Components/Tooltip/TooltipDialog.swift index 77806e86..ae8aeddd 100644 --- a/VDS/Components/Tooltip/TooltipDialog.swift +++ b/VDS/Components/Tooltip/TooltipDialog.swift @@ -79,6 +79,7 @@ open class TooltipDialog: View, UIScrollViewDelegate { //-------------------------------------------------- open override func setup() { super.setup() + layer.cornerRadius = 8 contentStackView.addArrangedSubview(titleLabel) contentStackView.addArrangedSubview(contentLabel) @@ -208,9 +209,9 @@ open class TooltipDialog: View, UIScrollViewDelegate { lazy var primaryAccessibilityElement = UIAccessibilityElement(accessibilityContainer: self).with { $0.accessibilityLabel = "Tooltip" $0.accessibilityValue = "expanded" - $0.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: fullWidth, height: 2)) + $0.accessibilityFrameInContainerSpace = .init(origin: .zero, size: .init(width: fullWidth, height: VDSLayout.Spacing.space1X.value)) } - + open override func updateAccessibility() { super.updateAccessibility() diff --git a/VDS/SupportingFiles/ReleaseNotes.txt b/VDS/SupportingFiles/ReleaseNotes.txt index c46e1b09..d01a5f52 100644 --- a/VDS/SupportingFiles/ReleaseNotes.txt +++ b/VDS/SupportingFiles/ReleaseNotes.txt @@ -1,3 +1,8 @@ +1.0.37 +======= +- ONEAPP-4684 - Update Accessibility for Tooltip +- Fixed bug in Typography TitleLarge letterSpacing + 1.0.36 ======= - Fixed bugs in Typography Definitions From 816ee9f0aa5f75f4d7efeeb4f021b0231ac14139 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 13:06:57 -0500 Subject: [PATCH 17/19] updated tooltip info for accessibility Signed-off-by: Matt Bruce --- VDS/Components/Tooltip/Tooltip.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index f983cfb7..c522137f 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -175,11 +175,13 @@ open class Tooltip: Control, TooltipLaunchable { if label == nil { label = content } + if let label, !label.isEmpty { + accessibilityLabel = label + } else { + accessibilityLabel = "Tooltip" + } accessibilityHint = isEnabled ? "Click to open Tooltip." : "" accessibilityValue = "collapsed" - if let label { - accessibilityLabel = label - } } public static func accessibleText(for title: String?, content: String?, closeButtonText: String) -> String { From d8df323da7d1c1a11b8710c13c4a5f331b974394 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 14:51:06 -0500 Subject: [PATCH 18/19] updated version Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 8de483a9..40fc0d9b 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -1167,7 +1167,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 36; + CURRENT_PROJECT_VERSION = 37; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1204,7 +1204,7 @@ BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 36; + CURRENT_PROJECT_VERSION = 37; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; From 6c6996fa33bb2c434fa445af83aac8af311fe92b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Aug 2023 14:51:27 -0500 Subject: [PATCH 19/19] Title Large mobile has a different Font that for Desktop Signed-off-by: Matt Bruce --- VDS/Typography/Typogprahy+Styles.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Typography/Typogprahy+Styles.swift b/VDS/Typography/Typogprahy+Styles.swift index e2d906fe..05a6eb64 100644 --- a/VDS/Typography/Typogprahy+Styles.swift +++ b/VDS/Typography/Typogprahy+Styles.swift @@ -108,7 +108,7 @@ extension TextStyle { lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28) public static let titleLarge = TextStyle(rawValue: "titleLarge", - fontFace: .dsLight, + fontFace: UIDevice.isIPad ? .dsLight : .edsRegular, pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24, lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28, letterSpacing: UIDevice.isIPad ? VDSTypography.letterSpacingSemiWide : 0)