     static let offset: CGFloat = 8
 }
 
+enum Type: String {
+    case name = "Imię"
+    case surname = "Nazwisko"
+    case password = "Hasło"
+    case phoneNumber = "Numer Telefonu"
+    case other = "inne"
+}
+
 class TextInputView: UIView, UITextFieldDelegate {
     private let textField = UITextField()
     private let label = UILabel()
+
+    var type: Type = .other {
+        didSet {
+            let typeString = self.type.rawValue
+            switch self.type {
+            case .name:
+                self.textField.placeholder = typeString
+                self.textChecker = CheckName()
+            case .surname:
+                textField.placeholder = typeString
+                self.textChecker = CheckSurname()
+            case .password:
+                textField.placeholder = typeString
+                self.textField.isSecureTextEntry = true
+                self.textChecker = CheckName()
+            case .phoneNumber:
+                self.textField.placeholder = typeString
+                self.textField.keyboardType = .numbersAndPunctuation
+                self.textChecker = CheckPhoneNumber()
+            default: break
+            }
+        }
+    }
 
     var textChecker: TextChecker?
 

        self.addSubview(textField)
        self.addSubview(label)

        self.textField.backgroundColor = .red

        let textFieldLeft: NSLayoutConstraint = NSLayoutConstraint(item: textField, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.left, multiplier: 1, constant: TextInputViewDimensions.margin)
        let textFieldRight: NSLayoutConstraint = NSLayoutConstraint(item: textField, attribute: NSLayoutAttribute.right, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.right, multiplier: 1, constant: -TextInputViewDimensions.margin)
        let textFieldTop: NSLayoutConstraint = NSLayoutConstraint(item: textField, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.top, multiplier: 1, constant: TextInputViewDimensions.margin)
        self.textField.translatesAutoresizingMaskIntoConstraints = false
        self.addConstraints([textFieldLeft, textFieldRight, textFieldTop])
    }

    func checkText() {
        let text = self.textField.text ?? ""
        if let textChecker = self.textChecker {
            if textChecker.check(text: text) {
                //configure for success
                print ("ok")
            } else {
                //configure for error
                print ("nope")
            }
        }
    }

    private func successLayout() {

    }

    private func errorLayout() {

    }


//
//  Copyright © 2017 intive. All rights reserved.
//
import UIKit

protocol TextChecker {
    func check(text: String) -> Bool
}
