Skip to content

Commit

Permalink
[Fix] #244 - navigation view button 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Mar 23, 2024
1 parent 438c7c3 commit 3ae38d0
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit

import SnapKit
import Then
import Combine

protocol NavigationDelegate: AnyObject {
func popViewController()
Expand All @@ -19,6 +20,8 @@ final class NottodoNavigationView: UIView {
// MARK: - Property

weak var delegate: NavigationDelegate?
var cancelBag = Set<AnyCancellable>()
var buttonTapped = PassthroughSubject<Void, Never>()

// MARK: - UI Components

Expand All @@ -31,6 +34,7 @@ final class NottodoNavigationView: UIView {

setUI()
setLayout()
setBindings()
}

required init?(coder: NSCoder) {
Expand Down Expand Up @@ -78,6 +82,14 @@ extension NottodoNavigationView {
}
}

private func setBindings() {
backButton.tapPublisher
.sink { [weak self] _ in
self?.buttonTapped.send(())
}
.store(in: &cancelBag)
}

func setTitle(_ text: String) {
navigationTitle.text = text
}
Expand All @@ -87,3 +99,10 @@ extension NottodoNavigationView {
delegate?.popViewController()
}
}
extension UIButton {
var tapPublisher: AnyPublisher<Void, Never> {
controlPublisher(for: .touchUpInside)
.map { _ in }
.eraseToAnyPublisher()
}
}

0 comments on commit 3ae38d0

Please sign in to comment.