FormView 2.0.4

FormView 2.0.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2018
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Mohsen Shakiba.



 
Depends on:
CUITools>= 0
AdvancedTableView>= 0
 

FormView 2.0.4

  • By
  • mohsenShakiba

FormView

Summery

This is a library for creating and managing form views

Components

FormView

Core view for showing and managing forms.
This view contains a UIScrollView which wraps a UIStackView inside.
The minimum height of stack view is the same as scroll view in order to allow the loading button to be aligned at the bottom of the view.

Methods & Propeties

  • .edgeInsets: UIEdgeInsets allows you to specify how much the formView places it's subviews from sides. default : UIEdgeInsets(top: 24, left: 16, bottom: 24, right: 16)
  • .rowSpacing: CGFloat indicates the space for items in the stackView, default is 16 this applies to FormItem and accessories
  • .add(formItem: yourFormItem): adds the formItem at the end of formView
  • .insert(formItem: yourFormItem, at: index): inserts the formItem at the specified position
  • .add(accessory: yourAccessory): adds the accessory at the end of formView
  • .insert(formItem: yourAccessory, at: index): inserts the accessory at the specified position

FormViewController

Wraps the FormView inside a UIViewController with adidtional functionalities including keyboard handling
The FormView is accessible throught the formView of the controller

WARNING: do not use this controller with navigation controller

Methods & Propeties

  • .showError(message: String) showes an error message on the top of view for a short period of time
  • .enableHeader(title: String) creates a header with the given title, this will also sets the appropriate edgeInset for the header, so after calling this method don't set the edgeInsets

Form Item

These are the items that can be used in the FormView

Custom FormItem

Each FormItem shoudl a subclass of FormItem.
If the custom class needs to be notified about the selection / deselection, it should also implement the appropriate methods.
but by default the FormItem is a subclass of UIControl so the user can set a selectot to be notifiied of the touch events.

TextFieldFormItem

Contains UITextField for user to write a single line string

  • title: String get / set the title for FormItem
  • value: String get / set the value for formItem
  • prompt: String get / set the prompt value for formItem

TextViewFormItem

Contains UITextView for user to write a multiline string

  • title: String get / set the title for FormItem
  • value: String get / set the value for formItem
  • prompt: String get / set the prompt value for formItem

SelectFormItem

Displays the value which is not editable
Use selector to get the touchUpInside event

  • title: String get / set the title for FormItem
  • value: String get / set the value for formItem
  • prompt: String get / set the prompt value for formItem

SelectImageFormItem

Displays the image which is selected by user
The image that is diplayed has 100 px size

  • set(image: UIImage) displays the given image
  • removeImage() removed the image and shows the default image

Accessories

FormLoadingButton

Wraps a LoadingButton
use add target for touchUpInside event

  • isLoading: Bool indicates wheter the button is loading
  • isEnabled: Bool indicates wheter the button is enabled
  • loadingButton: LoadingButton access to the original loadingButton

Author

mohsen shakiba, [email protected]

License

FormView is available under the MIT license. See the LICENSE file for more info.