Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserName Text Field #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
62 changes: 58 additions & 4 deletions LoginKit/Assets/SignupViewController.xib
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -17,6 +18,7 @@
<outlet property="passwordTextField" destination="8TC-HX-laI" id="iPU-WI-C95"/>
<outlet property="repeatPasswordTextField" destination="irT-Y1-JZM" id="ilC-dQ-PQZ"/>
<outlet property="signupButton" destination="b6U-Bx-8gq" id="HBD-Vf-tcW"/>
<outlet property="userNameTextField" destination="vsM-zW-Uhx" id="3Qf-Ll-WQf"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
<outletCollection property="fields" destination="XRx-9N-yQb" collectionClass="NSMutableArray" id="y1J-ff-yFA"/>
<outletCollection property="fields" destination="gbE-TG-9bX" collectionClass="NSMutableArray" id="DHi-9c-Sb2"/>
Expand Down Expand Up @@ -94,7 +96,7 @@
</connections>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="gbE-TG-9bX" customClass="SkyFloatingLabelTextField" customModule="ILLoginKit" customModuleProvider="target">
<rect key="frame" x="0.0" y="106" width="315" height="50"/>
<rect key="frame" x="0.0" y="79.5" width="315" height="50"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="GqJ-Bx-Rs2"/>
Expand Down Expand Up @@ -145,8 +147,60 @@
<outlet property="delegate" destination="-1" id="vJf-tn-WQo"/>
</connections>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="vsM-zW-Uhx" userLabel="User Name Text Field" customClass="SkyFloatingLabelTextField" customModule="ILLoginKit" customModuleProvider="target">
<rect key="frame" x="0.0" y="158.5" width="315" height="50"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="286" id="bp7-MF-Bsh"/>
<constraint firstAttribute="height" constant="50" id="jnn-ex-Mp4"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" spellCheckingType="no" returnKeyType="next"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="placeholder" value="USER NAME"/>
<userDefinedRuntimeAttribute type="string" keyPath="title" value="User Name"/>
<userDefinedRuntimeAttribute type="number" keyPath="selectedLineHeight">
<real key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="lineHeight">
<real key="value" value="1"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="errorColor">
<color key="value" red="0.94509803920000002" green="0.76862745099999996" blue="0.058823529409999999" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="selectedTitleColor">
<color key="value" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="selectedLineColor">
<color key="value" white="1" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="lineColor">
<color key="value" red="1" green="1" blue="1" alpha="0.69999999999999996" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="tag">
<integer key="value" value="1"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="placeholderColor">
<color key="value" red="1" green="1" blue="1" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="textColor">
<color key="value" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="titleColor">
<color key="value" white="1" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<variation key="default">
<mask key="constraints">
<exclude reference="bp7-MF-Bsh"/>
</mask>
</variation>
<connections>
<outlet property="delegate" destination="-1" id="AON-qk-USh"/>
</connections>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="8TC-HX-laI" customClass="SkyFloatingLabelTextField" customModule="ILLoginKit" customModuleProvider="target">
<rect key="frame" x="0.0" y="211" width="315" height="50"/>
<rect key="frame" x="0.0" y="238" width="315" height="50"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="IEP-g3-a6V"/>
Expand Down
22 changes: 15 additions & 7 deletions LoginKit/Classes/LoginCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ public protocol ConfigurationSource {
var passwordPlaceholder: String { get }
var repeatPasswordPlaceholder: String { get }
var namePlaceholder: String { get }

var userNamePlaceholder: String { get }

var shouldShowSignupButton: Bool { get }
var shouldShowLoginButton: Bool { get }
var shouldShowFacebookButton: Bool { get }
var shouldShowForgotPassword: Bool { get }
var shouldShowUserName: Bool { get }

}

Expand All @@ -56,12 +58,14 @@ public struct DefaultConfiguration: ConfigurationSource {
public var passwordPlaceholder: String
public var repeatPasswordPlaceholder: String
public var namePlaceholder: String

public var userNamePlaceholder: String

public var shouldShowSignupButton: Bool
public var shouldShowLoginButton: Bool
public var shouldShowFacebookButton: Bool
public var shouldShowForgotPassword: Bool

public var shouldShowUserName: Bool

public init(backgroundImage: UIImage = UIImage(),
backgroundImageGradient: Bool = true,
mainLogoImage: UIImage = UIImage(),
Expand All @@ -77,10 +81,12 @@ public struct DefaultConfiguration: ConfigurationSource {
passwordPlaceholder: String = "Password",
repeatPasswordPlaceholder: String = "Repeat Password",
namePlaceholder: String = "Full Name",
userNamePlaceholder: String = "User Name",
shouldShowSignupButton: Bool = true,
shouldShowLoginButton: Bool = true,
shouldShowFacebookButton: Bool = true,
shouldShowForgotPassword: Bool = true) {
shouldShowForgotPassword: Bool = true,
shouldShowUserName: Bool = true) {
self.backgroundImage = backgroundImage
self.backgroundImageGradient = backgroundImageGradient
self.mainLogoImage = mainLogoImage
Expand All @@ -96,10 +102,12 @@ public struct DefaultConfiguration: ConfigurationSource {
self.passwordPlaceholder = passwordPlaceholder
self.repeatPasswordPlaceholder = repeatPasswordPlaceholder
self.namePlaceholder = namePlaceholder
self.userNamePlaceholder = userNamePlaceholder
self.shouldShowSignupButton = shouldShowSignupButton
self.shouldShowLoginButton = shouldShowLoginButton
self.shouldShowFacebookButton = shouldShowFacebookButton
self.shouldShowForgotPassword = shouldShowForgotPassword
self.shouldShowUserName = shouldShowUserName
}

}
Expand Down Expand Up @@ -219,7 +227,7 @@ open class LoginCoordinator {
print("Implement this method in your subclass to handle login.")
}

open func signup(name: String, email: String, password: String) {
open func signup(name: String, userName: String, email: String, password: String) {
print("Implement this method in your subclass to handle signup.")
}

Expand Down Expand Up @@ -298,8 +306,8 @@ extension LoginCoordinator: LoginViewControllerDelegate {

extension LoginCoordinator: SignupViewControllerDelegate {

public func didSelectSignup(_ viewController: UIViewController, email: String, name: String, password: String) {
signup(name: name, email: email, password: password)
public func didSelectSignup(_ viewController: UIViewController, email: String, name: String, userName: String, password: String) {
signup(name: name, userName: userName, email: email, password: password)
}

public func signupDidSelectBack(_ viewController: UIViewController) {
Expand Down
15 changes: 12 additions & 3 deletions LoginKit/Classes/SignupViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Validator

public protocol SignupViewControllerDelegate: class {

func didSelectSignup(_ viewController: UIViewController, email: String, name: String, password: String)
func didSelectSignup(_ viewController: UIViewController, email: String, name: String, userName: String, password: String)
func signupDidSelectBack(_ viewController: UIViewController)

}
Expand Down Expand Up @@ -53,6 +53,7 @@ open class SignupViewController: UIViewController, KeyboardMovable, BackgroundMo
@IBOutlet var fields: [SkyFloatingLabelTextField]!
@IBOutlet weak var emailTextField: SkyFloatingLabelTextField!
@IBOutlet weak var nameTextField: SkyFloatingLabelTextField!
@IBOutlet weak var userNameTextField: SkyFloatingLabelTextField!
@IBOutlet weak var passwordTextField: SkyFloatingLabelTextField!
@IBOutlet weak var repeatPasswordTextField: SkyFloatingLabelTextField!
@IBOutlet weak var backgroundImageView: GradientImageView!
Expand Down Expand Up @@ -95,6 +96,7 @@ open class SignupViewController: UIViewController, KeyboardMovable, BackgroundMo
}

func applyConfiguration() {

view.backgroundColor = configuration.tintColor
signupButton.setTitle(configuration.signupButtonText, for: .normal)

Expand All @@ -112,6 +114,13 @@ open class SignupViewController: UIViewController, KeyboardMovable, BackgroundMo
passwordTextField.errorColor = configuration.errorTintColor
repeatPasswordTextField.placeholder = configuration.repeatPasswordPlaceholder
repeatPasswordTextField.errorColor = configuration.errorTintColor

if(configuration.shouldShowUserName) {
userNameTextField.placeholder = configuration.userNamePlaceholder
userNameTextField.errorColor = configuration.errorTintColor
} else {
userNameTextField.removeFromSuperview()
}
}

func setupFonts() {
Expand All @@ -129,13 +138,13 @@ open class SignupViewController: UIViewController, KeyboardMovable, BackgroundMo
}

@IBAction func didSelectSignup(_ sender: AnyObject) {
guard let email = emailTextField.text, let name = nameTextField.text, let password = passwordTextField.text else {
guard let email = emailTextField.text, let name = nameTextField.text, let userName = userNameTextField.text, let password = passwordTextField.text else {
return
}

signupAttempted = true
validateFields {
delegate?.didSelectSignup(self, email: email, name: name, password: password)
delegate?.didSelectSignup(self, email: email, name: name, userName: userName, password: password)
}
}

Expand Down