FUITitleFormCollectionViewCell
open class FUITitleFormCollectionViewCell : FUIInlineValidationDrawingCollectionViewCell<FUITitleFormView>
extension FUITitleFormCollectionViewCell: FUITintAttributesProvider
The reusable UI component implemented as a UICollectionViewCell
, allowing the user to enter a value using a UITextField
.
value
: The value of the property, asString
And an onChangeHandler
:
onChangeHandler
: a handler closure that is invoked on changes to the value.
Optionally, the developer may provide:
isEditable
: Indicates whether the cell’s value may be modified. The default istrue
.
Color settings:
Setting tintColor
for valueTextField
for a state using the setTintColor(_:for:)
API. Currently disabled
and normal
are supported.
cell.setAttributes([.foregroundColor: UIColor.red], for: .valueText, state: .normal)
Remark
Thefont-color
attribute will be overridden by the tint-color-disabled
attribute when the cell is switched to the disabled
state. Do not set textColor
for valueTextField
when the cell is in the disabled
state.
Example of usage in an application, UICollectionViewController
:
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.register(FUITitleFormCollectionViewCell.self, forCellWithReuseIdentifier: FUITitleFormCollectionViewCell.reuseIdentifier)
// ...
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FUITitleFormCollectionViewCell.reuseIdentifier, for: indexPath) as! FUITitleFormCollectionViewCell
cell.placeholderText = placeHolderText
cell.value = myObject.title
cell.isEditable = true
// MARK: implement onChangeHandler
cell.onChangeHandler = { newValue in
myObject.title = newValue
}
return cell
}
## Theming
Supported TableViewCell
class paths:
fdlFUITitleFormCell {}
Supported TableViewCell
attributes:
background-color (Color)
background-color-disabled (Color)
background-color-readonly (Color)
Supported TextField
class paths:
fdlFUITitleFormCell_valueTextField
Supported TextField
properties:
font-color: Color;
font-color-disabled: Color;
font-color-readonly: Color;
placeholder-color: Color;
font-style: UIFontTextStyle;
font-style-disabled: UIFontTextStyle;
font-style-readonly: UIFontTextStyle;
-
The default cell reuse identifier.
Declaration
Swift
open override class var reuseIdentifier: String { get }
-
The
FUITextField
holds the value string.Declaration
Swift
public var valueTextField: FUITextField { get }
-
The value for
FUITitleFormCollectionViewCell
is the text of the Title.Declaration
Swift
public var value: String { get set }
-
Indicates whether the cell is read-only or not. The default is
false
.Declaration
Swift
public var isReadOnly: Bool { get set }
-
Implementation of the change handler. This is invoked on changes to the
value
property.Declaration
Swift
public var onChangeHandler: ((String) -> Void)? { get set }
-
Indicates whether this title is editable or not. The default is true.
Declaration
Swift
public var isEditable: Bool { get set }
-
isEnabled
andisEditable
are in sync.Declaration
Swift
public var isEnabled: Bool { get set }
-
The maximum length of the title text.
Declaration
Swift
public var maxTitleTextLength: Int { get set }
-
The type of the keyboard being used when the cell is in input mode.
Declaration
Swift
public var keyboardType: UIKeyboardType { get set }
-
If
isTrackingLiveChanges == true
, thendidChangeValue
function ofonChangeHandler
, will be invoked for every letter entered.Otherwise,
onChangeHandler
will be invoked only after the user taps the Done key, or the field resigns as first responder.Declaration
Swift
public var isTrackingLiveChanges: Bool { get set }
-
The placeholder text for the title text field.
Declaration
Swift
public var placeholderText: String? { get set }
-
Declaration
Swift
public var tintAttributes: [FUIPropertyRef : [FUIControlState : [NSAttributedStringKey : Any]]] { get set }
-
Declaration
Swift
public var tintState: FUIControlState { get set }
-
Declaration
Swift
public func tintAttributes(for property: FUIPropertyRef) -> [NSAttributedStringKey : Any]
-
Declaration
Swift
public func tintAttributes(for property: FUIPropertyRef, state: TintState) -> [NSAttributedStringKey : Any]
-
Declaration
Swift
public func styleSheetTintAttributes(for property: FUIPropertyRef) -> [NSAttributedStringKey : Any]
-
Declaration
Swift
public func styleSheetTintAttributes(for property: FUIPropertyRef, state: TintState) -> [NSAttributedStringKey : Any]
-
Declaration
Swift
public typealias TintState = FUIControlState