Skip to content

Commit

Permalink
✨ 여정 완료 로직 구현 완료 (네트워킹 제외)
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftyJunnos committed Dec 4, 2023
1 parent 2764b62 commit 9a2b65f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
3 changes: 3 additions & 0 deletions iOS/Features/SaveJourney/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Combine
import UIKit

import CombineCocoa
import MSUIKit

protocol AlertViewControllerDelegate: AnyObject {
Expand All @@ -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

}

Expand All @@ -40,19 +42,22 @@ final class ConfirmTitleAlertViewController: MSAlertViewController {
textField.imageStyle = .none
textField.clearButtonMode = .whileEditing
textField.enablesReturnKeyAutomatically = true
textField.placeholder = "Placeholder"
textField.placeholder = Typo.placeholder
return textField
}()

// MARK: - Properties

weak var delegate: AlertViewControllerDelegate?

private var cancellables: Set<AnyCancellable> = []

// MARK: - Life Cycle

override func viewDidLoad() {
super.viewDidLoad()
self.configureButtonActions()
self.bind()
}

override func viewDidAppear(_ animated: Bool) {
Expand All @@ -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() {
Expand All @@ -85,7 +103,6 @@ final class ConfirmTitleAlertViewController: MSAlertViewController {
super.configureStyles()

self.updateTitle(Typo.title)
self.updateSubtitle(Typo.subtitle)
}

override func configureLayout() {
Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions iOS/MSUIKit/Sources/MSUIKit/MSAlertViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,13 @@ open class MSAlertViewController: UIViewController {
let label = UILabel()
label.font = .msFont(.headerTitle)
label.textColor = .msColor(.primaryTypo)
label.text = "Title"
return label
}()

private let subtitleLabel: UILabel = {
let label = UILabel()
label.font = .msFont(.caption)
label.textColor = .msColor(.secondaryTypo)
label.text = "Subtitle"
return label
}()

Expand Down Expand Up @@ -118,6 +116,7 @@ open class MSAlertViewController: UIViewController {
let button = MSButton.primary()
button.cornerStyle = .squared
button.title = Typo.doneButtonTitle
button.isEnabled = false
return button
}()

Expand Down Expand Up @@ -324,4 +323,8 @@ open class MSAlertViewController: UIViewController {
self.subtitleLabel.text = subtitle
}

public func updateDoneButton(isEnabled: Bool) {
self.doneButton.isEnabled = isEnabled
}

}

0 comments on commit 9a2b65f

Please sign in to comment.