FUIListPickerCollectionViewCell

open class FUIListPickerCollectionViewCell : FUIInlineValidationDrawingCollectionViewCell<FUIListPickerFormView>, FUIPickerFormCell

The reusable UI component implemented as a UICollectionViewCell to display a key-value pair property, which is integrated with a FUIListPicker controller for displaying a list of values.

  • title: The title of the property.
  • valueText: The title of the property.
  • value: The default selections.
  • valueOptions: The list of optional values the user may choose from.
  • allowsMultipleSelection: Indicates whether the user can select multiple values. The default is true, meaning that, by default, the user may select multiple values.
  • isEnabled: Determines whether the selection(s) can be modified or not. The default is true.
  • listPicker: The FUIListPicker for this FUIListPickerCollectionViewCell.

Note that the display of the selections in the valueLabel is the responsibility of the developer if the dataSource property of the listPicker is set. The developer needs to set the text of the valueLabel to reflect the selections. Otherwise, if the developer sets valueOptions and leaves dataSource of listPicker as nil, then the text in valueLabel will be set internally.

Here are the code snippets in the app’s UICollectionViewController implementation: (The app’s UICollectionViewController needs to be a subclass of FUIFormCollectionViewController.)

        var propValue7: [Int] = [1, 3, 6]
        var valueOptions7 = ["One", "Two", "Three", "Four", "Five", "Six", "Seven"]
        var listPickerDataSource7 = StringListPickerDataSource(options: valueOptions7)

        override func viewDidLoad() {
            super.viewDidLoad()
            self.collectionView.register(FUIListPickerCollectionViewCell.self, forCellWithReuseIdentifier: FUIListPickerCollectionViewCell.reuseIdentifier)
            // ...
        }

        override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FUIListPickerCollectionViewCell.reuseIdentifier, for: indexPath) as! FUIListPickerCollectionViewCell

        cell.title.text = "Choose Multiple"
        cell.value = propValue7
        cell.allowsMultipleSelection = true
        cell.valueText.text = descriptionForSelectedStrings(valueOptions7, at: propValue7) // See below

        cell.listPicker.dataSource = listPickerDataSource7
        cell.listPicker.searchResultsUpdating = listPickerDataSource7
        cell.listPicker.isSearchEnabled = true
        cell.listPicker.prompt = "Please select multiple items"

        cell.listPicker.searchBar?.isBarcodeScannerEnabled = true
        cell.listPicker.searchBar?.barcodeScanner?.scanMode = .EAN_UPC
        cell.listPicker.searchBar?.barcodeScanner?.scanResultTransformer = { (scanString) -> String in
            return self.transformStringToSearchBar(scanResultString: scanString)
        }
        // MARK:  implement onChangeHandler
        cell.onChangeHandler = { [weak self] newValue in
            self.propValue3 = newValue
        }
            return cell
        }

        func descriptionForSelectedStrings(_ options: [String], at indexes: [Int]) -> String {
            return options.enumerated().filter({ (index, element) -> Bool in
                return indexes.contains(index)
            }).reduce ("") { string, element in
                return string.isEmpty ? element.1 : "\(string), \(element.1)"
            }
        }

## Theming

Supported Text class paths:

 fdlFUIListPickerCollectionViewCell_title {}
 fdlFUIListPickerFormView_valueText {}

Supported Text attributes:

 font-color (Color)
 font-name (FontName)
 font-style (UIFontTextStyle)
 font-size (Number)
 text-align (TextAlign)
 text-line-clamp (Integer)

Supported UIView class paths:

 fdlFUIListPickerCollectionViewCell_selectedBackgroundView {}

Supported UIView properties:

 background-color: (Color)
  • The value text for this property

    Declaration

    Swift

    public var valueText: FUIMultiLineText { get }
  • The key name of the property.

    Declaration

    Swift

    public var keyName: String? { get set }
  • The value type is String array.

    Declaration

    Swift

    public typealias ValueType = [Int]
  • The value is the selected indexes to the items in the list. This property is not used when ListPicker‘s isDataSourceRequiringUniqueIdentifiers is true.

    Declaration

    Swift

    public var value: [Int] { get set }
  • Indicates whether this cell is enabled or not, that is, whether the selections can be changed or not. The default is true.

    Declaration

    Swift

    public var isEnabled: Bool { get set }
  • isEditable and isEnabled are in sync.

    Declaration

    Swift

    public var isEditable: Bool { get set }
  • This property specifies whether the valueLabel should always be below the keyLabel or not.

    The default is false.

    Declaration

    Swift

    public var alwaysShowValueTextOnBottom: Bool { get set }
  • Implementation of the change handler. This is invoked on changes to the value property.

    Declaration

    Swift

    public var onChangeHandler: (([Int]) -> Void)? { get set }
  • If the ListPicker‘s isDataSourceRequiringUniqueIdentifiers is true, then this is the handler to be invoked when uuidValues changes.

    Declaration

    Swift

    public var onUuidChangeHandler: (([String]) -> Void)?
  • The array of the valid options.

    Declaration

    Swift

    public var valueOptions: [String] { get set }
  • If the ListPicker‘s isDataSourceRequiringUniqueIdentifiers is true, this property is the selected UUID strings.

    Declaration

    Swift

    public var uuidValues: [String]
  • If isTrackingLiveChanges is true, then onChangeHandler or onUuidChangeHandler will be invoked for every selection and de-selection.

    Otherwise, the handler will be invoked only after the FUIListPicker is dismissed.

    Note that isTrackingLiveChanges is treated as false if isUndoEnabled is true.

    The default is false.

    Declaration

    Swift

    public var isTrackingLiveChanges: Bool
  • If this property is true, the Cancel button will be displayed on the right side of the navigation bar to allow the user to undo the change when tapped.

    The default is false (the Cancel button will not be displayed).

    Declaration

    Swift

    public var isUndoEnabled: Bool
  • Declaration

    Swift

    public var listPicker: FUIListPicker { get set }
  • Indicates whether the user can select multiple values.

    The default is true, meaning that, by default, the user can select multiple values.

    Declaration

    Swift

    public var allowsMultipleSelection: Bool { get set }
  • Indicates whether empty selection is allowed.

    The default is true, meaning that, by default, the user does not need to select an item.

    Declaration

    Swift

    public var allowsEmptySelection: Bool
  • Specifies whether the picker is to be dismissed after selection.

    If this property is true and allowsMultipleSelection is false, the picker will be dismissed after the user makes a selection. The default is false.

    Declaration

    Swift

    public var isPickerDismissedOnSelection: Bool
  • This property indicates whether the list picker should be presented modally or not. The default is false.

    Declaration

    Swift

    public var presentsListPickerModally: Bool
  • The FUIListPickerTableViewController associated with this FUIListPickerCollectionViewCell.

    Declaration

    Swift

    public private(set) var listPickerTableViewController: FUIListPickerTableViewController! { get }
  • Undocumented

    Declaration

    Swift

    open override var isSelected: Bool { get set }
  • Declaration

    Swift

    open override func layoutSubviews()