Merge branch 'master' into tweak-share-app-screen-text

pull/234/head
James Sangalli 7 years ago committed by GitHub
commit 0af42e8097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      Trust/Protection/Coordinators/LockEnterPasscodeCoordinator.swift
  2. 18
      Trust/Protection/Coordinators/ProtectionCoordinator.swift
  3. 12
      TrustTests/Coordinators/LockEnterPasscodeCoordinatorTest.swift

@ -5,8 +5,7 @@ import UIKit
class LockEnterPasscodeCoordinator: Coordinator {
var coordinators: [Coordinator] = []
var protectionWasShown = false
private let window: UIWindow = UIWindow()
let window: UIWindow = UIWindow()
private let model: LockEnterPasscodeViewModel
private let lock: LockInterface
private lazy var lockEnterPasscodeViewController: LockEnterPasscodeViewController = {
@ -20,21 +19,20 @@ class LockEnterPasscodeCoordinator: Coordinator {
if state {
self?.stop()
}
self?.protectionWasShown = bioUnlock
}
}
func start() {
guard lock.isPasscodeSet() else {
return
}
protectionWasShown = true
guard lock.isPasscodeSet() else { return }
window.rootViewController = lockEnterPasscodeViewController
window.makeKeyAndVisible()
//Because of the usage of the window and rootViewController we are not able to receive properly view life circle events. So we should call this methods manually.
lockEnterPasscodeViewController.showKeyboard()
lockEnterPasscodeViewController.showBioMerickAuth()
}
func stop() {
window.isHidden = true
}
func showAuthentication() {
guard lock.isPasscodeSet() else { return }
lockEnterPasscodeViewController.showKeyboard()
lockEnterPasscodeViewController.showBioMerickAuth()
}
}

@ -19,29 +19,25 @@ class ProtectionCoordinator: Coordinator {
func didFinishLaunchingWithOptions() {
splashCoordinator.start()
lockEnterPasscodeCoordinator.start()
}
func applicationWillResignActive() {
splashCoordinator.start()
lockEnterPasscodeCoordinator.showAuthentication()
}
func applicationDidBecomeActive() {
//We track protectionWasShown because of the Touch ID that will trigger applicationDidBecomeActive method after valdiation.
if !lockEnterPasscodeCoordinator.protectionWasShown {
lockEnterPasscodeCoordinator.start()
} else {
lockEnterPasscodeCoordinator.protectionWasShown = false
splashCoordinator.stop()
}
//We should dismiss spalsh screen when app become active.
splashCoordinator.stop()
func applicationWillResignActive() {
splashCoordinator.start()
}
func applicationDidEnterBackground() {
splashCoordinator.start()
lockEnterPasscodeCoordinator.start()
}
func applicationWillEnterForeground() {
splashCoordinator.stop()
lockEnterPasscodeCoordinator.start()
lockEnterPasscodeCoordinator.showAuthentication()
}
}

@ -8,26 +8,26 @@ class LockEnterPasscodeCoordinatorTest: XCTestCase {
let viewModel = LockEnterPasscodeViewModel()
let fakeLock = FakeLockProtocol()
let coordinator = LockEnterPasscodeCoordinator(model: viewModel, lock: fakeLock)
XCTAssertFalse(coordinator.protectionWasShown)
XCTAssertTrue(coordinator.window.isHidden)
coordinator.start()
XCTAssertTrue(coordinator.protectionWasShown)
XCTAssertFalse(coordinator.window.isHidden)
}
func testStop() {
let viewModel = LockEnterPasscodeViewModel()
let fakeLock = FakeLockProtocol()
let coordinator = LockEnterPasscodeCoordinator(model: viewModel, lock: fakeLock)
XCTAssertFalse(coordinator.protectionWasShown)
coordinator.start()
XCTAssertTrue(coordinator.protectionWasShown)
XCTAssertFalse(coordinator.window.isHidden)
coordinator.stop()
XCTAssertTrue(coordinator.window.isHidden)
}
func testDisableLock() {
let viewModel = LockEnterPasscodeViewModel()
let fakeLock = FakeLockProtocol()
fakeLock.passcodeSet = false
let coordinator = LockEnterPasscodeCoordinator(model: viewModel, lock: fakeLock)
XCTAssertFalse(coordinator.protectionWasShown)
XCTAssertTrue(coordinator.window.isHidden)
coordinator.start()
XCTAssertFalse(coordinator.protectionWasShown)
XCTAssertTrue(coordinator.window.isHidden)
}
}

Loading…
Cancel
Save