FUINoteFormCell
open class FUINoteFormCell : FUIAutofittingDrawingTableViewCell<FUINoteFormCellContentView>, FUIFormCell
The reusable UI component implemented as an UITableViewCell
to allow user enter notes.
This is the new implementation to replace the previous implementation of FUINoteFormCell
.
The cell height is automatically adjusted to allow the whole content to be displayed.
However, the cell height is also limited to the height of the screen above the soft keyboard height.
Developer could use to UITableViewDelegate
‘s func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat
to set a fixed height for the cell. Or, use minNumberOfLines
and maxNumberOfLines
properties to limit the cell height.
The character counter can be enabled by setting isCharCountEnabled
. It will show the updated the character count number during editing or has been entered. The message will be shown if the maxNoteTextLength
reached. The user can continue input the text if allowsBeyondLimit
is true
. It will show the text input field in error state with an error message and a semantic negative color.
If allowsBeyondLimit
is false
, it will auto-stop user input when maxNoteTextLength
is reached.
The application can validate the user input value and show error message by setting hasError
and errorText
. The text input field in error state with an error message and a semantic negative color. The error message can be shown in the validationMessage
if showsErrorInValidationMsg
is true
. Otherwise, the error message will be shown in the errorView
in the same layout as the hintView
.
Usage
let cell = tableView.dequeueReusableCell(withIdentifier: FUINoteFormCell.reuseIdentifier) as! FUINoteFormCell
cell.onChangeHandler = { [unowned self] newValue in
self.noteText = newValue
}
cell.placeholder.text = "Enter Description"
cell.value = noteText
cell.isTrackingLiveChanges = true
Theming
Supported TEXT
class paths:
fdlFUINoteFormCell_valueText {}
fdlFUINoteFormCell_placeholder {}
Supported TEXT
properties:
font-color: Color;
font-style: UIFontTextStyle;
Supported TINTABLE
class paths:
fdlFUIKeyValueFormCell_valueText {}
Supported TINTABLE
properties:
tint-color { -disabled }: Color;
font-style { -disabled }: UIFontTextStyle;
-
The enum for the version to be displayed in
See moreFUINoteFormCell
orFUIKeyValueFormCell
.Declaration
Swift
public enum Version
-
The version to be displayed.
The default is
.v2
Declaration
Swift
public var version: Version { get set }
-
Indicates if the note text could be modified or not. The default is true.
Declaration
Swift
public var isEditable: Bool { get set }
-
If
isTrackingLiveChanges
is true, thenonChangeHandler
will be invoked for every letter entered.Otherwise,
onChangeHandler
will be invoked only after user taps “Done” key, or the field resigns first responder.The default is
false
.Declaration
Swift
public var isTrackingLiveChanges: Bool { get set }
-
If this is true, this
FUINoteFormCell
will grow in height and the cell will not be scrollable. Otherwise, the cell height will be fixed.Declaration
Swift
@available(*, deprecated, message: "This property is deprecated. Please use 'maxNumberOfLines' property.") public var isAutoFitting: Bool { get set }
-
The minimum number of lines for the
valueTextView
.The cell height will be set to display the text with at least this number of lines.
The default and the hard minumum value is
2
forVersion.v2
and1
forVersion.v1
. Setting this value to less than the hard minimum will set this value to the hard minimum. This property is ignored when the height of the cell is fixed.Declaration
Swift
public var minNumberOfLines: Int { get set }
-
The maximum number of lines in this
FUINoteFormCell
.The cell height could grow to display the text with this number of lines. This property is ignored when the height of the cell is fixed. The view will be scrollable when the text entered needs more lines to be displayed. The default is 0, which means no limit.
Note that more text may be displayed in the view due to extra top and buttom margins of the text view in the cell.
Declaration
Swift
public var maxNumberOfLines: Int { get set }
-
This is the maximum length of the note text, if
maxNoteTextLength
is greater than 0.If the text length reaches this limit when
isCharCountEnabled
isfalse
, the user cannot enter more text. Note: If the user pastes a string and the length plus the current text length is greater than the limit, the insert is rejected. Partial strings are not accepted in the text field.If the text length reaches this limit when
isCharCountEnabled
istrue
, the user cannot enter more text ifallowsBeyondLimit
isfalse
. In the case whereallowsBeyondLimit
istrue
, the user can enter more text beyond the limitation in the error state.The default value for
maxNoteTextLength
is 0, which means no limit.Declaration
Swift
public var maxNoteTextLength: Int { get set }
-
The UI component holds the note text.
Declaration
Swift
public var valueTextView: FUITextView { get }
-
The placeholder string to be put on the text area before user typed anything.
Declaration
Swift
@available(*, deprecated, message: "This property is deprecated. Please use `placeholder.text`.") @IBInspectable public var placeholderText: String? { get set }
-
The hint text.
Declaration
Swift
open var hintText: String? { get set }
-
Indicates if the cell is read-only or not.
The default is
false
.Declaration
Swift
open var isReadOnly: Bool { get set }
-
Indiccates if to hide the read-only hint or not.
A default hint is provided when this cell’s
isReadOnly
is true unless this property istrue
. The default is false, means the default read-only hint will be shown whenisReadOnly
istrue
.Declaration
Swift
open var hidesReadOnlyHint: Bool { get set }
-
The error message when the character count limitation is reached.
Declaration
Swift
public var charCountReachLimitMsg: String { get set }
-
The error message when the character count exceeds the limitation.
Declaration
Swift
public var charCountBeyondLimitMsg: String { get set }
-
Declaration
Swift
public override var validationMessage: String? { get set }
-
If
isCharCountEnabled
is true, it will show the character count and themaxNoteTextLength
. The character count number will be updated during editing.The default is
false
.Declaration
Swift
public var isCharCountEnabled: Bool { get set }
-
If
showsErrorInValidationMsg
istrue
, it will show the character count error message in thevalidationMessage
of theFUITextFieldFormCell
. Otherwise, the error message will be shown in theerrorView
in the same layout as thehintView
.The default is
true
.Declaration
Swift
public var showsErrorInValidationMsg: Bool { get set }
-
If
allowsBeyondLimit
istrue
, it will allow the user to input continuously even aftermaxNoteTextLength
is reached. It will be in an error state with an error message and a semantic negative color. IfallowsBeyondLimit
isfalse
, it will auto-stop user input whenmaxNoteTextLength
is reached.The default is
false
.Declaration
Swift
public var allowsBeyondLimit: Bool { get set }
-
The error text.
Declaration
Swift
open var errorText: String? { get set }
-
If
hasError
istrue
, it will be in an error state with an error message and a semantic negative color.The default is
false
.Declaration
Swift
public var hasError: Bool { get set }
-
A
Bool
that indicates whether there is a character counting error. Whentrue
, the input character count exceeds themaxTextLength
.Declaration
Swift
public var hasCharCountError: Bool { get }
-
Declaration
Swift
open override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize