EnterpriseDS Documentation

Class DSSelect

@IBDesignable public final class DSSelect: UIView, DSSelectControl  

An Enterprise-styled option selection. This should be used when a user needs to select a value from a set of options.

For storyboards, add a UIView and change the class name to DSSelect.

Initialize and set properties as needed.

let select = DSSelect()

let options = [
    DSSelectOption(data: "medical", label: "Medical"),
    DSSelectOption(data: "dental", label: "Dental"),
    DSSelectOption(data: "vision", label: "Vision")
]

select.labelText = "Choose Your Coverage"
select.helperText = "You will be signed up after configuration"
select.options = options
select.value = options[0]

Use a DSSelectDelegate to detect when its tapped so you can navigate to the options list:

func selectTapped(_ select: DSSelect) {
    select.showOptionSelection(on: navigationController)
}
DSSelect DSSelect DSSelectControl DSSelectControl DSSelect->DSSelectControl UIView UIView DSSelect->UIView

Conforms To

DSSelectControl

A protocol extension for select controls.

UIView

Initializers

init(frame:​)

public override init(frame: CGRect)  

Properties

select​Delegate

@IBOutlet public weak var selectDelegate: DSSelectDelegate? 

The delegate which receives updates on the DSSelect's state.

is​Enabled

@IBInspectable public var isEnabled: Bool = true  

Returns true if the component is enabled and allows changing the value.

label​Text

@IBInspectable public var labelText: String?  

The text to be displayed in the label.

helper​Text

@IBInspectable public var helperText: String?  

The text to be displayed as helper (below the label) to clarify what the field's value represents.

value

public var value: DSSelectOption?  

The value of the field.

options

public var options: [DSSelectOption] = []  

The ordered list of valid values that can be selected for this field.

validation​Rules

public var validationRules  

The array of ValidationRule objects to be used for validating the current state of the field.

validation​State

public private(set) var validationState: DSValueValidationState = .unvalidated

validation state of the current value.

Methods

awake​From​Nib()

public override func awakeFromNib()  

prepare​For​Interface​Builder()

public override func prepareForInterfaceBuilder()  

layout​Subviews()

public override func layoutSubviews()  

add(validation​Rule:​)

func add(validationRule rule: DSValidationRule)  

Adds a validation rule to be used for validating the current value.

Parameters

validation​Rule DSValidation​Rule

A ValidationRule object to be used for checking a validation

add(validation​Rules:​)

func add(validationRules rules: [DSValidationRule])  

Adds an array of validation rules to be used for validating the current value.

Parameters

validation​Rules [DSValidation​Rule]

A ValidationRule array to be used for checking validations

remove​All​Validation​Rules()

func removeAllValidationRules()  

Removes all validation rules.

validate()

@discardableResult func validate() -> DSValidationRule?  

Returns the validation status of the current value based on the current validation rules.