Skip to content

Commit

Permalink
feat: coordinator를 채택한 구체타입을 감춤 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
dahun-lee-daji committed Jul 20, 2021
1 parent 2934a8e commit e4382d3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
6 changes: 3 additions & 3 deletions iOS/issue-tracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
10D4258326709D3300AE119C /* Extension */,
10BCA8A3266F38D700DBBA61 /* Login */,
10ED3B7E2671C1F600FCBF2E /* Photo */,
10ED3B7D2671AFA000FCBF2E /* NewIssue */,
10ED3B7D2671AFA000FCBF2E /* IssueEdit */,
10D4258026709CB000AE119C /* IssueList */,
);
path = "issue-tracker";
Expand All @@ -193,13 +193,13 @@
path = Extension;
sourceTree = "<group>";
};
10ED3B7D2671AFA000FCBF2E /* NewIssue */ = {
10ED3B7D2671AFA000FCBF2E /* IssueEdit */ = {
isa = PBXGroup;
children = (
1029609A26733FB800669988 /* IssueEdit.storyboard */,
10BDE6B42670C324007B38AF /* IssueEditViewController.swift */,
);
path = NewIssue;
path = IssueEdit;
sourceTree = "<group>";
};
10ED3B7E2671C1F600FCBF2E /* Photo */ = {
Expand Down
8 changes: 8 additions & 0 deletions iOS/issue-tracker/Common/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,13 @@
import UIKit

protocol Coordinator: AnyObject {

var navigationController: UINavigationController { get set }
func present(view: PresentableView)
}

enum PresentableView {
case IssueList
case IssueEdit
case ImagePicker
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ class IssueEditViewController: UIViewController, ReuseIdentity {

@objc
func insertPhoto() {
guard let issueCoordinator = coordinator as? IssueCoordinator else {
return
}
issueCoordinator.pushImagePickerView()
coordinator?.present(view: .ImagePicker)
}

}
Expand Down
17 changes: 15 additions & 2 deletions iOS/issue-tracker/IssueList/IssueCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ class IssueCoordinator: NSObject, Coordinator {
createIssueListVC()
}

func present(view: PresentableView) {
switch view {
case .IssueList:
createIssueListVC()
case .IssueEdit:
pushEditView()
case .ImagePicker:
pushImagePickerView()
default:
return
}
}

private func createIssueListVC() {
guard let issueListVC = IssueListViewController.instantiate(name: StoryBoardName.IssueList.description) else {
return
Expand All @@ -29,15 +42,15 @@ class IssueCoordinator: NSObject, Coordinator {
issueListVC.coordinator = self
}

func pushEditView() {
private func pushEditView() {
guard let issueEditVC = IssueEditViewController.instantiate(name: StoryBoardName.IssueEdit.description) else {
return
}
issueEditVC.coordinator = self
navigationController.pushViewController(issueEditVC, animated: true)
}

func pushImagePickerView() {
private func pushImagePickerView() {
let imagePickerDelegate = ImagePickerDelegate()
let imagePicker = ImagePicker.init(presentationController: self.navigationController, delegate: imagePickerDelegate)
imagePicker.coordinator = self
Expand Down
5 changes: 1 addition & 4 deletions iOS/issue-tracker/IssueList/IssueListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ class IssueListViewController: UIViewController, ReuseIdentity {
weak var coordinator: Coordinator?

@IBAction func pushToEditView(_ sender: Any) {
guard let issueCoordinator = coordinator as? IssueCoordinator else {
return
}
issueCoordinator.pushEditView()
coordinator?.present(view: .IssueEdit)
}

override func viewDidLoad() {
Expand Down

0 comments on commit e4382d3

Please sign in to comment.