-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MERGE] Curriculum, Challenge, Bookmark Adaptor Pattern 적용 (#155)
[REFACTOR] Curriculum, Challenge, Bookmark Adaptor Pattern 적용 (#155)
- Loading branch information
Showing
28 changed files
with
417 additions
and
198 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
31 changes: 31 additions & 0 deletions
31
LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/BookmarkAdaptor.swift
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,31 @@ | ||
// | ||
// BookmarkAdaptor.swift | ||
// LionHeart-iOS | ||
// | ||
// Created by 김민재 on 10/17/23. | ||
// | ||
|
||
import Foundation | ||
|
||
typealias EntireBookmarkNavigation = BookmarkNavigation | ||
|
||
final class BookmarkAdaptor: EntireBookmarkNavigation { | ||
|
||
let coordinator: BookmarkCoordinator | ||
|
||
init(coordinator: BookmarkCoordinator) { | ||
self.coordinator = coordinator | ||
} | ||
|
||
func bookmarkCellTapped(articleID: Int) { | ||
coordinator.showArticleDetailViewController(articleId: articleID) | ||
} | ||
|
||
func checkTokenIsExpired() { | ||
coordinator.exitApplication() | ||
} | ||
|
||
func backButtonTapped() { | ||
coordinator.pop() | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ChallengeAdaptor.swift
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,31 @@ | ||
// | ||
// ChallengeAdaptor.swift | ||
// LionHeart-iOS | ||
// | ||
// Created by 김민재 on 10/17/23. | ||
// | ||
|
||
import Foundation | ||
|
||
typealias EntireChallengeNavigation = ChallengeNavigation | ||
|
||
final class ChallengeAdaptor: EntireChallengeNavigation { | ||
|
||
let coordinator: ChallengeCoordinator | ||
|
||
init(coordinator: ChallengeCoordinator) { | ||
self.coordinator = coordinator | ||
} | ||
|
||
func navigationRightButtonTapped() { | ||
self.coordinator.showMypageViewController() | ||
} | ||
|
||
func navigationLeftButtonTapped() { | ||
self.coordinator.showBookmarkViewController() | ||
} | ||
|
||
func checkTokenIsExpired() { | ||
self.coordinator.exitApplication() | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/CurriculumAdaptor.swift
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,45 @@ | ||
// | ||
// CurriculumAdaptor.swift | ||
// LionHeart-iOS | ||
// | ||
// Created by 김민재 on 10/17/23. | ||
// | ||
|
||
import Foundation | ||
|
||
typealias EntireCurriculumNavigation = CurriculumNavigation & CurriculumListByWeekNavigation | ||
|
||
|
||
final class CurriculumAdaptor: EntireCurriculumNavigation { | ||
|
||
let coordinator: CurriculumCoordinator | ||
|
||
init(coordinator: CurriculumCoordinator) { | ||
self.coordinator = coordinator | ||
} | ||
|
||
func articleListCellTapped(itemIndex: Int) { | ||
self.coordinator.showCurriculumListViewController(itemIndex: itemIndex) | ||
} | ||
|
||
func navigationRightButtonTapped() { | ||
self.coordinator.showMypageViewController() | ||
} | ||
|
||
func navigationLeftButtonTapped() { | ||
self.coordinator.showBookmarkViewController() | ||
} | ||
|
||
func checkTokenIsExpired() { | ||
self.coordinator.exitApplication() | ||
} | ||
|
||
func curriculumArticleListCellTapped(articleId: Int) { | ||
self.coordinator.showArticleDetailViewController(articleId: articleId) | ||
} | ||
|
||
func backButtonTapped() { | ||
self.coordinator.pop() | ||
} | ||
|
||
} |
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 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 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 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
54 changes: 54 additions & 0 deletions
54
LionHeart-iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/BookmarkCoordinatorImpl.swift
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,54 @@ | ||
// | ||
// BookmarkCoordinatorImpl.swift | ||
// LionHeart-iOS | ||
// | ||
// Created by 김민재 on 10/17/23. | ||
// | ||
|
||
import UIKit | ||
|
||
final class BookmarkCoordinatorImpl: BookmarkCoordinator { | ||
|
||
weak var parentCoordinator: Coordinator? | ||
private let factory: BookmarkFactory | ||
|
||
var children: [Coordinator] = [] | ||
|
||
var navigationController: UINavigationController | ||
|
||
init(navigationController: UINavigationController, factory: BookmarkFactory) { | ||
self.navigationController = navigationController | ||
self.factory = factory | ||
} | ||
|
||
func start() { | ||
showBookmarkViewController() | ||
} | ||
|
||
func showBookmarkViewController() { | ||
let bookmarkViewController = factory.makeBookmarkViewController(coordinator: self) | ||
self.navigationController.pushViewController(bookmarkViewController, animated: true) | ||
} | ||
|
||
func showArticleDetailViewController(articleId: Int) { | ||
let articleCoordinator = ArticleCoordinator( | ||
navigationController: navigationController, | ||
factory: ArticleFactoryImpl(), | ||
articleId: articleId) | ||
articleCoordinator.start() | ||
children.append(articleCoordinator) | ||
} | ||
|
||
func pop() { | ||
self.navigationController.popViewController(animated: true) | ||
self.parentCoordinator?.childDidFinish(self) | ||
} | ||
|
||
func exitApplication() { | ||
UIApplication.shared.perform(#selector(NSXPCConnection.suspend)) | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { | ||
exit(0) | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.