From 3ae38d04c3a16f2158996c27471f62c222fcdce6 Mon Sep 17 00:00:00 2001 From: jeongdung-eo Date: Sat, 23 Mar 2024 16:24:16 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20#244=20-=20navigation=20view=20button?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/NottodoNavigationView.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/NottodoNavigationView.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/NottodoNavigationView.swift index 84dbcd3..b85d844 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/NottodoNavigationView.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/NottodoNavigationView.swift @@ -9,6 +9,7 @@ import UIKit import SnapKit import Then +import Combine protocol NavigationDelegate: AnyObject { func popViewController() @@ -19,6 +20,8 @@ final class NottodoNavigationView: UIView { // MARK: - Property weak var delegate: NavigationDelegate? + var cancelBag = Set() + var buttonTapped = PassthroughSubject() // MARK: - UI Components @@ -31,6 +34,7 @@ final class NottodoNavigationView: UIView { setUI() setLayout() + setBindings() } required init?(coder: NSCoder) { @@ -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 } @@ -87,3 +99,10 @@ extension NottodoNavigationView { delegate?.popViewController() } } +extension UIButton { + var tapPublisher: AnyPublisher { + controlPublisher(for: .touchUpInside) + .map { _ in } + .eraseToAnyPublisher() + } +}