Skip to content

Commit

Permalink
[README] Update for 0.1.1
Browse files Browse the repository at this point in the history
Replace description to helper
Add the counter function
  • Loading branch information
robergro authored Oct 29, 2024
1 parent 63f4caa commit 6aa5bdf
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# FormField
A wrapper component which support UIControl components with label and helper message (Success/Info/Error management).
A wrapper component which support UIView components with label and helper message (Success/Info/Error management).

![Figma anatomy](https://github.com/adevinta/spark-ios-component-form-field/blob/main/.github/assets/anatomy.png)

Expand All @@ -10,34 +10,43 @@ The formfield specifications on Zeroheight is [here](https://spark.adevinta.com/
FormField is available on UIKit and SwiftUI.

### FormFieldUIView
Parameters:

#### Parameters:
* `theme`: The current Spark-Theme. [You can always define your own theme.](https://github.com/adevinta/spark-ios/wiki/Theming#your-own-theming)
* `component`: The component (UIControl) is covered by formfield.
* `component`: The component (UIView) is covered by formfield.
* `feedbackState`: The formfield feedback state. 'Default' or 'Error'.(There aren't design changes for Success and Info states. They will be managed with 'Default')
* `title`: An option string. The title is rendered above the component.
* `attributedTitle`: An option attributed string to change label of font or size.
* `description`: An option string. The title is rendered under the component.
* `helper`: An option string. The title is rendered under the component.
* `attributedDescription`: An option attributed string to change helper message of font or size.
* `isTitleRequired`: A bool value to add asterisk character at the end of title for specifying required field.
* `isEnabled`: A bool value to change wrapped component enabled state
* `isSelected`: A bool value to change wrapped component selected state

#### Functions:
If the component inside the FormField is inherit from an UITextInput (The Spark TextField and TextEditor for example), a function to set the number of the characters is available:

```swift
func setCounter(on text: String?, limit: Int?)
```

### FormFieldView
Parameters:

#### Parameters:
* `theme`: The current Spark-Theme. [You can always define your own theme.](https://github.com/adevinta/spark-ios/wiki/Theming#your-own-theming)
* `component`: The component (UIControl) is covered by formfield.
* `component`: The component (UIView) is covered by formfield.
* `feedbackState`: The formfield feedback state. 'Default' or 'Error'.(There aren't design changes for Success and Info states. They will be managed with 'Default')
* `title`: An option string. The title is rendered above the component.
* `attributedTitle`: An option attributed string to change label of font or size.
* `description`: An option string. The title is rendered under the component.
* `helper`: An option string. The title is rendered under the component.
* `attributedDescription`: An option attributed string to change helper message of font or size.
* `isTitleRequired`: A bool value to add asterisk character at the end of title for specifying required field.

## Examples
### FormFieldUIView

```swift
let component: UIControl = CheckboxUIView(
let component: UIView = CheckboxUIView(
theme: SparkTheme.shared,
text: "Hello World",
checkedImage: DemoIconography.shared.checkmark.uiImage,
Expand All @@ -50,7 +59,7 @@ let formfield = FormFieldUIView(
component: self.component,
feedbackState: .default,
title: "Agreement",
description: "Your agreement is important to us."
helper: "Your agreement is important to us."
)

view.addSubview(formfield)
Expand Down Expand Up @@ -83,7 +92,7 @@ var body: some View {
},
feedbackState: .default,
title: "Agreement",
description: "Your agreement is important to us.",
helper: "Your agreement is important to us.",
isTitleRequired: false
)
.disabled(false)
Expand Down Expand Up @@ -114,4 +123,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
```

0 comments on commit 6aa5bdf

Please sign in to comment.