-
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] Splash, Auth, ArticleCategory Coordinator에 Adaptor Pattern적용(#…
- Loading branch information
Showing
38 changed files
with
500 additions
and
278 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/ArticleCategoryAdaptor.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,42 @@ | ||
// | ||
// ArticleCategoryAdaptor.swift | ||
// LionHeart-iOS | ||
// | ||
// Created by uiskim on 2023/10/17. | ||
// | ||
|
||
import Foundation | ||
|
||
typealias EntireArticleCategoryNavigation = ArticleCategoryNavigation & ArticleListByCategoryNavigation | ||
|
||
final class ArticleCategoryAdaptor: EntireArticleCategoryNavigation { | ||
|
||
let coordinator: ArticleCategoryCoordinator | ||
init(coordinator: ArticleCategoryCoordinator) { | ||
self.coordinator = coordinator | ||
} | ||
|
||
func articleListCellTapped(categoryName: String) { | ||
self.coordinator.showArticleListbyCategoryViewController(categoryName: categoryName) | ||
} | ||
|
||
func articleListByCategoryCellTapped(articleID: Int) { | ||
self.coordinator.showArticleDetailViewController(articleID: articleID) | ||
} | ||
|
||
func checkTokenIsExpired() { | ||
self.coordinator.exitApplication() | ||
} | ||
|
||
func navigationRightButtonTapped() { | ||
self.coordinator.showMypageViewController() | ||
} | ||
|
||
func navigationLeftButtonTapped() { | ||
self.coordinator.showBookmarkViewController() | ||
} | ||
|
||
func backButtonTapped() { | ||
self.coordinator.pop() | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/AuthAdaptor.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,38 @@ | ||
// | ||
// AuthAdaptor.swift | ||
// LionHeart-iOS | ||
// | ||
// Created by uiskim on 2023/10/17. | ||
// | ||
|
||
import Foundation | ||
|
||
typealias EntireAuthNaviation = LoginNavigation & OnboardingNavigation & CompleteOnbardingNavigation | ||
|
||
final class AuthAdaptor: EntireAuthNaviation { | ||
|
||
let coordinator: AuthCoordinator | ||
init(coordinator: AuthCoordinator) { | ||
self.coordinator = coordinator | ||
} | ||
|
||
func checkUserIsVerified(userState: UserState, kakaoToken: String?) { | ||
self.coordinator.showTabbarOrOnboardingViewController(userState: userState, kakaoToken: kakaoToken) | ||
} | ||
|
||
func onboardingCompleted(data: UserOnboardingModel) { | ||
self.coordinator.showOnboardingCompleteViewController(data: data) | ||
} | ||
|
||
func startButtonTapped() { | ||
self.coordinator.showTabbarController() | ||
} | ||
|
||
func checkTokenIsExpired() { | ||
self.coordinator.exitApplication() | ||
} | ||
|
||
func backButtonTapped() { | ||
self.coordinator.pop() | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
LionHeart-iOS/LionHeart-iOS/Scenes/Adaptor/SplashAdaptor.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,27 @@ | ||
// | ||
// SplashAdaptor.swift | ||
// LionHeart-iOS | ||
// | ||
// Created by uiskim on 2023/10/17. | ||
// | ||
|
||
import Foundation | ||
|
||
typealias EntireSplashNavigation = SplashNavigation | ||
|
||
final class SplashAdaptor: EntireSplashNavigation { | ||
|
||
let coordinator: SplashCoordinator | ||
init(coordinator: SplashCoordinator) { | ||
self.coordinator = coordinator | ||
} | ||
|
||
func checkToken(state: TokenState) { | ||
switch state { | ||
case .valid: | ||
coordinator.showTabbarViewContoller() | ||
case .expired: | ||
coordinator.showLoginViewController() | ||
} | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
.../Scenes/Coordinator/ControllerableInterface/ArticleListByCategoryViewControllerable.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,13 @@ | ||
// | ||
// ArticleListByCategoryViewControllerable.swift | ||
// LionHeart-iOS | ||
// | ||
// Created by uiskim on 2023/10/17. | ||
// | ||
|
||
import UIKit | ||
|
||
protocol ArticleListByCategoryViewControllerable where Self: UIViewController { | ||
var navigator: ArticleListByCategoryNavigation { get set } | ||
var categoryString: String? { get set } | ||
} |
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
78 changes: 78 additions & 0 deletions
78
...iOS/LionHeart-iOS/Scenes/Coordinator/CoordinatorImpl/ArticleCategoryCoordinatorImpl.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,78 @@ | ||
// | ||
// ArticleCategoryCoordinator.swift | ||
// LionHeart-iOS | ||
// | ||
// Created by uiskim on 2023/10/13. | ||
// | ||
|
||
import UIKit | ||
|
||
final class ArticleCategoryCoordinatorImpl: ArticleCategoryCoordinator { | ||
|
||
weak var parentCoordinator: Coordinator? | ||
|
||
private let factory: ArticleCategortFactory | ||
|
||
var children: [Coordinator] = [] | ||
|
||
var navigationController: UINavigationController | ||
|
||
init(navigationController: UINavigationController, factory: ArticleCategortFactory) { | ||
self.navigationController = navigationController | ||
self.factory = factory | ||
} | ||
|
||
func start() { | ||
showArticleCategoryViewController() | ||
} | ||
|
||
func showArticleCategoryViewController() { | ||
let articleCategoryAdaptor = ArticleCategoryAdaptor(coordinator: self) | ||
let articleCategoryViewController = factory.makeArticleCategoryViewController(navigator: articleCategoryAdaptor) | ||
self.navigationController.pushViewController(articleCategoryViewController, animated: true) | ||
} | ||
|
||
func showArticleDetailViewController(articleID: Int) { | ||
let articleCoordinator = ArticleCoordinator( | ||
navigationController: navigationController, | ||
factory: ArticleFactoryImpl(), | ||
articleId: articleID | ||
) | ||
articleCoordinator.parentCoordinator = self | ||
children.append(articleCoordinator) | ||
articleCoordinator.start() | ||
} | ||
|
||
func showArticleListbyCategoryViewController(categoryName: String) { | ||
let articleListbyCategoryViewController = factory.makeArticleListByCategoryViewController(coordinator: self) | ||
articleListbyCategoryViewController.categoryString = categoryName | ||
self.navigationController.pushViewController(articleListbyCategoryViewController, animated: true) | ||
} | ||
|
||
func showBookmarkViewController() { | ||
let bookmarkFactory = BookmarkFactoryImpl() | ||
let bookmarkCoordinator = BookmarkCoordinator(navigationController: navigationController, factory: bookmarkFactory) | ||
bookmarkCoordinator.start() | ||
children.append(bookmarkCoordinator) | ||
} | ||
|
||
func showMypageViewController() { | ||
let mypageCoordinator = MypageCoordinator( | ||
navigationController: navigationController, | ||
factory: MyPageFactoryImpl() | ||
) | ||
mypageCoordinator.start() | ||
children.append(mypageCoordinator) | ||
} | ||
|
||
func pop() { | ||
self.navigationController.popViewController(animated: true) | ||
} | ||
|
||
func exitApplication() { | ||
UIApplication.shared.perform(#selector(NSXPCConnection.suspend)) | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { | ||
exit(0) | ||
} | ||
} | ||
} |
Oops, something went wrong.