Handles some of the base configuration to make creating a UIAlertController with text entry even easier. Plus validation!

Overview

🍅 FancyTextEntryController

UIAlertController titled 'Filter Criteria' with two text fields, 'Author', and 'Subreddit', where the 'Add' button is disabled due to text fields not passing validation.

A simpler/easier API for adding text fields to UIAlertControllers. Not a custom view, just uses good ol' UIAlertController.

  • Easy text field validation. Specify none, or a length range (e.g.: 2 ..< 10) and only text that is between >= 2 and <= 9 characters long will be accepted, or finally a regular expression option that will let you specify a pattern for validation, for instance if you want to allow alphanumerics, but not whitespace. If the text isn't valid, the "Add" button is disabled
  • Less boilerplate code
  • This validation applies to multiple text fields, not only one
  • Makes the font of the text fields a bit larger/easier to see

Example

Create it, add some text fields, then present it.

let alertController = FancyTextEntryController.create(withTitle: "Filter Criteria") { controller in
    let text1 = controller.text(forTextFieldAtIndex: 0)
    let text2 = controller.text(forTextFieldAtIndex: 1)
    
    print("Tapped add with text: \(text1), \(text2)")
}

alertController.addTextField(withPrepopulatedText: nil, placeholder: "Author", validation: .regex(pattern: #"^\w+$"#, lengthRange: 2 ..< 25), keyboardType: .default)
alertController.addTextField(withPrepopulatedText: nil, placeholder: "Subreddit", validation: .regex(pattern: #"^\w+$"#, lengthRange: 2 ..< 25), keyboardType: .default)

present(alertController, animated: true, completion: nil)

Installation

Drag and drop FancyTextEntryController.swift into your project. When the code is this small and simple it becomes yours to raise as your child, no need for package managers!

You might also like...
Currency text field formatter available for UIKit and SwiftUI 💶✏️
Currency text field formatter available for UIKit and SwiftUI 💶✏️

CurrencyText provides lightweight libraries for formating text field text as currency, available for both UIKit and SwiftUI. Its main core, the Curren

ExpandableText 😎 (SwiftUI) Expand the text with the
ExpandableText 😎 (SwiftUI) Expand the text with the "more" button

ExpandableText 😎 (SwiftUI) Expand the text with the "more" button Get Started import SwiftUI import ExpandableText struct ExpandableText_Test: View

Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen in Apple's TV & TestFlight iOS apps.
Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen in Apple's TV & TestFlight iOS apps.

SwiftUI Matched Inline Title Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen i

Changes the color of the label text when the button is pressed and also prints hello to the console
Changes the color of the label text when the button is pressed and also prints hello to the console

MY FIRST APP App Description This app changes the color of the label text when the button is pressed and also prints "hello" to the console. App Walk-

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time
ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time. This is perfect for automatically suggesting the domain as a user types an email address, #hashtag or @alexruperez.

UITextField and UITextView subclasses with placeholders that change into floating labels when the fields are populated with text.
UITextField and UITextView subclasses with placeholders that change into floating labels when the fields are populated with text.

Deprecated Please use JVFloatLabeledTextField instead or feel free to chime in on an issue if you'd like to take over the repo. RPFloatingPlaceholders

UITextField that automatically formats text to display in the currency format
UITextField that automatically formats text to display in the currency format

CurrencyTextField The numbers that the user enters in the field are automatically formatted to display in the dollar amount format. For example, if th

A text view that supports selection and expansion
A text view that supports selection and expansion

The Problem UILabel and UITextView offer unsatisfying support for text selection. Existing solutions like TTTAttributedLabel are great but offer a som

Declarative text styles and streamlined Dynamic Type support for iOS
Declarative text styles and streamlined Dynamic Type support for iOS

StyledText StyledText is a library that simplifies styling dynamic text in iOS applications. Instead of having to use attributed strings every time yo

Owner
Christian Selig
Christian Selig
A passcode entry field for macOS similar to Apple's two-factor authentication field.

DSFPasscodeView A passcode entry field for macOS similar to Apple's two-factor authentication field. About The control is made up of multiple groups o

Darren Ford 10 Nov 12, 2022
An auto-layout base UITextView subclass which automatically grows with user input and can be constrained by maximal and minimal height - all without a single line of code

Deprecated This library is no longer maintained and is deprecated. The repository might be removed at any point in the future. MBAutoGrowingTextView A

Matej Balantič 125 Jan 13, 2022
🏄‍♂️ UITextField-Navigation makes it easier to navigate between UITextFields and UITextViews

' __________________ _______ _________ _______ _________ _______ _ ______ ' |\ /|\__ __/\__ __/( ____ \|\ /

Thanh Pham 446 Nov 24, 2022
AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

Abdelrhman Kamal 79 Jan 3, 2023
A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.

SkyFloatingLabelTextField SkyFloatingLabelTextField is a beautiful, flexible and customizable implementation of the space saving "Float Label Pattern"

Skyscanner 4k Jan 1, 2023
SwiftUI TextEdit View - A proof-of-concept text edit component in SwiftUI & CoreText.

A proof-of-concept text edit component in SwiftUI & CoreText. No UIKit, No AppKit, no UITextView/NSTextView/UITextField involved.

Marcin Krzyzanowski 80 Dec 1, 2022
A SwiftUI TextField with a prompt (or placeholder) that floats above the text field when active or not empty. Requires iOS 15.

FloatingPromptTextField A prompt is the label in a text field that informs the user about the kind of content the text field expects. In a default Tex

Emilio Peláez 43 Nov 3, 2022
Render Markdown text in SwiftUI

MarkdownUI MarkdownUI is a library for rendering Markdown in SwiftUI, fully compliant with the CommonMark Spec. Supported Platforms You can use the Ma

Guille Gonzalez 916 Jan 8, 2023
Focus text field in SwiftUI dynamically and progress through form using iOS keyboard.

Focuser Focuser allows to focus SwiftUI text fields dynamically and implements ability move go through the form using Keyboard for iOS 13 and iOS 14.

Art Technologies 118 Dec 25, 2022
Autocomplete for a text field in SwiftUI using async/await

Autocomplete for a text field in SwiftUI using async/await

Dmytro Anokhin 13 Oct 21, 2022