FUITextFieldFormCell
open class FUITextFieldFormCell : FUIInlineValidationDrawingTableViewCell<FUITextFieldContentView>, FUIFormCell
extension FUITextFieldFormCell: FUITintAttributesProvider
The reusable UI component implemented as an UITableViewCell
to display or edit a key-value pair property.
The developer should set the following properties on the cell, in their implementation of UITableViewDataSource
cellForRow(at:)
function:
keyName
: The key name of the property.value
: The value of the property.
And an onChangeHandler
:
onChangeHandler
: a handler closure, which is invoked on changes to the value
Optionally, the developer may provide
isEditable
: Indicates if the cell’s value may be modified. Defaults totrue
.isStacked
: A boolean value to determine if the cell should use a stacked or linear layout. If the device’s accessibility settings font size is increased, the cell will force a stacked layout. By default, this property is set totrue
.maxKeyWidth
: The maximum width of the key with a linear layout - By default, the width is 115 for compact and 160 for regular. The set value must meet the minimum default threshold.alternativeInputButton
: AnFUIButton
that manages an alternative method to fill thetextField
.isAlternativeInputEnabled
: ABool
that shows or hides thealternativeInputButton
. This button will be displayed ifisAlternativeInputEnabled
andisEditable
aretrue
.isReadOnly
: Indicates if the cell is read-only or not. The default isfalse
.isTrackingLiveChanges
: Indicates if theonChangeHandler
will be invoked for every letter entered. The default isfalse
.isCharCountEnabled
: A Boolean value to enable a character counter and show the updated character count number during editing. The default isfalse
.maxTextLength
: The maximum length of the text.allowsBeyondLimit
: A Boolean value to determine whether the user can continue to input text even aftermaxValueTextLength
has been reached. If it istrue
, it will be in an error state with an error message and a semantic negative color when the text input exceedsmaxTextLength
. The default isfalse
.showsErrorInValidationMsg
: A Boolean value to determine whether an error message will be shown in thevalidationMessage
or in theerrorView
in the same layout as thehintView
. The default istrue
.hasError
: A Boolean value to indicate if there is an error in the text input value. It will be in an error state with an error message and a semantic negative color if it istrue
. The default isfalse
.
Color settings:
Manage the color of the control by setting the textColor
and tintColor
programmatically.
The following is an example of usage in an application UITableViewController
:
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(FUITextFieldFormCell.self, forCellReuseIdentifier: FUITextFieldFormCell.reuseIdentifier)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: FUITextFieldFormCell.reuseIdentifier, for: indexPath) as! FUITextFieldFormCell
cell.keyName = "Editable"
cell.value = myObject.productName
// MARK: implement onChangeHandler
cell.onChangeHandler = { newValue in
myObject.productName = newValue
}
// MARK: Implement alternative input, i.e. use OCR to capture input
cell.isAlternativeInputEnabled = true
let inputImage = FUIIconLibrary.system.camera
cell.alternativeInputButton.setImage(inputImage.withRenderingMode(.alwaysTemplate), for: .normal)
cell.alternativeInputButton.didSelectHandler = { [weak self, weak cell] (button) in
//Import SAPML to use OCR capability
let textRecController = FUITextRecognitionViewController()
textRecController.recognitionView.observationHandler = { [unowned textRecController] observations in
let filteredObservations = <#filter out unwanted text#>
textRecController.recognitionView.showTexts(for: filteredObservations)
let areObservationsValid = <#filteredObservations meets desired criteria#>
if areObservationsValid {
DispatchQueue.main.async {
cell?.value = filteredObservations.map { $0.value }.joined(separator:" ")
}
return true
}
return false
}
textRecController.onClose = {
self?.dismiss(animated: true)
}
self?.present(UINavigationController(rootViewController: textRecController), animated: true)
}
return cell
}
## Theming
nuiClass
:
fdlFUITextFieldFormCell {}
Supported TEXT
class paths:
fdlFUITextFieldFormCell_keyText {}
fdlFUITextFieldFormCell_valueText {}
Supported TEXT
properties:
font-color: Color;
placeholder-color: Color;
font-style: UIFontTextStyle;
Supported BUTTON
class paths:
fdlFUITextFieldFormCell_alternativeInputButton {}
Supported BUTTON
properties:
background-color: Color;
font-color: Color;
-
The enum for the version to be displayed in
See moreFUITextFieldFormCell
.Declaration
Swift
public enum Version
-
The version to be displayed.
The default is
.v2
Declaration
Swift
public var version: Version { get set }
-
The key name of the property.
Declaration
Swift
open var keyName: String? { get set }
-
The
UILabel
holds the key name string.Declaration
Swift
@available(*, deprecated, message: "This property has been deprecated. Please set the `title.text` property.") public var keyLabel: UILabel
-
The
FUITextField
holds the value string.Declaration
Swift
open var valueTextField: FUITextField { get }
-
A boolean value to determine if the cell should use a stacked or linear layout.
For version
v1
if the device’s accessibility settings font size is increased, the cell will force a stacked layout. By default, this property is set totrue
.For version
v2
, this property is alwaystrue
.Declaration
Swift
open var isStacked: Bool { get set }
-
The maximum width of the key with a linear layout - By default, the width is 115 for compact and 160 for regular. The set value must meet the minimum default threshold.
Declaration
Swift
open var maxKeyWidth: CGFloat { get set }
-
Indicates if the value of the cell could be changed or not. For
FUISimplePropertyFormCell
this property is always false.Declaration
Swift
open var isEditable: Bool { get set }
-
A
Bool
to enable alternative entry. The cell must also haveisEditable
set totrue
to display the button. The button will be hidden while text entry is in progress.The default value is
false
.Declaration
Swift
open var isAlternativeInputEnabled: Bool { get set }
-
isEnabled
andisEditable
are in sync.Declaration
Swift
override open var isEnabled: Bool { get set }
-
This is the maximum length of the text if
maxTextLength
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
maxTextLength
is 0, which means no limit.Declaration
Swift
public var maxTextLength: Int { get set }
-
The value of the property.
Declaration
Swift
open var value: String { 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 }
-
Implementation of change handler. Is invoked on changes to the
value
property.Declaration
Swift
open var onChangeHandler: ((String) -> Void)? { get set }
-
The placeholder text for the value text field.
Declaration
Swift
@available(*, deprecated, message: "This property is deprecated. Please use `placeholder.text`.") open var placeholderText: String? { get set }
-
Method determining the type of presented keyboard
Declaration
Swift
open var keyboardType: UIKeyboardType { get set }
-
The formatter for the
UITextField
in this cell.Currently, SAPFiori provides two implementations:
FUIPhoneNumberFormatter
to format phone numbers.FUINumberFormatter
to format numbers that uses the regular iOSNumberFormatter
.
Declaration
Swift
open var formatter: FUIFormattedStringEditing? { get set }
-
If
isTrackingLiveChanges == 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
open var isTrackingLiveChanges: Bool { get set }
-
The customized text alignment for the
valueTextField
,If this property is
nil
, the default alignment is used.- For left to right languages and the cell is
editable
, the default is left aligned. - For left to right languages and the cell is not
editable
, the default is right aligned. - For righ to left languages and the cell is
editable
, the default is rignt aligned. - For righ to left languages and the cell is not
editable
, the default is left aligned.
Declaration
Swift
open var valueTextAlignment: NSTextAlignment? { get set }
- For left to right languages and the cell is
-
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 }
-
Declaration
Swift
public override var validationMessage: String? { get set }
-
If
isCharCountEnabled
is true, it will show the character count and themaxValueTextLength
. 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 aftermaxValueTextLength
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 whenmaxValueTextLength
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
to indicate whether there is a character counting error. When it istrue
, the input character count exceeds themaxTextLength
.Declaration
Swift
public var hasCharCountError: Bool { get }
-
Declaration
Swift
override open func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize
-
Declaration
Swift
public var tintAttributes: [FUIPropertyRef : [FUIControlState : [NSAttributedStringKey : Any]]] { get set }
-
Declaration
Swift
public var tintState: FUIControlState { get set }
-
Declaration
Swift
public typealias TintState = FUIControlState
-
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]