Skip to content

Commit 8a1a981

Browse files
authored
Merge pull request #9 from ahmetsina/development
Global and spesific UI configurations added
2 parents 64da5bb + 0d472ba commit 8a1a981

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

ALFormInput.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'ALFormInput'
11-
s.version = '0.2.0'
11+
s.version = '0.2.1'
1212
s.summary = 'Commonly used form inputs in our projects'
1313

1414
s.homepage = 'https://github.com/applogistdev/ALFormInput'

ALFormInput/Classes/ALValidatableConfig.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import UIKit
99
import SkyFloatingLabelTextField
1010

11-
public class ALTextFieldConfig {
12-
static let shared = ALTextFieldConfig()
11+
public class ALTextFieldConfig: NSObject {
12+
public static let shared = ALTextFieldConfig()
1313

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

7575
public var isIconVisible: Bool = false
7676

77-
public init () {}
77+
public override init () {}
7878
}

ALFormInput/Classes/ALValidatableTextField.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import FontAwesome_swift
1616
public class ALValidatableTextField: SkyFloatingLabelTextFieldWithIcon {
1717

1818
private let validator = Validator()
19-
private var config = ALTextFieldConfig()
19+
private var config = ALTextFieldConfig.shared
2020
private var type = ALValidatableTextFieldType.optional
2121

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

111111
public func setConfig(_ config: ALTextFieldConfig = ALTextFieldConfig()) {
112112
self.config = config
113+
setupDefaultLook()
113114
}
114115

115116
public func setTypesAndRules(_ type: ALValidatableTextFieldType = .optional,

Example/ALFormInput/AppDelegate.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1515

1616
func application(_ application: UIApplication,
1717
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
18+
19+
// Set global configurations like below for all ALValidatableTextField's
20+
ALTextFieldConfig.shared.errorColor = .red
21+
1822
return true
1923
}
2024

Example/ALFormInput/ViewController.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,24 @@ class ViewController: UIViewController {
4343
}
4444

4545
private func setupTextFields() {
46+
47+
4648
emailTextField.setTypesAndRules(.email)
4749
emailTextField.fontAwesomeImage = .envelope
4850
passwordTextField.setTypesAndRules(.password)
4951
nameTextField.setTypesAndRules(.name)
5052
nameTextField.fontAwesomeImage = .user
5153
surnameTextfield.setTypesAndRules(.surname)
5254
surnameTextfield.fontAwesomeImage = .user
55+
56+
// Set spesific configuration
57+
let config = ALTextFieldConfig()
58+
config.errorColor = .purple
59+
phoneTextField.setConfig(config)
60+
5361
phoneTextField.setTypesAndRules(.phoneNumber)
5462
phoneTextField.fontAwesomeImage = .mobileAlt
5563
phoneTextField.fontAwesomeStyle = .solid
56-
5764
phoneTextField.setFormattedPhoneNumber("+905318888741")
5865

5966

0 commit comments

Comments
 (0)