diff --git a/PasscodeLock.podspec b/PasscodeLock.podspec index f27b3db6..5003f6ab 100755 --- a/PasscodeLock.podspec +++ b/PasscodeLock.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'PasscodeLock' -s.version = '1.0.1' +s.version = '1.0.2' 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' @@ -18,4 +18,4 @@ s.resources = [ ] s.requires_arc = true -end \ No newline at end of file +end diff --git a/PasscodeLock.xcodeproj/project.pbxproj b/PasscodeLock.xcodeproj/project.pbxproj index 0849b504..2e2ead92 100644 --- a/PasscodeLock.xcodeproj/project.pbxproj +++ b/PasscodeLock.xcodeproj/project.pbxproj @@ -8,8 +8,8 @@ /* Begin PBXBuildFile section */ C99EAF431B90B05700D61E1B /* PasscodeLock.h in Headers */ = {isa = PBXBuildFile; fileRef = C99EAF421B90B05700D61E1B /* PasscodeLock.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C99EAF4A1B90B05800D61E1B /* PasscodeLock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; settings = {ASSET_TAGS = (); }; }; - C9D3DF0B1B919CE4008561EB /* PasscodeLockView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C9D3DF0A1B919CE4008561EB /* PasscodeLockView.xib */; settings = {ASSET_TAGS = (); }; }; + C99EAF4A1B90B05800D61E1B /* PasscodeLock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; }; + C9D3DF0B1B919CE4008561EB /* PasscodeLockView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C9D3DF0A1B919CE4008561EB /* PasscodeLockView.xib */; }; C9D3DF131B91AD11008561EB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF121B91AD11008561EB /* AppDelegate.swift */; }; C9D3DF151B91AD11008561EB /* PasscodeSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF141B91AD11008561EB /* PasscodeSettingsViewController.swift */; }; C9D3DF181B91AD11008561EB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C9D3DF161B91AD11008561EB /* Main.storyboard */; }; @@ -17,45 +17,45 @@ C9D3DF1D1B91AD11008561EB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C9D3DF1B1B91AD11008561EB /* LaunchScreen.storyboard */; }; C9D3DF3E1B91AD7A008561EB /* PasscodeLock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; }; C9D3DF3F1B91AD7A008561EB /* PasscodeLock.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - C9D3DF441B91B9CD008561EB /* UserDefaultsPasscodeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF431B91B9CD008561EB /* UserDefaultsPasscodeRepository.swift */; settings = {ASSET_TAGS = (); }; }; - C9D3DF461B91BD0E008561EB /* PasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF451B91BD0E008561EB /* PasscodeLockConfiguration.swift */; settings = {ASSET_TAGS = (); }; }; - C9D3DF481B91F099008561EB /* PasscodeLockPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF471B91F099008561EB /* PasscodeLockPresenter.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07D51B90B1F6007A4DD0 /* PasscodeRepositoryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D41B90B1F6007A4DD0 /* PasscodeRepositoryType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07D61B90B1F6007A4DD0 /* PasscodeRepositoryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D41B90B1F6007A4DD0 /* PasscodeRepositoryType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07D81B90B261007A4DD0 /* PasscodeLockStateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D71B90B261007A4DD0 /* PasscodeLockStateType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07D91B90B261007A4DD0 /* PasscodeLockStateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D71B90B261007A4DD0 /* PasscodeLockStateType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07DB1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DA1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07DC1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DA1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07DE1B90BA06007A4DD0 /* PasscodeLockType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DD1B90BA06007A4DD0 /* PasscodeLockType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07DF1B90BA06007A4DD0 /* PasscodeLockType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DD1B90BA06007A4DD0 /* PasscodeLockType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07E11B90BBFD007A4DD0 /* PasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E01B90BBFD007A4DD0 /* PasscodeLock.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07E21B90BBFD007A4DD0 /* PasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E01B90BBFD007A4DD0 /* PasscodeLock.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07E51B90BCF9007A4DD0 /* PasscodeLockTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E41B90BCF9007A4DD0 /* PasscodeLockTests.swift */; settings = {ASSET_TAGS = (); }; }; + C9D3DF441B91B9CD008561EB /* UserDefaultsPasscodeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF431B91B9CD008561EB /* UserDefaultsPasscodeRepository.swift */; }; + C9D3DF461B91BD0E008561EB /* PasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF451B91BD0E008561EB /* PasscodeLockConfiguration.swift */; }; + C9D3DF481B91F099008561EB /* PasscodeLockPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF471B91F099008561EB /* PasscodeLockPresenter.swift */; }; + C9DC07D51B90B1F6007A4DD0 /* PasscodeRepositoryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D41B90B1F6007A4DD0 /* PasscodeRepositoryType.swift */; }; + C9DC07D61B90B1F6007A4DD0 /* PasscodeRepositoryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D41B90B1F6007A4DD0 /* PasscodeRepositoryType.swift */; }; + C9DC07D81B90B261007A4DD0 /* PasscodeLockStateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D71B90B261007A4DD0 /* PasscodeLockStateType.swift */; }; + C9DC07D91B90B261007A4DD0 /* PasscodeLockStateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D71B90B261007A4DD0 /* PasscodeLockStateType.swift */; }; + C9DC07DB1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DA1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift */; }; + C9DC07DC1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DA1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift */; }; + C9DC07DE1B90BA06007A4DD0 /* PasscodeLockType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DD1B90BA06007A4DD0 /* PasscodeLockType.swift */; }; + C9DC07DF1B90BA06007A4DD0 /* PasscodeLockType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DD1B90BA06007A4DD0 /* PasscodeLockType.swift */; }; + C9DC07E11B90BBFD007A4DD0 /* PasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E01B90BBFD007A4DD0 /* PasscodeLock.swift */; }; + C9DC07E21B90BBFD007A4DD0 /* PasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E01B90BBFD007A4DD0 /* PasscodeLock.swift */; }; + C9DC07E51B90BCF9007A4DD0 /* PasscodeLockTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E41B90BCF9007A4DD0 /* PasscodeLockTests.swift */; }; C9DC07E71B90C382007A4DD0 /* LocalAuthentication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9DC07E61B90C382007A4DD0 /* LocalAuthentication.framework */; }; - C9DC07EA1B90C690007A4DD0 /* FakePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E91B90C690007A4DD0 /* FakePasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07EC1B90C72A007A4DD0 /* FakePasscodeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07EB1B90C72A007A4DD0 /* FakePasscodeRepository.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07EE1B90C7CD007A4DD0 /* FakePasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07ED1B90C7CD007A4DD0 /* FakePasscodeLockConfiguration.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F01B90C8E1007A4DD0 /* FakePasscodeLockDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07EF1B90C8E1007A4DD0 /* FakePasscodeLockDelegate.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F21B90C9DE007A4DD0 /* EnterPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F11B90C9DE007A4DD0 /* EnterPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F31B90C9DE007A4DD0 /* EnterPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F11B90C9DE007A4DD0 /* EnterPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F81B90CF29007A4DD0 /* Functions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F71B90CF29007A4DD0 /* Functions.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F91B90CF29007A4DD0 /* Functions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F71B90CF29007A4DD0 /* Functions.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07FC1B90D0A3007A4DD0 /* PasscodeLock.strings in Resources */ = {isa = PBXBuildFile; fileRef = C9DC07FA1B90D0A3007A4DD0 /* PasscodeLock.strings */; settings = {ASSET_TAGS = (); }; }; - C9DC07FD1B90D0A3007A4DD0 /* PasscodeLock.strings in Resources */ = {isa = PBXBuildFile; fileRef = C9DC07FA1B90D0A3007A4DD0 /* PasscodeLock.strings */; settings = {ASSET_TAGS = (); }; }; - C9DC07FF1B90D24A007A4DD0 /* SetPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07FE1B90D24A007A4DD0 /* SetPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08001B90D24A007A4DD0 /* SetPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07FE1B90D24A007A4DD0 /* SetPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08021B90D2BA007A4DD0 /* ConfirmPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08011B90D2BA007A4DD0 /* ConfirmPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08031B90D2BA007A4DD0 /* ConfirmPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08011B90D2BA007A4DD0 /* ConfirmPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08051B90D394007A4DD0 /* ChangePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08041B90D394007A4DD0 /* ChangePasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08061B90D394007A4DD0 /* ChangePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08041B90D394007A4DD0 /* ChangePasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08081B90DAE6007A4DD0 /* EnterPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08071B90DAE6007A4DD0 /* EnterPasscodeStateTests.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC080A1B90DB09007A4DD0 /* FakePasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08091B90DB09007A4DD0 /* FakePasscodeLock.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC080C1B90DC38007A4DD0 /* SetPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080B1B90DC38007A4DD0 /* SetPasscodeStateTests.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC080E1B90DC8F007A4DD0 /* ConfirmPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080D1B90DC8F007A4DD0 /* ConfirmPasscodeStateTests.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08101B90DD91007A4DD0 /* ChangePasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080F1B90DD91007A4DD0 /* ChangePasscodeStateTests.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08121B90DE1B007A4DD0 /* PasscodeSignPlaceholderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08111B90DE1B007A4DD0 /* PasscodeSignPlaceholderView.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08141B90DE50007A4DD0 /* PasscodeSignButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08131B90DE50007A4DD0 /* PasscodeSignButton.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08161B90DF4E007A4DD0 /* PasscodeLockViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08151B90DF4E007A4DD0 /* PasscodeLockViewController.swift */; settings = {ASSET_TAGS = (); }; }; + C9DC07EA1B90C690007A4DD0 /* FakePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E91B90C690007A4DD0 /* FakePasscodeState.swift */; }; + C9DC07EC1B90C72A007A4DD0 /* FakePasscodeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07EB1B90C72A007A4DD0 /* FakePasscodeRepository.swift */; }; + C9DC07EE1B90C7CD007A4DD0 /* FakePasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07ED1B90C7CD007A4DD0 /* FakePasscodeLockConfiguration.swift */; }; + C9DC07F01B90C8E1007A4DD0 /* FakePasscodeLockDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07EF1B90C8E1007A4DD0 /* FakePasscodeLockDelegate.swift */; }; + C9DC07F21B90C9DE007A4DD0 /* EnterPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F11B90C9DE007A4DD0 /* EnterPasscodeState.swift */; }; + C9DC07F31B90C9DE007A4DD0 /* EnterPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F11B90C9DE007A4DD0 /* EnterPasscodeState.swift */; }; + C9DC07F81B90CF29007A4DD0 /* Functions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F71B90CF29007A4DD0 /* Functions.swift */; }; + C9DC07F91B90CF29007A4DD0 /* Functions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F71B90CF29007A4DD0 /* Functions.swift */; }; + C9DC07FC1B90D0A3007A4DD0 /* PasscodeLock.strings in Resources */ = {isa = PBXBuildFile; fileRef = C9DC07FA1B90D0A3007A4DD0 /* PasscodeLock.strings */; }; + C9DC07FD1B90D0A3007A4DD0 /* PasscodeLock.strings in Resources */ = {isa = PBXBuildFile; fileRef = C9DC07FA1B90D0A3007A4DD0 /* PasscodeLock.strings */; }; + C9DC07FF1B90D24A007A4DD0 /* SetPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07FE1B90D24A007A4DD0 /* SetPasscodeState.swift */; }; + C9DC08001B90D24A007A4DD0 /* SetPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07FE1B90D24A007A4DD0 /* SetPasscodeState.swift */; }; + C9DC08021B90D2BA007A4DD0 /* ConfirmPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08011B90D2BA007A4DD0 /* ConfirmPasscodeState.swift */; }; + C9DC08031B90D2BA007A4DD0 /* ConfirmPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08011B90D2BA007A4DD0 /* ConfirmPasscodeState.swift */; }; + C9DC08051B90D394007A4DD0 /* ChangePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08041B90D394007A4DD0 /* ChangePasscodeState.swift */; }; + C9DC08061B90D394007A4DD0 /* ChangePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08041B90D394007A4DD0 /* ChangePasscodeState.swift */; }; + C9DC08081B90DAE6007A4DD0 /* EnterPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08071B90DAE6007A4DD0 /* EnterPasscodeStateTests.swift */; }; + C9DC080A1B90DB09007A4DD0 /* FakePasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08091B90DB09007A4DD0 /* FakePasscodeLock.swift */; }; + C9DC080C1B90DC38007A4DD0 /* SetPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080B1B90DC38007A4DD0 /* SetPasscodeStateTests.swift */; }; + C9DC080E1B90DC8F007A4DD0 /* ConfirmPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080D1B90DC8F007A4DD0 /* ConfirmPasscodeStateTests.swift */; }; + C9DC08101B90DD91007A4DD0 /* ChangePasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080F1B90DD91007A4DD0 /* ChangePasscodeStateTests.swift */; }; + C9DC08121B90DE1B007A4DD0 /* PasscodeSignPlaceholderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08111B90DE1B007A4DD0 /* PasscodeSignPlaceholderView.swift */; }; + C9DC08141B90DE50007A4DD0 /* PasscodeSignButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08131B90DE50007A4DD0 /* PasscodeSignButton.swift */; }; + C9DC08161B90DF4E007A4DD0 /* PasscodeLockViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08151B90DF4E007A4DD0 /* PasscodeLockViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -451,6 +451,7 @@ TargetAttributes = { C99EAF3E1B90B05700D61E1B = { CreatedOnToolsVersion = 7.0; + LastSwiftMigration = 0800; }; C99EAF481B90B05700D61E1B = { CreatedOnToolsVersion = 7.0; @@ -765,6 +766,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -782,6 +784,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.yankodimitrov.PasscodeLock; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/PasscodeLock/Functions.swift b/PasscodeLock/Functions.swift index adb03903..173caf16 100644 --- a/PasscodeLock/Functions.swift +++ b/PasscodeLock/Functions.swift @@ -8,7 +8,7 @@ import Foundation -func localizedStringFor(key: String, comment: String) -> String { +func localizedStringFor(_ key: String, comment: String) -> String { let name = "PasscodeLock" let bundle = bundleForResource(name, ofType: "strings") @@ -16,11 +16,11 @@ func localizedStringFor(key: String, comment: String) -> String { return NSLocalizedString(key, tableName: name, bundle: bundle, comment: comment) } -func bundleForResource(name: String, ofType type: String) -> NSBundle { +func bundleForResource(_ name: String, ofType type: String) -> Bundle { - if(NSBundle.mainBundle().pathForResource(name, ofType: type) != nil) { - return NSBundle.mainBundle() + if(Bundle.main.path(forResource: name, ofType: type) != nil) { + return Bundle.main } - return NSBundle(forClass: PasscodeLock.self) + return Bundle(for: PasscodeLock.self) } diff --git a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift index 1106f145..aefaacae 100644 --- a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift @@ -21,7 +21,7 @@ struct ChangePasscodeState: PasscodeLockStateType { description = localizedStringFor("PasscodeLockChangeDescription", comment: "Change passcode description") } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) { + func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) { guard let currentPasscode = lock.repository.passcode else { return diff --git a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift index c6683cea..371562b5 100644 --- a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift @@ -15,7 +15,7 @@ struct ConfirmPasscodeState: PasscodeLockStateType { let isCancellableAction = true var isTouchIDAllowed = false - private var passcodeToConfirm: [String] + fileprivate var passcodeToConfirm: [String] init(passcode: [String]) { @@ -24,7 +24,7 @@ struct ConfirmPasscodeState: PasscodeLockStateType { description = localizedStringFor("PasscodeLockConfirmDescription", comment: "Confirm passcode description") } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) { + func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) { if passcode == passcodeToConfirm { diff --git a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift index 60f58bc8..6716e0cd 100644 --- a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift @@ -17,8 +17,8 @@ struct EnterPasscodeState: PasscodeLockStateType { let isCancellableAction: Bool var isTouchIDAllowed = true - private var inccorectPasscodeAttempts = 0 - private var isNotificationSent = false + fileprivate var inccorectPasscodeAttempts = 0 + fileprivate var isNotificationSent = false init(allowCancellation: Bool = false) { @@ -27,7 +27,7 @@ struct EnterPasscodeState: PasscodeLockStateType { description = localizedStringFor("PasscodeLockEnterDescription", comment: "Enter passcode description") } - mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) { + mutating func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) { guard let currentPasscode = lock.repository.passcode else { return @@ -50,13 +50,13 @@ struct EnterPasscodeState: PasscodeLockStateType { } } - private mutating func postNotification() { + fileprivate mutating func postNotification() { guard !isNotificationSent else { return } - let center = NSNotificationCenter.defaultCenter() + let center = NotificationCenter.default - center.postNotificationName(PasscodeLockIncorrectPasscodeNotification, object: nil) + center.post(name: Notification.Name(rawValue: PasscodeLockIncorrectPasscodeNotification), object: nil) isNotificationSent = true } diff --git a/PasscodeLock/PasscodeLock/PasscodeLock.swift b/PasscodeLock/PasscodeLock/PasscodeLock.swift index a6ca8372..dc5698f5 100644 --- a/PasscodeLock/PasscodeLock/PasscodeLock.swift +++ b/PasscodeLock/PasscodeLock/PasscodeLock.swift @@ -9,25 +9,25 @@ import Foundation import LocalAuthentication -public class PasscodeLock: PasscodeLockType { +open class PasscodeLock: PasscodeLockType { - public weak var delegate: PasscodeLockTypeDelegate? - public let configuration: PasscodeLockConfigurationType + open weak var delegate: PasscodeLockTypeDelegate? + open let configuration: PasscodeLockConfigurationType - public var repository: PasscodeRepositoryType { + open var repository: PasscodeRepositoryType { return configuration.repository } - public var state: PasscodeLockStateType { + open var state: PasscodeLockStateType { return lockState } - public var isTouchIDAllowed: Bool { + open var isTouchIDAllowed: Bool { return isTouchIDEnabled() && configuration.isTouchIDAllowed && lockState.isTouchIDAllowed } - private var lockState: PasscodeLockStateType - private lazy var passcode = [String]() + fileprivate var lockState: PasscodeLockStateType + fileprivate lazy var passcode = [String]() public init(state: PasscodeLockStateType, configuration: PasscodeLockConfigurationType) { @@ -37,7 +37,7 @@ public class PasscodeLock: PasscodeLockType { self.configuration = configuration } - public func addSign(sign: String) { + open func addSign(_ sign: String) { passcode.append(sign) delegate?.passcodeLock(self, addedSignAtIndex: passcode.count - 1) @@ -45,11 +45,11 @@ public class PasscodeLock: PasscodeLockType { if passcode.count >= configuration.passcodeLength { lockState.acceptPasscode(passcode, fromLock: self) - passcode.removeAll(keepCapacity: true) + passcode.removeAll(keepingCapacity: true) } } - public func removeSign() { + open func removeSign() { guard passcode.count > 0 else { return } @@ -57,13 +57,13 @@ public class PasscodeLock: PasscodeLockType { delegate?.passcodeLock(self, removedSignAtIndex: passcode.count) } - public func changeStateTo(state: PasscodeLockStateType) { + open func changeStateTo(_ state: PasscodeLockStateType) { lockState = state delegate?.passcodeLockDidChangeState(self) } - public func authenticateWithBiometrics() { + open func authenticateWithBiometrics() { guard isTouchIDAllowed else { return } @@ -72,16 +72,16 @@ public class PasscodeLock: PasscodeLockType { context.localizedFallbackTitle = localizedStringFor("PasscodeLockTouchIDButton", comment: "TouchID authentication fallback button") - context.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { + context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, error in self.handleTouchIDResult(success) } } - private func handleTouchIDResult(success: Bool) { + fileprivate func handleTouchIDResult(_ success: Bool) { - dispatch_async(dispatch_get_main_queue()) { + DispatchQueue.main.async { if success { @@ -90,10 +90,10 @@ public class PasscodeLock: PasscodeLockType { } } - private func isTouchIDEnabled() -> Bool { + fileprivate func isTouchIDEnabled() -> Bool { let context = LAContext() - return context.canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: nil) + return context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) } } diff --git a/PasscodeLock/PasscodeLock/SetPasscodeState.swift b/PasscodeLock/PasscodeLock/SetPasscodeState.swift index f4a96be9..b43e4bbb 100644 --- a/PasscodeLock/PasscodeLock/SetPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/SetPasscodeState.swift @@ -27,7 +27,7 @@ struct SetPasscodeState: PasscodeLockStateType { description = localizedStringFor("PasscodeLockSetDescription", comment: "Set passcode description") } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) { + func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) { let nextState = ConfirmPasscodeState(passcode: passcode) diff --git a/PasscodeLock/PasscodeLockPresenter.swift b/PasscodeLock/PasscodeLockPresenter.swift index c2ac3d6d..b32ab26a 100644 --- a/PasscodeLock/PasscodeLockPresenter.swift +++ b/PasscodeLock/PasscodeLockPresenter.swift @@ -8,13 +8,13 @@ import UIKit -public class PasscodeLockPresenter { +open class PasscodeLockPresenter { - private var mainWindow: UIWindow? + fileprivate var mainWindow: UIWindow? - private lazy var passcodeLockWindow: UIWindow = { + fileprivate lazy var passcodeLockWindow: UIWindow = { - let window = UIWindow(frame: UIScreen.mainScreen().bounds) + let window = UIWindow(frame: UIScreen.main.bounds) window.windowLevel = 0 window.makeKeyAndVisible() @@ -22,9 +22,9 @@ public class PasscodeLockPresenter { return window }() - private let passcodeConfiguration: PasscodeLockConfigurationType - public var isPasscodePresented = false - public let passcodeLockVC: PasscodeLockViewController + fileprivate let passcodeConfiguration: PasscodeLockConfigurationType + open var isPasscodePresented = false + open let passcodeLockVC: PasscodeLockViewController public init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType, viewController: PasscodeLockViewController) { @@ -37,12 +37,12 @@ public class PasscodeLockPresenter { public convenience init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType) { - let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: configuration) + let passcodeLockVC = PasscodeLockViewController(state: .enterPasscode, config: configuration) self.init(mainWindow: window, configuration: configuration, viewController: passcodeLockVC) } - public func presentPasscodeLock() { + open func presentPasscodeLock() { guard passcodeConfiguration.repository.hasPasscode else { return } guard !isPasscodePresented else { return } @@ -50,12 +50,12 @@ public class PasscodeLockPresenter { isPasscodePresented = true passcodeLockWindow.windowLevel = 2 - passcodeLockWindow.hidden = false + passcodeLockWindow.isHidden = false mainWindow?.windowLevel = 1 mainWindow?.endEditing(true) - let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: passcodeConfiguration) + let passcodeLockVC = PasscodeLockViewController(state: .enterPasscode, config: passcodeConfiguration) let userDismissCompletionCallback = passcodeLockVC.dismissCompletionCallback passcodeLockVC.dismissCompletionCallback = { [weak self] in @@ -68,7 +68,7 @@ public class PasscodeLockPresenter { passcodeLockWindow.rootViewController = passcodeLockVC } - public func dismissPasscodeLock(animated animated: Bool = true) { + open func dismissPasscodeLock(animated: Bool = true) { isPasscodePresented = false mainWindow?.windowLevel = 1 @@ -87,12 +87,12 @@ public class PasscodeLockPresenter { internal func animatePasscodeLockDismissal() { - UIView.animateWithDuration( - 0.5, + UIView.animate( + withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, - options: [.CurveEaseInOut], + options: UIViewAnimationOptions(), animations: { [weak self] in self?.passcodeLockWindow.alpha = 0 diff --git a/PasscodeLock/PasscodeLockViewController.swift b/PasscodeLock/PasscodeLockViewController.swift index 095f10f2..6c12e393 100644 --- a/PasscodeLock/PasscodeLockViewController.swift +++ b/PasscodeLock/PasscodeLockViewController.swift @@ -8,43 +8,43 @@ import UIKit -public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDelegate { +open class PasscodeLockViewController: UIViewController, PasscodeLockTypeDelegate { public enum LockState { - case EnterPasscode - case SetPasscode - case ChangePasscode - case RemovePasscode + case enterPasscode + case setPasscode + case changePasscode + case removePasscode func getState() -> PasscodeLockStateType { switch self { - case .EnterPasscode: return EnterPasscodeState() - case .SetPasscode: return SetPasscodeState() - case .ChangePasscode: return ChangePasscodeState() - case .RemovePasscode: return EnterPasscodeState(allowCancellation: true) + case .enterPasscode: return EnterPasscodeState() + case .setPasscode: return SetPasscodeState() + case .changePasscode: return ChangePasscodeState() + case .removePasscode: return EnterPasscodeState(allowCancellation: true) } } } - @IBOutlet public weak var titleLabel: UILabel? - @IBOutlet public weak var descriptionLabel: UILabel? - @IBOutlet public var placeholders: [PasscodeSignPlaceholderView] = [PasscodeSignPlaceholderView]() - @IBOutlet public weak var cancelButton: UIButton? - @IBOutlet public weak var deleteSignButton: UIButton? - @IBOutlet public weak var touchIDButton: UIButton? - @IBOutlet public weak var placeholdersX: NSLayoutConstraint? + @IBOutlet open weak var titleLabel: UILabel? + @IBOutlet open weak var descriptionLabel: UILabel? + @IBOutlet open var placeholders: [PasscodeSignPlaceholderView] = [PasscodeSignPlaceholderView]() + @IBOutlet open weak var cancelButton: UIButton? + @IBOutlet open weak var deleteSignButton: UIButton? + @IBOutlet open weak var touchIDButton: UIButton? + @IBOutlet open weak var placeholdersX: NSLayoutConstraint? - public var successCallback: ((lock: PasscodeLockType) -> Void)? - public var dismissCompletionCallback: (()->Void)? - public var animateOnDismiss: Bool - public var notificationCenter: NSNotificationCenter? + open var successCallback: ((_ lock: PasscodeLockType) -> Void)? + open var dismissCompletionCallback: (()->Void)? + open var animateOnDismiss: Bool + open var notificationCenter: NotificationCenter? internal let passcodeConfiguration: PasscodeLockConfigurationType - internal let passcodeLock: PasscodeLockType + internal var passcodeLock: PasscodeLockType internal var isPlaceholdersAnimationCompleted = true - private var shouldTryToAuthenticateWithBiometrics = true + fileprivate var shouldTryToAuthenticateWithBiometrics = true // MARK: - Initializers @@ -56,17 +56,17 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg passcodeLock = PasscodeLock(state: state, configuration: configuration) let nibName = "PasscodeLockView" - let bundle: NSBundle = bundleForResource(nibName, ofType: "nib") + let bundle: Bundle = bundleForResource(nibName, ofType: "nib") super.init(nibName: nibName, bundle: bundle) passcodeLock.delegate = self - notificationCenter = NSNotificationCenter.defaultCenter() + notificationCenter = NotificationCenter.default } - public convenience init(state: LockState, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true) { + public convenience init(state: LockState, config: PasscodeLockConfigurationType, animateOnDismiss: Bool = true) { - self.init(state: state.getState(), configuration: configuration, animateOnDismiss: animateOnDismiss) + self.init(state: state.getState(), configuration: config, animateOnDismiss: animateOnDismiss) } public required init(coder aDecoder: NSCoder) { @@ -80,16 +80,16 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg // MARK: - View - public override func viewDidLoad() { + open override func viewDidLoad() { super.viewDidLoad() updatePasscodeView() - deleteSignButton?.enabled = false + deleteSignButton?.isEnabled = false setupEvents() } - public override func viewDidAppear(animated: Bool) { + open override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) if shouldTryToAuthenticateWithBiometrics { @@ -102,59 +102,59 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg titleLabel?.text = passcodeLock.state.title descriptionLabel?.text = passcodeLock.state.description - cancelButton?.hidden = !passcodeLock.state.isCancellableAction - touchIDButton?.hidden = !passcodeLock.isTouchIDAllowed + cancelButton?.isHidden = !passcodeLock.state.isCancellableAction + touchIDButton?.isHidden = !passcodeLock.isTouchIDAllowed } // MARK: - Events - private func setupEvents() { + fileprivate func setupEvents() { - notificationCenter?.addObserver(self, selector: "appWillEnterForegroundHandler:", name: UIApplicationWillEnterForegroundNotification, object: nil) - notificationCenter?.addObserver(self, selector: "appDidEnterBackgroundHandler:", name: UIApplicationDidEnterBackgroundNotification, object: nil) + notificationCenter?.addObserver(self, selector: #selector(PasscodeLockViewController.appWillEnterForegroundHandler(_:)), name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil) + notificationCenter?.addObserver(self, selector: #selector(PasscodeLockViewController.appDidEnterBackgroundHandler(_:)), name: NSNotification.Name.UIApplicationDidEnterBackground, object: nil) } - private func clearEvents() { + fileprivate func clearEvents() { - notificationCenter?.removeObserver(self, name: UIApplicationWillEnterForegroundNotification, object: nil) - notificationCenter?.removeObserver(self, name: UIApplicationDidEnterBackgroundNotification, object: nil) + notificationCenter?.removeObserver(self, name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil) + notificationCenter?.removeObserver(self, name: NSNotification.Name.UIApplicationDidEnterBackground, object: nil) } - public func appWillEnterForegroundHandler(notification: NSNotification) { + @objc open func appWillEnterForegroundHandler(_ notification: Notification) { authenticateWithBiometrics() } - public func appDidEnterBackgroundHandler(notification: NSNotification) { + @objc open func appDidEnterBackgroundHandler(_ notification: Notification) { shouldTryToAuthenticateWithBiometrics = false } // MARK: - Actions - @IBAction func passcodeSignButtonTap(sender: PasscodeSignButton) { + @IBAction func passcodeSignButtonTap(_ sender: PasscodeSignButton) { guard isPlaceholdersAnimationCompleted else { return } passcodeLock.addSign(sender.passcodeSign) } - @IBAction func cancelButtonTap(sender: UIButton) { + @IBAction func cancelButtonTap(_ sender: UIButton) { dismissPasscodeLock(passcodeLock) } - @IBAction func deleteSignButtonTap(sender: UIButton) { + @IBAction func deleteSignButtonTap(_ sender: UIButton) { passcodeLock.removeSign() } - @IBAction func touchIDButtonTap(sender: UIButton) { + @IBAction func touchIDButtonTap(_ sender: UIButton) { passcodeLock.authenticateWithBiometrics() } - private func authenticateWithBiometrics() { + fileprivate func authenticateWithBiometrics() { if passcodeConfiguration.shouldRequestTouchIDImmediately && passcodeLock.isTouchIDAllowed { @@ -162,16 +162,15 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg } } - internal func dismissPasscodeLock(lock: PasscodeLockType, completionHandler: (() -> Void)? = nil) { + internal func dismissPasscodeLock(_ lock: PasscodeLockType, completionHandler: (() -> Void)? = nil) { // if presented as modal if presentingViewController?.presentedViewController == self { - dismissViewControllerAnimated(animateOnDismiss, completion: { [weak self] _ in - - self?.dismissCompletionCallback?() + + dismiss(animated: animateOnDismiss, completion: { () -> Void in + self.dismissCompletionCallback?() - completionHandler?() }) return @@ -179,7 +178,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg // if pushed in a navigation controller } else if navigationController != nil { - navigationController?.popViewControllerAnimated(animateOnDismiss) + navigationController?.popViewController(animated: animateOnDismiss) } dismissCompletionCallback?() @@ -191,16 +190,16 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg internal func animateWrongPassword() { - deleteSignButton?.enabled = false + deleteSignButton?.isEnabled = false isPlaceholdersAnimationCompleted = false - animatePlaceholders(placeholders, toState: .Error) + animatePlaceholders(placeholders, toState: .error) placeholdersX?.constant = -40 view.layoutIfNeeded() - UIView.animateWithDuration( - 0.5, + UIView.animate( + withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.2, initialSpringVelocity: 0, @@ -213,11 +212,11 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg completion: { completed in self.isPlaceholdersAnimationCompleted = true - self.animatePlaceholders(self.placeholders, toState: .Inactive) + self.animatePlaceholders(self.placeholders, toState: .inactive) }) } - internal func animatePlaceholders(placeholders: [PasscodeSignPlaceholderView], toState state: PasscodeSignPlaceholderView.State) { + internal func animatePlaceholders(_ placeholders: [PasscodeSignPlaceholderView], toState state: PasscodeSignPlaceholderView.State) { for placeholder in placeholders { @@ -225,7 +224,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg } } - private func animatePlacehodlerAtIndex(index: Int, toState state: PasscodeSignPlaceholderView.State) { + fileprivate func animatePlacehodlerAtIndex(_ index: Int, toState state: PasscodeSignPlaceholderView.State) { guard index < placeholders.count && index >= 0 else { return } @@ -234,40 +233,43 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg // MARK: - PasscodeLockDelegate - public func passcodeLockDidSucceed(lock: PasscodeLockType) { + open func passcodeLockDidSucceed(_ lock: PasscodeLockType) { - deleteSignButton?.enabled = true - animatePlaceholders(placeholders, toState: .Inactive) - dismissPasscodeLock(lock, completionHandler: { [weak self] _ in - self?.successCallback?(lock: lock) + deleteSignButton?.isEnabled = true + animatePlaceholders(placeholders, toState: .inactive) + dismissPasscodeLock(lock, completionHandler: { () -> Void in + self.successCallback?(lock) + }) + } - public func passcodeLockDidFail(lock: PasscodeLockType) { + open func passcodeLockDidFail(_ lock: PasscodeLockType) { animateWrongPassword() } - public func passcodeLockDidChangeState(lock: PasscodeLockType) { + open func passcodeLockDidChangeState(_ lock: PasscodeLockType) { updatePasscodeView() - animatePlaceholders(placeholders, toState: .Inactive) - deleteSignButton?.enabled = false + animatePlaceholders(placeholders, toState: .inactive) + deleteSignButton?.isEnabled = false } - public func passcodeLock(lock: PasscodeLockType, addedSignAtIndex index: Int) { + open func passcodeLock(_ lock: PasscodeLockType, addedSignAtIndex index: Int) { - animatePlacehodlerAtIndex(index, toState: .Active) - deleteSignButton?.enabled = true + animatePlacehodlerAtIndex(index, toState: .active) + deleteSignButton?.isEnabled = true } - public func passcodeLock(lock: PasscodeLockType, removedSignAtIndex index: Int) { + open func passcodeLock(_ lock: PasscodeLockType, removedSignAtIndex index: Int) { - animatePlacehodlerAtIndex(index, toState: .Inactive) + animatePlacehodlerAtIndex(index, toState: .inactive) if index == 0 { - deleteSignButton?.enabled = false + deleteSignButton?.isEnabled = false } } } + diff --git a/PasscodeLock/Protocols/PasscodeLockStateType.swift b/PasscodeLock/Protocols/PasscodeLockStateType.swift index d9725f15..f246e2d9 100644 --- a/PasscodeLock/Protocols/PasscodeLockStateType.swift +++ b/PasscodeLock/Protocols/PasscodeLockStateType.swift @@ -15,5 +15,5 @@ public protocol PasscodeLockStateType { var isCancellableAction: Bool {get} var isTouchIDAllowed: Bool {get} - mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) + mutating func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) } diff --git a/PasscodeLock/Protocols/PasscodeLockType.swift b/PasscodeLock/Protocols/PasscodeLockType.swift index e236b05c..434c87d6 100644 --- a/PasscodeLock/Protocols/PasscodeLockType.swift +++ b/PasscodeLock/Protocols/PasscodeLockType.swift @@ -16,17 +16,17 @@ public protocol PasscodeLockType { var state: PasscodeLockStateType {get} var isTouchIDAllowed: Bool {get} - func addSign(sign: String) + func addSign(_ sign: String) func removeSign() - func changeStateTo(state: PasscodeLockStateType) + func changeStateTo(_ state: PasscodeLockStateType) func authenticateWithBiometrics() } public protocol PasscodeLockTypeDelegate: class { - func passcodeLockDidSucceed(lock: PasscodeLockType) - func passcodeLockDidFail(lock: PasscodeLockType) - func passcodeLockDidChangeState(lock: PasscodeLockType) - func passcodeLock(lock: PasscodeLockType, addedSignAtIndex index: Int) - func passcodeLock(lock: PasscodeLockType, removedSignAtIndex index: Int) + func passcodeLockDidSucceed(_ lock: PasscodeLockType) + func passcodeLockDidFail(_ lock: PasscodeLockType) + func passcodeLockDidChangeState(_ lock: PasscodeLockType) + func passcodeLock(_ lock: PasscodeLockType, addedSignAtIndex index: Int) + func passcodeLock(_ lock: PasscodeLockType, removedSignAtIndex index: Int) } diff --git a/PasscodeLock/Protocols/PasscodeRepositoryType.swift b/PasscodeLock/Protocols/PasscodeRepositoryType.swift index 19272379..79475434 100644 --- a/PasscodeLock/Protocols/PasscodeRepositoryType.swift +++ b/PasscodeLock/Protocols/PasscodeRepositoryType.swift @@ -13,6 +13,6 @@ public protocol PasscodeRepositoryType { var hasPasscode: Bool {get} var passcode: [String]? {get} - func savePasscode(passcode: [String]) + func savePasscode(_ passcode: [String]) func deletePasscode() } diff --git a/PasscodeLock/Views/PasscodeSignButton.swift b/PasscodeLock/Views/PasscodeSignButton.swift index 9fb3968a..0ed0d7fe 100644 --- a/PasscodeLock/Views/PasscodeSignButton.swift +++ b/PasscodeLock/Views/PasscodeSignButton.swift @@ -9,27 +9,27 @@ import UIKit @IBDesignable -public class PasscodeSignButton: UIButton { +open class PasscodeSignButton: UIButton { @IBInspectable - public var passcodeSign: String = "1" + open var passcodeSign: String = "1" @IBInspectable - public var borderColor: UIColor = UIColor.whiteColor() { + open var borderColor: UIColor = UIColor.white { didSet { setupView() } } @IBInspectable - public var borderRadius: CGFloat = 30 { + open var borderRadius: CGFloat = 30 { didSet { setupView() } } @IBInspectable - public var highlightBackgroundColor: UIColor = UIColor.clearColor() { + open var highlightBackgroundColor: UIColor = UIColor.clear { didSet { setupView() } @@ -50,18 +50,18 @@ public class PasscodeSignButton: UIButton { setupActions() } - public override func intrinsicContentSize() -> CGSize { + open override var intrinsicContentSize : CGSize { - return CGSizeMake(60, 60) + return CGSize(width: 60, height: 60) } - private var defaultBackgroundColor = UIColor.clearColor() + fileprivate var defaultBackgroundColor = UIColor.clear - private func setupView() { + fileprivate func setupView() { layer.borderWidth = 1 layer.cornerRadius = borderRadius - layer.borderColor = borderColor.CGColor + layer.borderColor = borderColor.cgColor if let backgroundColor = backgroundColor { @@ -69,30 +69,30 @@ public class PasscodeSignButton: UIButton { } } - private func setupActions() { + fileprivate func setupActions() { - addTarget(self, action: Selector("handleTouchDown"), forControlEvents: .TouchDown) - addTarget(self, action: Selector("handleTouchUp"), forControlEvents: [.TouchUpInside, .TouchDragOutside, .TouchCancel]) + addTarget(self, action: #selector(PasscodeSignButton.handleTouchDown), for: .touchDown) + addTarget(self, action: #selector(PasscodeSignButton.handleTouchUp), for: [.touchUpInside, .touchDragOutside, .touchCancel]) } - func handleTouchDown() { + @objc func handleTouchDown() { animateBackgroundColor(highlightBackgroundColor) } - func handleTouchUp() { + @objc func handleTouchUp() { animateBackgroundColor(defaultBackgroundColor) } - private func animateBackgroundColor(color: UIColor) { + fileprivate func animateBackgroundColor(_ color: UIColor) { - UIView.animateWithDuration( - 0.3, + UIView.animate( + withDuration: 0.3, delay: 0.0, usingSpringWithDamping: 1, initialSpringVelocity: 0.0, - options: [.AllowUserInteraction, .BeginFromCurrentState], + options: [.allowUserInteraction, .beginFromCurrentState], animations: { self.backgroundColor = color diff --git a/PasscodeLock/Views/PasscodeSignPlaceholderView.swift b/PasscodeLock/Views/PasscodeSignPlaceholderView.swift index 953c9ef4..2191a302 100644 --- a/PasscodeLock/Views/PasscodeSignPlaceholderView.swift +++ b/PasscodeLock/Views/PasscodeSignPlaceholderView.swift @@ -9,30 +9,30 @@ import UIKit @IBDesignable -public class PasscodeSignPlaceholderView: UIView { +open class PasscodeSignPlaceholderView: UIView { public enum State { - case Inactive - case Active - case Error + case inactive + case active + case error } @IBInspectable - public var inactiveColor: UIColor = UIColor.whiteColor() { + open var inactiveColor: UIColor = UIColor.white { didSet { setupView() } } @IBInspectable - public var activeColor: UIColor = UIColor.grayColor() { + open var activeColor: UIColor = UIColor.gray { didSet { setupView() } } @IBInspectable - public var errorColor: UIColor = UIColor.redColor() { + open var errorColor: UIColor = UIColor.red { didSet { setupView() } @@ -50,34 +50,34 @@ public class PasscodeSignPlaceholderView: UIView { super.init(coder: aDecoder) } - public override func intrinsicContentSize() -> CGSize { + open override var intrinsicContentSize : CGSize { - return CGSizeMake(16, 16) + return CGSize(width: 16, height: 16) } - private func setupView() { + fileprivate func setupView() { layer.cornerRadius = 8 layer.borderWidth = 1 - layer.borderColor = activeColor.CGColor + layer.borderColor = activeColor.cgColor backgroundColor = inactiveColor } - private func colorsForState(state: State) -> (backgroundColor: UIColor, borderColor: UIColor) { + fileprivate func colorsForState(_ state: State) -> (backgroundColor: UIColor, borderColor: UIColor) { switch state { - case .Inactive: return (inactiveColor, activeColor) - case .Active: return (activeColor, activeColor) - case .Error: return (errorColor, errorColor) + case .inactive: return (inactiveColor, activeColor) + case .active: return (activeColor, activeColor) + case .error: return (errorColor, errorColor) } } - public func animateState(state: State) { + open func animateState(_ state: State) { let colors = colorsForState(state) - UIView.animateWithDuration( - 0.5, + UIView.animate( + withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, @@ -85,7 +85,7 @@ public class PasscodeSignPlaceholderView: UIView { animations: { self.backgroundColor = colors.backgroundColor - self.layer.borderColor = colors.borderColor.CGColor + self.layer.borderColor = colors.borderColor.cgColor }, completion: nil