From 8c3bce746e48a2951e24c9c52960bf16740dd5f6 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 22 May 2024 15:33:30 -0500 Subject: [PATCH 1/6] refactored models Signed-off-by: Matt Bruce --- VDS/Components/Tilelet/Tilelet.swift | 4 +-- .../Tilelet/TileletIconModels.swift | 32 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 98ce49aa..104d3551 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -532,7 +532,7 @@ open class Tilelet: TileContainerBase { var showIconContainerView = false if let descriptiveIconModel { descriptiveIcon.name = descriptiveIconModel.name - descriptiveIcon.color = descriptiveIconModel.color + descriptiveIcon.colorConfiguration = descriptiveIconModel.colorConfiguration descriptiveIcon.size = descriptiveIconModel.size descriptiveIcon.surface = backgroundColorSurface descriptiveIcon.accessibilityLabel = descriptiveIconModel.accessibleText @@ -541,7 +541,7 @@ open class Tilelet: TileContainerBase { if let directionalIconModel { directionalIcon.name = directionalIconModel.iconType.iconName - directionalIcon.color = directionalIconModel.color + directionalIcon.colorConfiguration = directionalIconModel.colorConfiguration directionalIcon.size = directionalIconModel.size directionalIcon.surface = backgroundColorSurface directionalIcon.accessibilityLabel = directionalIconModel.accessibleText diff --git a/VDS/Components/Tilelet/TileletIconModels.swift b/VDS/Components/Tilelet/TileletIconModels.swift index 788a2155..30048a3e 100644 --- a/VDS/Components/Tilelet/TileletIconModels.swift +++ b/VDS/Components/Tilelet/TileletIconModels.swift @@ -17,23 +17,23 @@ extension Tilelet { public var name: Icon.Name /// Color of the icon. - public var color: UIColor + public var colorConfiguration: SurfaceColorConfiguration /// Enum for a preset height and width for the icon. public var size: Icon.Size /// Accessible Text for the Icon public var accessibleText: String - - /// 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, color: UIColor = VDSColor.paletteBlack, size: Icon.Size = .medium, accessibleText: String? = nil, surface: Surface = .dark) { + public init(name: Icon.Name = .multipleDocuments, + colorConfiguration: SurfaceColorConfiguration = .init(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark), + size: Icon.Size = .medium, + accessibleText: String? = nil) { + self.name = name - self.color = color + self.colorConfiguration = colorConfiguration self.accessibleText = accessibleText ?? name.rawValue self.size = size - self.surface = surface } } @@ -49,8 +49,8 @@ extension Tilelet { } /// Color of the icon. - public var color: UIColor - + public var colorConfiguration: SurfaceColorConfiguration + /// Accessible Text for the Icon public var accessibleText: String @@ -59,16 +59,16 @@ extension Tilelet { /// Enum for a preset height and width for the icon. 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(iconType: IconType = .rightArrow, color: UIColor = VDSColor.paletteBlack, size: Icon.Size = .medium, accessibleText: String? = nil, surface: Surface = .dark) { + + public init(iconType: IconType = .rightArrow, + colorConfiguration: SurfaceColorConfiguration = .init(.black, .white), + size: Icon.Size = .medium, + accessibleText: String? = nil) { + self.iconType = iconType - self.color = color + self.colorConfiguration = colorConfiguration self.accessibleText = accessibleText ?? iconType.iconName.rawValue self.size = size - self.surface = surface } } } From 1d1bab13d07048c81f9c41a2b7eb72e48ab3f098 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 22 May 2024 15:34:43 -0500 Subject: [PATCH 2/6] udpated spacing Signed-off-by: Matt Bruce --- VDS/Components/TextFields/EntryFieldBase.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VDS/Components/TextFields/EntryFieldBase.swift b/VDS/Components/TextFields/EntryFieldBase.swift index 631cf029..02767152 100644 --- a/VDS/Components/TextFields/EntryFieldBase.swift +++ b/VDS/Components/TextFields/EntryFieldBase.swift @@ -58,7 +58,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable { /// only used for helperTextPosition == .right internal let row1StackView = UIStackView().with { $0.axis = .horizontal - $0.spacing = 8 + $0.spacing = VDSLayout.space3X $0.alignment = .top $0.distribution = .fillEqually } @@ -66,7 +66,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable { /// only used for helperTextPosition == .right internal let row2StackView = UIStackView().with { $0.axis = .horizontal - $0.spacing = 8 + $0.spacing = VDSLayout.space3X $0.alignment = .top $0.distribution = .fillEqually } From ad1d2bf945789da94436845fcb8c8005fe6932f9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 22 May 2024 15:45:14 -0500 Subject: [PATCH 3/6] updated models Signed-off-by: Matt Bruce --- VDS/Components/Tilelet/TileletIconModels.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Components/Tilelet/TileletIconModels.swift b/VDS/Components/Tilelet/TileletIconModels.swift index 30048a3e..1772f817 100644 --- a/VDS/Components/Tilelet/TileletIconModels.swift +++ b/VDS/Components/Tilelet/TileletIconModels.swift @@ -61,7 +61,7 @@ extension Tilelet { public var size: Icon.Size public init(iconType: IconType = .rightArrow, - colorConfiguration: SurfaceColorConfiguration = .init(.black, .white), + colorConfiguration: SurfaceColorConfiguration = .init(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark), size: Icon.Size = .medium, accessibleText: String? = nil) { From 2e2beee8c37c22453dab23ae824837f63290ba48 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 22 May 2024 16:28:30 -0500 Subject: [PATCH 4/6] fixed bug in word wrapping Signed-off-by: Matt Bruce --- VDS/Components/DropdownSelect/DropdownSelect.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VDS/Components/DropdownSelect/DropdownSelect.swift b/VDS/Components/DropdownSelect/DropdownSelect.swift index ac5cb29b..cf3539fb 100644 --- a/VDS/Components/DropdownSelect/DropdownSelect.swift +++ b/VDS/Components/DropdownSelect/DropdownSelect.swift @@ -93,7 +93,7 @@ open class DropdownSelect: EntryFieldBase { $0.setContentCompressionResistancePriority(.required, for: .horizontal) $0.textAlignment = .left $0.textStyle = .boldBodyLarge - $0.lineBreakMode = .byCharWrapping + $0.numberOfLines = 1 $0.sizeToFit() } @@ -102,7 +102,7 @@ open class DropdownSelect: EntryFieldBase { $0.setContentCompressionResistancePriority(.required, for: .horizontal) $0.textAlignment = .left $0.textStyle = .bodyLarge - $0.lineBreakMode = .byCharWrapping + $0.numberOfLines = 1 } open var dropdownField = UITextField().with { From 44323a0a847cc58284f8ae0d85641b420da0d0f0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 22 May 2024 16:28:44 -0500 Subject: [PATCH 5/6] fixed width issues reset label color configs Signed-off-by: Matt Bruce --- .../TextFields/EntryFieldBase.swift | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/VDS/Components/TextFields/EntryFieldBase.swift b/VDS/Components/TextFields/EntryFieldBase.swift index 02767152..2c2435be 100644 --- a/VDS/Components/TextFields/EntryFieldBase.swift +++ b/VDS/Components/TextFields/EntryFieldBase.swift @@ -101,6 +101,13 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable { /// This is set by a local method. internal var bottomContainerView: UIView! + //-------------------------------------------------- + // MARK: - Constraints + //-------------------------------------------------- + internal var widthConstraint: NSLayoutConstraint? + internal var trailingEqualsConstraint: NSLayoutConstraint? + internal var trailingLessThanEqualsConstraint: NSLayoutConstraint? + //-------------------------------------------------- // MARK: - Configuration Properties //-------------------------------------------------- @@ -228,11 +235,27 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable { open override func setup() { super.setup() + let layoutGuide = UILayoutGuide() + addLayoutGuide(layoutGuide) + layoutGuide + .pinTop() + .pinLeading() + .pinBottom() + + trailingEqualsConstraint = layoutGuide.pinTrailing(anchor: trailingAnchor) + + // width constraints + trailingLessThanEqualsConstraint = layoutGuide.pinTrailingLessThanOrEqualTo(anchor: trailingAnchor)?.deactivate() + widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: 0).deactivate() + // Add mainStackView to the view addSubview(mainStackView) - - mainStackView.pinToSuperView() - + + mainStackView.pinTop(anchor: layoutGuide.topAnchor) + mainStackView.pinLeading(anchor: layoutGuide.leadingAnchor) + mainStackView.pinBottom(anchor: layoutGuide.bottomAnchor) + mainStackView.pinTrailing(anchor: layoutGuide.trailingAnchor) + //add ContainerStackView //this is the horizontal stack that contains //InputContainer, Icons, Buttons @@ -265,12 +288,18 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable { // Initial position of the helper label updateHelperTextPosition() + + // colorconfigs + titleLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable() + errorLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable() + helperLabel.textColorConfiguration = secondaryColorConfiguration.eraseToAnyColorable() } /// Updates the UI open override func updateView() { super.updateView() updateContainerView() + updateContainerWidth() updateTitleLabel() updateErrorLabel() updateHelperLabel() @@ -411,7 +440,21 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable { containerView.layer.borderWidth = VDSFormControls.borderWidth containerView.layer.cornerRadius = VDSFormControls.borderRadius } - + + internal func updateContainerWidth() { + widthConstraint?.deactivate() + trailingLessThanEqualsConstraint?.deactivate() + trailingEqualsConstraint?.deactivate() + + if let width, width >= minWidth, width <= maxWidth { + widthConstraint?.constant = width + widthConstraint?.activate() + trailingLessThanEqualsConstraint?.activate() + } else { + trailingEqualsConstraint?.activate() + } + } + internal func updateHelperTextPosition() { titleLabel.removeFromSuperview() From 4ba2b4e744352c499bb5e1ca407dc9b84b366cef Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 22 May 2024 16:54:33 -0500 Subject: [PATCH 6/6] updated tilelet directional icon model Signed-off-by: Matt Bruce --- VDS/Components/Tilelet/Tilelet.swift | 2 +- VDS/Components/Tilelet/TileletIconModels.swift | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 104d3551..5dcd5a09 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -542,7 +542,7 @@ open class Tilelet: TileContainerBase { if let directionalIconModel { directionalIcon.name = directionalIconModel.iconType.iconName directionalIcon.colorConfiguration = directionalIconModel.colorConfiguration - directionalIcon.size = directionalIconModel.size + directionalIcon.size = directionalIconModel.size.value directionalIcon.surface = backgroundColorSurface directionalIcon.accessibilityLabel = directionalIconModel.accessibleText showIconContainerView = true diff --git a/VDS/Components/Tilelet/TileletIconModels.swift b/VDS/Components/Tilelet/TileletIconModels.swift index 1772f817..7fc408a3 100644 --- a/VDS/Components/Tilelet/TileletIconModels.swift +++ b/VDS/Components/Tilelet/TileletIconModels.swift @@ -39,7 +39,7 @@ extension Tilelet { /// Model that represents the options available for the directional icon. public struct DirectionalIcon { - public enum IconType { + public enum IconType: String, CaseIterable { case rightArrow case externalLink @@ -48,6 +48,14 @@ extension Tilelet { } } + public enum IconSize: String, EnumSubset { + case small + case medium + case large + + public var defaultValue: Icon.Size { .medium } + } + /// Color of the icon. public var colorConfiguration: SurfaceColorConfiguration @@ -58,11 +66,11 @@ extension Tilelet { public var iconType: IconType /// Enum for a preset height and width for the icon. - public var size: Icon.Size + public var size: IconSize public init(iconType: IconType = .rightArrow, colorConfiguration: SurfaceColorConfiguration = .init(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark), - size: Icon.Size = .medium, + size: IconSize = .medium, accessibleText: String? = nil) { self.iconType = iconType