From 353f7c021a76b50178d2462d1d78a7abb2d7ed77 Mon Sep 17 00:00:00 2001 From: Hansangjin98 Date: Thu, 6 Feb 2025 00:22:11 +0900 Subject: [PATCH 1/3] =?UTF-8?q?bug:=20#59=20-=20=EB=AA=A8=EC=A7=91=20?= =?UTF-8?q?=EB=8C=80=EC=83=81=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=A1=9C?= =?UTF-8?q?=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 --- .../Component/PostUpload/RecruitJobView.swift | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/Targets/DesignSystem/Sources/Component/PostUpload/RecruitJobView.swift b/Targets/DesignSystem/Sources/Component/PostUpload/RecruitJobView.swift index 33d2266..f827330 100644 --- a/Targets/DesignSystem/Sources/Component/PostUpload/RecruitJobView.swift +++ b/Targets/DesignSystem/Sources/Component/PostUpload/RecruitJobView.swift @@ -50,14 +50,7 @@ public final class RecruitJobGroupView: UIView { return button }() - private let jobGroupRelay: BehaviorRelay<[BehaviorSubject]> = .init(value: []) - - public var allValueObservable: Observable<[String]> { - jobGroupRelay - .flatMapLatest { - Observable.combineLatest($0) - } - } + public let jobGroupRelay: BehaviorRelay<[String]> = .init(value: []) public let updatedStackViewSubject: PublishSubject = .init() private let disposeBag: DisposeBag = .init() @@ -86,17 +79,26 @@ public final class RecruitJobGroupView: UIView { // MARK: - Methods public func setEditMode() { jobGroupStackView.arrangedSubviews.first?.removeFromSuperview() - jobGroupRelay.accept([]) + jobGroupRelay.accept(Array(jobGroupRelay.value.dropFirst())) } public func makeField(value: String = "") { + jobGroupRelay.accept(jobGroupRelay.value + [value]) + let textField: MozipTextField = .init(placeHolder: "모집 대상을 입력해주세요. (공백 포함 최대 25자)") + textField.tag = jobGroupRelay.value.count - 1 + jobGroupStackView.addArrangedSubview(textField) + + textField.rx.text.orEmpty + .skip(1) + .filter { [weak self] in self?.checkTextCount(textField, text: $0) ?? false } + .compactMap { [weak self] text in self?.updateJobGroupArray(tag: textField.tag, text: text) } + .bind(to: jobGroupRelay) + .disposed(by: disposeBag) if !value.isEmpty { textField.rx.text.onNext(value) } - jobGroupStackView.addArrangedSubview(textField) - jobGroupRelay.accept(jobGroupRelay.value + [BehaviorSubject(value: value)]) } } @@ -148,14 +150,10 @@ private extension RecruitJobGroupView { } func removeLastArrangedSubview() { - guard let lastView = jobGroupStackView.arrangedSubviews.last else { - return - } + guard let lastView = jobGroupStackView.arrangedSubviews.last else { return } jobGroupStackView.removeArrangedSubview(lastView) lastView.removeFromSuperview() - var currentSubjects = jobGroupRelay.value - currentSubjects.removeLast() - jobGroupRelay.accept(currentSubjects) + jobGroupRelay.accept(jobGroupRelay.value.dropLast()) } func updatejobGroupStackViewHeight() { @@ -164,4 +162,19 @@ private extension RecruitJobGroupView { rootContainer.flex.layout() updatedStackViewSubject.onNext(()) } + + func checkTextCount(_ textField: UITextField, text: String) -> Bool { + guard text.count > 25 else { return true } + + textField.text = text.dropLast().map { String($0) }.joined() + return false + } + + func updateJobGroupArray(tag: Int, text: String) -> [String] { + var jobGroupArray = jobGroupRelay.value + guard tag < jobGroupArray.count else { return jobGroupArray } + + jobGroupArray[tag] = text + return jobGroupArray + } } From 42923ecdaf98be124d717ad2bbe64a6dc7cc11e7 Mon Sep 17 00:00:00 2001 From: Hansangjin98 Date: Thu, 6 Feb 2025 00:23:11 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20#59=20-=20=EB=AA=A8=EC=A7=91=20?= =?UTF-8?q?=EB=8C=80=EC=83=81=EC=97=90=20=ED=95=84=EC=88=98=20=EA=B8=B0?= =?UTF-8?q?=EC=9E=85=20=EC=82=AC=ED=95=AD=20=ED=91=9C=EA=B8=B0=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Component/PostUpload/RecruitJobView.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Targets/DesignSystem/Sources/Component/PostUpload/RecruitJobView.swift b/Targets/DesignSystem/Sources/Component/PostUpload/RecruitJobView.swift index f827330..ccf92ad 100644 --- a/Targets/DesignSystem/Sources/Component/PostUpload/RecruitJobView.swift +++ b/Targets/DesignSystem/Sources/Component/PostUpload/RecruitJobView.swift @@ -19,6 +19,7 @@ public final class RecruitJobGroupView: UIView { // MARK: - Properties private let rootContainer: UIView = .init() private let titleLabel: MozipLabel = .init(style: .heading3, color: MozipColor.gray800, text: "모집 대상") + private let requiredLabel: MozipLabel = .init(style: .heading3, color: MozipColor.primary500, text: " *") private enum StackViewConstants { static let rowHeight: Int = 56 @@ -109,7 +110,12 @@ private extension RecruitJobGroupView { rootContainer.flex .define { - $0.addItem(titleLabel) + $0.addItem() + .direction(.row) + .define { + $0.addItem(titleLabel) + $0.addItem(requiredLabel) + } $0.addItem(jobGroupStackView).marginTop(12).height(56) $0.addItem() From e3015b8c1815a22274751446e9b83e7af27db474 Mon Sep 17 00:00:00 2001 From: Hansangjin98 Date: Thu, 6 Feb 2025 00:24:26 +0900 Subject: [PATCH 3/3] =?UTF-8?q?style:=20#59=20-=20jobGroupRelay=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EC=88=98=EC=A0=95=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/PostUpload/View/PostUploadViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Targets/PresentationLayer/Sources/PostUpload/View/PostUploadViewController.swift b/Targets/PresentationLayer/Sources/PostUpload/View/PostUploadViewController.swift index becfa30..dc5e02b 100644 --- a/Targets/PresentationLayer/Sources/PostUpload/View/PostUploadViewController.swift +++ b/Targets/PresentationLayer/Sources/PostUpload/View/PostUploadViewController.swift @@ -258,7 +258,7 @@ private extension PostUploadViewController { .bind(to: reactor.action) .disposed(by: disposeBag) - recruitJobView.allValueObservable + recruitJobView.jobGroupRelay .skip(1) .map { Action.inputJobGroup($0) } .bind(to: reactor.action)