Merge branch 'mbruce/bugfix' into 'develop'
Tilelet updates See merge request BPHV_MIPS/vds_ios!231
This commit is contained in:
commit
d7beafc956
@ -93,7 +93,7 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
|
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
$0.textAlignment = .left
|
$0.textAlignment = .left
|
||||||
$0.textStyle = .boldBodyLarge
|
$0.textStyle = .boldBodyLarge
|
||||||
$0.lineBreakMode = .byCharWrapping
|
$0.numberOfLines = 1
|
||||||
$0.sizeToFit()
|
$0.sizeToFit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
|
$0.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
$0.textAlignment = .left
|
$0.textAlignment = .left
|
||||||
$0.textStyle = .bodyLarge
|
$0.textStyle = .bodyLarge
|
||||||
$0.lineBreakMode = .byCharWrapping
|
$0.numberOfLines = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
open var dropdownField = UITextField().with {
|
open var dropdownField = UITextField().with {
|
||||||
|
|||||||
@ -58,7 +58,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
/// only used for helperTextPosition == .right
|
/// only used for helperTextPosition == .right
|
||||||
internal let row1StackView = UIStackView().with {
|
internal let row1StackView = UIStackView().with {
|
||||||
$0.axis = .horizontal
|
$0.axis = .horizontal
|
||||||
$0.spacing = 8
|
$0.spacing = VDSLayout.space3X
|
||||||
$0.alignment = .top
|
$0.alignment = .top
|
||||||
$0.distribution = .fillEqually
|
$0.distribution = .fillEqually
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
/// only used for helperTextPosition == .right
|
/// only used for helperTextPosition == .right
|
||||||
internal let row2StackView = UIStackView().with {
|
internal let row2StackView = UIStackView().with {
|
||||||
$0.axis = .horizontal
|
$0.axis = .horizontal
|
||||||
$0.spacing = 8
|
$0.spacing = VDSLayout.space3X
|
||||||
$0.alignment = .top
|
$0.alignment = .top
|
||||||
$0.distribution = .fillEqually
|
$0.distribution = .fillEqually
|
||||||
}
|
}
|
||||||
@ -101,6 +101,13 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
/// This is set by a local method.
|
/// This is set by a local method.
|
||||||
internal var bottomContainerView: UIView!
|
internal var bottomContainerView: UIView!
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Constraints
|
||||||
|
//--------------------------------------------------
|
||||||
|
internal var widthConstraint: NSLayoutConstraint?
|
||||||
|
internal var trailingEqualsConstraint: NSLayoutConstraint?
|
||||||
|
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration Properties
|
// MARK: - Configuration Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -228,11 +235,27 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.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
|
// Add mainStackView to the view
|
||||||
addSubview(mainStackView)
|
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
|
//add ContainerStackView
|
||||||
//this is the horizontal stack that contains
|
//this is the horizontal stack that contains
|
||||||
//InputContainer, Icons, Buttons
|
//InputContainer, Icons, Buttons
|
||||||
@ -265,12 +288,18 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
|
|
||||||
// Initial position of the helper label
|
// Initial position of the helper label
|
||||||
updateHelperTextPosition()
|
updateHelperTextPosition()
|
||||||
|
|
||||||
|
// colorconfigs
|
||||||
|
titleLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||||
|
errorLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||||
|
helperLabel.textColorConfiguration = secondaryColorConfiguration.eraseToAnyColorable()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the UI
|
/// Updates the UI
|
||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
updateContainerView()
|
updateContainerView()
|
||||||
|
updateContainerWidth()
|
||||||
updateTitleLabel()
|
updateTitleLabel()
|
||||||
updateErrorLabel()
|
updateErrorLabel()
|
||||||
updateHelperLabel()
|
updateHelperLabel()
|
||||||
@ -411,7 +440,21 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
||||||
containerView.layer.cornerRadius = VDSFormControls.borderRadius
|
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() {
|
internal func updateHelperTextPosition() {
|
||||||
|
|
||||||
titleLabel.removeFromSuperview()
|
titleLabel.removeFromSuperview()
|
||||||
|
|||||||
@ -532,7 +532,7 @@ open class Tilelet: TileContainerBase<Tilelet.Padding> {
|
|||||||
var showIconContainerView = false
|
var showIconContainerView = false
|
||||||
if let descriptiveIconModel {
|
if let descriptiveIconModel {
|
||||||
descriptiveIcon.name = descriptiveIconModel.name
|
descriptiveIcon.name = descriptiveIconModel.name
|
||||||
descriptiveIcon.color = descriptiveIconModel.color
|
descriptiveIcon.colorConfiguration = descriptiveIconModel.colorConfiguration
|
||||||
descriptiveIcon.size = descriptiveIconModel.size
|
descriptiveIcon.size = descriptiveIconModel.size
|
||||||
descriptiveIcon.surface = backgroundColorSurface
|
descriptiveIcon.surface = backgroundColorSurface
|
||||||
descriptiveIcon.accessibilityLabel = descriptiveIconModel.accessibleText
|
descriptiveIcon.accessibilityLabel = descriptiveIconModel.accessibleText
|
||||||
@ -541,8 +541,8 @@ open class Tilelet: TileContainerBase<Tilelet.Padding> {
|
|||||||
|
|
||||||
if let directionalIconModel {
|
if let directionalIconModel {
|
||||||
directionalIcon.name = directionalIconModel.iconType.iconName
|
directionalIcon.name = directionalIconModel.iconType.iconName
|
||||||
directionalIcon.color = directionalIconModel.color
|
directionalIcon.colorConfiguration = directionalIconModel.colorConfiguration
|
||||||
directionalIcon.size = directionalIconModel.size
|
directionalIcon.size = directionalIconModel.size.value
|
||||||
directionalIcon.surface = backgroundColorSurface
|
directionalIcon.surface = backgroundColorSurface
|
||||||
directionalIcon.accessibilityLabel = directionalIconModel.accessibleText
|
directionalIcon.accessibilityLabel = directionalIconModel.accessibleText
|
||||||
showIconContainerView = true
|
showIconContainerView = true
|
||||||
|
|||||||
@ -17,29 +17,29 @@ extension Tilelet {
|
|||||||
public var name: Icon.Name
|
public var name: Icon.Name
|
||||||
|
|
||||||
/// Color of the icon.
|
/// Color of the icon.
|
||||||
public var color: UIColor
|
public var colorConfiguration: SurfaceColorConfiguration
|
||||||
|
|
||||||
/// Enum for a preset height and width for the icon.
|
/// Enum for a preset height and width for the icon.
|
||||||
public var size: Icon.Size
|
public var size: Icon.Size
|
||||||
|
|
||||||
/// Accessible Text for the Icon
|
/// Accessible Text for the Icon
|
||||||
public var accessibleText: String
|
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.name = name
|
||||||
self.color = color
|
self.colorConfiguration = colorConfiguration
|
||||||
self.accessibleText = accessibleText ?? name.rawValue
|
self.accessibleText = accessibleText ?? name.rawValue
|
||||||
self.size = size
|
self.size = size
|
||||||
self.surface = surface
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Model that represents the options available for the directional icon.
|
/// Model that represents the options available for the directional icon.
|
||||||
public struct DirectionalIcon {
|
public struct DirectionalIcon {
|
||||||
public enum IconType {
|
public enum IconType: String, CaseIterable {
|
||||||
case rightArrow
|
case rightArrow
|
||||||
case externalLink
|
case externalLink
|
||||||
|
|
||||||
@ -48,9 +48,17 @@ extension Tilelet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color of the icon.
|
public enum IconSize: String, EnumSubset {
|
||||||
public var color: UIColor
|
case small
|
||||||
|
case medium
|
||||||
|
case large
|
||||||
|
|
||||||
|
public var defaultValue: Icon.Size { .medium }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Color of the icon.
|
||||||
|
public var colorConfiguration: SurfaceColorConfiguration
|
||||||
|
|
||||||
/// Accessible Text for the Icon
|
/// Accessible Text for the Icon
|
||||||
public var accessibleText: String
|
public var accessibleText: String
|
||||||
|
|
||||||
@ -58,17 +66,17 @@ extension Tilelet {
|
|||||||
public var iconType: IconType
|
public var iconType: IconType
|
||||||
|
|
||||||
/// Enum for a preset height and width for the icon.
|
/// Enum for a preset height and width for the icon.
|
||||||
public var size: Icon.Size
|
public var size: IconSize
|
||||||
|
|
||||||
/// Current Surface and this is used to pass down to child objects that implement Surfacable
|
public init(iconType: IconType = .rightArrow,
|
||||||
public var surface: Surface
|
colorConfiguration: SurfaceColorConfiguration = .init(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark),
|
||||||
|
size: IconSize = .medium,
|
||||||
public init(iconType: IconType = .rightArrow, color: UIColor = VDSColor.paletteBlack, size: Icon.Size = .medium, accessibleText: String? = nil, surface: Surface = .dark) {
|
accessibleText: String? = nil) {
|
||||||
|
|
||||||
self.iconType = iconType
|
self.iconType = iconType
|
||||||
self.color = color
|
self.colorConfiguration = colorConfiguration
|
||||||
self.accessibleText = accessibleText ?? iconType.iconName.rawValue
|
self.accessibleText = accessibleText ?? iconType.iconName.rawValue
|
||||||
self.size = size
|
self.size = size
|
||||||
self.surface = surface
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user