From 2259b24152991e002febc9957e8a77c7ced40d33 Mon Sep 17 00:00:00 2001 From: hwangJi-dev Date: Mon, 10 Oct 2022 04:01:06 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=85=C2=A0Chore:=20PostFilterType?= =?UTF-8?q?=EC=97=90=20rawValue=EA=B0=92=20=EC=B6=94=EA=B0=80=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20(#514)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NadoSunbae-iOS/Global/Struct/PostFilterType.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NadoSunbae-iOS/NadoSunbae-iOS/Global/Struct/PostFilterType.swift b/NadoSunbae-iOS/NadoSunbae-iOS/Global/Struct/PostFilterType.swift index 9e8fa10b..1b18aef1 100644 --- a/NadoSunbae-iOS/NadoSunbae-iOS/Global/Struct/PostFilterType.swift +++ b/NadoSunbae-iOS/NadoSunbae-iOS/Global/Struct/PostFilterType.swift @@ -7,11 +7,11 @@ import Foundation -enum PostFilterType: CaseIterable { - case community - case general - case questionToEveryone // 전체에게 질문 (커뮤니티 질문) - case information +enum PostFilterType: Int, CaseIterable { + case community = 0 + case general = 1 + case questionToEveryone = 2 // 전체에게 질문 (커뮤니티 질문) + case information = 3 case questionToPerson // 1:1 질문 } From f24f5c4d66f0c5c524febabd0c38831bdb1e50f5 Mon Sep 17 00:00:00 2001 From: hwangJi-dev Date: Mon, 10 Oct 2022 04:01:58 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=C2=A0Feat:=20=EC=BB=A4=EB=AE=A4?= =?UTF-8?q?=EB=8B=88=ED=8B=B0=20=EA=B8=80=EC=93=B0=EA=B8=B0=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=EC=8B=9C=20=EA=B8=80=EC=93=B4=20PostFilterType?= =?UTF-8?q?=EC=9D=84=20=EC=A0=84=EB=8B=AC=ED=95=98=EB=8A=94=20delegate=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20(#514)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Screen/Community/VC/CommunityWriteVC.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NadoSunbae-iOS/NadoSunbae-iOS/Screen/Community/VC/CommunityWriteVC.swift b/NadoSunbae-iOS/NadoSunbae-iOS/Screen/Community/VC/CommunityWriteVC.swift index 4470fd43..dfe19448 100644 --- a/NadoSunbae-iOS/NadoSunbae-iOS/Screen/Community/VC/CommunityWriteVC.swift +++ b/NadoSunbae-iOS/NadoSunbae-iOS/Screen/Community/VC/CommunityWriteVC.swift @@ -51,6 +51,7 @@ final class CommunityWriteVC: BaseWritePostVC, View { var categoryIndex: Int? var originTitle: String? var originContent: String? + var sendPostTypeDelegate: SendUpdateModalDelegate? // MARK: Life Cycle override func viewDidLoad() { @@ -196,9 +197,11 @@ extension CommunityWriteVC { reactor.state .map{ $0.writePostSuccess } - .subscribe(onNext: { success in + .subscribe(onNext: { [weak self] success in if success { - self.dismiss(animated: true, completion: nil) + self?.dismiss(animated: true, completion: { + self?.sendPostTypeDelegate?.sendUpdate(data: (self?.selectedCategory ?? .community) as PostFilterType) + }) } }) .disposed(by: disposeBag) From 351454c7ef54953fe87c56bac3ad1ca5c10ca2b1 Mon Sep 17 00:00:00 2001 From: hwangJi-dev Date: Mon, 10 Oct 2022 04:02:30 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=94=A8=C2=A0Fix:=20=EC=BB=A4=EB=AE=A4?= =?UTF-8?q?=EB=8B=88=ED=8B=B0=20=EA=B8=80=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=81=B4=EB=A6=AD=20=ED=9B=84=20=EB=92=A4=EB=A1=9C=20=EB=8F=8C?= =?UTF-8?q?=EC=95=84=EC=99=94=EC=9D=84=20=EB=95=8C=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EA=B8=80=EB=A1=9C=20reload=20=EB=90=98=EB=8A=94=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=ED=95=B4=EA=B2=B0=20(#514)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Screen/Community/VC/CommunityMainVC.swift | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/NadoSunbae-iOS/NadoSunbae-iOS/Screen/Community/VC/CommunityMainVC.swift b/NadoSunbae-iOS/NadoSunbae-iOS/Screen/Community/VC/CommunityMainVC.swift index a842acd6..d5ea3181 100644 --- a/NadoSunbae-iOS/NadoSunbae-iOS/Screen/Community/VC/CommunityMainVC.swift +++ b/NadoSunbae-iOS/NadoSunbae-iOS/Screen/Community/VC/CommunityMainVC.swift @@ -59,11 +59,7 @@ final class CommunityMainVC: BaseVC, View { registerCell() setUpDelegate() bindCommunityTV() - } - - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - setUpInitAction() + setUpSegmentAction(type: PostFilterType(rawValue: communitySegmentedControl.selectedSegmentIndex) ?? .community) } func bind(reactor: CommunityMainReactor) { @@ -109,6 +105,7 @@ extension CommunityMainVC { .subscribe(onNext: { self.navigator?.instantiateVC(destinationViewControllerType: CommunityWriteVC.self, useStoryboard: false, storyboardName: "", naviType: .present, modalPresentationStyle: .fullScreen) { communityWriteVC in communityWriteVC.reactor = CommunityWriteReactor() + communityWriteVC.sendPostTypeDelegate = self } }) .disposed(by: disposeBag) @@ -174,10 +171,6 @@ extension CommunityMainVC { .disposed(by: disposeBag) } - private func setUpInitAction() { - reactor?.action.onNext(.reloadCommunityTV(majorID: 0, type: .community, sort: "recent", search: "")) - } - /// CommunityTV를 bind하는 메서드 private func bindCommunityTV() { communityTV.rx.modelSelected(PostListResModel.self) @@ -262,6 +255,11 @@ extension CommunityMainVC { communityTV.rx.setDelegate(self) .disposed(by: disposeBag) } + + /// segment Action을 설정하는 메서드 + private func setUpSegmentAction(type: PostFilterType) { + reactor?.action.onNext(.reloadCommunityTV(type: type)) + } } // MARK: - UITableViewDelegate @@ -277,3 +275,12 @@ extension CommunityMainVC: UITableViewDelegate { return UITableView.automaticDimension } } + +// MARK: - SendUpdateModalDelegate +extension CommunityMainVC: SendUpdateModalDelegate { + func sendUpdate(data: Any) { + let postFilterType = data as? PostFilterType + communitySegmentedControl.selectedSegmentIndex = postFilterType?.rawValue ?? 0 + setUpSegmentAction(type: postFilterType ?? .community) + } +}