From aff3b9c4ea218ae4ed3638ab84b65fe998c0f593 Mon Sep 17 00:00:00 2001 From: namsoo5 Date: Wed, 3 Nov 2021 21:09:14 +0900 Subject: [PATCH 1/8] =?UTF-8?q?:bulb:=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EA=B2=80=EC=83=89=EA=B2=B0=EA=B3=BC=20UI=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 카테고리 가로리스트 - 길정보 리스트 - 헤더뷰 애니메이션 --- HikingClub.xcodeproj/project.pbxproj | 16 ++ .../Cell/CategoryTabCollectionViewCell.swift | 32 ++++ .../Cell/CategoryTabCollectionViewCell.xib | 25 ++++ HikingClub/Feature/Search/Search.storyboard | 40 +++++ .../SearchCategoryResultViewController.swift | 137 ++++++++++++++++++ .../SearchCategoryResultViewModel.swift | 15 ++ .../Feature/Search/SearchViewController.swift | 8 +- 7 files changed, 271 insertions(+), 2 deletions(-) create mode 100644 HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.swift create mode 100644 HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.xib create mode 100644 HikingClub/Feature/Search/SearchCategoryResultViewController.swift create mode 100644 HikingClub/Feature/Search/SearchCategoryResultViewModel.swift diff --git a/HikingClub.xcodeproj/project.pbxproj b/HikingClub.xcodeproj/project.pbxproj index 25c99f4..cb9eec8 100644 --- a/HikingClub.xcodeproj/project.pbxproj +++ b/HikingClub.xcodeproj/project.pbxproj @@ -39,6 +39,10 @@ 06A1ECB5271952B100EA78D8 /* NDTextFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06A1ECB4271952B100EA78D8 /* NDTextFieldView.swift */; }; 06A1ECB7271967E600EA78D8 /* ComponentTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06A1ECB6271967E600EA78D8 /* ComponentTestViewController.swift */; }; 06A1ECB927198ED200EA78D8 /* UITextField+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06A1ECB827198ED200EA78D8 /* UITextField+.swift */; }; + 06AB8CBA273136F7007F32AA /* SearchCategoryResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06AB8CB9273136F7007F32AA /* SearchCategoryResultViewController.swift */; }; + 06AB8CBC27326A3C007F32AA /* SearchCategoryResultViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06AB8CBB27326A3C007F32AA /* SearchCategoryResultViewModel.swift */; }; + 06AB8CBF273287B4007F32AA /* CategoryTabCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06AB8CBD273287B4007F32AA /* CategoryTabCollectionViewCell.swift */; }; + 06AB8CC0273287B4007F32AA /* CategoryTabCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 06AB8CBE273287B4007F32AA /* CategoryTabCollectionViewCell.xib */; }; 06B68F9727228FF9007174E1 /* NDSearchTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B68F9627228FF9007174E1 /* NDSearchTextField.swift */; }; 06BC1F74271C1B79001A6584 /* NDAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06BC1F73271C1B79001A6584 /* NDAlert.swift */; }; 283AF0502708672C0033ED71 /* Home.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 283AF04F2708672C0033ED71 /* Home.storyboard */; }; @@ -136,6 +140,10 @@ 06A1ECB4271952B100EA78D8 /* NDTextFieldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NDTextFieldView.swift; sourceTree = ""; }; 06A1ECB6271967E600EA78D8 /* ComponentTestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComponentTestViewController.swift; sourceTree = ""; }; 06A1ECB827198ED200EA78D8 /* UITextField+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+.swift"; sourceTree = ""; }; + 06AB8CB9273136F7007F32AA /* SearchCategoryResultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchCategoryResultViewController.swift; sourceTree = ""; }; + 06AB8CBB27326A3C007F32AA /* SearchCategoryResultViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchCategoryResultViewModel.swift; sourceTree = ""; }; + 06AB8CBD273287B4007F32AA /* CategoryTabCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryTabCollectionViewCell.swift; sourceTree = ""; }; + 06AB8CBE273287B4007F32AA /* CategoryTabCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CategoryTabCollectionViewCell.xib; sourceTree = ""; }; 06B68F9627228FF9007174E1 /* NDSearchTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NDSearchTextField.swift; sourceTree = ""; }; 06BC1F73271C1B79001A6584 /* NDAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NDAlert.swift; sourceTree = ""; }; 283AF04F2708672C0033ED71 /* Home.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Home.storyboard; sourceTree = ""; }; @@ -229,6 +237,8 @@ 06962E94272927A00021402F /* Search.storyboard */, 06962E92272927770021402F /* SearchViewController.swift */, 06962E96272928290021402F /* SearchViewModel.swift */, + 06AB8CB9273136F7007F32AA /* SearchCategoryResultViewController.swift */, + 06AB8CBB27326A3C007F32AA /* SearchCategoryResultViewModel.swift */, ); path = Search; sourceTree = ""; @@ -240,6 +250,8 @@ 06962E98272A86100021402F /* RecentSearchCollectionViewCell.swift */, 06962E9E272BCD400021402F /* CategoryCollectionViewCell.xib */, 06962E9D272BCD400021402F /* CategoryCollectionViewCell.swift */, + 06AB8CBE273287B4007F32AA /* CategoryTabCollectionViewCell.xib */, + 06AB8CBD273287B4007F32AA /* CategoryTabCollectionViewCell.swift */, ); path = Cell; sourceTree = ""; @@ -669,6 +681,7 @@ 283AF07827086DA40033ED71 /* RoadTableViewCell.xib in Resources */, 06962E95272927A00021402F /* Search.storyboard in Resources */, 06A1EC9027088F4400EA78D8 /* HitThemeTableHeaderView.xib in Resources */, + 06AB8CC0273287B4007F32AA /* CategoryTabCollectionViewCell.xib in Resources */, 7755080326F842E6005B8763 /* LaunchScreen.storyboard in Resources */, 06A1ECA12708CEFA00EA78D8 /* HitThemeHeaderCollectionViewCell.xib in Resources */, 7755080026F842E6005B8763 /* Assets.xcassets in Resources */, @@ -695,6 +708,7 @@ 06A1EC992708A7F300EA78D8 /* UIFont+.swift in Sources */, 77E5913827115F890070F381 /* LoginNavigationViewController.swift in Sources */, 77C69BE927294775004C2207 /* SignUpInputViewModel.swift in Sources */, + 06AB8CBF273287B4007F32AA /* CategoryTabCollectionViewCell.swift in Sources */, 775B95AC27204D1C004D4540 /* UITabBarItem+.swift in Sources */, 06A1EC9B2708B12A00EA78D8 /* UILabel+.swift in Sources */, 777B517C2712AEB300299430 /* EmailAuthroizeViewController.swift in Sources */, @@ -737,12 +751,14 @@ 775507F926F842E5005B8763 /* SceneDelegate.swift in Sources */, 283AF06D27086B950033ED71 /* HomeViewController.swift in Sources */, 77C69BEB272CD4E6004C2207 /* KeyboardAccessoryToolbar.swift in Sources */, + 06AB8CBA273136F7007F32AA /* SearchCategoryResultViewController.swift in Sources */, 777B517327129D6500299430 /* CodeBasedProtocol.swift in Sources */, 7760CA8F2725313B006B39A9 /* EmailAPI.swift in Sources */, 773D61A02719D0D0001528B3 /* SignInViewController.swift in Sources */, 7760CA91272540B2006B39A9 /* PlaceAPI.swift in Sources */, 06A1ECA32708D21400EA78D8 /* UITableView+.swift in Sources */, 067DC4F026FEF8A000650862 /* NetworkProvider.swift in Sources */, + 06AB8CBC27326A3C007F32AA /* SearchCategoryResultViewModel.swift in Sources */, 7760CA9E27259F53006B39A9 /* PlaceModel.swift in Sources */, 777B517E2714336700299430 /* InitialSettingViewController.swift in Sources */, 77213CF82708EF1600994C9A /* BaseWebView.swift in Sources */, diff --git a/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.swift b/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.swift new file mode 100644 index 0000000..1dbbf71 --- /dev/null +++ b/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.swift @@ -0,0 +1,32 @@ +// +// CategoryTabCollectionViewCell.swift +// HikingClub +// +// Created by 남수김 on 2021/11/03. +// + +import UIKit + +final class CategoryTabCollectionViewCell: UICollectionViewCell { + + private let tabButton: NDTabButton = NDTabButton() + + override func awakeFromNib() { + super.awakeFromNib() + addSubview(tabButton) + tabButton.snp.makeConstraints { + $0.leading.top.trailing.bottom.equalToSuperview() + } + } + + override func prepareForReuse() { + super.prepareForReuse() + tabButton.setTitle("") + } + + func configure(with model: String) { + tabButton.setTitle(model) + } + + // TODO: - 버튼 선택상태초기화가능하도록 구현하기 +} diff --git a/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.xib b/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.xib new file mode 100644 index 0000000..fcf49c7 --- /dev/null +++ b/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.xib @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HikingClub/Feature/Search/Search.storyboard b/HikingClub/Feature/Search/Search.storyboard index d9b0559..d4bc227 100644 --- a/HikingClub/Feature/Search/Search.storyboard +++ b/HikingClub/Feature/Search/Search.storyboard @@ -52,6 +52,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift new file mode 100644 index 0000000..9363b3c --- /dev/null +++ b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift @@ -0,0 +1,137 @@ +// +// SearchCategoryResultViewController.swift +// HikingClub +// +// Created by 남수김 on 2021/11/02. +// + +import UIKit +import RxCocoa +import RxSwift + +final class SearchCategoryResultViewController: BaseViewController { + + @IBOutlet private weak var naviBar: NaviBar! + @IBOutlet private weak var tableView: UITableView! + private var collectionView: UICollectionView = { + let flowLayout = UICollectionViewFlowLayout() + flowLayout.scrollDirection = .horizontal + flowLayout.minimumInteritemSpacing = 6 + flowLayout.sectionInset = .zero + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout) + collectionView.showsVerticalScrollIndicator = false + collectionView.showsHorizontalScrollIndicator = false + collectionView.contentInset = .init(top: 0, left: 16, bottom: 0, right: 0) + collectionView.backgroundColor = .gray100 + return collectionView + }() + private var tableViewHeaderView: UIView? + private var tableViewHeaderViewTitleView: UIView? + private let headerHeight: CGFloat = 108 + 57 + + private func setTableHeaderView() { + tableViewHeaderView = UIView(frame: .init(x: 0, y: 0, width: tableView.frame.width, height: headerHeight)) + view.addSubview(tableViewHeaderView!) + view.bringSubviewToFront(naviBar) + tableViewHeaderView?.snp.makeConstraints { + $0.leading.trailing.equalToSuperview() + $0.top.equalTo(view.safeAreaLayoutGuide.snp.top) + $0.height.equalTo(headerHeight) + } + + let backButton: UIButton = { + let button = UIButton(type: .custom) + button.setImage(.icon_angleBracket_left_gray900_24) + return button + }() + + let titleLabel: UILabel = { + let label = UILabel() + label.text = "테스트" + label.setFont(.semiBold24) + label.textColor = .gray900 + return label + }() + + tableViewHeaderViewTitleView = UIView() + tableViewHeaderView?.addSubViews(tableViewHeaderViewTitleView!, collectionView) + tableViewHeaderViewTitleView?.addSubViews(backButton, titleLabel) + tableViewHeaderViewTitleView?.snp.makeConstraints { + $0.leading.top.trailing.equalToSuperview() + $0.height.equalTo(108) + } + + backButton.snp.makeConstraints { + $0.top.equalToSuperview().offset(8) + $0.leading.equalToSuperview().offset(16) + } + + titleLabel.snp.makeConstraints { + $0.top.equalTo(backButton.snp.bottom).offset(38) + $0.leading.equalToSuperview().offset(20) + } + + collectionView.snp.makeConstraints { + $0.leading.trailing.bottom.equalToSuperview() + $0.height.equalTo(57) + } + } + + override func attribute() { + super.attribute() + setTableHeaderView() + naviBar.setBackItemImage() + naviBar.setTitle("테스트") + naviBar.isHidden = true + tableView.register(RoadTableViewCell.self) + collectionView.register(CategoryTabCollectionViewCell.self) + collectionView.rx.setDelegate(self).disposed(by: disposeBag) + } + + override func bind() { + super.bind() + // 카테고리 셀 + viewModel.categoryWords + .bind(to: collectionView.rx.items(cellIdentifier: "CategoryTabCollectionViewCell", + cellType: CategoryTabCollectionViewCell.self)) { item, cellModel, cell in + cell.configure(with: cellModel) + }.disposed(by: disposeBag) + + // 길정보 셀 + viewModel.roadDatas + .bind(to: tableView.rx.items(cellIdentifier: "RoadTableViewCell", + cellType: RoadTableViewCell.self)) { row, cellModel, cell in + cell.configure(tags: [cellModel]) + }.disposed(by: disposeBag) + + // 헤더뷰 스크롤 효과 + tableView.contentInset = .init(top: headerHeight, left: 0, bottom: 0, right: 0) + tableView.rx.contentOffset + .subscribe(onNext: { [weak self] in + // -165(headerHeight)부터 스크롤시 + + guard let self = self else { return } + let posY = $0.y + self.headerHeight + self.naviBar.isHidden = posY <= 70 + self.tableViewHeaderViewTitleView?.alpha = 1 - posY / 70 + self.tableViewHeaderView?.frame.origin.y = posY <= 70 ? 44 - posY : -108 + 40 + 44 + }) + .disposed(by: disposeBag) + + // FIXME: - mock데이터 삭제 + viewModel.roadDatas.accept(["1","1","1","1"]) + viewModel.categoryWords.accept(["가가가가나나나나다다다다라라라라","12","13","14","12345","하하하하하하하하하하ㅏ"]) + } +} + +extension SearchCategoryResultViewController: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let word = viewModel.categoryWords.value[indexPath.item] + let tab: NDTabButton = { + let tab = NDTabButton() + tab.setTitle(word) + return tab + }() + tab.layoutIfNeeded() + return CGSize(width: tab.bounds.width, height: 33) + } +} diff --git a/HikingClub/Feature/Search/SearchCategoryResultViewModel.swift b/HikingClub/Feature/Search/SearchCategoryResultViewModel.swift new file mode 100644 index 0000000..4c8f33b --- /dev/null +++ b/HikingClub/Feature/Search/SearchCategoryResultViewModel.swift @@ -0,0 +1,15 @@ +// +// SearchCategoryResultViewModel.swift +// HikingClub +// +// Created by 남수김 on 2021/11/03. +// + +import Foundation +import RxRelay + +final class SearchCategoryResultViewModel: BaseViewModel { + let roadDatas: BehaviorRelay<[String]> = BehaviorRelay(value: []) + let categoryWords: BehaviorRelay<[String]> = BehaviorRelay(value: []) + +} diff --git a/HikingClub/Feature/Search/SearchViewController.swift b/HikingClub/Feature/Search/SearchViewController.swift index e63ac30..fe28143 100644 --- a/HikingClub/Feature/Search/SearchViewController.swift +++ b/HikingClub/Feature/Search/SearchViewController.swift @@ -157,8 +157,12 @@ final class SearchViewController: BaseViewController { // TODO: 터치시 해당 카테고리로 이동 categoryCollectionView.rx.itemSelected - .subscribe(onNext: { - print($0) + .subscribe(onNext: { [weak self] _ in + let nextViewController = self?.storyboard?.instantiate("SearchCategoryResultViewController") { coder -> SearchCategoryResultViewController? in + .init(coder, SearchCategoryResultViewModel()) + } + guard let nextViewController = nextViewController else { return } + self?.navigationController?.pushViewController(nextViewController, animated: true) }) .disposed(by: disposeBag) } From f47d62cf8e3d3335c0f66aa49a87794aa156c12a Mon Sep 17 00:00:00 2001 From: namsoo5 Date: Thu, 4 Nov 2021 00:27:43 +0900 Subject: [PATCH 2/8] =?UTF-8?q?:bulb:=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=ED=83=80=EC=9D=B4=ED=8B=80=20=EC=A0=81=EC=9A=A9=20?= =?UTF-8?q?=EB=B0=8F=20=EC=BD=94=EB=93=9C=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 뒤로가기 버튼기능 추가 - UI구성요소 위치변경 --- .../SearchCategoryResultViewController.swift | 72 ++++++++++++------- .../SearchCategoryResultViewModel.swift | 5 ++ .../Feature/Search/SearchViewController.swift | 8 ++- 3 files changed, 57 insertions(+), 28 deletions(-) diff --git a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift index 9363b3c..8abeec2 100644 --- a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift +++ b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift @@ -10,7 +10,6 @@ import RxCocoa import RxSwift final class SearchCategoryResultViewController: BaseViewController { - @IBOutlet private weak var naviBar: NaviBar! @IBOutlet private weak var tableView: UITableView! private var collectionView: UICollectionView = { @@ -26,7 +25,19 @@ final class SearchCategoryResultViewController: BaseViewController = BehaviorRelay(value: []) let categoryWords: BehaviorRelay<[String]> = BehaviorRelay(value: []) + let categoryName: BehaviorRelay = BehaviorRelay(value: "") + init(categoryName: String) { + self.categoryName.accept(categoryName) + } } diff --git a/HikingClub/Feature/Search/SearchViewController.swift b/HikingClub/Feature/Search/SearchViewController.swift index fe28143..ae9ecdd 100644 --- a/HikingClub/Feature/Search/SearchViewController.swift +++ b/HikingClub/Feature/Search/SearchViewController.swift @@ -157,9 +157,11 @@ final class SearchViewController: BaseViewController { // TODO: 터치시 해당 카테고리로 이동 categoryCollectionView.rx.itemSelected - .subscribe(onNext: { [weak self] _ in - let nextViewController = self?.storyboard?.instantiate("SearchCategoryResultViewController") { coder -> SearchCategoryResultViewController? in - .init(coder, SearchCategoryResultViewModel()) + .subscribe(onNext: { [weak self] indexPath in + let item = indexPath.item + let nextViewController = self?.storyboard?.instantiate("SearchCategoryResultViewController") { [weak self] coder -> SearchCategoryResultViewController? in + guard let word = self?.viewModel.categoryWords.value[item] else { return nil } + return .init(coder, SearchCategoryResultViewModel(categoryName: word)) } guard let nextViewController = nextViewController else { return } self?.navigationController?.pushViewController(nextViewController, animated: true) From ba01f8cbb7d8cf491f71e2e93aed753d8f5816c1 Mon Sep 17 00:00:00 2001 From: namsoo5 Date: Thu, 4 Nov 2021 22:37:37 +0900 Subject: [PATCH 3/8] =?UTF-8?q?:bulb:=20=EA=B8=B0=EB=8A=A5=EA=B0=9C?= =?UTF-8?q?=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 네비바 바인딩 - 스크롤 인디케이터 기능 --- .../Search/SearchCategoryResultViewController.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift index 8abeec2..39f1aaa 100644 --- a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift +++ b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift @@ -81,7 +81,6 @@ final class SearchCategoryResultViewController: BaseViewController Date: Thu, 4 Nov 2021 23:31:02 +0900 Subject: [PATCH 4/8] =?UTF-8?q?:bulb:=20=ED=85=9D=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=ED=81=B4=EB=A6=AD=EC=8B=9C=20=ED=83=80=EC=9D=B4=ED=8B=80?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Search/Cell/CategoryTabCollectionViewCell.swift | 8 ++++++-- .../Search/SearchCategoryResultViewController.swift | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.swift b/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.swift index 1dbbf71..531f12b 100644 --- a/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.swift +++ b/HikingClub/Feature/Search/Cell/CategoryTabCollectionViewCell.swift @@ -10,6 +10,11 @@ import UIKit final class CategoryTabCollectionViewCell: UICollectionViewCell { private let tabButton: NDTabButton = NDTabButton() + override var isSelected: Bool { + didSet { + tabButton.setSelected(isSelected) + } + } override func awakeFromNib() { super.awakeFromNib() @@ -17,6 +22,7 @@ final class CategoryTabCollectionViewCell: UICollectionViewCell { tabButton.snp.makeConstraints { $0.leading.top.trailing.bottom.equalToSuperview() } + tabButton.setEnabledTouch(false) } override func prepareForReuse() { @@ -27,6 +33,4 @@ final class CategoryTabCollectionViewCell: UICollectionViewCell { func configure(with model: String) { tabButton.setTitle(model) } - - // TODO: - 버튼 선택상태초기화가능하도록 구현하기 } diff --git a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift index 39f1aaa..c1b1685 100644 --- a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift +++ b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift @@ -119,6 +119,11 @@ final class SearchCategoryResultViewController: BaseViewController Date: Thu, 4 Nov 2021 23:45:43 +0900 Subject: [PATCH 5/8] =?UTF-8?q?:bulb:=20=ED=83=80=EC=9D=B4=ED=8B=80=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - input, output구분 --- .../SearchCategoryResultViewController.swift | 7 ++----- .../SearchCategoryResultViewModel.swift | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift index c1b1685..6f05617 100644 --- a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift +++ b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift @@ -119,9 +119,10 @@ final class SearchCategoryResultViewController: BaseViewController = BehaviorRelay(value: []) let categoryName: BehaviorRelay = BehaviorRelay(value: "") + // MARK: - Input + let _categoryName: BehaviorRelay = BehaviorRelay(value: "") + init(categoryName: String) { - self.categoryName.accept(categoryName) + super.init() + _categoryName.accept(categoryName) + bind() + // FIXME: - mock데이터 삭제 + roadDatas.accept(["1","1","1","1"]) + categoryWords.accept(["가가가가나나나나다다다다라라라라","12","13","14","12345","하하하하하하하하하하ㅏ"]) + } + + private func bind() { + _categoryName + .distinctUntilChanged() + .subscribe(onNext: { [weak self] in + print("기능처리") + self?.categoryName.accept($0) + }) + .disposed(by: disposeBag) } } From 9b8c67b5c71f1f850c861670ac403c532de21922 Mon Sep 17 00:00:00 2001 From: namsoo5 Date: Fri, 5 Nov 2021 03:45:32 +0900 Subject: [PATCH 6/8] =?UTF-8?q?:bulb:=20=EA=B8=B8=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=ED=81=B4=EB=A6=AD=20=EA=B8=B0=EB=8A=A5=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HikingClub/Feature/Search/Search.storyboard | 2 +- .../Search/SearchCategoryResultViewController.swift | 12 ++++++++++++ .../Search/SearchCategoryResultViewModel.swift | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/HikingClub/Feature/Search/Search.storyboard b/HikingClub/Feature/Search/Search.storyboard index d4bc227..7210ad2 100644 --- a/HikingClub/Feature/Search/Search.storyboard +++ b/HikingClub/Feature/Search/Search.storyboard @@ -60,7 +60,7 @@ - + diff --git a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift index 6f05617..fa63191 100644 --- a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift +++ b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift @@ -90,6 +90,7 @@ final class SearchCategoryResultViewController: BaseViewController Date: Fri, 5 Nov 2021 18:06:58 +0900 Subject: [PATCH 7/8] =?UTF-8?q?:recycle:=20=EC=83=81=EC=88=98=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Feature/Search/SearchCategoryResultViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift index fa63191..d37d13c 100644 --- a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift +++ b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift @@ -12,7 +12,7 @@ import RxSwift final class SearchCategoryResultViewController: BaseViewController { @IBOutlet private weak var naviBar: NaviBar! @IBOutlet private weak var tableView: UITableView! - private var collectionView: UICollectionView = { + private let collectionView: UICollectionView = { let flowLayout = UICollectionViewFlowLayout() flowLayout.scrollDirection = .horizontal flowLayout.minimumInteritemSpacing = 6 From 6e3b5132bf26ef056294fabeac8496fa2a59b2ec Mon Sep 17 00:00:00 2001 From: namsoo5 Date: Sat, 6 Nov 2021 17:48:45 +0900 Subject: [PATCH 8/8] =?UTF-8?q?:bulb:=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=BB=AC=EB=9E=99=EC=85=98=EB=B7=B0=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=20=EB=A1=9C=EC=A7=81=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 카테고리 초기설정 - 뷰모델 로직변경 --- .../SearchCategoryResultViewController.swift | 24 ++++++++++++------- .../SearchCategoryResultViewModel.swift | 17 +++++++------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift index d37d13c..f497a5d 100644 --- a/HikingClub/Feature/Search/SearchCategoryResultViewController.swift +++ b/HikingClub/Feature/Search/SearchCategoryResultViewController.swift @@ -12,7 +12,7 @@ import RxSwift final class SearchCategoryResultViewController: BaseViewController { @IBOutlet private weak var naviBar: NaviBar! @IBOutlet private weak var tableView: UITableView! - private let collectionView: UICollectionView = { + private let categoryCollectionView: UICollectionView = { let flowLayout = UICollectionViewFlowLayout() flowLayout.scrollDirection = .horizontal flowLayout.minimumInteritemSpacing = 6 @@ -40,6 +40,12 @@ final class SearchCategoryResultViewController: BaseViewController = BehaviorRelay(value: "") // MARK: - Input - let _categoryName: BehaviorRelay = BehaviorRelay(value: "") + let selectedCategory: BehaviorRelay = BehaviorRelay(value: 0) init(categoryName: String) { super.init() - _categoryName.accept(categoryName) - bind() // FIXME: - mock데이터 삭제 roadDatas.accept(["1","1","1","1"]) categoryWords.accept(["가가가가나나나나다다다다라라라라","12","13","14","12345","하하하하하하하하하하ㅏ"]) + + bind() } private func bind() { - _categoryName - .distinctUntilChanged() - .subscribe(onNext: { [weak self] in - // TODO: 카테고리 통신 - print("기능처리") - self?.categoryName.accept($0) + selectedCategory + .filter { [weak self] in 0 <= $0 && $0 < self?.categoryWords.value.count ?? 0 } + .subscribe(onNext: { [weak self] index in + guard let word = self?.categoryWords.value[index] else { return } + self?.categoryName.accept(word) }) .disposed(by: disposeBag) }