Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ALFormInput.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'ALFormInput'
s.version = '0.2.0'
s.version = '0.2.1'
s.summary = 'Commonly used form inputs in our projects'

s.homepage = 'https://github.com/applogistdev/ALFormInput'
Expand Down
6 changes: 3 additions & 3 deletions ALFormInput/Classes/ALValidatableConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import UIKit
import SkyFloatingLabelTextField

public class ALTextFieldConfig {
static let shared = ALTextFieldConfig()
public class ALTextFieldConfig: NSObject {
public static let shared = ALTextFieldConfig()

// MARK: - Fonts
public var titleFont : UIFont = UIFont.systemFont(ofSize: 13, weight: .semibold)
Expand Down Expand Up @@ -74,5 +74,5 @@ public class ALTextFieldConfig {

public var isIconVisible: Bool = false

public init () {}
public override init () {}
}
3 changes: 2 additions & 1 deletion ALFormInput/Classes/ALValidatableTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import FontAwesome_swift
public class ALValidatableTextField: SkyFloatingLabelTextFieldWithIcon {

private let validator = Validator()
private var config = ALTextFieldConfig()
private var config = ALTextFieldConfig.shared
private var type = ALValidatableTextFieldType.optional

private lazy var phoneNumberKit = PhoneNumberKit()
Expand Down Expand Up @@ -110,6 +110,7 @@ public class ALValidatableTextField: SkyFloatingLabelTextFieldWithIcon {

public func setConfig(_ config: ALTextFieldConfig = ALTextFieldConfig()) {
self.config = config
setupDefaultLook()
}

public func setTypesAndRules(_ type: ALValidatableTextFieldType = .optional,
Expand Down
4 changes: 4 additions & 0 deletions Example/ALFormInput/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// Set global configurations like below for all ALValidatableTextField's
ALTextFieldConfig.shared.errorColor = .red

return true
}

Expand Down
9 changes: 8 additions & 1 deletion Example/ALFormInput/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,24 @@ class ViewController: UIViewController {
}

private func setupTextFields() {


emailTextField.setTypesAndRules(.email)
emailTextField.fontAwesomeImage = .envelope
passwordTextField.setTypesAndRules(.password)
nameTextField.setTypesAndRules(.name)
nameTextField.fontAwesomeImage = .user
surnameTextfield.setTypesAndRules(.surname)
surnameTextfield.fontAwesomeImage = .user

// Set spesific configuration
let config = ALTextFieldConfig()
config.errorColor = .purple
phoneTextField.setConfig(config)

phoneTextField.setTypesAndRules(.phoneNumber)
phoneTextField.fontAwesomeImage = .mobileAlt
phoneTextField.fontAwesomeStyle = .solid

phoneTextField.setFormattedPhoneNumber("+905318888741")


Expand Down