From 9a2b65f1440a1959e0fa54b6cd47aed9c656fa94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Junnos=20=EF=A3=BF?= Date: Mon, 4 Dec 2023 22:55:25 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=EC=97=AC=EC=A0=95=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20(=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=82=B9=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iOS/Features/SaveJourney/Package.swift | 3 +++ .../ConfirmTitleAlertViewController.swift | 26 ++++++++++++++++--- .../MSUIKit/MSAlertViewController.swift | 7 +++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/iOS/Features/SaveJourney/Package.swift b/iOS/Features/SaveJourney/Package.swift index 01bb06a..b6ce195 100644 --- a/iOS/Features/SaveJourney/Package.swift +++ b/iOS/Features/SaveJourney/Package.swift @@ -28,6 +28,7 @@ private enum Target { private enum Dependency { static let msData = "MSData" + static let combineCocoa = "CombineCocoa" static let msUIKit = "MSUIKit" static let msDesignsystem = "MSDesignSystem" static let msLogger = "MSLogger" @@ -61,6 +62,8 @@ let package = Package( package: Dependency.msData), .product(name: Dependency.msUIKit, package: Dependency.msUIKit), + .product(name: Dependency.combineCocoa, + package: Dependency.msUIKit), .product(name: Dependency.msLogger, package: Dependency.msFoundation) ]) diff --git a/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/ConfirmTitleAlertViewController.swift b/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/ConfirmTitleAlertViewController.swift index 6c10d43..71075f1 100644 --- a/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/ConfirmTitleAlertViewController.swift +++ b/iOS/Features/SaveJourney/Sources/SaveJourney/Presentation/ConfirmTitleAlertViewController.swift @@ -8,6 +8,7 @@ import Combine import UIKit +import CombineCocoa import MSUIKit protocol AlertViewControllerDelegate: AnyObject { @@ -23,13 +24,14 @@ final class ConfirmTitleAlertViewController: MSAlertViewController { private enum Typo { static let title = "여정 이름" - static let subtitle = "마지막으로 여정의 이름을 정해주세요." + static let placeholder = "마지막으로 여정의 이름을 정해주세요." } private enum Metric { static let horizontalInset: CGFloat = 12.0 + static let textFieldCenterOffset: CGFloat = 15.0 } @@ -40,7 +42,7 @@ final class ConfirmTitleAlertViewController: MSAlertViewController { textField.imageStyle = .none textField.clearButtonMode = .whileEditing textField.enablesReturnKeyAutomatically = true - textField.placeholder = "Placeholder" + textField.placeholder = Typo.placeholder return textField }() @@ -48,11 +50,14 @@ final class ConfirmTitleAlertViewController: MSAlertViewController { weak var delegate: AlertViewControllerDelegate? + private var cancellables: Set = [] + // MARK: - Life Cycle override func viewDidLoad() { super.viewDidLoad() self.configureButtonActions() + self.bind() } override func viewDidAppear(_ animated: Bool) { @@ -61,6 +66,19 @@ final class ConfirmTitleAlertViewController: MSAlertViewController { self.textField.becomeFirstResponder() } + // MARK: - Combine Binding + + private func bind() { + self.textField.textPublisher + .receive(on: DispatchQueue.main) + .map { $0.isEmpty } + .removeDuplicates() + .sink { [weak self] isTextEmpty in + self?.updateDoneButton(isEnabled: !isTextEmpty) + } + .store(in: &self.cancellables) + } + // MARK: - Helpers override func dismissBottomSheet() { @@ -85,7 +103,6 @@ final class ConfirmTitleAlertViewController: MSAlertViewController { super.configureStyles() self.updateTitle(Typo.title) - self.updateSubtitle(Typo.subtitle) } override func configureLayout() { @@ -94,7 +111,8 @@ final class ConfirmTitleAlertViewController: MSAlertViewController { self.containerView.addSubview(self.textField) self.textField.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ - self.textField.centerYAnchor.constraint(equalTo: self.containerView.centerYAnchor), + self.textField.centerYAnchor.constraint(equalTo: self.containerView.centerYAnchor, + constant: -Metric.textFieldCenterOffset), self.textField.leadingAnchor.constraint(equalTo: self.containerView.leadingAnchor, constant: Metric.horizontalInset), self.textField.trailingAnchor.constraint(equalTo: self.containerView.trailingAnchor, diff --git a/iOS/MSUIKit/Sources/MSUIKit/MSAlertViewController.swift b/iOS/MSUIKit/Sources/MSUIKit/MSAlertViewController.swift index 81bb0b7..bbd0d8d 100644 --- a/iOS/MSUIKit/Sources/MSUIKit/MSAlertViewController.swift +++ b/iOS/MSUIKit/Sources/MSUIKit/MSAlertViewController.swift @@ -82,7 +82,6 @@ open class MSAlertViewController: UIViewController { let label = UILabel() label.font = .msFont(.headerTitle) label.textColor = .msColor(.primaryTypo) - label.text = "Title" return label }() @@ -90,7 +89,6 @@ open class MSAlertViewController: UIViewController { let label = UILabel() label.font = .msFont(.caption) label.textColor = .msColor(.secondaryTypo) - label.text = "Subtitle" return label }() @@ -118,6 +116,7 @@ open class MSAlertViewController: UIViewController { let button = MSButton.primary() button.cornerStyle = .squared button.title = Typo.doneButtonTitle + button.isEnabled = false return button }() @@ -324,4 +323,8 @@ open class MSAlertViewController: UIViewController { self.subtitleLabel.text = subtitle } + public func updateDoneButton(isEnabled: Bool) { + self.doneButton.isEnabled = isEnabled + } + }