From 9ef5fe1cf5c58a16d1dee65a55c70a2eed8a862d Mon Sep 17 00:00:00 2001 From: Ramiro Ramirez Date: Wed, 11 Jan 2017 19:37:01 +0100 Subject: [PATCH 01/12] Adding new variable to make tintColor customise. Lots of improvements in code quality. STRATODRVE-1146 --- .../PasscodeLock/ChangePasscodeState.swift | 28 +++--- .../PasscodeLock/ConfirmPasscodeState.swift | 26 ++--- .../PasscodeLock/EnterPasscodeState.swift | 32 +++---- PasscodeLock/PasscodeLock/PasscodeLock.swift | 10 +- .../PasscodeLock/SetPasscodeState.swift | 28 +++--- PasscodeLock/PasscodeLockPresenter.swift | 8 +- PasscodeLock/PasscodeLockViewController.swift | 57 +++++++---- .../Protocols/PasscodeLockStateType.swift | 11 ++- PasscodeLock/Protocols/PasscodeLockType.swift | 2 +- PasscodeLock/Views/PasscodeLockView.xib | 12 ++- PasscodeLock/Views/PasscodeSignButton.swift | 96 ++----------------- .../Views/PasscodeSignPlaceholderView.swift | 73 +++++++------- PasscodeLockDemo/AppDelegate.swift | 6 +- .../PasscodeSettingsViewController.swift | 6 +- 14 files changed, 170 insertions(+), 225 deletions(-) diff --git a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift index da097c7b..9c3dc35e 100644 --- a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift @@ -10,31 +10,31 @@ import Foundation struct ChangePasscodeState: PasscodeLockStateType { - let title: String - let description: String + let title : String + let description : String let isCancellableAction = true - var isTouchIDAllowed = false - - init(stringsToShow: StringsToBeDisplayed?) { - - title = (stringsToShow?.passcodeLockChangeTitle ?? localizedStringFor("PasscodeLockChangeTitle", comment: "Change passcode title")) - description = (stringsToShow?.passcodeLockChangeDescription ?? localizedStringFor("PasscodeLockChangeDescription", comment: "Change passcode description")) + var isTouchIDAllowed = false + var tintColor : UIColor? + + init(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + + let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + self.title = (stringsToShow?.passcodeLockChangeTitle ?? localizedStringFor("PasscodeLockChangeTitle", comment: "Change passcode title")) + self.description = (stringsToShow?.passcodeLockChangeDescription ?? localizedStringFor("PasscodeLockChangeDescription", comment: "Change passcode description")) + self.tintColor = (tintColor ?? defaultColor) } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?) { + func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { guard let currentPasscode = lock.repository.passcode else { return } - if passcode == currentPasscode { - - let nextState = SetPasscodeState(stringsToShow: stringsToShow) - + if (passcode == currentPasscode) { + let nextState = SetPasscodeState(stringsToShow: stringsToShow, tintColor: tintColor) lock.changeStateTo(nextState) } else { - lock.delegate?.passcodeLockDidFail(lock) } } diff --git a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift index 22f94ad2..9851a3b2 100644 --- a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift @@ -10,24 +10,26 @@ import Foundation struct ConfirmPasscodeState: PasscodeLockStateType { - let title: String - let description: String + let title : String + let description : String let isCancellableAction = true - var isTouchIDAllowed = false + var isTouchIDAllowed = false + var tintColor : UIColor? private var passcodeToConfirm: [String] - init(passcode: [String], stringsToShow: StringsToBeDisplayed?) { - - passcodeToConfirm = passcode - title = (stringsToShow?.passcodeLockConfirmTitle ?? localizedStringFor("PasscodeLockConfirmTitle", comment: "Confirm passcode title")) - description = (stringsToShow?.passcodeLockConfirmDescription ?? localizedStringFor("PasscodeLockConfirmDescription", comment: "Confirm passcode description")) + init(passcode: [String], stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + + let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + self.passcodeToConfirm = passcode + self.title = (stringsToShow?.passcodeLockConfirmTitle ?? localizedStringFor("PasscodeLockConfirmTitle", comment: "Confirm passcode title")) + self.description = (stringsToShow?.passcodeLockConfirmDescription ?? localizedStringFor("PasscodeLockConfirmDescription", comment: "Confirm passcode description")) + self.tintColor = (tintColor ?? defaultColor) } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?) { + func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { - if passcode == passcodeToConfirm { - + if (passcode == passcodeToConfirm) { lock.repository.savePasscode(passcode) lock.delegate?.passcodeLockDidSucceed(lock) @@ -35,9 +37,7 @@ struct ConfirmPasscodeState: PasscodeLockStateType { let mismatchTitle = (stringsToShow?.passcodeLockMismatchTitle ?? localizedStringFor("PasscodeLockMismatchTitle", comment: "Passcode mismatch title")) let mismatchDescription = (stringsToShow?.passcodeLockMismatchDescription ?? localizedStringFor("PasscodeLockMismatchDescription", comment: "Passcode mismatch description")) - let nextState = SetPasscodeState(title: mismatchTitle, description: mismatchDescription) - lock.changeStateTo(nextState) lock.delegate?.passcodeLockDidFail(lock) } diff --git a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift index fc006f05..1672a1c0 100644 --- a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift @@ -12,37 +12,37 @@ public let PasscodeLockIncorrectPasscodeNotification = "passcode.lock.incorrect. struct EnterPasscodeState: PasscodeLockStateType { - let title: String - let description: String - let isCancellableAction: Bool - var isTouchIDAllowed = true + let title : String + let description : String + let isCancellableAction : Bool + var isTouchIDAllowed = true + var tintColor : UIColor? private var inccorectPasscodeAttempts = 0 private var isNotificationSent = false - init(allowCancellation: Bool = false, stringsToShow: StringsToBeDisplayed?) { + init(allowCancellation: Bool = false, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { - isCancellableAction = allowCancellation - title = (stringsToShow?.passcodeLockEnterTitle ?? localizedStringFor("PasscodeLockEnterTitle", comment: "Enter passcode title")) - description = (stringsToShow?.passcodeLockEnterDescription ?? localizedStringFor("PasscodeLockEnterDescription", comment: "Enter passcode description")) + let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + self.isCancellableAction = allowCancellation + self.title = (stringsToShow?.passcodeLockEnterTitle ?? localizedStringFor("PasscodeLockEnterTitle", comment: "Enter passcode title")) + self.description = (stringsToShow?.passcodeLockEnterDescription ?? localizedStringFor("PasscodeLockEnterDescription", comment: "Enter passcode description")) + self.tintColor = (tintColor ?? defaultColor) } - mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?) { + mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { guard let currentPasscode = lock.repository.passcode else { return } - if passcode == currentPasscode { - + if (passcode == currentPasscode) { lock.delegate?.passcodeLockDidSucceed(lock) } else { inccorectPasscodeAttempts += 1 - - if inccorectPasscodeAttempts >= lock.configuration.maximumInccorectPasscodeAttempts { - + if (inccorectPasscodeAttempts >= lock.configuration.maximumInccorectPasscodeAttempts) { postNotification() } @@ -55,9 +55,7 @@ struct EnterPasscodeState: PasscodeLockStateType { guard !isNotificationSent else { return } let center = NSNotificationCenter.defaultCenter() - center.postNotificationName(PasscodeLockIncorrectPasscodeNotification, object: nil) - - isNotificationSent = true + self.isNotificationSent = true } } diff --git a/PasscodeLock/PasscodeLock/PasscodeLock.swift b/PasscodeLock/PasscodeLock/PasscodeLock.swift index f147932f..4537930f 100644 --- a/PasscodeLock/PasscodeLock/PasscodeLock.swift +++ b/PasscodeLock/PasscodeLock/PasscodeLock.swift @@ -41,15 +41,15 @@ public class PasscodeLock: PasscodeLockType { self.configuration = configuration } - public func addSign(sign: String) { + public func addSign(sign: String, stringsToBeDisplayed: StringsToBeDisplayed?, tintColor: UIColor?) { passcode.append(sign) delegate?.passcodeLock(self, addedSignAtIndex: passcode.count - 1) - if passcode.count >= configuration.passcodeLength { - - lockState.acceptPasscode(passcode, fromLock: self, stringsToShow: nil) - passcode.removeAll(keepCapacity: true) + if (passcode.count >= configuration.passcodeLength) { + + self.lockState.acceptPasscode(self.passcode, fromLock: self, stringsToShow: stringsToBeDisplayed, tintColor: tintColor) + self.passcode.removeAll(keepCapacity: true) } } diff --git a/PasscodeLock/PasscodeLock/SetPasscodeState.swift b/PasscodeLock/PasscodeLock/SetPasscodeState.swift index 3c1be804..d244fa95 100644 --- a/PasscodeLock/PasscodeLock/SetPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/SetPasscodeState.swift @@ -10,27 +10,31 @@ import Foundation struct SetPasscodeState: PasscodeLockStateType { - let title: String - let description: String + let title : String + let description : String let isCancellableAction = true - var isTouchIDAllowed = false + var isTouchIDAllowed = false + var tintColor : UIColor? - init(title: String, description: String) { - + init(title: String, description: String, tintColor: UIColor?) { + + let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) self.title = title self.description = description + self.tintColor = (tintColor ?? defaultColor) } - init(stringsToShow: StringsToBeDisplayed?) { - - title = (stringsToShow?.passcodeLockSetTitle ?? localizedStringFor("PasscodeLockSetTitle", comment: "Set passcode title")) - description = (stringsToShow?.passcodeLockSetDescription ?? localizedStringFor("PasscodeLockSetDescription", comment: "Set passcode description")) + init(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + + let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + self.title = (stringsToShow?.passcodeLockSetTitle ?? localizedStringFor("PasscodeLockSetTitle", comment: "Set passcode title")) + self.description = (stringsToShow?.passcodeLockSetDescription ?? localizedStringFor("PasscodeLockSetDescription", comment: "Set passcode description")) + self.tintColor = (tintColor ?? defaultColor) } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?) { + func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { - let nextState = ConfirmPasscodeState(passcode: passcode, stringsToShow: stringsToShow) - + let nextState = ConfirmPasscodeState(passcode: passcode, stringsToShow: stringsToShow, tintColor: tintColor) lock.changeStateTo(nextState) } } diff --git a/PasscodeLock/PasscodeLockPresenter.swift b/PasscodeLock/PasscodeLockPresenter.swift index a4a65c33..40c13e50 100644 --- a/PasscodeLock/PasscodeLockPresenter.swift +++ b/PasscodeLock/PasscodeLockPresenter.swift @@ -75,14 +75,14 @@ public class PasscodeLockPresenter { passcodeLockVC = viewController } - public convenience init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType, stringsToShow: StringsToBeDisplayed?) { + public convenience init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { - let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: configuration, stringsToShow: stringsToShow) + let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: configuration, stringsToShow: stringsToShow, tintColor: tintColor) self.init(mainWindow: window, configuration: configuration, viewController: passcodeLockVC) } - public func presentPasscodeLock(withImage image: UIImage? = nil, andStrings stringsToShow: StringsToBeDisplayed? = nil, dismissCompletionBlock: (() -> Void)? = nil) { + public func presentPasscodeLock(withImage image: UIImage? = nil, andStrings stringsToShow: StringsToBeDisplayed? = nil, tintColor: UIColor?, dismissCompletionBlock: (() -> Void)? = nil) { guard passcodeConfiguration.repository.hasPasscode else { return } guard !isPasscodePresented else { return } @@ -95,7 +95,7 @@ public class PasscodeLockPresenter { mainWindow?.windowLevel = 1 mainWindow?.endEditing(true) - let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: passcodeConfiguration, stringsToShow: stringsToShow) + let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: passcodeConfiguration, stringsToShow: stringsToShow, tintColor: tintColor) if (image != nil) { passcodeLockVC.customImage = image } diff --git a/PasscodeLock/PasscodeLockViewController.swift b/PasscodeLock/PasscodeLockViewController.swift index f050af97..32a5c8b7 100644 --- a/PasscodeLock/PasscodeLockViewController.swift +++ b/PasscodeLock/PasscodeLockViewController.swift @@ -16,17 +16,18 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg case ChangePasscode case RemovePasscode - func getState(stringsToShow: StringsToBeDisplayed?) -> PasscodeLockStateType { + func getState(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) -> PasscodeLockStateType { switch self { - case .EnterPasscode: return EnterPasscodeState(stringsToShow: stringsToShow) - case .SetPasscode: return SetPasscodeState(stringsToShow: stringsToShow) - case .ChangePasscode: return ChangePasscodeState(stringsToShow: stringsToShow) - case .RemovePasscode: return EnterPasscodeState(allowCancellation: true, stringsToShow: stringsToShow) + case .EnterPasscode: return EnterPasscodeState(stringsToShow: stringsToShow, tintColor: tintColor) + case .SetPasscode: return SetPasscodeState(stringsToShow: stringsToShow, tintColor: tintColor) + case .ChangePasscode: return ChangePasscodeState(stringsToShow: stringsToShow, tintColor: tintColor) + case .RemovePasscode: return EnterPasscodeState(allowCancellation: true, stringsToShow: stringsToShow, tintColor: tintColor) } } } + @IBOutlet public var passcodeButtons : [PasscodeSignButton]? @IBOutlet public weak var titleLabel : UILabel? @IBOutlet public weak var customImageView : UIImageView? @IBOutlet public weak var descriptionLabel : UILabel? @@ -48,13 +49,15 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg internal var isPlaceholdersAnimationCompleted = true private var shouldTryToAuthenticateWithBiometrics = true + private var customTintColor : UIColor? // MARK: - Initializers - public init(state: PasscodeLockStateType, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true, stringToShow: StringsToBeDisplayed?) { + public init(state: PasscodeLockStateType, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true, stringToShow: StringsToBeDisplayed?, tintColor: UIColor?) { self.stringsToShow = stringToShow self.animateOnDismiss = animateOnDismiss + self.customTintColor = (tintColor ?? UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1)) passcodeConfiguration = configuration passcodeLock = PasscodeLock(state: state, configuration: configuration) let nibName = "PasscodeLockView" @@ -65,9 +68,9 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg notificationCenter = NSNotificationCenter.defaultCenter() } - public convenience init(state: LockState, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true, stringsToShow: StringsToBeDisplayed?) { + public convenience init(state: LockState, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { - self.init(state: state.getState(stringsToShow), configuration: configuration, animateOnDismiss: animateOnDismiss, stringToShow: stringsToShow) + self.init(state: state.getState(stringsToShow, tintColor: tintColor), configuration: configuration, animateOnDismiss: animateOnDismiss, stringToShow: stringsToShow, tintColor: tintColor) } public required init(coder aDecoder: NSCoder) { @@ -82,10 +85,21 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg public override func viewDidLoad() { super.viewDidLoad() - - updatePasscodeView() - setupEvents() + + self.configurePasscodeButtons() + self.updatePasscodeView() + self.setupEvents() } + + private func configurePasscodeButtons() { + + self.placeholders.forEach { (passcodePlaceHolder: PasscodeSignPlaceholderView) in + if let _customTintColor = self.customTintColor { + passcodePlaceHolder.activeColor = _customTintColor + } + passcodePlaceHolder.setupView() + } + } public override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) @@ -97,11 +111,17 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg internal func updatePasscodeView() { - customImageView?.image = self.customImage - titleLabel?.text = passcodeLock.state.title - descriptionLabel?.text = passcodeLock.state.description - touchIDButton?.hidden = !passcodeLock.isTouchIDAllowed - touchIDButton?.setTitle((self.stringsToShow?.useTouchID ?? localizedStringFor("UseTouchId", comment: "")), forState: .Normal) + self.customImageView?.image = self.customImage + self.titleLabel?.text = passcodeLock.state.title + self.titleLabel?.textColor = self.customTintColor + self.descriptionLabel?.text = passcodeLock.state.description + self.touchIDButton?.hidden = !passcodeLock.isTouchIDAllowed + self.touchIDButton?.setTitle((self.stringsToShow?.useTouchID ?? localizedStringFor("UseTouchId", comment: "")), forState: .Normal) + + self.passcodeButtons?.forEach({ (passcodeButton: PasscodeSignButton) in + passcodeButton.tintColor = self.customTintColor + }) + self.cancelDeleteButtonSetup() } @@ -137,7 +157,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg return } - passcodeLock.addSign(sender.passcodeSign) + passcodeLock.addSign(sender.passcodeSign, stringsToBeDisplayed: self.stringsToShow, tintColor: customTintColor) } @IBAction func cancelButtonTap(sender: UIButton) { @@ -222,7 +242,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg guard (index < placeholders.count && index >= 0) else { return } - + placeholders[index].animateState(state) } @@ -269,6 +289,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg let cancelButton = ((self.passcodeLock.isPincodeEmpty == true) ? (self.stringsToShow?.cancel ?? localizedStringFor("Cancel", comment: "")) : (self.stringsToShow?.delete ?? localizedStringFor("Delete", comment: ""))) let titleForButton = ((self.passcodeLock.state.isCancellableAction == true) ? cancelButton : (self.stringsToShow?.delete ?? localizedStringFor("Delete", comment: ""))) self.cancelDeleteButton?.setTitle(titleForButton, forState: .Normal) + self.cancelDeleteButton?.setTitleColor(self.customTintColor, forState: .Normal) if (self.passcodeLock.isPincodeEmpty == true && self.passcodeLock.state.isCancellableAction == false) { self.cancelDeleteButton?.enabled = false diff --git a/PasscodeLock/Protocols/PasscodeLockStateType.swift b/PasscodeLock/Protocols/PasscodeLockStateType.swift index 8598c1f2..3fad2299 100644 --- a/PasscodeLock/Protocols/PasscodeLockStateType.swift +++ b/PasscodeLock/Protocols/PasscodeLockStateType.swift @@ -10,10 +10,11 @@ import Foundation public protocol PasscodeLockStateType { - var title: String {get} - var description: String {get} - var isCancellableAction: Bool {get} - var isTouchIDAllowed: Bool {get} + var title : String {get} + var description : String {get} + var isCancellableAction : Bool {get} + var isTouchIDAllowed : Bool {get} + var tintColor : UIColor? {get} - mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?) + mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) } diff --git a/PasscodeLock/Protocols/PasscodeLockType.swift b/PasscodeLock/Protocols/PasscodeLockType.swift index cd00a4c6..3a21729e 100644 --- a/PasscodeLock/Protocols/PasscodeLockType.swift +++ b/PasscodeLock/Protocols/PasscodeLockType.swift @@ -17,7 +17,7 @@ public protocol PasscodeLockType { var isTouchIDAllowed: Bool {get} var isPincodeEmpty: Bool {get} - func addSign(sign: String) + func addSign(sign: String, stringsToBeDisplayed: StringsToBeDisplayed?, tintColor: UIColor?) func removeSign() func changeStateTo(state: PasscodeLockStateType) func authenticateWithBiometrics(stringsToShow: StringsToBeDisplayed?) diff --git a/PasscodeLock/Views/PasscodeLockView.xib b/PasscodeLock/Views/PasscodeLockView.xib index ed21f2c0..694aaf33 100644 --- a/PasscodeLock/Views/PasscodeLockView.xib +++ b/PasscodeLock/Views/PasscodeLockView.xib @@ -1,5 +1,5 @@ - + @@ -23,6 +23,16 @@ + + + + + + + + + + diff --git a/PasscodeLock/Views/PasscodeSignButton.swift b/PasscodeLock/Views/PasscodeSignButton.swift index 97df2716..ceb08817 100644 --- a/PasscodeLock/Views/PasscodeSignButton.swift +++ b/PasscodeLock/Views/PasscodeSignButton.swift @@ -8,96 +8,14 @@ import UIKit -//@IBDesignable public class PasscodeSignButton: UIButton { -// @IBInspectable public var passcodeSign: String = "1" - -// @IBInspectable -// public var borderColor: UIColor = UIColor.whiteColor() { -// didSet { -// setupView() -// } -// } -// -// @IBInspectable -// public var borderRadius: CGFloat = 30 { -// didSet { -// setupView() -// } -// } -// -// @IBInspectable -// public var highlightBackgroundColor: UIColor = UIColor.clearColor() { -// didSet { -// setupView() -// } -// } -// -// public override init(frame: CGRect) { -// -// super.init(frame: frame) -// -// setupView() -// setupActions() -// } -// -// public required init?(coder aDecoder: NSCoder) { -// -// super.init(coder: aDecoder) -// -// setupActions() -// } -// -// public override func intrinsicContentSize() -> CGSize { -// -// return CGSizeMake(60, 60) -// } -// -// private var defaultBackgroundColor = UIColor.clearColor() -// -// private func setupView() { -// -// layer.borderWidth = 1 -// layer.cornerRadius = layer.frame.height/2 -// layer.borderColor = borderColor.CGColor -// -// if let backgroundColor = backgroundColor { -// -// defaultBackgroundColor = backgroundColor -// } -// } -// -// private func setupActions() { -// -// addTarget(self, action: #selector(self.handleTouchDown), forControlEvents: .TouchDown) -// addTarget(self, action: #selector(self.handleTouchUp), forControlEvents: [.TouchUpInside, .TouchDragOutside, .TouchCancel]) -// } -// -// func handleTouchDown() { -// -// animateBackgroundColor(highlightBackgroundColor) -// } -// -// func handleTouchUp() { -// -// animateBackgroundColor(defaultBackgroundColor) -// } -// -// private func animateBackgroundColor(color: UIColor) { -// -// UIView.animateWithDuration( -// 0.3, -// delay: 0.0, -// usingSpringWithDamping: 1, -// initialSpringVelocity: 0.0, -// options: [.AllowUserInteraction, .BeginFromCurrentState], -// animations: { -// -// self.backgroundColor = color -// }, -// completion: nil -// ) -// } + public var customTintColor: UIColor? = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + + public override func awakeFromNib() { + super.awakeFromNib() + + self.tintColor = customTintColor + } } diff --git a/PasscodeLock/Views/PasscodeSignPlaceholderView.swift b/PasscodeLock/Views/PasscodeSignPlaceholderView.swift index 42a28770..b769d230 100644 --- a/PasscodeLock/Views/PasscodeSignPlaceholderView.swift +++ b/PasscodeLock/Views/PasscodeSignPlaceholderView.swift @@ -16,28 +16,28 @@ public class PasscodeSignPlaceholderView: UIView { case Active case Error } - - @IBInspectable - public var inactiveColor: UIColor = UIColor.whiteColor() { - didSet { - setupView() - } - } - - @IBInspectable - public var activeColor: UIColor = UIColor.grayColor() { - didSet { - setupView() - } - } - - @IBInspectable - public var errorColor: UIColor = UIColor.redColor() { - didSet { - setupView() - } - } - + + @IBInspectable + public var inactiveColor: UIColor = UIColor.whiteColor() { + didSet { + self.setupView() + } + } + + @IBInspectable + public var activeColor: UIColor = UIColor.grayColor() { + didSet { + self.setupView() + } + } + + @IBInspectable + public var errorColor: UIColor = UIColor.redColor() { + didSet { + self.setupView() + } + } + public override init(frame: CGRect) { super.init(frame: frame) @@ -55,7 +55,7 @@ public class PasscodeSignPlaceholderView: UIView { return CGSizeMake(16, 16) } - private func setupView() { + func setupView() { layer.cornerRadius = 7 layer.borderWidth = 1 @@ -72,23 +72,16 @@ public class PasscodeSignPlaceholderView: UIView { } } - public func animateState(state: State) { + public func animateState(state: State, completion: (() -> Void)? = nil) { let colors = colorsForState(state) - - UIView.animateWithDuration( - 0.5, - delay: 0, - usingSpringWithDamping: 1, - initialSpringVelocity: 0, - options: [], - animations: { - - self.backgroundColor = colors.backgroundColor - self.layer.borderColor = colors.borderColor.CGColor - - }, - completion: nil - ) - } + + UIView.animateWithDuration(0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: [], animations: { [weak self] in + self?.backgroundColor = colors.backgroundColor + self?.layer.borderColor = colors.borderColor.CGColor + + }, completion: nil) + } + } + diff --git a/PasscodeLockDemo/AppDelegate.swift b/PasscodeLockDemo/AppDelegate.swift index 06a5d90f..953735ab 100644 --- a/PasscodeLockDemo/AppDelegate.swift +++ b/PasscodeLockDemo/AppDelegate.swift @@ -17,14 +17,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate { lazy var passcodeLockPresenter: PasscodeLockPresenter = { let configuration = PasscodeLockConfiguration() - let presenter = PasscodeLockPresenter(mainWindow: self.window, configuration: configuration, stringsToShow: nil) + let presenter = PasscodeLockPresenter(mainWindow: self.window, configuration: configuration, stringsToShow: nil, tintColor: UIColor.blueColor()) return presenter }() func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - passcodeLockPresenter.presentPasscodeLock() + passcodeLockPresenter.presentPasscodeLock(tintColor: UIColor.blueColor()) return true } @@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - passcodeLockPresenter.presentPasscodeLock() + passcodeLockPresenter.presentPasscodeLock(tintColor: UIColor.blueColor()) } func applicationWillEnterForeground(application: UIApplication) { diff --git a/PasscodeLockDemo/PasscodeSettingsViewController.swift b/PasscodeLockDemo/PasscodeSettingsViewController.swift index 073b9546..1744c8d5 100644 --- a/PasscodeLockDemo/PasscodeSettingsViewController.swift +++ b/PasscodeLockDemo/PasscodeSettingsViewController.swift @@ -57,11 +57,11 @@ class PasscodeSettingsViewController: UIViewController { if passcodeSwitch.on { - passcodeVC = PasscodeLockViewController(state: .SetPasscode, configuration: configuration, stringsToShow: nil) + passcodeVC = PasscodeLockViewController(state: .SetPasscode, configuration: configuration, stringsToShow: nil, tintColor: UIColor.blueColor()) } else { - passcodeVC = PasscodeLockViewController(state: .RemovePasscode, configuration: configuration, stringsToShow: nil) + passcodeVC = PasscodeLockViewController(state: .RemovePasscode, configuration: configuration, stringsToShow: nil, tintColor: UIColor.blueColor()) passcodeVC.successCallback = { lock in @@ -77,7 +77,7 @@ class PasscodeSettingsViewController: UIViewController { let repo = UserDefaultsPasscodeRepository() let config = PasscodeLockConfiguration(repository: repo) - let passcodeLock = PasscodeLockViewController(state: .ChangePasscode, configuration: config, stringsToShow: nil) + let passcodeLock = PasscodeLockViewController(state: .ChangePasscode, configuration: config, stringsToShow: nil, tintColor: UIColor.blueColor()) presentViewController(passcodeLock, animated: true, completion: nil) } From 79c86573e709ce47f3b04c4bdffa64cf6b65ccc5 Mon Sep 17 00:00:00 2001 From: Ramiro Ramirez Date: Wed, 11 Jan 2017 20:02:34 +0100 Subject: [PATCH 02/12] Customising font for passcode view. STRATODRVE-1146 --- .../PasscodeLock/ChangePasscodeState.swift | 8 ++++--- .../PasscodeLock/ConfirmPasscodeState.swift | 8 ++++--- .../PasscodeLock/EnterPasscodeState.swift | 6 +++-- PasscodeLock/PasscodeLock/PasscodeLock.swift | 4 ++-- .../PasscodeLock/SetPasscodeState.swift | 11 ++++++---- PasscodeLock/PasscodeLockPresenter.swift | 8 +++---- PasscodeLock/PasscodeLockViewController.swift | 22 +++++++++++-------- .../Protocols/PasscodeLockStateType.swift | 2 +- PasscodeLock/Protocols/PasscodeLockType.swift | 2 +- PasscodeLockDemo/AppDelegate.swift | 6 ++--- .../PasscodeSettingsViewController.swift | 6 ++--- 11 files changed, 48 insertions(+), 35 deletions(-) diff --git a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift index 9c3dc35e..6d1b378f 100644 --- a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift @@ -15,23 +15,25 @@ struct ChangePasscodeState: PasscodeLockStateType { let isCancellableAction = true var isTouchIDAllowed = false var tintColor : UIColor? + var font : UIFont? - init(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + init(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) self.title = (stringsToShow?.passcodeLockChangeTitle ?? localizedStringFor("PasscodeLockChangeTitle", comment: "Change passcode title")) self.description = (stringsToShow?.passcodeLockChangeDescription ?? localizedStringFor("PasscodeLockChangeDescription", comment: "Change passcode description")) self.tintColor = (tintColor ?? defaultColor) + self.font = (font ?? UIFont.systemFontOfSize(16)) } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { guard let currentPasscode = lock.repository.passcode else { return } if (passcode == currentPasscode) { - let nextState = SetPasscodeState(stringsToShow: stringsToShow, tintColor: tintColor) + let nextState = SetPasscodeState(stringsToShow: stringsToShow, tintColor: tintColor, font: font) lock.changeStateTo(nextState) } else { diff --git a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift index 9851a3b2..eb22952f 100644 --- a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift @@ -15,19 +15,21 @@ struct ConfirmPasscodeState: PasscodeLockStateType { let isCancellableAction = true var isTouchIDAllowed = false var tintColor : UIColor? + var font : UIFont? private var passcodeToConfirm: [String] - init(passcode: [String], stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + init(passcode: [String], stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) self.passcodeToConfirm = passcode self.title = (stringsToShow?.passcodeLockConfirmTitle ?? localizedStringFor("PasscodeLockConfirmTitle", comment: "Confirm passcode title")) self.description = (stringsToShow?.passcodeLockConfirmDescription ?? localizedStringFor("PasscodeLockConfirmDescription", comment: "Confirm passcode description")) self.tintColor = (tintColor ?? defaultColor) + self.font = (font ?? UIFont.systemFontOfSize(16)) } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { if (passcode == passcodeToConfirm) { lock.repository.savePasscode(passcode) @@ -37,7 +39,7 @@ struct ConfirmPasscodeState: PasscodeLockStateType { let mismatchTitle = (stringsToShow?.passcodeLockMismatchTitle ?? localizedStringFor("PasscodeLockMismatchTitle", comment: "Passcode mismatch title")) let mismatchDescription = (stringsToShow?.passcodeLockMismatchDescription ?? localizedStringFor("PasscodeLockMismatchDescription", comment: "Passcode mismatch description")) - let nextState = SetPasscodeState(title: mismatchTitle, description: mismatchDescription) + let nextState = SetPasscodeState(title: mismatchTitle, description: mismatchDescription, tintColor: tintColor, font: font) lock.changeStateTo(nextState) lock.delegate?.passcodeLockDidFail(lock) } diff --git a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift index 1672a1c0..ce32cdd1 100644 --- a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift @@ -17,20 +17,22 @@ struct EnterPasscodeState: PasscodeLockStateType { let isCancellableAction : Bool var isTouchIDAllowed = true var tintColor : UIColor? + var font : UIFont? private var inccorectPasscodeAttempts = 0 private var isNotificationSent = false - init(allowCancellation: Bool = false, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + init(allowCancellation: Bool = false, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) self.isCancellableAction = allowCancellation self.title = (stringsToShow?.passcodeLockEnterTitle ?? localizedStringFor("PasscodeLockEnterTitle", comment: "Enter passcode title")) self.description = (stringsToShow?.passcodeLockEnterDescription ?? localizedStringFor("PasscodeLockEnterDescription", comment: "Enter passcode description")) self.tintColor = (tintColor ?? defaultColor) + self.font = (font ?? UIFont.systemFontOfSize(16)) } - mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { guard let currentPasscode = lock.repository.passcode else { return diff --git a/PasscodeLock/PasscodeLock/PasscodeLock.swift b/PasscodeLock/PasscodeLock/PasscodeLock.swift index 4537930f..6f9aecd9 100644 --- a/PasscodeLock/PasscodeLock/PasscodeLock.swift +++ b/PasscodeLock/PasscodeLock/PasscodeLock.swift @@ -41,14 +41,14 @@ public class PasscodeLock: PasscodeLockType { self.configuration = configuration } - public func addSign(sign: String, stringsToBeDisplayed: StringsToBeDisplayed?, tintColor: UIColor?) { + public func addSign(sign: String, stringsToBeDisplayed: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { passcode.append(sign) delegate?.passcodeLock(self, addedSignAtIndex: passcode.count - 1) if (passcode.count >= configuration.passcodeLength) { - self.lockState.acceptPasscode(self.passcode, fromLock: self, stringsToShow: stringsToBeDisplayed, tintColor: tintColor) + self.lockState.acceptPasscode(self.passcode, fromLock: self, stringsToShow: stringsToBeDisplayed, tintColor: tintColor, font: font) self.passcode.removeAll(keepCapacity: true) } } diff --git a/PasscodeLock/PasscodeLock/SetPasscodeState.swift b/PasscodeLock/PasscodeLock/SetPasscodeState.swift index d244fa95..9eb6a2dd 100644 --- a/PasscodeLock/PasscodeLock/SetPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/SetPasscodeState.swift @@ -15,26 +15,29 @@ struct SetPasscodeState: PasscodeLockStateType { let isCancellableAction = true var isTouchIDAllowed = false var tintColor : UIColor? + var font : UIFont? - init(title: String, description: String, tintColor: UIColor?) { + init(title: String, description: String, tintColor: UIColor?, font: UIFont?) { let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) self.title = title self.description = description self.tintColor = (tintColor ?? defaultColor) + self.font = (font ?? UIFont.systemFontOfSize(16)) } - init(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + init(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) self.title = (stringsToShow?.passcodeLockSetTitle ?? localizedStringFor("PasscodeLockSetTitle", comment: "Set passcode title")) self.description = (stringsToShow?.passcodeLockSetDescription ?? localizedStringFor("PasscodeLockSetDescription", comment: "Set passcode description")) self.tintColor = (tintColor ?? defaultColor) + self.font = (font ?? UIFont.systemFontOfSize(16)) } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { - let nextState = ConfirmPasscodeState(passcode: passcode, stringsToShow: stringsToShow, tintColor: tintColor) + let nextState = ConfirmPasscodeState(passcode: passcode, stringsToShow: stringsToShow, tintColor: tintColor, font: font) lock.changeStateTo(nextState) } } diff --git a/PasscodeLock/PasscodeLockPresenter.swift b/PasscodeLock/PasscodeLockPresenter.swift index 40c13e50..1967290f 100644 --- a/PasscodeLock/PasscodeLockPresenter.swift +++ b/PasscodeLock/PasscodeLockPresenter.swift @@ -75,14 +75,14 @@ public class PasscodeLockPresenter { passcodeLockVC = viewController } - public convenience init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + public convenience init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { - let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: configuration, stringsToShow: stringsToShow, tintColor: tintColor) + let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: configuration, stringsToShow: stringsToShow, tintColor: tintColor, font: font) self.init(mainWindow: window, configuration: configuration, viewController: passcodeLockVC) } - public func presentPasscodeLock(withImage image: UIImage? = nil, andStrings stringsToShow: StringsToBeDisplayed? = nil, tintColor: UIColor?, dismissCompletionBlock: (() -> Void)? = nil) { + public func presentPasscodeLock(withImage image: UIImage? = nil, andStrings stringsToShow: StringsToBeDisplayed? = nil, tintColor: UIColor?, font: UIFont?, dismissCompletionBlock: (() -> Void)? = nil) { guard passcodeConfiguration.repository.hasPasscode else { return } guard !isPasscodePresented else { return } @@ -95,7 +95,7 @@ public class PasscodeLockPresenter { mainWindow?.windowLevel = 1 mainWindow?.endEditing(true) - let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: passcodeConfiguration, stringsToShow: stringsToShow, tintColor: tintColor) + let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: passcodeConfiguration, stringsToShow: stringsToShow, tintColor: tintColor, font: font) if (image != nil) { passcodeLockVC.customImage = image } diff --git a/PasscodeLock/PasscodeLockViewController.swift b/PasscodeLock/PasscodeLockViewController.swift index 32a5c8b7..b607dc86 100644 --- a/PasscodeLock/PasscodeLockViewController.swift +++ b/PasscodeLock/PasscodeLockViewController.swift @@ -16,13 +16,13 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg case ChangePasscode case RemovePasscode - func getState(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) -> PasscodeLockStateType { + func getState(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) -> PasscodeLockStateType { switch self { - case .EnterPasscode: return EnterPasscodeState(stringsToShow: stringsToShow, tintColor: tintColor) - case .SetPasscode: return SetPasscodeState(stringsToShow: stringsToShow, tintColor: tintColor) - case .ChangePasscode: return ChangePasscodeState(stringsToShow: stringsToShow, tintColor: tintColor) - case .RemovePasscode: return EnterPasscodeState(allowCancellation: true, stringsToShow: stringsToShow, tintColor: tintColor) + case .EnterPasscode: return EnterPasscodeState(stringsToShow: stringsToShow, tintColor: tintColor, font: font) + case .SetPasscode: return SetPasscodeState(stringsToShow: stringsToShow, tintColor: tintColor, font: font) + case .ChangePasscode: return ChangePasscodeState(stringsToShow: stringsToShow, tintColor: tintColor, font: font) + case .RemovePasscode: return EnterPasscodeState(allowCancellation: true, stringsToShow: stringsToShow, tintColor: tintColor, font: font) } } } @@ -50,13 +50,15 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg private var shouldTryToAuthenticateWithBiometrics = true private var customTintColor : UIColor? + private var font : UIFont? // MARK: - Initializers - public init(state: PasscodeLockStateType, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true, stringToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + public init(state: PasscodeLockStateType, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true, stringToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { self.stringsToShow = stringToShow self.animateOnDismiss = animateOnDismiss + self.font = (font ?? UIFont.systemFontOfSize(16)) self.customTintColor = (tintColor ?? UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1)) passcodeConfiguration = configuration passcodeLock = PasscodeLock(state: state, configuration: configuration) @@ -68,9 +70,9 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg notificationCenter = NSNotificationCenter.defaultCenter() } - public convenience init(state: LockState, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) { + public convenience init(state: LockState, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { - self.init(state: state.getState(stringsToShow, tintColor: tintColor), configuration: configuration, animateOnDismiss: animateOnDismiss, stringToShow: stringsToShow, tintColor: tintColor) + self.init(state: state.getState(stringsToShow, tintColor: tintColor, font: font), configuration: configuration, animateOnDismiss: animateOnDismiss, stringToShow: stringsToShow, tintColor: tintColor, font: font) } public required init(coder aDecoder: NSCoder) { @@ -113,6 +115,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg self.customImageView?.image = self.customImage self.titleLabel?.text = passcodeLock.state.title + self.titleLabel?.font = self.font self.titleLabel?.textColor = self.customTintColor self.descriptionLabel?.text = passcodeLock.state.description self.touchIDButton?.hidden = !passcodeLock.isTouchIDAllowed @@ -157,7 +160,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg return } - passcodeLock.addSign(sender.passcodeSign, stringsToBeDisplayed: self.stringsToShow, tintColor: customTintColor) + passcodeLock.addSign(sender.passcodeSign, stringsToBeDisplayed: self.stringsToShow, tintColor: customTintColor, font: font) } @IBAction func cancelButtonTap(sender: UIButton) { @@ -290,6 +293,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg let titleForButton = ((self.passcodeLock.state.isCancellableAction == true) ? cancelButton : (self.stringsToShow?.delete ?? localizedStringFor("Delete", comment: ""))) self.cancelDeleteButton?.setTitle(titleForButton, forState: .Normal) self.cancelDeleteButton?.setTitleColor(self.customTintColor, forState: .Normal) + self.cancelDeleteButton?.titleLabel?.font = self.font if (self.passcodeLock.isPincodeEmpty == true && self.passcodeLock.state.isCancellableAction == false) { self.cancelDeleteButton?.enabled = false diff --git a/PasscodeLock/Protocols/PasscodeLockStateType.swift b/PasscodeLock/Protocols/PasscodeLockStateType.swift index 3fad2299..59c07353 100644 --- a/PasscodeLock/Protocols/PasscodeLockStateType.swift +++ b/PasscodeLock/Protocols/PasscodeLockStateType.swift @@ -16,5 +16,5 @@ public protocol PasscodeLockStateType { var isTouchIDAllowed : Bool {get} var tintColor : UIColor? {get} - mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?) + mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) } diff --git a/PasscodeLock/Protocols/PasscodeLockType.swift b/PasscodeLock/Protocols/PasscodeLockType.swift index 3a21729e..257d005e 100644 --- a/PasscodeLock/Protocols/PasscodeLockType.swift +++ b/PasscodeLock/Protocols/PasscodeLockType.swift @@ -17,7 +17,7 @@ public protocol PasscodeLockType { var isTouchIDAllowed: Bool {get} var isPincodeEmpty: Bool {get} - func addSign(sign: String, stringsToBeDisplayed: StringsToBeDisplayed?, tintColor: UIColor?) + func addSign(sign: String, stringsToBeDisplayed: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) func removeSign() func changeStateTo(state: PasscodeLockStateType) func authenticateWithBiometrics(stringsToShow: StringsToBeDisplayed?) diff --git a/PasscodeLockDemo/AppDelegate.swift b/PasscodeLockDemo/AppDelegate.swift index 953735ab..11814561 100644 --- a/PasscodeLockDemo/AppDelegate.swift +++ b/PasscodeLockDemo/AppDelegate.swift @@ -17,14 +17,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate { lazy var passcodeLockPresenter: PasscodeLockPresenter = { let configuration = PasscodeLockConfiguration() - let presenter = PasscodeLockPresenter(mainWindow: self.window, configuration: configuration, stringsToShow: nil, tintColor: UIColor.blueColor()) + let presenter = PasscodeLockPresenter(mainWindow: self.window, configuration: configuration, stringsToShow: nil, tintColor: UIColor.blueColor(), font: UIFont.italicSystemFontOfSize(16)) return presenter }() func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - passcodeLockPresenter.presentPasscodeLock(tintColor: UIColor.blueColor()) + passcodeLockPresenter.presentPasscodeLock(tintColor: UIColor.blueColor(), font: UIFont.italicSystemFontOfSize(16)) return true } @@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - passcodeLockPresenter.presentPasscodeLock(tintColor: UIColor.blueColor()) + passcodeLockPresenter.presentPasscodeLock(tintColor: UIColor.blueColor(), font: UIFont.italicSystemFontOfSize(16)) } func applicationWillEnterForeground(application: UIApplication) { diff --git a/PasscodeLockDemo/PasscodeSettingsViewController.swift b/PasscodeLockDemo/PasscodeSettingsViewController.swift index 1744c8d5..5bc806b1 100644 --- a/PasscodeLockDemo/PasscodeSettingsViewController.swift +++ b/PasscodeLockDemo/PasscodeSettingsViewController.swift @@ -57,11 +57,11 @@ class PasscodeSettingsViewController: UIViewController { if passcodeSwitch.on { - passcodeVC = PasscodeLockViewController(state: .SetPasscode, configuration: configuration, stringsToShow: nil, tintColor: UIColor.blueColor()) + passcodeVC = PasscodeLockViewController(state: .SetPasscode, configuration: configuration, stringsToShow: nil, tintColor: UIColor.blueColor(), font: UIFont.italicSystemFontOfSize(16)) } else { - passcodeVC = PasscodeLockViewController(state: .RemovePasscode, configuration: configuration, stringsToShow: nil, tintColor: UIColor.blueColor()) + passcodeVC = PasscodeLockViewController(state: .RemovePasscode, configuration: configuration, stringsToShow: nil, tintColor: UIColor.blueColor(), font: UIFont.italicSystemFontOfSize(16)) passcodeVC.successCallback = { lock in @@ -77,7 +77,7 @@ class PasscodeSettingsViewController: UIViewController { let repo = UserDefaultsPasscodeRepository() let config = PasscodeLockConfiguration(repository: repo) - let passcodeLock = PasscodeLockViewController(state: .ChangePasscode, configuration: config, stringsToShow: nil, tintColor: UIColor.blueColor()) + let passcodeLock = PasscodeLockViewController(state: .ChangePasscode, configuration: config, stringsToShow: nil, tintColor: UIColor.blueColor(), font: UIFont.italicSystemFontOfSize(16)) presentViewController(passcodeLock, animated: true, completion: nil) } From 1f6024512dfab00824ea65a30496ef9ecdb45266 Mon Sep 17 00:00:00 2001 From: Ramiro Ramirez Date: Thu, 12 Jan 2017 10:22:51 +0100 Subject: [PATCH 03/12] Minor improvements. --- PasscodeLock/Functions.swift | 4 ++++ PasscodeLock/PasscodeLock/ChangePasscodeState.swift | 3 ++- PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift | 2 +- PasscodeLock/PasscodeLock/EnterPasscodeState.swift | 2 +- PasscodeLock/PasscodeLock/SetPasscodeState.swift | 4 ++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/PasscodeLock/Functions.swift b/PasscodeLock/Functions.swift index 9e9cec25..6b61c4bd 100644 --- a/PasscodeLock/Functions.swift +++ b/PasscodeLock/Functions.swift @@ -24,3 +24,7 @@ func bundleForResource(name: String, ofType type: String) -> NSBundle { return NSBundle(forClass: PasscodeLock.self) } + +func defaultCustomColor() -> UIColor { + return UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) +} diff --git a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift index 6d1b378f..066d990e 100644 --- a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift @@ -19,7 +19,8 @@ struct ChangePasscodeState: PasscodeLockStateType { init(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { - let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + + let defaultColor = defaultCustomColor() self.title = (stringsToShow?.passcodeLockChangeTitle ?? localizedStringFor("PasscodeLockChangeTitle", comment: "Change passcode title")) self.description = (stringsToShow?.passcodeLockChangeDescription ?? localizedStringFor("PasscodeLockChangeDescription", comment: "Change passcode description")) self.tintColor = (tintColor ?? defaultColor) diff --git a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift index eb22952f..e676f4a2 100644 --- a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift @@ -21,7 +21,7 @@ struct ConfirmPasscodeState: PasscodeLockStateType { init(passcode: [String], stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { - let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + let defaultColor = defaultCustomColor() self.passcodeToConfirm = passcode self.title = (stringsToShow?.passcodeLockConfirmTitle ?? localizedStringFor("PasscodeLockConfirmTitle", comment: "Confirm passcode title")) self.description = (stringsToShow?.passcodeLockConfirmDescription ?? localizedStringFor("PasscodeLockConfirmDescription", comment: "Confirm passcode description")) diff --git a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift index ce32cdd1..86a75a87 100644 --- a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift @@ -24,7 +24,7 @@ struct EnterPasscodeState: PasscodeLockStateType { init(allowCancellation: Bool = false, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { - let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + let defaultColor = defaultCustomColor() self.isCancellableAction = allowCancellation self.title = (stringsToShow?.passcodeLockEnterTitle ?? localizedStringFor("PasscodeLockEnterTitle", comment: "Enter passcode title")) self.description = (stringsToShow?.passcodeLockEnterDescription ?? localizedStringFor("PasscodeLockEnterDescription", comment: "Enter passcode description")) diff --git a/PasscodeLock/PasscodeLock/SetPasscodeState.swift b/PasscodeLock/PasscodeLock/SetPasscodeState.swift index 9eb6a2dd..f4853ab4 100644 --- a/PasscodeLock/PasscodeLock/SetPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/SetPasscodeState.swift @@ -19,7 +19,7 @@ struct SetPasscodeState: PasscodeLockStateType { init(title: String, description: String, tintColor: UIColor?, font: UIFont?) { - let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + let defaultColor = defaultCustomColor() self.title = title self.description = description self.tintColor = (tintColor ?? defaultColor) @@ -28,7 +28,7 @@ struct SetPasscodeState: PasscodeLockStateType { init(stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { - let defaultColor = UIColor(red: 0, green: 100/255, blue: 165/255, alpha: 1) + let defaultColor = defaultCustomColor() self.title = (stringsToShow?.passcodeLockSetTitle ?? localizedStringFor("PasscodeLockSetTitle", comment: "Set passcode title")) self.description = (stringsToShow?.passcodeLockSetDescription ?? localizedStringFor("PasscodeLockSetDescription", comment: "Set passcode description")) self.tintColor = (tintColor ?? defaultColor) From 455dd2021fdd4e173f5579f9e3e4299e071dc7eb Mon Sep 17 00:00:00 2001 From: Ramiro Ramirez Date: Thu, 12 Jan 2017 12:30:05 +0100 Subject: [PATCH 04/12] Minor Improvement --- PasscodeLock/PasscodeLockViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/PasscodeLock/PasscodeLockViewController.swift b/PasscodeLock/PasscodeLockViewController.swift index b607dc86..a5bfc561 100644 --- a/PasscodeLock/PasscodeLockViewController.swift +++ b/PasscodeLock/PasscodeLockViewController.swift @@ -293,6 +293,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg let titleForButton = ((self.passcodeLock.state.isCancellableAction == true) ? cancelButton : (self.stringsToShow?.delete ?? localizedStringFor("Delete", comment: ""))) self.cancelDeleteButton?.setTitle(titleForButton, forState: .Normal) self.cancelDeleteButton?.setTitleColor(self.customTintColor, forState: .Normal) + self.cancelDeleteButton?.setTitleColor(self.customTintColor?.colorWithAlphaComponent(0.5), forState: .Disabled) self.cancelDeleteButton?.titleLabel?.font = self.font if (self.passcodeLock.isPincodeEmpty == true && self.passcodeLock.state.isCancellableAction == false) { From f762d3d60d1bb4f8ddaa396d33280fbd48e53ee2 Mon Sep 17 00:00:00 2001 From: Hans Seiffert Date: Fri, 13 Jan 2017 11:00:40 +0100 Subject: [PATCH 05/12] Release version 1.0.2 --- .swift-version | 1 + PasscodeLock.podspec | 21 --------------------- SMFPasscodeLock.podspec | 29 +++++++++++++++++++++++++++++ VERSION | 1 + 4 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 .swift-version delete mode 100755 PasscodeLock.podspec create mode 100755 SMFPasscodeLock.podspec create mode 100644 VERSION diff --git a/.swift-version b/.swift-version new file mode 100644 index 00000000..c0943d3e --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +2.3 \ No newline at end of file diff --git a/PasscodeLock.podspec b/PasscodeLock.podspec deleted file mode 100755 index f27b3db6..00000000 --- a/PasscodeLock.podspec +++ /dev/null @@ -1,21 +0,0 @@ -Pod::Spec.new do |s| -s.name = 'PasscodeLock' -s.version = '1.0.1' -s.license = { :type => "MIT", :file => 'LICENSE.txt' } -s.summary = 'An iOS passcode lock with Touch ID authentication written in Swift.' -s.homepage = 'https://github.com/yankodimitrov/SwiftPasscodeLock' -s.authors = { 'Yanko Dimitrov' => '' } -s.source = { :git => 'https://github.com/yankodimitrov/SwiftPasscodeLock.git' } - -s.ios.deployment_target = '8.0' - -s.source_files = 'PasscodeLock/*.{h,swift}', - 'PasscodeLock/*/*.{swift}' - -s.resources = [ - 'PasscodeLock/Views/PasscodeLockView.xib', - 'PasscodeLock/en.lproj/*' - ] - -s.requires_arc = true -end \ No newline at end of file diff --git a/SMFPasscodeLock.podspec b/SMFPasscodeLock.podspec new file mode 100755 index 00000000..4b8d7f72 --- /dev/null +++ b/SMFPasscodeLock.podspec @@ -0,0 +1,29 @@ +# +# Be sure to run `pod lib lint TestLib.podspec' to ensure this is a +# valid spec before submitting. +# +# Any lines starting with a # are optional, but their use is encouraged +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html +# + +Pod::Spec.new do |s| +s.name = 'SMFPasscodeLock' +s.version = File.read('VERSION') +s.license = { :type => "MIT", :file => 'LICENSE.txt' } +s.summary = 'SMF Fork of PasscodeLock: An iOS passcode lock with Touch ID authentication written in Swift.' +s.homepage = 'https://github.com/smartmobilefactory/SwiftPasscodeLock' +s.source = { :git => 'https://github.com/smartmobilefactory/SwiftPasscodeLock.git' } +s.authors = [{ 'Ramiro Ramirez' => '' }, { 'Yanko Dimitrov' => '' }, { 'Hans Seiffert' => '' }] + +s.ios.deployment_target = '8.0' + +s.source_files = 'PasscodeLock/*.{h,swift}', + 'PasscodeLock/*/*.{swift}' + +s.resources = [ + 'PasscodeLock/Views/PasscodeLockView.xib', + 'PasscodeLock/en.lproj/*' + ] + +s.requires_arc = true +end \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..e6d5cb83 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.2 \ No newline at end of file From c9f922e37090773e201e4691b2719502b0b1fc8b Mon Sep 17 00:00:00 2001 From: Hans Seiffert Date: Fri, 13 Jan 2017 11:20:29 +0100 Subject: [PATCH 06/12] Release version 1.0.3 --- SMFPasscodeLock.podspec | 2 +- VERSION | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 VERSION diff --git a/SMFPasscodeLock.podspec b/SMFPasscodeLock.podspec index 4b8d7f72..f88fa83f 100755 --- a/SMFPasscodeLock.podspec +++ b/SMFPasscodeLock.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'SMFPasscodeLock' -s.version = File.read('VERSION') +s.version = '1.0.3' s.license = { :type => "MIT", :file => 'LICENSE.txt' } s.summary = 'SMF Fork of PasscodeLock: An iOS passcode lock with Touch ID authentication written in Swift.' s.homepage = 'https://github.com/smartmobilefactory/SwiftPasscodeLock' diff --git a/VERSION b/VERSION deleted file mode 100644 index e6d5cb83..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.2 \ No newline at end of file From 2af8a46d7fd11eba867a774e313e2c07a121b197 Mon Sep 17 00:00:00 2001 From: Pierre Rothmaler Date: Thu, 9 Feb 2017 17:54:00 +0100 Subject: [PATCH 07/12] included resources --- SMFPasscodeLock.podspec | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SMFPasscodeLock.podspec b/SMFPasscodeLock.podspec index f88fa83f..f33b8b91 100755 --- a/SMFPasscodeLock.podspec +++ b/SMFPasscodeLock.podspec @@ -8,11 +8,11 @@ Pod::Spec.new do |s| s.name = 'SMFPasscodeLock' -s.version = '1.0.3' +s.version = '1.0.6' s.license = { :type => "MIT", :file => 'LICENSE.txt' } s.summary = 'SMF Fork of PasscodeLock: An iOS passcode lock with Touch ID authentication written in Swift.' s.homepage = 'https://github.com/smartmobilefactory/SwiftPasscodeLock' -s.source = { :git => 'https://github.com/smartmobilefactory/SwiftPasscodeLock.git' } +s.source = { :git => 'https://github.com/smartmobilefactory/SwiftPasscodeLock.git', :tag => "versions/#{s.version}" } s.authors = [{ 'Ramiro Ramirez' => '' }, { 'Yanko Dimitrov' => '' }, { 'Hans Seiffert' => '' }] s.ios.deployment_target = '8.0' @@ -22,8 +22,10 @@ s.source_files = 'PasscodeLock/*.{h,swift}', s.resources = [ 'PasscodeLock/Views/PasscodeLockView.xib', - 'PasscodeLock/en.lproj/*' + 'PasscodeLock/en.lproj/*', + 'PasscodeLock/PasscodeLockImages.xcassets', + 'PasscodeLock/PasscodeLockImages.xcassets/**/*' ] s.requires_arc = true -end \ No newline at end of file +end From ab17b8ba8d9ca02b3df72d5c0a7123b5413e2e03 Mon Sep 17 00:00:00 2001 From: Ramiro Ramirez Date: Fri, 3 Mar 2017 10:57:23 +0100 Subject: [PATCH 08/12] Adding tint color for touch id button --- PasscodeLock/PasscodeLockViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PasscodeLock/PasscodeLockViewController.swift b/PasscodeLock/PasscodeLockViewController.swift index a5bfc561..25e826df 100644 --- a/PasscodeLock/PasscodeLockViewController.swift +++ b/PasscodeLock/PasscodeLockViewController.swift @@ -120,7 +120,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg self.descriptionLabel?.text = passcodeLock.state.description self.touchIDButton?.hidden = !passcodeLock.isTouchIDAllowed self.touchIDButton?.setTitle((self.stringsToShow?.useTouchID ?? localizedStringFor("UseTouchId", comment: "")), forState: .Normal) - + self.touchIDButton?.setTitleColor(self.customTintColor, forState: .Normal) self.passcodeButtons?.forEach({ (passcodeButton: PasscodeSignButton) in passcodeButton.tintColor = self.customTintColor }) From 2a68e3d7df96817c5e637316f1439eed0c2ce75a Mon Sep 17 00:00:00 2001 From: Pierre Rothmaler Date: Fri, 3 Mar 2017 11:13:46 +0100 Subject: [PATCH 09/12] version bump --- SMFPasscodeLock.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SMFPasscodeLock.podspec b/SMFPasscodeLock.podspec index f33b8b91..c03ba799 100755 --- a/SMFPasscodeLock.podspec +++ b/SMFPasscodeLock.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'SMFPasscodeLock' -s.version = '1.0.6' +s.version = '1.0.7' s.license = { :type => "MIT", :file => 'LICENSE.txt' } s.summary = 'SMF Fork of PasscodeLock: An iOS passcode lock with Touch ID authentication written in Swift.' s.homepage = 'https://github.com/smartmobilefactory/SwiftPasscodeLock' From d8ef94a13d3c15ee008ebd3c12af55b8f557dbf1 Mon Sep 17 00:00:00 2001 From: Mauro Torres Mejia Date: Thu, 20 Apr 2017 15:34:45 +0200 Subject: [PATCH 10/12] Allow to pass new configuration when presenting passcode --- PasscodeLock/PasscodeLockPresenter.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PasscodeLock/PasscodeLockPresenter.swift b/PasscodeLock/PasscodeLockPresenter.swift index 1967290f..681402e9 100644 --- a/PasscodeLock/PasscodeLockPresenter.swift +++ b/PasscodeLock/PasscodeLockPresenter.swift @@ -82,7 +82,7 @@ public class PasscodeLockPresenter { self.init(mainWindow: window, configuration: configuration, viewController: passcodeLockVC) } - public func presentPasscodeLock(withImage image: UIImage? = nil, andStrings stringsToShow: StringsToBeDisplayed? = nil, tintColor: UIColor?, font: UIFont?, dismissCompletionBlock: (() -> Void)? = nil) { + public func presentPasscodeLock(withImage image: UIImage? = nil, configuration config: PasscodeLockConfigurationType? = nil, andStrings stringsToShow: StringsToBeDisplayed? = nil, tintColor: UIColor?, font: UIFont?, dismissCompletionBlock: (() -> Void)? = nil) { guard passcodeConfiguration.repository.hasPasscode else { return } guard !isPasscodePresented else { return } @@ -95,7 +95,7 @@ public class PasscodeLockPresenter { mainWindow?.windowLevel = 1 mainWindow?.endEditing(true) - let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: passcodeConfiguration, stringsToShow: stringsToShow, tintColor: tintColor, font: font) + let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: (config ?? passcodeConfiguration), stringsToShow: stringsToShow, tintColor: tintColor, font: font) if (image != nil) { passcodeLockVC.customImage = image } From d3c3e489d53027ca5871dd3f0bb0324f920e94fa Mon Sep 17 00:00:00 2001 From: Pierre Rothmaler Date: Thu, 20 Apr 2017 15:55:04 +0200 Subject: [PATCH 11/12] Pod Release 1.0.8 --- SMFPasscodeLock.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SMFPasscodeLock.podspec b/SMFPasscodeLock.podspec index c03ba799..42cfcd04 100755 --- a/SMFPasscodeLock.podspec +++ b/SMFPasscodeLock.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'SMFPasscodeLock' -s.version = '1.0.7' +s.version = '1.0.8' s.license = { :type => "MIT", :file => 'LICENSE.txt' } s.summary = 'SMF Fork of PasscodeLock: An iOS passcode lock with Touch ID authentication written in Swift.' s.homepage = 'https://github.com/smartmobilefactory/SwiftPasscodeLock' From fa73ffa828017af015032d7b3f123cdbbcd55070 Mon Sep 17 00:00:00 2001 From: Mauro Torres Mejia Date: Fri, 16 Jun 2017 12:31:10 +0200 Subject: [PATCH 12/12] Send notification when maximum failed attempt reached --- PasscodeLock/PasscodeLock/EnterPasscodeState.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift index 86a75a87..89b611db 100644 --- a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift @@ -20,7 +20,6 @@ struct EnterPasscodeState: PasscodeLockStateType { var font : UIFont? private var inccorectPasscodeAttempts = 0 - private var isNotificationSent = false init(allowCancellation: Bool = false, stringsToShow: StringsToBeDisplayed?, tintColor: UIColor?, font: UIFont?) { @@ -53,11 +52,8 @@ struct EnterPasscodeState: PasscodeLockStateType { } private mutating func postNotification() { - - guard !isNotificationSent else { return } - + let center = NSNotificationCenter.defaultCenter() center.postNotificationName(PasscodeLockIncorrectPasscodeNotification, object: nil) - self.isNotificationSent = true } }