Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Domain
import BaseFeatureDependency

public protocol PokeFeatureBuildable {
func makePokeMain(isRouteFromTabBar: Bool, coordinator: Coordinator) -> PokeMainPresentable
func makePokeMain(coordinator: Coordinator) -> PokeMainPresentable
func makePokeMyFriends(coordinator: Coordinator) -> PokeMyFriendsPresentable
func makePokeMyFriendsList(relation: PokeRelation) -> PokeMyFriendsListPresentable
func makePokeOnboarding(coordinator: AnyCoordinatorObject) -> PokeOnboardingPresentable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Domain
public protocol PokeMainViewControllable: LegacyViewControllable { }

public protocol PokeMainRoutingTrigger {
var onNaviBackTap: (() -> Void)? { get set }
var onPokeNotificationsTap: (() -> Void)? { get set }
var onMyFriendsTap: (() -> Void)? { get set }
var onProfileImageTapped: ((Int) -> Void)? { get set }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension LegacyPokeBuilder: LegacyPokeFeatureBuildable {
public func makePokeMain(isRouteFromRoot: Bool, coordinator: Coordinator) -> PokeFeatureInterface.LegacyPokeMainPresentable {
let useCase = DefaultPokeMainUseCase(repository: pokeMainRepository)
let viewModel = PokeMainViewModel(useCase: useCase, coordinator: coordinator)
let pokeMainVC = PokeMainVC(viewModel: viewModel, isRouteFromTabBar: true)
let pokeMainVC = PokeMainVC(viewModel: viewModel)
return (pokeMainVC, viewModel)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ final class LegacyPokeCoordinator: BaseCoordinator {
}

public func showPokeMain(isRouteFromRoot: Bool) {
var pokeMain = factory.makePokeMain(isRouteFromRoot: isRouteFromRoot, coordinator: self)

pokeMain.vm.onNaviBackTap = { [weak self] in
self?.router.dismissModule(animated: true)
self?.finishFlow?()
}
var pokeMain = factory.makePokeMain(isRouteFromRoot: isRouteFromRoot, coordinator: self)

pokeMain.vm.onPokeNotificationsTap = { [weak self] in
self?.runPokeNotificationListFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ extension PokeBuilder: PokeFeatureBuildable {
return (viewController, viewModel)
}

public func makePokeMain(isRouteFromTabBar: Bool, coordinator: Coordinator) -> PokeFeatureInterface.PokeMainPresentable {
public func makePokeMain(coordinator: Coordinator) -> PokeFeatureInterface.PokeMainPresentable {
let useCase = DefaultPokeMainUseCase(repository: pokeMainRepository)
let viewModel = PokeMainViewModel(useCase: useCase, coordinator: coordinator)
let pokeMainVC = PokeMainVC(viewModel: viewModel, isRouteFromTabBar: isRouteFromTabBar)
let pokeMainVC = PokeMainVC(viewModel: viewModel)

return (pokeMainVC, viewModel)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,16 @@ public final class PokeCoordinator: BaseCoordinator {

// MARK: - Coordinator Life Cycle

public func start(isRouteFromTabBar: Bool = true) {
showPokeMain(isRouteFromTabBar: isRouteFromTabBar)
}

public override func start() {
start(isRouteFromTabBar: true)
showPokeMain()
}

// MARK: - Navigation

public func showPokeMain(isRouteFromTabBar: Bool) {
var pokeMain = factory.makePokeMain(isRouteFromTabBar: isRouteFromTabBar, coordinator: self)

if isRouteFromTabBar {
self.rootController = self.navigationController
self.navigationController?.setViewControllers([pokeMain.vc], animated: false)
} else {
let newNav = UINavigationController(rootViewController: pokeMain.vc)
newNav.modalPresentationStyle = .overFullScreen
self.rootController = newNav
pokeMain.vm.onNaviBackTap = { [weak self] in
self?.navigationController?.dismiss(animated: true)
}

self.navigationController?.present(newNav, animated: true)
}
public func showPokeMain() {
var pokeMain = factory.makePokeMain(coordinator: self)
self.rootController = self.navigationController
self.navigationController?.setViewControllers([pokeMain.vc], animated: false)

pokeMain.vm.onPokeOnboardingNeeded = { [weak self] isNeeded in
if isNeeded { self?.runPokeOnboardingFlow() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,18 @@ public final class PokeMainVC: UIViewController, PokeMainViewControllable {
// MARK: - Properties

public var viewModel: PokeMainViewModel
private var isRouteFromTabBar: Bool
private var cancelBag = CancelBag()

// MARK: - UI Components

private let backButton = UIButton().then {
$0.setImage(DSKitAsset.Assets.xMark.image.withTintColor(DSKitAsset.Colors.gray30.color), for: .normal)
}

private let serviceTitleLabel = UILabel().then {
$0.font = UIFont.MDS.heading6.font
$0.textColor = DSKitAsset.Colors.gray30.color
$0.text = I18N.Poke.poke
}

private lazy var navigationView = UIStackView(
arrangedSubviews: [backButton, serviceTitleLabel]
arrangedSubviews: [serviceTitleLabel]
).then {
$0.axis = .horizontal
$0.spacing = 2
Expand Down Expand Up @@ -92,11 +87,9 @@ public final class PokeMainVC: UIViewController, PokeMainViewControllable {
// MARK: - initialization

public init(
viewModel: PokeMainViewModel,
isRouteFromTabBar: Bool
viewModel: PokeMainViewModel
) {
self.viewModel = viewModel
self.isRouteFromTabBar = isRouteFromTabBar
super.init(nibName: nil, bundle: nil)
}

Expand All @@ -122,8 +115,6 @@ extension PokeMainVC {
private func setUI() {
self.navigationController?.isNavigationBarHidden = true
view.backgroundColor = DSKitAsset.Colors.semanticBackground.color

backButton.isHidden = isRouteFromTabBar
}

private func setDelegate() {
Expand Down Expand Up @@ -165,11 +156,6 @@ extension PokeMainVC {
private func setLayout() {
self.view.addSubviews(navigationView, scrollView)

backButton.snp.makeConstraints { make in
make.width.equalTo(40)
make.height.equalTo(40)
}

navigationView.snp.makeConstraints { make in
make.top.equalTo(view.safeAreaLayoutGuide)
make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(20)
Expand Down Expand Up @@ -235,9 +221,6 @@ extension PokeMainVC {
let input = PokeMainViewModel
.Input(
viewDidLoad: Just(()).asDriver(),
naviBackButtonTap: self.backButton
.publisher(for: .touchUpInside)
.mapVoid().asDriver(),
pokedSectionHeaderButtonTap: pokedSectionHeaderView
.rightButtonTap,
friendSectionHeaderButtonTap: friendSectionHeaderView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class PokeMainViewModel: PokeMainViewModelType {

// MARK: - Trigger

public var onNaviBackTap: (() -> Void)?
public var onPokeNotificationsTap: (() -> Void)?
public var onMyFriendsTap: (() -> Void)?
public var onProfileImageTapped: ((Int) -> Void)?
Expand All @@ -41,7 +40,6 @@ public class PokeMainViewModel: PokeMainViewModelType {

public struct Input {
let viewDidLoad: Driver<Void>
let naviBackButtonTap: Driver<Void>
let pokedSectionHeaderButtonTap: Driver<Void>
let friendSectionHeaderButtonTap: Driver<Void>
let pokedSectionKokButtonTap: Driver<PokeUserModel?>
Expand Down Expand Up @@ -88,13 +86,7 @@ extension PokeMainViewModel {
.sink { [weak self] _ in
self?.useCase.checkPokeOnboardingNeeded()
self?.eventTracker.trackViewEvent(with: .viewPokeMain)
}.store(in: cancelBag)

input.naviBackButtonTap
.sink { [weak self] _ in
self?.eventTracker.trackViewEvent(with: .clickPokeQuit)
self?.onNaviBackTap?()
}.store(in: cancelBag)
}.store(in: cancelBag)

input.pokedSectionHeaderButtonTap
.sink { [weak self] _ in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extension ApplicationCoordinator: NotificationCoordinatorDelegate {
switch destination {
case .deepLink(let url):
self.notificationHandler.receive(deepLink: url)
guard let deepLink = self.notificationHandler.deepLink.value else { return }
guard let deepLink = self.notificationHandler.deepLink.value else { return }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의미없는 공백은 지워주세요!

Suggested change
guard let deepLink = self.notificationHandler.deepLink.value else { return }
guard let deepLink = self.notificationHandler.deepLink.value else { return }

handleDeepLink(deepLink: deepLink)
case .webLink(let url):
self.notificationHandler.receive(webLink: url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public final class ApplicationCoordinator: BaseCoordinator {

private func handleNewDeepLink(deepLink: DeepLinkComponentsExecutable) {
self.rootNavigationController.popToRootViewController(animated: false)
deepLink.execute(coordinator: self)
deepLink.execute(coordinator: self)
}

// MARK: - handleWebLink
Expand Down Expand Up @@ -627,7 +627,7 @@ extension ApplicationCoordinator {

extension ApplicationCoordinator {
@discardableResult
internal func runPokeFlow(isRouteFromTabBar: Bool = true) -> BaseCoordinator {
internal func runPokeFlow() -> BaseCoordinator {
var coordinator: BaseCoordinator

switch Config.coordinatorFlag {
Expand All @@ -650,7 +650,7 @@ extension ApplicationCoordinator {
navigationController: pokeNavigationController,
factory: PokeBuilder()
)
newCoordinator.start(isRouteFromTabBar: isRouteFromTabBar)
newCoordinator.start()
coordinator = newCoordinator
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import BaseFeatureDependency
import PokeFeature
import Core

public struct PokeDeepLink: DeepLinkExecutable {
public let name = "poke"
Expand All @@ -18,11 +19,13 @@ public struct PokeDeepLink: DeepLinkExecutable {
public func execute(with coordinator: Coordinator, queryItems: [URLQueryItem]?) -> Coordinator? {
guard let coordinator = coordinator as? ApplicationCoordinator else { return nil }

let userType = UserDefaultKeyList.Auth.getUserType()
coordinator.tabBarController?.selectedIndex = TabBarItemType.poke.getTabIndex(userType: userType)

if self.isDestination == true {
coordinator.runTabBarFlow(initSelectedTabType: .poke)
return coordinator
}

return coordinator.runPokeFlow(isRouteFromTabBar: false)
return coordinator.runPokeFlow()
}
}