-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from clutter/camera-coordinator
Add Camera Coordinator
- Loading branch information
Showing
10 changed files
with
163 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// CameraCoordinatorTests.swift | ||
// TiltUp_Tests | ||
// | ||
// Created by John Brophy on 8/17/21. | ||
// Copyright © 2021 Clutter. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
import TiltUpTest | ||
|
||
@testable import TiltUp | ||
|
||
final class CameraCoordinatorTests: XCTestCase, WaitableCoordinatorTest { | ||
private var parent: TestCoordinator! | ||
|
||
override func setUp() { | ||
parent = TestCoordinator() | ||
} | ||
|
||
override func tearDown() { | ||
parent = nil | ||
} | ||
|
||
func testStartForModal() { | ||
let coordinator = CameraCoordinator( | ||
parent: parent, | ||
modal: true, | ||
hintProvider: { _ in return nil }, | ||
viewModel: .init( | ||
settings: .init(numberOfPhotos: 1...1), | ||
logger: .init(info: { _ in }, bug: { _ in }) | ||
) | ||
) | ||
|
||
waitForPresentedViewControllerChange(in: parent.router) { | ||
coordinator.start() | ||
} | ||
|
||
assertRetained(coordinator, withTopViewControllerOfType: CameraController.self) | ||
} | ||
|
||
func testStartForNonModal() { | ||
let coordinator = CameraCoordinator( | ||
parent: parent, | ||
modal: false, | ||
hintProvider: { _ in return nil }, | ||
viewModel: .init( | ||
settings: .init(numberOfPhotos: 1...1), | ||
logger: .init(info: { _ in }, bug: { _ in }) | ||
) | ||
) | ||
|
||
waitForTopViewControllerChange(in: coordinator.router) { | ||
coordinator.start() | ||
} | ||
|
||
assertRetained(coordinator, withTopViewControllerOfType: CameraController.self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// CameraCoordiantor.swift | ||
// TiltUp | ||
// | ||
// Created by John Brophy on 8/17/21. | ||
// Copyright © 2021 Clutter. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public final class CameraCoordinator: Coordinator { | ||
private let viewModel: CameraViewModel | ||
private let hintProvider: HintProvider | ||
|
||
public init( | ||
parent: Coordinating, | ||
modal: Bool, | ||
hintProvider: @escaping HintProvider, | ||
viewModel: CameraViewModel | ||
) { | ||
self.hintProvider = hintProvider | ||
self.viewModel = viewModel | ||
super.init(parent: parent, modal: modal) | ||
} | ||
|
||
public override func start() { | ||
goToCamera() | ||
} | ||
} | ||
|
||
private extension CameraCoordinator { | ||
func goToCamera() { | ||
let controller = CameraController(viewModel: viewModel, hint: hintProvider) | ||
router.push(controller, retaining: self) | ||
|
||
if router != parent?.router { | ||
parent?.router.presentModal(router) | ||
} | ||
} | ||
} |
Oops, something went wrong.