Skip to content

Commit

Permalink
[Refactor] #239 - Refactor Clip Coordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
mini-min committed Jan 13, 2025
1 parent 60498d9 commit 65813f4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ private extension ClipCoordinator {
func showDetailClipVC(id: Int, name: String) {
let vc = viewControllerFactory.makeDetailClipVC()
vc.setupCategory(id: id, name: name)
router.push(vc, animated: true)
vc.onLinkSelected = { [weak self] linkURL, isRead, id in
self?.showLinkWebVC(linkURL: linkURL, isRead: isRead, id: id)
}
router.push(vc, animated: true, hideBottomBarWhenPushed: true)
}

func showLinkWebVC(linkURL: String, isRead: Bool, id: Int) {
let vc = viewControllerFactory.makeLinkWebVC()
vc.setupDataBind(linkURL: linkURL, isRead: isRead, id: id)
vc.onBack = { [weak self] in
self?.router.pop(animated: true)
}
router.push(vc, animated: true, hideBottomBarWhenPushed: true)
}
}
18 changes: 10 additions & 8 deletions TOASTER-iOS/Present/DetailClip/View/DetailClipViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import Then

final class DetailClipViewController: UIViewController {

// MARK: - View Controllable

var onLinkSelected: ((String, Bool, Int) -> Void)?

// MARK: - Data Streams

private let viewModel: DetailClipViewModel!
private var cancelBag = CancelBag()

Expand Down Expand Up @@ -366,14 +372,10 @@ extension DetailClipViewController: UICollectionViewDataSource {
extension DetailClipViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
indexNumber = indexPath.item
let nextVC = ViewControllerFactory.shared.makeLinkWebVC()
nextVC.hidesBottomBarWhenPushed = true
nextVC.setupDataBind(
linkURL: viewModel.toastList.toastList[indexPath.item].url,
isRead: viewModel.toastList.toastList[indexPath.item].isRead,
id: viewModel.toastList.toastList[indexPath.item].id
)
self.navigationController?.pushViewController(nextVC, animated: true)
let linkURL = viewModel.toastList.toastList[indexPath.item].url
let isRead = viewModel.toastList.toastList[indexPath.item].isRead
let id = viewModel.toastList.toastList[indexPath.item].id
onLinkSelected?(linkURL, isRead, id)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import Then

final class LinkWebViewController: UIViewController {

// MARK: - View Controllable

var onBack: (() -> Void)?

// MARK: - Properties

private var viewModel: LinkWebViewModel!
Expand Down Expand Up @@ -175,10 +179,7 @@ private extension LinkWebViewController {

func setupNavigationBarAction() {
/// 네비게이션바 뒤로가기 버튼 클릭 액션 클로저
navigationView.popButtonTapped {
self.navigationController?.popViewController(animated: true)
self.showNavigationBar()
}
navigationView.popButtonTapped { self.onBack?() }

/// 네비게이션바 새로고침 버튼 클릭 액션 클로저
navigationView.reloadButtonTapped { self.webView.reload() }
Expand Down

0 comments on commit 65813f4

Please sign in to comment.