Add validations to your text fields, Group them together and navigate through them via keyboard's return button and accessory view.

Related tags

Layout TFManager
Overview

TFManager

Let's say you have multiple UITextFields to get data from users. You need to handle each field keyboard's return key and add an accessory view to the keyboard for navigating through fields. TFManager will do this for you in just one line of code! And if you want more you can add validation rules to the text fields and check if they're valid or not.

iOS SPM MIT

Navigate

Installation

Ready for use on iOS and iPadOS 11+.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Once you have your Swift package set up, adding as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/abspr/TFManager", .upToNextMajor(from: "1.1.0"))
]

CocoaPods:

CocoaPods is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your Podfile:

pod 'TFManager'

Manually

If you prefer not to use any of dependency managers, you can integrate manually. Put Sources/TFManager folder in your Xcode project. Make sure to enable Copy items if needed and Create groups.

Basic Usage

  1. Create an instance of TFManager in your viewController
var fieldsManager = TFManager()
  1. Add your textFields to it:
fieldsManager.add([nameField, mailField, ageField])
  1. There is no more steps 😯

Validate All Fields

You can add rules to your UITextFields and ask TFManager to apply validation to all of child fields:

  1. Change your textField class to ValidatableField.

  1. Then you can call validate() method on your TFManager instance.
let result = fieldsManager.validate()
result.forEach { (invalidField, validationResult) in
    invalidField.textColor = .systemRed
    print(validationResult.message)
}

💡 You can set TFManager's delegate and use its methods to get notified which textField is become active or its text is changing:

fieldsManager.delegate = self

extension ViewController: TFManagerDelegate {
    func textDidChange(_ textField: UITextField, validationResult: ValidationResult?) {
        guard let validationResult = validationResult else { return }
        textField.textColor = validationResult.isValid ? .label : .systemRed
    }
}

💡 You also can subclass ValidatableField and customize your textField. Override didFailValidation(_:) and didPass() methods to handle valid/invalid states (eg: show/hide the error label)

Rules

TFManager comes with set of rules (TextRulesSet) and you can add them to any ValidatableField:

ageField.rulesRepo.add(TextRulesSet.numbersOnly())
ageField.rulesRepo.add(TextRulesSet.minLenght(1))
ageField.rulesRepo.add(TextRulesSet.maxLenght(2))

💡 You can have your own rules too. Just create a struct and implement TextRule:

struct YourRule: TextRule {
    var message: String

    func validate(_ text: String) -> Bool {
        // code
    }
}

Contact

email : [email protected]

License

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

You might also like...
LayoutKit is a fast view layout library for iOS, macOS, and tvOS.
LayoutKit is a fast view layout library for iOS, macOS, and tvOS.

🚨 UNMAINTAINED 🚨 This project is no longer used by LinkedIn and is currently unmaintained. LayoutKit is a fast view layout library for iOS, macOS, a

MyLayout is a simple and easy objective-c framework for iOS view layout
MyLayout is a simple and easy objective-c framework for iOS view layout

MyLayout is a powerful iOS UI framework implemented by Objective-C. It integrates the functions with Android Layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,PathLayout,GridLayout,LayoutSizeClass to build your App 自动布局 UIView UITableView UICollectionView RTL

Boardy - Boardy serves as a digital bulletin board on iOS platforms built for high schoolers to share and view information from others in a convenient manner.

Boardy Boardy serves as a lightweight digital bulletin board on iOS platforms built for high schoolers to share and view information from others in a

Horizontal and Vertical collection view for infinite scrolling that was designed to be used in SwiftUI
Horizontal and Vertical collection view for infinite scrolling that was designed to be used in SwiftUI

InfiniteScroller Example struct ContentView: View { @State var selected: Int = 1 var body: some View { InfiniteScroller(direction: .ve

SwiftLayout - View hierarchy and autolayout DSL library

SwiftLayout view hierarchy and autolayout DSL library goal 뷰의 계층구조와 constraint 관

A SwiftUI proof-of-concept, and some sleight-of-hand, which adds rain to a view's background
A SwiftUI proof-of-concept, and some sleight-of-hand, which adds rain to a view's background

Atmos A SwiftUI proof-of-concept, and some sleight-of-hand, which adds rain to a view's background. "Ima use this in my app..." Introducing Metal to S

A SwiftUI ScrollView that runs a callback when subviews are scrolled in and out of view.

VisibilityTrackingScrollView This package provides a variant of ScrollView that you can use to track whether views inside it are actually visible. Usa

Flow layout / tag cloud / collection view in SwiftUI.
Flow layout / tag cloud / collection view in SwiftUI.

SwiftUIFlowLayout A Flow Layout is a container that orders its views sequentially, breaking into a new "line" according to the available width of the

iOS simple project to create half-screen modal view controller with pan
iOS simple project to create half-screen modal view controller with pan

Simple Half-screen view controller, draggable and less code (learning purpose)

Releases(1.1.0)
Owner
Hosein Abbaspour
Hosein Abbaspour
LoadingButtton - Add button extendded from LoadingButton in the view and make it center horizontally

LoadingButtton Usage/Examples Add button extendded from LoadingButton in the vie

Alireza 1 Jan 8, 2022
Bootcamp1000 - Practical application of a design taken from the Dribble website -> For our group in WhatsApp

Bootcamp1000 New Challenge Practical application of a design taken from the Drib

ibrahim almutiry 1 Jun 24, 2022
Проект команды DreamTeam по курсу "Разработка приложений на iOS" VK Group (весна 2022)

2022_1_DreamTeam Проект команды DreamTeam по курсу "Разработка приложений на iOS" VK Group (весна 2022) meet2guide Программа для выбора экскурсии и об

null 4 Apr 7, 2022
Make your notification banners smaller and add some color to them

Liddell Liddell notification banners Installation Add this repository to your Package Manager: https://repo.litten.love Install Liddell Compiling Depe

alexandra 34 Dec 22, 2022
Launches unc0ver in a way that works when it's installed through TrollStore

u0Launcher Normally when you install unc0ver through TrollStore and try to jailbreak with it, it fails with a "Failed to disable codesigning" error be

Lars Fröder 55 Dec 21, 2022
⌨️ KeyboardToolbar - Add tools above your keyboard with iOS-like keyboard buttons

KeyboardToolbar ?? Overview Use KeyboardToolbar to add tools as an input accessory view to a UITextField, UITextView, or any other view conforming to

Simon Støvring 197 Dec 21, 2022
IOS-App4 - Core Data add new data and update data

iOS-App4 Core Data add new data and update data.

null 0 Jan 8, 2022
Enables you to hide ur UIViews and make them screen/screen shot proof. objective c/c++ only

SecureView Enables you to hide ur UIViews and make them screen/screen shot proof. objective c/c++ only Usage UIWindow* mainWindow; - (void) setup {

Red16 6 Oct 13, 2022
Modern-collection-view - Modern collection view for swift

Modern collection view Sample application demonstrating the use of collection vi

Nitanta Adhikari 1 Jan 24, 2022
LayoutKit is a fast view layout library for iOS, macOS, and tvOS.

?? UNMAINTAINED ?? This project is no longer used by LinkedIn and is currently unmaintained. LayoutKit is a fast view layout library for iOS, macOS, a

LinkedIn's Attic 3.2k Dec 27, 2022