From 5f485d9421fbf1456462f85d5b21793e06c9e644 Mon Sep 17 00:00:00 2001 From: thoonk Date: Sun, 7 Jul 2024 23:17:39 +0900 Subject: [PATCH 01/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=B7=B0=20=EA=B0=9C=EC=84=A0=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기존 UITableView DataSource 에서 Diffable DataSource 로 변경 작업 - 기존 2개(드랍, 좋아요)의 UITableView(Hidden 처리)를 1개의 UICollectionView를 이용한 개선 작업 - Compositional Layout 적용 - 콘텐츠 수에 따른 CollectionView Height 업데이트를 통한 전체 스크롤뷰 높이 조정 --- .../StreetDrop.xcodeproj/project.pbxproj | 8 +- .../MyPage/Model/Entites/MyMusic.swift | 58 +-- ...ableViewCell.swift => MusicListCell.swift} | 24 +- .../View/MusicListSectionHeaderView.swift | 16 +- .../Presentation/MyPage/View/MyPageType.swift | 8 +- .../MyPage/View/MyPageViewController.swift | 366 +++++++++--------- .../MyPage/ViewModel/MyPageViewModel.swift | 66 ++-- 7 files changed, 271 insertions(+), 275 deletions(-) rename StreetDrop/StreetDrop/Presentation/MyPage/View/{MusicTableViewCell.swift => MusicListCell.swift} (94%) diff --git a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj index cef54718..873c35e5 100644 --- a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj +++ b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj @@ -57,7 +57,7 @@ 1824F13A2A34A4B700A10320 /* MusicCountEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1824F1362A349F3700A10320 /* MusicCountEntity.swift */; }; 1824F13B2A34A4C900A10320 /* PoiEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18683FE02A349109005A94AC /* PoiEntity.swift */; }; 1867C8202A4DDB8C00F8EC48 /* MyPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1867C81F2A4DDB8C00F8EC48 /* MyPageViewController.swift */; }; - 1867C8242A4FFCDF00F8EC48 /* MusicTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1867C8232A4FFCDF00F8EC48 /* MusicTableViewCell.swift */; }; + 1867C8242A4FFCDF00F8EC48 /* MusicListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1867C8232A4FFCDF00F8EC48 /* MusicListCell.swift */; }; 18683FD92A2A251E005A94AC /* ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18683FD82A2A251E005A94AC /* ViewModel.swift */; }; 18683FDC2A348B15005A94AC /* DefaultMainRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18683FDB2A348B15005A94AC /* DefaultMainRepository.swift */; }; 18683FDF2A348B25005A94AC /* MainRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18683FDE2A348B25005A94AC /* MainRepository.swift */; }; @@ -332,7 +332,7 @@ 1816ED482A68591F005009FC /* DefaultNicknameEditRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultNicknameEditRepository.swift; sourceTree = ""; }; 1824F1362A349F3700A10320 /* MusicCountEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicCountEntity.swift; sourceTree = ""; }; 1867C81F2A4DDB8C00F8EC48 /* MyPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewController.swift; sourceTree = ""; }; - 1867C8232A4FFCDF00F8EC48 /* MusicTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicTableViewCell.swift; sourceTree = ""; }; + 1867C8232A4FFCDF00F8EC48 /* MusicListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicListCell.swift; sourceTree = ""; }; 18683FD82A2A251E005A94AC /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = ""; }; 18683FDB2A348B15005A94AC /* DefaultMainRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultMainRepository.swift; sourceTree = ""; }; 18683FDE2A348B25005A94AC /* MainRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainRepository.swift; sourceTree = ""; }; @@ -902,7 +902,7 @@ isa = PBXGroup; children = ( 1867C81F2A4DDB8C00F8EC48 /* MyPageViewController.swift */, - 1867C8232A4FFCDF00F8EC48 /* MusicTableViewCell.swift */, + 1867C8232A4FFCDF00F8EC48 /* MusicListCell.swift */, 18EF9FC82A5C51FB00266D27 /* NicknameEditViewController.swift */, 1816ED3B2A680608005009FC /* MusicListSectionHeaderView.swift */, 0856524F2AFBB73100FD9BCB /* MyPageType.swift */, @@ -1880,7 +1880,7 @@ C44A549C2BBC099E00354F8F /* DefaultFetchingPopUpInfomationUseCase.swift in Sources */, 082F17242ADD60BB00174D98 /* UINavigation+Gesture.swift in Sources */, 415113272A165DC50051F809 /* MusicDropViewController.swift in Sources */, - 1867C8242A4FFCDF00F8EC48 /* MusicTableViewCell.swift in Sources */, + 1867C8242A4FFCDF00F8EC48 /* MusicListCell.swift in Sources */, C45BF3A12A1D133000CEDE74 /* RecentMusicQueryDTO.swift in Sources */, 040685002A01539800377094 /* AppDelegate.swift in Sources */, 18CB7BED2A359F53002B31FB /* MusicWithinAreaEntity.swift in Sources */, diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/Model/Entites/MyMusic.swift b/StreetDrop/StreetDrop/Presentation/MyPage/Model/Entites/MyMusic.swift index 75296f1c..1db157c0 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/Model/Entites/MyMusic.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/Model/Entites/MyMusic.swift @@ -8,7 +8,17 @@ import Foundation import RxDataSources -struct MyMusic { +struct TotalMyMusics { + let musics: [MyMusics] + let totalCount: Int +} + +struct MyMusics { + let date: String + let musics: [MyMusic] +} + +struct MyMusic: Hashable { let id: Int let userId: Int var userName: String @@ -22,33 +32,33 @@ struct MyMusic { let createdAt: String let location: String let likeCount: Int -} - -struct MyMusics { - let date: String - let musics: [MyMusic] -} - -struct TotalMyMusics { - let musics: [MyMusics] - let totalCount: Int -} - -struct MyMusicsSection { - var date: String - var items: [Item] - init(date: String, items: [MyMusic]) { - self.date = date - self.items = items + private let identifier = UUID() + + func hash(into hasher: inout Hasher) { + hasher.combine(identifier) + } + + static func == (lhs: MyMusic, rhs: MyMusic) -> Bool { + return lhs.identifier == rhs.identifier } } -extension MyMusicsSection: SectionModelType { - typealias Item = MyMusic +struct MyMusicsSectionType: Hashable { + let section: MyMusicsSection + let items: [MyMusic] - init(original: MyMusicsSection, items: [MyMusic]) { - self = original - self.items = items + private let identifier = UUID() + + func hash(into hasher: inout Hasher) { + hasher.combine(identifier) } + + static func == (lhs: MyMusicsSectionType, rhs: MyMusicsSectionType) -> Bool { + return lhs.identifier == rhs.identifier + } +} + +enum MyMusicsSection: Hashable { + case musics(date: String) } diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicTableViewCell.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift similarity index 94% rename from StreetDrop/StreetDrop/Presentation/MyPage/View/MusicTableViewCell.swift rename to StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift index 9806dd0f..116654e9 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicTableViewCell.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift @@ -11,13 +11,14 @@ import SnapKit import RxCocoa import RxSwift -final class MusicTableViewCell: UITableViewCell { +final class MusicListCell: UICollectionViewCell { static let identifier = "MusicTableViewCell" private var disposeBag: DisposeBag = DisposeBag() - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - self.configureUI() + override init(frame: CGRect) { + super.init(frame: frame) + + configureUI() } @available(*, unavailable) @@ -138,7 +139,9 @@ final class MusicTableViewCell: UITableViewCell { }() } -private extension MusicTableViewCell { +// MARK: - Private Methods + +private extension MusicListCell { // MARK: - UI @@ -147,7 +150,6 @@ private extension MusicTableViewCell { // MARK: - Cell self.backgroundColor = UIColor.gray900 - self.selectionStyle = .none // MARK: - Container StackView @@ -291,13 +293,3 @@ struct UIViewPreview: UIViewRepresentable { view.setContentHuggingPriority(.defaultHigh, for: .vertical) } } - -@available(iOS 13.0.0, *) -struct MusicTableViewCellPreview: PreviewProvider{ - static var previews: some View { - UIViewPreview { - return MusicTableViewCell() - } - .previewLayout(.fixed(width: 327, height: 92)) - } -} diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListSectionHeaderView.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListSectionHeaderView.swift index 9765ebb7..48a250d5 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListSectionHeaderView.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListSectionHeaderView.swift @@ -9,7 +9,7 @@ import UIKit import SnapKit -final class MusicListSectionHeaderView: UITableViewHeaderFooterView { +final class MusicListSectionHeaderView: UICollectionReusableView { static let identifier = "MusicListSectionHeaderView" private lazy var dateLabel: UILabel = { @@ -19,9 +19,10 @@ final class MusicListSectionHeaderView: UITableViewHeaderFooterView { return label }() - override init(reuseIdentifier: String?) { - super.init(reuseIdentifier: reuseIdentifier) - self.configureUI() + override init(frame: CGRect) { + super.init(frame: frame) + + configureUI() } @available(*, unavailable) @@ -38,12 +39,7 @@ extension MusicListSectionHeaderView { // MARK: - UI func configureUI() { - - // MARK: - View - - let backgroundView = UIView() - backgroundView.backgroundColor = UIColor.gray900 - self.backgroundView = backgroundView + backgroundColor = UIColor.gray900 // MARK: - Date Label diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageType.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageType.swift index d3b5b64b..6c0981e2 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageType.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageType.swift @@ -7,9 +7,7 @@ import Foundation -enum MyPageType: Int { - case dropMusic = 100 - case likeMusic = 101 +enum MyMusicType { + case drop + case like } - -typealias MusicInfo = (type: MyPageType, itemID: Int) diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift index 2464afb9..f737597e 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift @@ -14,18 +14,20 @@ import RxSwift import SnapKit final class MyPageViewController: UIViewController, Toastable, Alertable { - typealias DataSource = RxTableViewSectionedReloadDataSource + fileprivate typealias MusicDataSource = UICollectionViewDiffableDataSource private var stickyTapListStackView: UIStackView? private var stickyTopDimmedView: UIView? - private lazy var dropMusicDataSource: DataSource = configureDataSource() - private lazy var likeMusicDataSource: DataSource = configureDataSource() + private lazy var musicDataSource: MusicDataSource = configureMusicDataSource() + private var myMusicType: MyMusicType = .drop + private var collectionViewHeightConstraint: Constraint? private var viewModel: MyPageViewModel private let viewWillAppearEvent = PublishRelay() + private let listTypeTapEvent = PublishRelay() private let levelPolicyTapEvent = PublishRelay() - private let selectedMusicEvent = PublishRelay() + private let selectedMusicEvent = PublishRelay() private let disposeBag = DisposeBag() init(viewModel: MyPageViewModel = MyPageViewModel()) { @@ -44,6 +46,7 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { self.configureUI() self.bindAction() self.bindViewModel() + self.configureSupplementaryViewRegistration() } override func viewWillAppear(_ animated: Bool) { @@ -188,38 +191,17 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { label.isHidden = true return label }() - - private lazy var dropMusicListTableView: MusicListTableView = { - let tableView = MusicListTableView() - tableView.backgroundColor = .gray900 - tableView.isScrollEnabled = false - tableView.rowHeight = UITableView.automaticDimension - tableView.estimatedRowHeight = 100 - tableView.register(MusicTableViewCell.self, forCellReuseIdentifier: MusicTableViewCell.identifier) - tableView.register(MusicListSectionHeaderView.self, forHeaderFooterViewReuseIdentifier: MusicListSectionHeaderView.identifier) - tableView.sectionFooterHeight = 0 - tableView.tableFooterView = UIView() - tableView.tag = MyPageType.dropMusic.rawValue - tableView.rx.setDelegate(self) - .disposed(by: disposeBag) - return tableView - }() - - private lazy var likeMusicListTableView: MusicListTableView = { - let tableView = MusicListTableView() - tableView.backgroundColor = .gray900 - tableView.isHidden = true - tableView.isScrollEnabled = false - tableView.rowHeight = UITableView.automaticDimension - tableView.estimatedRowHeight = 100 - tableView.register(MusicTableViewCell.self, forCellReuseIdentifier: MusicTableViewCell.identifier) - tableView.register(MusicListSectionHeaderView.self, forHeaderFooterViewReuseIdentifier: MusicListSectionHeaderView.identifier) - tableView.sectionFooterHeight = 0 - tableView.tableFooterView = UIView() - tableView.tag = MyPageType.likeMusic.rawValue - tableView.rx.setDelegate(self) - .disposed(by: disposeBag) - return tableView + + private lazy var musicListCollectionView: UICollectionView = { + let collectionView = UICollectionView ( + frame: .zero, + collectionViewLayout: createMusicListLayout() + ) + collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + collectionView.isScrollEnabled = false + collectionView.backgroundColor = .clear + + return collectionView }() private lazy var scrollToTopButton: UIButton = { @@ -396,20 +378,13 @@ private extension MyPageViewController { self.tapListStackView.addArrangedSubview(dropCountLabel) - // MARK: - Drop Music List TableView - - self.containerView.addSubview(dropMusicListTableView) - self.dropMusicListTableView.snp.makeConstraints { make in - make.top.equalTo(tapListStackView.snp.bottom).offset(8) - make.leading.trailing.bottom.equalToSuperview() - } - - // MARK: - Like Music List TableView + // MARK: - Music List CollectionView - self.containerView.addSubview(likeMusicListTableView) - self.likeMusicListTableView.snp.makeConstraints { make in - make.top.equalTo(tapListStackView.snp.bottom).offset(8) - make.leading.trailing.bottom.equalToSuperview() + containerView.addSubview(musicListCollectionView) + musicListCollectionView.snp.makeConstraints { + $0.top.equalTo(tapListStackView.snp.bottom).offset(8) + $0.leading.trailing.bottom.equalToSuperview() + self.collectionViewHeightConstraint = $0.height.equalTo(1).constraint } // MARK: - Scroll To Top Button @@ -459,7 +434,7 @@ private extension MyPageViewController { newLikeButton.setTitle("좋아요", for: .normal) newLikeButton.titleLabel?.font = .pretendard(size: 20, weightName: .bold) - if self.dropMusicListTableView.isHidden { + if myMusicType == .like { newDropButton.setTitleColor(UIColor.gray400, for: .normal) newDropButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) @@ -476,7 +451,7 @@ private extension MyPageViewController { let newLabel = UILabel() newLabel.textColor = UIColor.gray400 newLabel.font = .pretendard(size: 14, weightName: .regular) - if self.dropMusicListTableView.isHidden { + if myMusicType == .like { newLabel.text = likeCountLabel.text } else { newLabel.text = dropCountLabel.text @@ -504,55 +479,19 @@ private extension MyPageViewController { private func bindTapButtonAction(dropTapButton: UIButton, likeTapButton: UIButton) { dropTapButton.rx.tap - .subscribe(onNext: { [weak self] in - guard let self = self else { return } - self.dropMusicListTableView.isHidden = false - self.likeMusicListTableView.isHidden = true - - self.tapListStackView.removeArrangedSubview(self.likeCountLabel) - self.likeCountLabel.isHidden = true - self.tapListStackView.addArrangedSubview(self.dropCountLabel) - self.dropCountLabel.isHidden = false - - dropTapButton.setTitleColor(.white, for: .normal) - dropTapButton.setTitleColor(.lightGray, for: .highlighted) - self.dropTapButton.setTitleColor(.white, for: .normal) - self.dropTapButton.setTitleColor(.lightGray, for: .highlighted) - likeTapButton.setTitleColor(UIColor.gray400, for: .normal) - likeTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) - self.likeTapButton.setTitleColor(UIColor.gray400, for: .normal) - self.likeTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) - - if self.scrollView.contentOffset.y > 343 { - self.scrollView.setContentOffset(CGPoint(x: 0, y: 343), animated: true) - } - }) + .bind(with: self) { owner, _ in + owner.listTypeTapEvent.accept(.drop) + owner.updateTapListUI(by: .drop) + owner.myMusicType = .drop + } .disposed(by: disposeBag) likeTapButton.rx.tap - .subscribe(onNext: { [weak self] in - guard let self = self else { return } - self.dropMusicListTableView.isHidden = true - self.likeMusicListTableView.isHidden = false - - self.tapListStackView.removeArrangedSubview(self.dropCountLabel) - self.dropCountLabel.isHidden = true - self.tapListStackView.addArrangedSubview(self.likeCountLabel) - self.likeCountLabel.isHidden = false - - dropTapButton.setTitleColor(UIColor.gray400, for: .normal) - dropTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) - self.dropTapButton.setTitleColor(UIColor.gray400, for: .normal) - self.dropTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) - likeTapButton.setTitleColor(.white, for: .normal) - likeTapButton.setTitleColor(.lightGray, for: .highlighted) - self.likeTapButton.setTitleColor(.white, for: .normal) - self.likeTapButton.setTitleColor(.lightGray, for: .highlighted) - - if self.scrollView.contentOffset.y > 343 { - self.scrollView.setContentOffset(CGPoint(x: 0, y: 343), animated: true) - } - }) + .bind(with: self) { owner, _ in + owner.listTypeTapEvent.accept(.like) + owner.updateTapListUI(by: .like) + owner.myMusicType = .like + } .disposed(by: disposeBag) } @@ -591,19 +530,11 @@ private extension MyPageViewController { .bind(to: levelPolicyTapEvent) .disposed(by: disposeBag) - dropMusicListTableView.rx.itemSelected + musicListCollectionView.rx.itemSelected .throttle(.seconds(2), scheduler: MainScheduler.instance) .bind(with: self) { owner, indexPath in - let itemID = owner.viewModel.myDropMusicList[indexPath.section][indexPath.row].id - owner.selectedMusicEvent.accept((MyPageType.dropMusic ,itemID)) - } - .disposed(by: disposeBag) - - likeMusicListTableView.rx.itemSelected - .throttle(.seconds(2), scheduler: MainScheduler.instance) - .bind(with: self) { owner, indexPath in - let itemID = owner.viewModel.myLikeMusicList[indexPath.section][indexPath.row].id - owner.selectedMusicEvent.accept((MyPageType.likeMusic ,itemID)) + guard let item = owner.musicDataSource.itemIdentifier(for: indexPath) else { return } + owner.selectedMusicEvent.accept(item.id) } .disposed(by: disposeBag) } @@ -612,10 +543,12 @@ private extension MyPageViewController { private func bindViewModel() { let input = MyPageViewModel.Input( - viewWillAppearEvent: self.viewWillAppearEvent, + viewWillAppearEvent: viewWillAppearEvent, + listTypeTapEvent: listTypeTapEvent, levelPolicyTapEvent: levelPolicyTapEvent, selectedMusicEvent: selectedMusicEvent ) + let output = viewModel.convert(input: input, disposedBag: disposeBag) output.levelName @@ -637,12 +570,10 @@ private extension MyPageViewController { }) .disposed(by: disposeBag) - output.myDropMusicsSections - .bind(to: dropMusicListTableView.rx.items(dataSource: dropMusicDataSource)) - .disposed(by: disposeBag) - - output.myLikeMusicsSections - .bind(to: likeMusicListTableView.rx.items(dataSource: likeMusicDataSource)) + output.myMusicsSections + .bind(with: self) { owner, sections in + owner.displayMusicList(sections) + } .disposed(by: disposeBag) output.totalDropMusicsCount @@ -761,58 +692,111 @@ extension MyPageViewController: UIScrollViewDelegate { } } -// MARK: - TableView Delegate +// MARK: - Private Methods + +private extension MyPageViewController { + func configureMusicDataSource() -> MusicDataSource { + typealias MusicListCellRegistration = UICollectionView.CellRegistration -extension MyPageViewController: UITableViewDelegate { - func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - return 32 + let musicCellRegistration = MusicListCellRegistration { cell, _ , item in + cell.setData(item: item) + } + + return MusicDataSource(collectionView: musicListCollectionView) { collectionView, indexPath, item in + + return collectionView.dequeueConfiguredReusableCell( + using: musicCellRegistration, + for: indexPath, + item: item + ) + } + } + + func configureSupplementaryViewRegistration() { + typealias MusicListHeaderRegistration = UICollectionView.SupplementaryRegistration + + let headerRegistration = MusicListHeaderRegistration(elementKind: UICollectionView.elementKindSectionHeader) { [weak self] headerView, elementKind, indexPath in + guard let self else { return } + + let section = self.musicDataSource.snapshot().sectionIdentifiers[safe: indexPath.section] + if case let .musics(date) = section { + headerView.setData(date: date) + } + } + + musicDataSource.supplementaryViewProvider = { [weak self] _, kind, index in + switch kind { + case UICollectionView.elementKindSectionHeader: + return self?.musicListCollectionView.dequeueConfiguredReusableSupplementary( + using: headerRegistration, + for: index + ) + default: + return UICollectionReusableView() + } + } } - func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - if let type = MyPageType(rawValue: tableView.tag) { - return configureHeaderView( - type: type, - tableView: tableView, - section: section + func createMusicListLayout() -> UICollectionViewLayout { + return UICollectionViewCompositionalLayout { [weak self] section, env -> NSCollectionLayoutSection? in + guard let self else { return nil } + let itemSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1.0), + heightDimension: .estimated(100) ) - } else { - return nil + + let item = NSCollectionLayoutItem(layoutSize: itemSize) + + let groupSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1.0), + heightDimension: .estimated(100) + ) + + let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitems: [item]) + + let section = NSCollectionLayoutSection(group: group) + let sectionHeader = self.configureSectionHeader() + section.boundarySupplementaryItems = [sectionHeader] + + return section } } -} - -// MARK: - Private Methods - -private extension MyPageViewController { - func configureDataSource() -> DataSource { - return DataSource( - configureCell: { _, tableView, indexPath, item in - guard let cell = tableView.dequeueReusableCell(withIdentifier: MusicTableViewCell.identifier, for: indexPath) as? MusicTableViewCell else { return UITableViewCell() } - cell.setData(item: item) - return cell - }) + + func configureSectionHeader() -> NSCollectionLayoutBoundarySupplementaryItem { + return NSCollectionLayoutBoundarySupplementaryItem( + layoutSize: NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1.0), + heightDimension: .estimated(32) + ), + elementKind: UICollectionView.elementKindSectionHeader, + alignment: .top + ) } - func configureHeaderView( - type: MyPageType, - tableView: UITableView, - section: Int - ) -> UIView? { - var dataSource: DataSource + func displayMusicList(_ sectionTypes: [MyMusicsSectionType]) { + var snapshot = NSDiffableDataSourceSnapshot() - switch type { - case .dropMusic: - dataSource = dropMusicDataSource - case .likeMusic: - dataSource = likeMusicDataSource + sectionTypes.forEach { sectionType in + snapshot.appendSections([sectionType.section]) + snapshot.appendItems(sectionType.items, toSection: sectionType.section) } - guard let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: MusicListSectionHeaderView.identifier) as? MusicListSectionHeaderView - else { return UIView() } - - let sectionData = dataSource[section] - headerView.setData(date: sectionData.date) - return headerView + musicDataSource.apply(snapshot, animatingDifferences: true) { [weak self] in + self?.updateCollectionViewHeight() + } + } + + func updateCollectionViewHeight() { + DispatchQueue.main.async { [weak self] in + guard let self else { return } + self.musicListCollectionView.layoutIfNeeded() + let contentHeight = self.musicListCollectionView.contentSize.height + 50 + self.collectionViewHeightConstraint?.update(offset: contentHeight) + + UIView.animate(withDuration: 0.3) { + self.view.layoutIfNeeded() + } + } } func updateLevelupGuideViewConstraints(by isShow: Bool) { @@ -827,40 +811,42 @@ private extension MyPageViewController { } } } -} - -// MARK: - 커스텀 테이블뷰 - -private final class MusicListTableView: UITableView { - override var contentSize:CGSize { - didSet { - invalidateIntrinsicContentSize() - } - } - - override var intrinsicContentSize: CGSize { - layoutIfNeeded() - return CGSize(width: UIView.noIntrinsicMetric, height: contentSize.height) - } -} - - -//MARK: - for canvas -import SwiftUI -struct MyPageViewControllerRepresentable: UIViewControllerRepresentable { - typealias UIViewControllerType = MyPageViewController - - func makeUIViewController(context: Context) -> MyPageViewController { - return MyPageViewController() - } - func updateUIViewController(_ uiViewController: MyPageViewController, context: Context) { - } -} - -@available(iOS 13.0.0, *) -struct MyPageViewControllerPreview: PreviewProvider { - static var previews: some View { - MyPageViewControllerRepresentable() + func updateTapListUI(by type: MyMusicType) { + switch type { + case .drop: + tapListStackView.removeArrangedSubview(self.likeCountLabel) + likeCountLabel.isHidden = true + tapListStackView.addArrangedSubview(self.dropCountLabel) + dropCountLabel.isHidden = false + + dropTapButton.setTitleColor(.white, for: .normal) + dropTapButton.setTitleColor(.lightGray, for: .highlighted) + dropTapButton.setTitleColor(.white, for: .normal) + dropTapButton.setTitleColor(.lightGray, for: .highlighted) + likeTapButton.setTitleColor(UIColor.gray400, for: .normal) + likeTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) + likeTapButton.setTitleColor(UIColor.gray400, for: .normal) + likeTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) + + case.like: + tapListStackView.removeArrangedSubview(self.dropCountLabel) + dropCountLabel.isHidden = true + tapListStackView.addArrangedSubview(self.likeCountLabel) + likeCountLabel.isHidden = false + + dropTapButton.setTitleColor(UIColor.gray400, for: .normal) + dropTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) + dropTapButton.setTitleColor(UIColor.gray400, for: .normal) + dropTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) + likeTapButton.setTitleColor(.white, for: .normal) + likeTapButton.setTitleColor(.lightGray, for: .highlighted) + likeTapButton.setTitleColor(.white, for: .normal) + likeTapButton.setTitleColor(.lightGray, for: .highlighted) + } + + if scrollView.contentOffset.y > 343 { + scrollView.setContentOffset(CGPoint(x: 0, y: 343), animated: true) + } } } diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift index 382d76b5..2cdec98f 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift @@ -18,23 +18,23 @@ final class MyPageViewModel { ) ) - var myDropMusicList: [[MyMusic]] = [] - var myLikeMusicList: [[MyMusic]] = [] + private var myDropMusicSections: [MyMusicsSectionType] = .init() + private var myLikeMusicSections: [MyMusicsSectionType] = .init() } extension MyPageViewModel: ViewModel { struct Input { let viewWillAppearEvent: PublishRelay + let listTypeTapEvent: PublishRelay let levelPolicyTapEvent: PublishRelay - let selectedMusicEvent: PublishRelay + let selectedMusicEvent: PublishRelay } struct Output { let levelImageURL = PublishRelay() let levelName = PublishRelay() let nickName = PublishRelay() - let myDropMusicsSections = PublishRelay<[MyMusicsSection]>() - let myLikeMusicsSections = PublishRelay<[MyMusicsSection]>() + let myMusicsSections = PublishRelay<[MyMusicsSectionType]>() let totalDropMusicsCount = PublishRelay() let totalLikeMusicsCount = PublishRelay() let pushCommunityView = PublishRelay() @@ -61,6 +61,17 @@ extension MyPageViewModel: ViewModel { } .disposed(by: disposedBag) + input.listTypeTapEvent + .bind(with: self) { owner, type in + switch type { + case .drop: + output.myMusicsSections.accept(owner.myDropMusicSections) + case .like: + output.myMusicsSections.accept(owner.myLikeMusicSections) + } + } + .disposed(by: disposedBag) + input.levelPolicyTapEvent .bind(with: self) { owner, _ in owner.fetchLevelPolicy(output: output, disposeBag: disposedBag) @@ -68,9 +79,9 @@ extension MyPageViewModel: ViewModel { .disposed(by: disposedBag) input.selectedMusicEvent - .bind(with: self) { owner, musicInfo in + .bind(with: self) { owner, itemID in owner.fetchMyDropMusic( - itemID: musicInfo.itemID, + itemID: itemID, output: output, disposedBag: disposedBag ) @@ -81,6 +92,8 @@ extension MyPageViewModel: ViewModel { } } +// MARK: - Private Methods + private extension MyPageViewModel { func fetchLevelItems(output: Output, disposedBag: DisposeBag) { model.fetchMyLevel() @@ -121,19 +134,17 @@ private extension MyPageViewModel { .disposed(by: disposeBag) } - func fetchMyDropMusicsSections(output: Output, disposedBag: DisposeBag) { + func fetchMyDropMusicsSections( + output: Output, + disposedBag: DisposeBag + ) { model.fetchMyDropList() .subscribe(with: self, onSuccess: { owner, totalMusics in output.totalDropMusicsCount.accept(totalMusics.totalCount) - output.myDropMusicsSections.accept( - totalMusics.musics.map { - .init(date: $0.date, items: $0.musics) - } - ) - - owner.myDropMusicList = totalMusics.musics.map { $0.musics } - }, onFailure: { _, _ in - output.myDropMusicsSections.accept([]) + owner.myDropMusicSections = owner.convertToSectionTypes(from: totalMusics) + output.myMusicsSections.accept(owner.myDropMusicSections) + }, onFailure: { _, error in + print("❌Fetching My Drop List Error: \(error.localizedDescription)") }) .disposed(by: disposedBag) } @@ -142,15 +153,9 @@ private extension MyPageViewModel { model.fetchMyLikeList() .subscribe(with: self, onSuccess: { owner, totalMusics in output.totalLikeMusicsCount.accept(totalMusics.totalCount) - output.myLikeMusicsSections.accept( - totalMusics.musics.map { - .init(date: $0.date, items: $0.musics) - } - ) - - owner.myLikeMusicList = totalMusics.musics.map { $0.musics } - }, onFailure: { _, _ in - output.myLikeMusicsSections.accept([]) + owner.myLikeMusicSections = owner.convertToSectionTypes(from: totalMusics) + }, onFailure: { _, error in + print("❌Fetching My Like List Error: \(error.localizedDescription)") }) .disposed(by: disposedBag) } @@ -173,4 +178,13 @@ private extension MyPageViewModel { }) .disposed(by: disposedBag) } + + func convertToSectionTypes(from totalMusics: TotalMyMusics) -> [MyMusicsSectionType] { + return totalMusics.musics.map { myMusics in + MyMusicsSectionType( + section: .musics(date: myMusics.date), + items: myMusics.musics + ) + } + } } From 5b683f4a86ad54af3d0d1c9a6bace29e51ea1577 Mon Sep 17 00:00:00 2001 From: thoonk Date: Mon, 8 Jul 2024 18:23:56 +0900 Subject: [PATCH 02/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=B7=B0=20Height=20=EC=A1=B0=EC=A0=95=20=EB=B0=8F=20?= =?UTF-8?q?=EC=A7=84=EC=9E=85=20=EC=8B=9C=20Height=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EC=84=A0=20=ED=98=B8=EC=B6=9C=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 마이페이지 진입 시 Height 값과 이후 다른 탭(좋아요) 선택 후 Height 값(정상)이 달라 section 값 전달되고 선 호출 처리를 통해 임시 해결 --- .../Presentation/MyPage/View/MyPageViewController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift index f737597e..6bf2b00e 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift @@ -46,7 +46,6 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { self.configureUI() self.bindAction() self.bindViewModel() - self.configureSupplementaryViewRegistration() } override func viewWillAppear(_ animated: Bool) { @@ -387,6 +386,8 @@ private extension MyPageViewController { self.collectionViewHeightConstraint = $0.height.equalTo(1).constraint } + configureSupplementaryViewRegistration() + // MARK: - Scroll To Top Button self.view.addSubview(scrollToTopButton) @@ -572,6 +573,7 @@ private extension MyPageViewController { output.myMusicsSections .bind(with: self) { owner, sections in + owner.updateCollectionViewHeight() owner.displayMusicList(sections) } .disposed(by: disposeBag) @@ -790,7 +792,7 @@ private extension MyPageViewController { DispatchQueue.main.async { [weak self] in guard let self else { return } self.musicListCollectionView.layoutIfNeeded() - let contentHeight = self.musicListCollectionView.contentSize.height + 50 + let contentHeight = self.musicListCollectionView.contentSize.height self.collectionViewHeightConstraint?.update(offset: contentHeight) UIView.animate(withDuration: 0.3) { From 2c40d346e1c7a4b6f8975bae70550bacf6f1595f Mon Sep 17 00:00:00 2001 From: thoonk Date: Wed, 10 Jul 2024 14:14:20 +0900 Subject: [PATCH 03/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20MyMusicType=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EA=B4=80=EB=A6=AC=20=EB=A1=9C=EC=A7=81=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/View/MyPageViewController.swift | 47 ++++++++++--------- .../MyPage/ViewModel/MyPageViewModel.swift | 28 ++++++----- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift index 6bf2b00e..0b838b57 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift @@ -20,7 +20,6 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { private var stickyTopDimmedView: UIView? private lazy var musicDataSource: MusicDataSource = configureMusicDataSource() - private var myMusicType: MyMusicType = .drop private var collectionViewHeightConstraint: Constraint? private var viewModel: MyPageViewModel @@ -57,7 +56,6 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { private lazy var scrollView: UIScrollView = { let scrollView = UIScrollView() scrollView.backgroundColor = UIColor.gray900 - scrollView.delegate = self return scrollView }() @@ -420,7 +418,7 @@ private extension MyPageViewController { return dimmedView } - func createTapListStackView() -> UIStackView { + func createTapListStackView(with type: MyMusicType) -> UIStackView { let newStackView = UIStackView() newStackView.axis = .horizontal newStackView.spacing = 8 @@ -435,7 +433,7 @@ private extension MyPageViewController { newLikeButton.setTitle("좋아요", for: .normal) newLikeButton.titleLabel?.font = .pretendard(size: 20, weightName: .bold) - if myMusicType == .like { + if type == .like { newDropButton.setTitleColor(UIColor.gray400, for: .normal) newDropButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) @@ -452,7 +450,7 @@ private extension MyPageViewController { let newLabel = UILabel() newLabel.textColor = UIColor.gray400 newLabel.font = .pretendard(size: 14, weightName: .regular) - if myMusicType == .like { + if type == .like { newLabel.text = likeCountLabel.text } else { newLabel.text = dropCountLabel.text @@ -483,7 +481,6 @@ private extension MyPageViewController { .bind(with: self) { owner, _ in owner.listTypeTapEvent.accept(.drop) owner.updateTapListUI(by: .drop) - owner.myMusicType = .drop } .disposed(by: disposeBag) @@ -491,7 +488,6 @@ private extension MyPageViewController { .bind(with: self) { owner, _ in owner.listTypeTapEvent.accept(.like) owner.updateTapListUI(by: .like) - owner.myMusicType = .like } .disposed(by: disposeBag) } @@ -538,16 +534,25 @@ private extension MyPageViewController { owner.selectedMusicEvent.accept(item.id) } .disposed(by: disposeBag) + + typealias ScrollViewState = (contentOffset: CGPoint, type: MyMusicType) + + scrollView.rx.contentOffset + .withLatestFrom(listTypeTapEvent) { (contentOffset: $0, type: $1) } + .bind(with: self) { owner, state in + owner.handleScrollEvent(contentOffset: state.contentOffset, type: state.type) + } + .disposed(by: disposeBag) } // MARK: - Data Binding private func bindViewModel() { let input = MyPageViewModel.Input( - viewWillAppearEvent: viewWillAppearEvent, - listTypeTapEvent: listTypeTapEvent, - levelPolicyTapEvent: levelPolicyTapEvent, - selectedMusicEvent: selectedMusicEvent + viewWillAppearEvent: viewWillAppearEvent.asObservable(), + listTypeTapEvent: listTypeTapEvent.asObservable(), + levelPolicyTapEvent: levelPolicyTapEvent.asObservable(), + selectedMusicEvent: selectedMusicEvent.asObservable() ) let output = viewModel.convert(input: input, disposedBag: disposeBag) @@ -648,22 +653,20 @@ private extension MyPageViewController { // MARK: - ScrollView Delegate -extension MyPageViewController: UIScrollViewDelegate { - func scrollViewDidScroll(_ scrollView: UIScrollView) { +extension MyPageViewController { + func handleScrollEvent(contentOffset: CGPoint, type: MyMusicType) { // 맨 위로 스크롤하기 버튼 활성화 - if scrollView == self.scrollView { - let offsetY = scrollView.contentOffset.y - if offsetY > 400 { - scrollToTopButton.isHidden = false - } else { - scrollToTopButton.isHidden = true - } + let offsetY = contentOffset.y + if offsetY > 400 { + scrollToTopButton.isHidden = false + } else { + scrollToTopButton.isHidden = true } // 드랍, 좋아요 탭 상단에 고정시키기 - if scrollView.contentOffset.y > 343 { + if contentOffset.y > 343 { if self.stickyTapListStackView == nil { - self.stickyTapListStackView = createTapListStackView() + self.stickyTapListStackView = createTapListStackView(with: type) self.stickyTopDimmedView = createDimmedView(isFromTop: true) guard let stickyTapListStackView = stickyTapListStackView else { return } diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift index 2cdec98f..cce1bf5f 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift @@ -24,10 +24,10 @@ final class MyPageViewModel { extension MyPageViewModel: ViewModel { struct Input { - let viewWillAppearEvent: PublishRelay - let listTypeTapEvent: PublishRelay - let levelPolicyTapEvent: PublishRelay - let selectedMusicEvent: PublishRelay + let viewWillAppearEvent: Observable + let listTypeTapEvent: Observable + let levelPolicyTapEvent: Observable + let selectedMusicEvent: Observable } struct Output { @@ -51,23 +51,28 @@ extension MyPageViewModel: ViewModel { func convert(input: Input, disposedBag: RxSwift.DisposeBag) -> Output { let output = Output() + let lastestListType = BehaviorRelay(value: .drop) input.viewWillAppearEvent .bind(with: self) { owner, _ in owner.fetchLevelItems(output: output, disposedBag: disposedBag) owner.fetchLevelProgress(output: output, disposeBag: disposedBag) - owner.fetchMyDropMusicsSections(output: output, disposedBag: disposedBag) - owner.fetchMyLikeMusicsSections(output: output, disposedBag: disposedBag) + + lastestListType.accept(lastestListType.value) } .disposed(by: disposedBag) input.listTypeTapEvent + .bind(to: lastestListType) + .disposed(by: disposedBag) + + lastestListType .bind(with: self) { owner, type in switch type { case .drop: - output.myMusicsSections.accept(owner.myDropMusicSections) + owner.fetchMyDropMusicsSections(output: output, disposedBag: disposedBag) case .like: - output.myMusicsSections.accept(owner.myLikeMusicSections) + owner.fetchMyLikeMusicsSections(output: output, disposedBag: disposedBag) } } .disposed(by: disposedBag) @@ -141,8 +146,8 @@ private extension MyPageViewModel { model.fetchMyDropList() .subscribe(with: self, onSuccess: { owner, totalMusics in output.totalDropMusicsCount.accept(totalMusics.totalCount) - owner.myDropMusicSections = owner.convertToSectionTypes(from: totalMusics) - output.myMusicsSections.accept(owner.myDropMusicSections) + let myMusicsSections = owner.convertToSectionTypes(from: totalMusics) + output.myMusicsSections.accept(myMusicsSections) }, onFailure: { _, error in print("❌Fetching My Drop List Error: \(error.localizedDescription)") }) @@ -153,7 +158,8 @@ private extension MyPageViewModel { model.fetchMyLikeList() .subscribe(with: self, onSuccess: { owner, totalMusics in output.totalLikeMusicsCount.accept(totalMusics.totalCount) - owner.myLikeMusicSections = owner.convertToSectionTypes(from: totalMusics) + let myMusicsSections = owner.convertToSectionTypes(from: totalMusics) + output.myMusicsSections.accept(myMusicsSections) }, onFailure: { _, error in print("❌Fetching My Like List Error: \(error.localizedDescription)") }) From 3912cb5465ff8120df96f8e120e2426b9e8f4f4a Mon Sep 17 00:00:00 2001 From: thoonk Date: Wed, 10 Jul 2024 14:43:23 +0900 Subject: [PATCH 04/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC=20=EB=B0=8F=20ViewWillAppearEvent=20?= =?UTF-8?q?=EB=B0=94=EC=9D=B8=EB=94=A9=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StreetDrop.xcodeproj/project.pbxproj | 8 + .../MyPage/View/MyPageViewController.swift | 138 +++++++++--------- .../MyPage/ViewModel/MyPageViewModel.swift | 3 - .../StreetDrop/Util/Extensions/Map+Rx.swift | 20 +++ .../Util/Extensions/UIViewController+Rx.swift | 73 +++++++++ 5 files changed, 172 insertions(+), 70 deletions(-) create mode 100644 StreetDrop/StreetDrop/Util/Extensions/Map+Rx.swift create mode 100644 StreetDrop/StreetDrop/Util/Extensions/UIViewController+Rx.swift diff --git a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj index 873c35e5..75578a48 100644 --- a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj +++ b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj @@ -140,6 +140,8 @@ 6A26BF322B33D1E40007B6B7 /* FetchingSingleMusicUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A26BF312B33D1E40007B6B7 /* FetchingSingleMusicUseCase.swift */; }; 6A26BF342B33D2210007B6B7 /* DefaultFetchingSingleMusicUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A26BF332B33D2210007B6B7 /* DefaultFetchingSingleMusicUseCase.swift */; }; 6A3AFB582B8DB399003BD144 /* GADUnitID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A3AFB572B8DB399003BD144 /* GADUnitID.swift */; }; + 6A51EC3C2C3E52FE00DEF6F3 /* UIViewController+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A51EC3B2C3E52FE00DEF6F3 /* UIViewController+Rx.swift */; }; + 6A51EC3E2C3E536000DEF6F3 /* Map+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A51EC3D2C3E536000DEF6F3 /* Map+Rx.swift */; }; 6A7D73D92BB11A0E009340E3 /* LevelUpGuideView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7D73D82BB11A0E009340E3 /* LevelUpGuideView.swift */; }; 6A7D73DD2BB14015009340E3 /* GradientProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7D73DC2BB14015009340E3 /* GradientProgressBar.swift */; }; 6A7D73DF2BB15826009340E3 /* UIView+RoundCorners.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7D73DE2BB15826009340E3 /* UIView+RoundCorners.swift */; }; @@ -410,6 +412,8 @@ 6A26BF312B33D1E40007B6B7 /* FetchingSingleMusicUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchingSingleMusicUseCase.swift; sourceTree = ""; }; 6A26BF332B33D2210007B6B7 /* DefaultFetchingSingleMusicUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingSingleMusicUseCase.swift; sourceTree = ""; }; 6A3AFB572B8DB399003BD144 /* GADUnitID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GADUnitID.swift; sourceTree = ""; }; + 6A51EC3B2C3E52FE00DEF6F3 /* UIViewController+Rx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Rx.swift"; sourceTree = ""; }; + 6A51EC3D2C3E536000DEF6F3 /* Map+Rx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Map+Rx.swift"; sourceTree = ""; }; 6A7D73D82BB11A0E009340E3 /* LevelUpGuideView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LevelUpGuideView.swift; sourceTree = ""; }; 6A7D73DC2BB14015009340E3 /* GradientProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientProgressBar.swift; sourceTree = ""; }; 6A7D73DE2BB15826009340E3 /* UIView+RoundCorners.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+RoundCorners.swift"; sourceTree = ""; }; @@ -1475,6 +1479,8 @@ 6A1386AA2B4F8A5000E49BB5 /* String+Base64.swift */, C49EDACD2BBD7EFE0025DB55 /* GradientLabel.swift */, F4AA84DE2C1F3B0200CADB1A /* Array+Extension.swift */, + 6A51EC3B2C3E52FE00DEF6F3 /* UIViewController+Rx.swift */, + 6A51EC3D2C3E536000DEF6F3 /* Map+Rx.swift */, ); path = Extensions; sourceTree = ""; @@ -1954,6 +1960,7 @@ 41396DA42A51B61000B69341 /* EditCommentViewModel.swift in Sources */, 049F50222A122C8A001528CB /* DropMusicRequestDTO+Mapping.swift in Sources */, C49EDACC2BBD75480025DB55 /* CongratulationsLevelUpPopUpViewController.swift in Sources */, + 6A51EC3C2C3E52FE00DEF6F3 /* UIViewController+Rx.swift in Sources */, F4C996AF2C1EF6C100FF7B9A /* Notice.swift in Sources */, 41A9BEB92A4DCA4A00F3605C /* ClaimCommentRepository.swift in Sources */, C45BF3A32A1D179C00CEDE74 /* RecentMusicQueriesStorage.swift in Sources */, @@ -2002,6 +2009,7 @@ 188D2C7B2A1E448C0088F49C /* DroppedMusicWithinAreaCollectionViewCell.swift in Sources */, 41396D9B2A4F1C5600B69341 /* OptionModalViewController.swift in Sources */, C47C1D1F2A643C07007317EA /* SplashViewController.swift in Sources */, + 6A51EC3E2C3E536000DEF6F3 /* Map+Rx.swift in Sources */, C449807C2BC3B07E0001E6C3 /* PostingPopUpUserReadingUseCase.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift index 0b838b57..f0afedd4 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift @@ -29,6 +29,8 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { private let selectedMusicEvent = PublishRelay() private let disposeBag = DisposeBag() + // MARK: - Init + init(viewModel: MyPageViewModel = MyPageViewModel()) { self.viewModel = viewModel super.init(nibName: nil, bundle: nil) @@ -47,12 +49,8 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { self.bindViewModel() } - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - self.viewWillAppearEvent.accept(Void()) - } - // MARK: - UI + private lazy var scrollView: UIScrollView = { let scrollView = UIScrollView() scrollView.backgroundColor = UIColor.gray900 @@ -214,6 +212,8 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { private lazy var bottomDimmedView: UIView = self.createDimmedView(isFromTop: false) } +// MARK: - UI Methods + private extension MyPageViewController { // MARK: - UI @@ -474,9 +474,62 @@ private extension MyPageViewController { return newStackView } - // MARK: - Action Binding + func updateLevelupGuideViewConstraints(by isShow: Bool) { + if isShow == false { + if levelUpGuideView.isDescendant(of: view) { + levelUpGuideView.removeFromSuperview() + + tapListStackView.snp.remakeConstraints { make in + make.top.equalTo(levelImageView.snp.bottom).offset(24) + make.leading.trailing.equalToSuperview().inset(24) + } + } + } + } - private func bindTapButtonAction(dropTapButton: UIButton, likeTapButton: UIButton) { + func updateTapListUI(by type: MyMusicType) { + switch type { + case .drop: + tapListStackView.removeArrangedSubview(self.likeCountLabel) + likeCountLabel.isHidden = true + tapListStackView.addArrangedSubview(self.dropCountLabel) + dropCountLabel.isHidden = false + + dropTapButton.setTitleColor(.white, for: .normal) + dropTapButton.setTitleColor(.lightGray, for: .highlighted) + dropTapButton.setTitleColor(.white, for: .normal) + dropTapButton.setTitleColor(.lightGray, for: .highlighted) + likeTapButton.setTitleColor(UIColor.gray400, for: .normal) + likeTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) + likeTapButton.setTitleColor(UIColor.gray400, for: .normal) + likeTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) + + case.like: + tapListStackView.removeArrangedSubview(self.dropCountLabel) + dropCountLabel.isHidden = true + tapListStackView.addArrangedSubview(self.likeCountLabel) + likeCountLabel.isHidden = false + + dropTapButton.setTitleColor(UIColor.gray400, for: .normal) + dropTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) + dropTapButton.setTitleColor(UIColor.gray400, for: .normal) + dropTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) + likeTapButton.setTitleColor(.white, for: .normal) + likeTapButton.setTitleColor(.lightGray, for: .highlighted) + likeTapButton.setTitleColor(.white, for: .normal) + likeTapButton.setTitleColor(.lightGray, for: .highlighted) + } + + if scrollView.contentOffset.y > 343 { + scrollView.setContentOffset(CGPoint(x: 0, y: 343), animated: true) + } + } +} + +// MARK: - Binding Methods + +private extension MyPageViewController { + func bindTapButtonAction(dropTapButton: UIButton, likeTapButton: UIButton) { dropTapButton.rx.tap .bind(with: self) { owner, _ in owner.listTypeTapEvent.accept(.drop) @@ -492,7 +545,12 @@ private extension MyPageViewController { .disposed(by: disposeBag) } - private func bindAction() { + func bindAction() { + rx.viewWillAppear + .mapVoid() + .bind(to: viewWillAppearEvent) + .disposed(by: disposeBag) + bindTapButtonAction(dropTapButton: self.dropTapButton, likeTapButton: self.likeTapButton) scrollToTopButton.rx.tap @@ -544,10 +602,8 @@ private extension MyPageViewController { } .disposed(by: disposeBag) } - - // MARK: - Data Binding - - private func bindViewModel() { + + func bindViewModel() { let input = MyPageViewModel.Input( viewWillAppearEvent: viewWillAppearEvent.asObservable(), listTypeTapEvent: listTypeTapEvent.asObservable(), @@ -578,7 +634,6 @@ private extension MyPageViewController { output.myMusicsSections .bind(with: self) { owner, sections in - owner.updateCollectionViewHeight() owner.displayMusicList(sections) } .disposed(by: disposeBag) @@ -651,9 +706,9 @@ private extension MyPageViewController { } } -// MARK: - ScrollView Delegate +// MARK: - ScrollView Methods -extension MyPageViewController { +private extension MyPageViewController { func handleScrollEvent(contentOffset: CGPoint, type: MyMusicType) { // 맨 위로 스크롤하기 버튼 활성화 let offsetY = contentOffset.y @@ -697,7 +752,7 @@ extension MyPageViewController { } } -// MARK: - Private Methods +// MARK: - UICollectionView Methods private extension MyPageViewController { func configureMusicDataSource() -> MusicDataSource { @@ -803,55 +858,4 @@ private extension MyPageViewController { } } } - - func updateLevelupGuideViewConstraints(by isShow: Bool) { - if isShow == false { - if levelUpGuideView.isDescendant(of: view) { - levelUpGuideView.removeFromSuperview() - - tapListStackView.snp.remakeConstraints { make in - make.top.equalTo(levelImageView.snp.bottom).offset(24) - make.leading.trailing.equalToSuperview().inset(24) - } - } - } - } - - func updateTapListUI(by type: MyMusicType) { - switch type { - case .drop: - tapListStackView.removeArrangedSubview(self.likeCountLabel) - likeCountLabel.isHidden = true - tapListStackView.addArrangedSubview(self.dropCountLabel) - dropCountLabel.isHidden = false - - dropTapButton.setTitleColor(.white, for: .normal) - dropTapButton.setTitleColor(.lightGray, for: .highlighted) - dropTapButton.setTitleColor(.white, for: .normal) - dropTapButton.setTitleColor(.lightGray, for: .highlighted) - likeTapButton.setTitleColor(UIColor.gray400, for: .normal) - likeTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) - likeTapButton.setTitleColor(UIColor.gray400, for: .normal) - likeTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) - - case.like: - tapListStackView.removeArrangedSubview(self.dropCountLabel) - dropCountLabel.isHidden = true - tapListStackView.addArrangedSubview(self.likeCountLabel) - likeCountLabel.isHidden = false - - dropTapButton.setTitleColor(UIColor.gray400, for: .normal) - dropTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) - dropTapButton.setTitleColor(UIColor.gray400, for: .normal) - dropTapButton.setTitleColor(UIColor(hexString: "#43464B"), for: .highlighted) - likeTapButton.setTitleColor(.white, for: .normal) - likeTapButton.setTitleColor(.lightGray, for: .highlighted) - likeTapButton.setTitleColor(.white, for: .normal) - likeTapButton.setTitleColor(.lightGray, for: .highlighted) - } - - if scrollView.contentOffset.y > 343 { - scrollView.setContentOffset(CGPoint(x: 0, y: 343), animated: true) - } - } } diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift index cce1bf5f..f8519037 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift @@ -17,9 +17,6 @@ final class MyPageViewModel { networkManager: NetworkManager() ) ) - - private var myDropMusicSections: [MyMusicsSectionType] = .init() - private var myLikeMusicSections: [MyMusicsSectionType] = .init() } extension MyPageViewModel: ViewModel { diff --git a/StreetDrop/StreetDrop/Util/Extensions/Map+Rx.swift b/StreetDrop/StreetDrop/Util/Extensions/Map+Rx.swift new file mode 100644 index 00000000..91c1fe87 --- /dev/null +++ b/StreetDrop/StreetDrop/Util/Extensions/Map+Rx.swift @@ -0,0 +1,20 @@ +// +// Map+Rx.swift +// StreetDrop +// +// Created by thoonk on 7/10/24. +// + +import Foundation + +import RxSwift + +extension ObservableType { + func map(_ element: T) -> Observable { + self.map({ _ in element }) + } + + func mapVoid() -> Observable { + self.map(Void()) + } +} diff --git a/StreetDrop/StreetDrop/Util/Extensions/UIViewController+Rx.swift b/StreetDrop/StreetDrop/Util/Extensions/UIViewController+Rx.swift new file mode 100644 index 00000000..cfc7866d --- /dev/null +++ b/StreetDrop/StreetDrop/Util/Extensions/UIViewController+Rx.swift @@ -0,0 +1,73 @@ +// +// UIViewController+Rx.swift +// StreetDrop +// +// Created by thoonk on 7/10/24. +// + +import Foundation +import UIKit + +import RxSwift +import RxCocoa + +extension Reactive where Base: UIViewController { + var viewDidLoad: ControlEvent { + let source = self.methodInvoked(#selector(Base.viewDidLoad)).map { _ in } + return ControlEvent(events: source) + } + + var viewWillAppear: ControlEvent { + let source = self.methodInvoked(#selector(Base.viewWillAppear)).map { $0.first as? Bool ?? false } + return ControlEvent(events: source) + } + var viewDidAppear: ControlEvent { + let source = self.methodInvoked(#selector(Base.viewDidAppear)).map { $0.first as? Bool ?? false } + return ControlEvent(events: source) + } + + var viewWillDisappear: ControlEvent { + let source = self.methodInvoked(#selector(Base.viewWillDisappear)).map { $0.first as? Bool ?? false } + return ControlEvent(events: source) + } + var viewDidDisappear: ControlEvent { + let source = self.methodInvoked(#selector(Base.viewDidDisappear)).map { $0.first as? Bool ?? false } + return ControlEvent(events: source) + } + + var viewWillLayoutSubviews: ControlEvent { + let source = self.methodInvoked(#selector(Base.viewWillLayoutSubviews)).map { _ in } + return ControlEvent(events: source) + } + var viewDidLayoutSubviews: ControlEvent { + let source = self.methodInvoked(#selector(Base.viewDidLayoutSubviews)).map { _ in } + return ControlEvent(events: source) + } + + var willMoveToParentViewController: ControlEvent { + let source = self.methodInvoked(#selector(Base.willMove)).map { $0.first as? UIViewController } + return ControlEvent(events: source) + } + var didMoveToParentViewController: ControlEvent { + let source = self.methodInvoked(#selector(Base.didMove)).map { $0.first as? UIViewController } + return ControlEvent(events: source) + } + + var didReceiveMemoryWarning: ControlEvent { + let source = self.methodInvoked(#selector(Base.didReceiveMemoryWarning)).map { _ in } + return ControlEvent(events: source) + } + + /// Rx observable, triggered when the ViewController appearance state changes (true if the View is being displayed, false otherwise) + var isVisible: Observable { + let viewDidAppearObservable = self.base.rx.viewDidAppear.map { _ in true } + let viewWillDisappearObservable = self.base.rx.viewWillDisappear.map { _ in false } + return Observable.merge(viewDidAppearObservable, viewWillDisappearObservable) + } + + /// Rx observable, triggered when the ViewController is being dismissed + var isDismissing: ControlEvent { + let source = self.sentMessage(#selector(Base.dismiss)).map { $0.first as? Bool ?? false } + return ControlEvent(events: source) + } +} From b7783d3104705f45d65a9722ac53450849e0a692 Mon Sep 17 00:00:00 2001 From: thoonk Date: Wed, 10 Jul 2024 14:51:33 +0900 Subject: [PATCH 05/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EC=A7=84=EC=9E=85=ED=95=A0=20=EB=95=8C,=20sticky=20tap=20list?= =?UTF-8?q?=20=EB=AF=B8=EB=85=B8=EC=B6=9C=20=EC=9D=B4=EC=8A=88=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/MyPage/View/MyPageViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift index f0afedd4..8afd04c2 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift @@ -24,7 +24,7 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { private var viewModel: MyPageViewModel private let viewWillAppearEvent = PublishRelay() - private let listTypeTapEvent = PublishRelay() + private let listTypeTapEvent = BehaviorRelay(value: .drop) private let levelPolicyTapEvent = PublishRelay() private let selectedMusicEvent = PublishRelay() private let disposeBag = DisposeBag() From 01b3f6d656e41a4feb7547e54fbabefb7748e786 Mon Sep 17 00:00:00 2001 From: thoonk Date: Thu, 11 Jul 2024 10:58:08 +0900 Subject: [PATCH 06/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=83=AD=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=EC=93=B0=EB=A1=9C=ED=8B=80=20=EC=B6=94=EA=B0=80,?= =?UTF-8?q?=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=B7=B0=20separator=20=EB=AF=B8?= =?UTF-8?q?=EB=85=B8=EC=B6=9C=EB=90=98=EB=8A=94=20=EC=9D=B4=EC=8A=88=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC,=20=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=81=AC=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=ED=86=A0=EC=8A=A4=ED=8A=B8=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StreetDrop/Presentation/MyPage/View/MusicListCell.swift | 4 ++-- .../Presentation/MyPage/View/MyPageViewController.swift | 3 +++ .../Presentation/MyPage/ViewModel/MyPageViewModel.swift | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift index 116654e9..79103f62 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift @@ -267,9 +267,9 @@ private extension MusicListCell { // MARK: - Separator View self.addSubview(separatorView) - self.separatorView.snp.makeConstraints { make in - make.top.equalTo(self.snp.bottom) + separatorView.snp.makeConstraints { make in make.leading.trailing.equalToSuperview() + make.bottom.equalToSuperview() make.height.equalTo(1) } } diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift index 8afd04c2..0184104d 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift @@ -531,6 +531,7 @@ private extension MyPageViewController { private extension MyPageViewController { func bindTapButtonAction(dropTapButton: UIButton, likeTapButton: UIButton) { dropTapButton.rx.tap + .throttle(.seconds(2), scheduler: MainScheduler.instance) .bind(with: self) { owner, _ in owner.listTypeTapEvent.accept(.drop) owner.updateTapListUI(by: .drop) @@ -538,6 +539,7 @@ private extension MyPageViewController { .disposed(by: disposeBag) likeTapButton.rx.tap + .throttle(.seconds(2), scheduler: MainScheduler.instance) .bind(with: self) { owner, _ in owner.listTypeTapEvent.accept(.like) owner.updateTapListUI(by: .like) @@ -634,6 +636,7 @@ private extension MyPageViewController { output.myMusicsSections .bind(with: self) { owner, sections in + owner.updateCollectionViewHeight() owner.displayMusicList(sections) } .disposed(by: disposeBag) diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift index f8519037..f8dc3e35 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift @@ -147,6 +147,7 @@ private extension MyPageViewModel { output.myMusicsSections.accept(myMusicsSections) }, onFailure: { _, error in print("❌Fetching My Drop List Error: \(error.localizedDescription)") + output.toast.accept("네트워크를 확인해 주세요") }) .disposed(by: disposedBag) } @@ -159,6 +160,7 @@ private extension MyPageViewModel { output.myMusicsSections.accept(myMusicsSections) }, onFailure: { _, error in print("❌Fetching My Like List Error: \(error.localizedDescription)") + output.toast.accept("네트워크를 확인해 주세요") }) .disposed(by: disposedBag) } From 29cc826a1c7f49440f59d99b0452f623a4a7d38a Mon Sep 17 00:00:00 2001 From: thoonk Date: Thu, 11 Jul 2024 17:47:59 +0900 Subject: [PATCH 07/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EC=A7=84=EC=9E=85=ED=95=A0=20=EB=95=8C=202=EB=B2=88=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=EB=90=98=EB=8A=94=20=EC=9D=B4=EC=8A=88=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/MyPage/ViewModel/MyPageViewModel.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift index f8dc3e35..42cde5d8 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift @@ -17,6 +17,8 @@ final class MyPageViewModel { networkManager: NetworkManager() ) ) + + private var myMusicType: MyMusicType = .drop } extension MyPageViewModel: ViewModel { @@ -48,14 +50,14 @@ extension MyPageViewModel: ViewModel { func convert(input: Input, disposedBag: RxSwift.DisposeBag) -> Output { let output = Output() - let lastestListType = BehaviorRelay(value: .drop) + let lastestListType = PublishRelay() input.viewWillAppearEvent .bind(with: self) { owner, _ in owner.fetchLevelItems(output: output, disposedBag: disposedBag) owner.fetchLevelProgress(output: output, disposeBag: disposedBag) - lastestListType.accept(lastestListType.value) + lastestListType.accept(owner.myMusicType) } .disposed(by: disposedBag) @@ -65,6 +67,8 @@ extension MyPageViewModel: ViewModel { lastestListType .bind(with: self) { owner, type in + owner.myMusicType = type + switch type { case .drop: owner.fetchMyDropMusicsSections(output: output, disposedBag: disposedBag) From 6f35825f50ad4735547fcc101fa1aad35ae428e8 Mon Sep 17 00:00:00 2001 From: thoonk Date: Fri, 12 Jul 2024 17:42:22 +0900 Subject: [PATCH 08/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20ScrollView=20?= =?UTF-8?q?=EC=95=88=20CollectionView=20contentSize=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EC=9D=B4=EC=8A=88=EB=A1=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=95=B4=20UITableView=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기존 Diffable DataSource 로직 변경 없음 - Compositional Layout 제거 --- .../StreetDrop.xcodeproj/project.pbxproj | 4 + .../MyPage/View/MusicListCell.swift | 11 +- .../View/MusicListSectionHeaderView.swift | 8 +- .../MyPage/View/MusicListTableView.swift | 21 +++ .../MyPage/View/MyPageViewController.swift | 152 ++++++------------ 5 files changed, 83 insertions(+), 113 deletions(-) create mode 100644 StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListTableView.swift diff --git a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj index 75578a48..bc9090e5 100644 --- a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj +++ b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj @@ -142,6 +142,7 @@ 6A3AFB582B8DB399003BD144 /* GADUnitID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A3AFB572B8DB399003BD144 /* GADUnitID.swift */; }; 6A51EC3C2C3E52FE00DEF6F3 /* UIViewController+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A51EC3B2C3E52FE00DEF6F3 /* UIViewController+Rx.swift */; }; 6A51EC3E2C3E536000DEF6F3 /* Map+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A51EC3D2C3E536000DEF6F3 /* Map+Rx.swift */; }; + 6A51EC402C411FB000DEF6F3 /* MusicListTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A51EC3F2C411FB000DEF6F3 /* MusicListTableView.swift */; }; 6A7D73D92BB11A0E009340E3 /* LevelUpGuideView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7D73D82BB11A0E009340E3 /* LevelUpGuideView.swift */; }; 6A7D73DD2BB14015009340E3 /* GradientProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7D73DC2BB14015009340E3 /* GradientProgressBar.swift */; }; 6A7D73DF2BB15826009340E3 /* UIView+RoundCorners.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A7D73DE2BB15826009340E3 /* UIView+RoundCorners.swift */; }; @@ -414,6 +415,7 @@ 6A3AFB572B8DB399003BD144 /* GADUnitID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GADUnitID.swift; sourceTree = ""; }; 6A51EC3B2C3E52FE00DEF6F3 /* UIViewController+Rx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Rx.swift"; sourceTree = ""; }; 6A51EC3D2C3E536000DEF6F3 /* Map+Rx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Map+Rx.swift"; sourceTree = ""; }; + 6A51EC3F2C411FB000DEF6F3 /* MusicListTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicListTableView.swift; sourceTree = ""; }; 6A7D73D82BB11A0E009340E3 /* LevelUpGuideView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LevelUpGuideView.swift; sourceTree = ""; }; 6A7D73DC2BB14015009340E3 /* GradientProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientProgressBar.swift; sourceTree = ""; }; 6A7D73DE2BB15826009340E3 /* UIView+RoundCorners.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+RoundCorners.swift"; sourceTree = ""; }; @@ -912,6 +914,7 @@ 0856524F2AFBB73100FD9BCB /* MyPageType.swift */, 6A7D73D82BB11A0E009340E3 /* LevelUpGuideView.swift */, 6A7D73DC2BB14015009340E3 /* GradientProgressBar.swift */, + 6A51EC3F2C411FB000DEF6F3 /* MusicListTableView.swift */, ); path = View; sourceTree = ""; @@ -1875,6 +1878,7 @@ F4C996A12C1E15CD00FF7B9A /* NoticeListViewController.swift in Sources */, 1867C8202A4DDB8C00F8EC48 /* MyPageViewController.swift in Sources */, 1816ED432A685865005009FC /* NicknameEditModel.swift in Sources */, + 6A51EC402C411FB000DEF6F3 /* MusicListTableView.swift in Sources */, C40008EA2A32012B00EA7FA9 /* Music.swift in Sources */, 413ABEEC2A39D1E900EA1010 /* UIcolor+.swift in Sources */, 41A9BEBB2A4DCBDA00F3605C /* DefaultClaimCommentRepository.swift in Sources */, diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift index 79103f62..01e9a92f 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListCell.swift @@ -11,14 +11,14 @@ import SnapKit import RxCocoa import RxSwift -final class MusicListCell: UICollectionViewCell { - static let identifier = "MusicTableViewCell" +final class MusicListCell: UITableViewCell { + static let identifier = "MusicListCell" private var disposeBag: DisposeBag = DisposeBag() - override init(frame: CGRect) { - super.init(frame: frame) + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) - configureUI() + self.configureUI() } @available(*, unavailable) @@ -150,6 +150,7 @@ private extension MusicListCell { // MARK: - Cell self.backgroundColor = UIColor.gray900 + self.selectionStyle = .none // MARK: - Container StackView diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListSectionHeaderView.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListSectionHeaderView.swift index 48a250d5..36b585f7 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListSectionHeaderView.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListSectionHeaderView.swift @@ -9,7 +9,7 @@ import UIKit import SnapKit -final class MusicListSectionHeaderView: UICollectionReusableView { +final class MusicListSectionHeaderView: UITableViewHeaderFooterView { static let identifier = "MusicListSectionHeaderView" private lazy var dateLabel: UILabel = { @@ -19,10 +19,10 @@ final class MusicListSectionHeaderView: UICollectionReusableView { return label }() - override init(frame: CGRect) { - super.init(frame: frame) + override init(reuseIdentifier: String?) { + super.init(reuseIdentifier: reuseIdentifier) - configureUI() + self.configureUI() } @available(*, unavailable) diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListTableView.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListTableView.swift new file mode 100644 index 00000000..83ec7fe1 --- /dev/null +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MusicListTableView.swift @@ -0,0 +1,21 @@ +// +// MusicListTableView.swift +// StreetDrop +// +// Created by thoonk on 7/12/24. +// + +import UIKit + +final class MusicListTableView: UITableView { + override var intrinsicContentSize: CGSize { + layoutIfNeeded() + return contentSize + } + + override var contentSize: CGSize { + didSet { + invalidateIntrinsicContentSize() + } + } +} diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift index 0184104d..3eaba55b 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift @@ -14,13 +14,12 @@ import RxSwift import SnapKit final class MyPageViewController: UIViewController, Toastable, Alertable { - fileprivate typealias MusicDataSource = UICollectionViewDiffableDataSource + fileprivate typealias MusicDataSource = UITableViewDiffableDataSource private var stickyTapListStackView: UIStackView? private var stickyTopDimmedView: UIView? private lazy var musicDataSource: MusicDataSource = configureMusicDataSource() - private var collectionViewHeightConstraint: Constraint? private var viewModel: MyPageViewModel private let viewWillAppearEvent = PublishRelay() @@ -187,16 +186,26 @@ final class MyPageViewController: UIViewController, Toastable, Alertable { return label }() - private lazy var musicListCollectionView: UICollectionView = { - let collectionView = UICollectionView ( - frame: .zero, - collectionViewLayout: createMusicListLayout() + private lazy var musicListTableView: MusicListTableView = { + let tableView = MusicListTableView(frame: .zero, style: .grouped) + tableView.isScrollEnabled = false + tableView.backgroundColor = .clear + tableView.rowHeight = UITableView.automaticDimension + tableView.estimatedRowHeight = 100 + tableView.delegate = self + tableView.sectionFooterHeight = 0 + tableView.separatorStyle = .none + + tableView.register( + MusicListCell.self, + forCellReuseIdentifier: MusicListCell.identifier + ) + tableView.register( + MusicListSectionHeaderView.self, + forHeaderFooterViewReuseIdentifier: MusicListSectionHeaderView.identifier ) - collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight] - collectionView.isScrollEnabled = false - collectionView.backgroundColor = .clear - return collectionView + return tableView }() private lazy var scrollToTopButton: UIButton = { @@ -377,15 +386,12 @@ private extension MyPageViewController { // MARK: - Music List CollectionView - containerView.addSubview(musicListCollectionView) - musicListCollectionView.snp.makeConstraints { + containerView.addSubview(musicListTableView) + musicListTableView.snp.makeConstraints { $0.top.equalTo(tapListStackView.snp.bottom).offset(8) $0.leading.trailing.bottom.equalToSuperview() - self.collectionViewHeightConstraint = $0.height.equalTo(1).constraint } - - configureSupplementaryViewRegistration() - + // MARK: - Scroll To Top Button self.view.addSubview(scrollToTopButton) @@ -587,7 +593,7 @@ private extension MyPageViewController { .bind(to: levelPolicyTapEvent) .disposed(by: disposeBag) - musicListCollectionView.rx.itemSelected + musicListTableView.rx.itemSelected .throttle(.seconds(2), scheduler: MainScheduler.instance) .bind(with: self) { owner, indexPath in guard let item = owner.musicDataSource.itemIdentifier(for: indexPath) else { return } @@ -636,7 +642,6 @@ private extension MyPageViewController { output.myMusicsSections .bind(with: self) { owner, sections in - owner.updateCollectionViewHeight() owner.displayMusicList(sections) } .disposed(by: disposeBag) @@ -759,81 +764,16 @@ private extension MyPageViewController { private extension MyPageViewController { func configureMusicDataSource() -> MusicDataSource { - typealias MusicListCellRegistration = UICollectionView.CellRegistration - - let musicCellRegistration = MusicListCellRegistration { cell, _ , item in - cell.setData(item: item) - } - - return MusicDataSource(collectionView: musicListCollectionView) { collectionView, indexPath, item in - - return collectionView.dequeueConfiguredReusableCell( - using: musicCellRegistration, - for: indexPath, - item: item - ) - } - } - - func configureSupplementaryViewRegistration() { - typealias MusicListHeaderRegistration = UICollectionView.SupplementaryRegistration - - let headerRegistration = MusicListHeaderRegistration(elementKind: UICollectionView.elementKindSectionHeader) { [weak self] headerView, elementKind, indexPath in - guard let self else { return } + return MusicDataSource(tableView: musicListTableView, cellProvider: { tableView, indexPath, item -> UITableViewCell? in + guard let cell = tableView.dequeueReusableCell( + withIdentifier: MusicListCell.identifier, + for: indexPath + ) as? MusicListCell else { return nil } - let section = self.musicDataSource.snapshot().sectionIdentifiers[safe: indexPath.section] - if case let .musics(date) = section { - headerView.setData(date: date) - } - } - - musicDataSource.supplementaryViewProvider = { [weak self] _, kind, index in - switch kind { - case UICollectionView.elementKindSectionHeader: - return self?.musicListCollectionView.dequeueConfiguredReusableSupplementary( - using: headerRegistration, - for: index - ) - default: - return UICollectionReusableView() - } - } - } - - func createMusicListLayout() -> UICollectionViewLayout { - return UICollectionViewCompositionalLayout { [weak self] section, env -> NSCollectionLayoutSection? in - guard let self else { return nil } - let itemSize = NSCollectionLayoutSize( - widthDimension: .fractionalWidth(1.0), - heightDimension: .estimated(100) - ) - - let item = NSCollectionLayoutItem(layoutSize: itemSize) - - let groupSize = NSCollectionLayoutSize( - widthDimension: .fractionalWidth(1.0), - heightDimension: .estimated(100) - ) - - let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitems: [item]) - - let section = NSCollectionLayoutSection(group: group) - let sectionHeader = self.configureSectionHeader() - section.boundarySupplementaryItems = [sectionHeader] + cell.setData(item: item) - return section - } - } - - func configureSectionHeader() -> NSCollectionLayoutBoundarySupplementaryItem { - return NSCollectionLayoutBoundarySupplementaryItem( - layoutSize: NSCollectionLayoutSize( - widthDimension: .fractionalWidth(1.0), - heightDimension: .estimated(32) - ), - elementKind: UICollectionView.elementKindSectionHeader, - alignment: .top - ) + return cell + }) } func displayMusicList(_ sectionTypes: [MyMusicsSectionType]) { @@ -844,21 +784,25 @@ private extension MyPageViewController { snapshot.appendItems(sectionType.items, toSection: sectionType.section) } - musicDataSource.apply(snapshot, animatingDifferences: true) { [weak self] in - self?.updateCollectionViewHeight() + musicDataSource.apply(snapshot, animatingDifferences: false) + } +} + +// MARK: - UITableViewDelegate + +extension MyPageViewController: UITableViewDelegate { + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let section = self.musicDataSource.snapshot().sectionIdentifiers[safe: section] + let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: MusicListSectionHeaderView.identifier) as? MusicListSectionHeaderView + + if case let .musics(date) = section { + headerView?.setData(date: date) } + + return headerView } - func updateCollectionViewHeight() { - DispatchQueue.main.async { [weak self] in - guard let self else { return } - self.musicListCollectionView.layoutIfNeeded() - let contentHeight = self.musicListCollectionView.contentSize.height - self.collectionViewHeightConstraint?.update(offset: contentHeight) - - UIView.animate(withDuration: 0.3) { - self.view.layoutIfNeeded() - } - } + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + return 20 } } From 556ed14d1a4d3ee3979f205c4ed2215a6ab4eeb3 Mon Sep 17 00:00:00 2001 From: thoonk Date: Fri, 12 Jul 2024 17:53:40 +0900 Subject: [PATCH 09/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20datasource=20ap?= =?UTF-8?q?ply=20=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98=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 --- .../Presentation/MyPage/View/MyPageViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift index 3eaba55b..464cc2c0 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/View/MyPageViewController.swift @@ -784,7 +784,7 @@ private extension MyPageViewController { snapshot.appendItems(sectionType.items, toSection: sectionType.section) } - musicDataSource.apply(snapshot, animatingDifferences: false) + musicDataSource.apply(snapshot, animatingDifferences: true) } } From 60cb96488980092bd5ea4d078abee7bdc2df0ad0 Mon Sep 17 00:00:00 2001 From: thoonk Date: Tue, 16 Jul 2024 21:42:22 +0900 Subject: [PATCH 10/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20UseCase=20=EB=A6=AC?= =?UTF-8?q?=ED=8E=99=ED=86=A0=EB=A7=81=20=EB=B0=8F=20=EA=B8=B0=EC=A1=B4=20?= =?UTF-8?q?UseCase=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B0=8F=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EA=B5=AC=EC=A1=B0=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StreetDrop.xcodeproj/project.pbxproj | 290 +++++++++++++++--- .../{ => BlockUser}/BlockUserUseCase.swift | 0 .../DefaultBlockUserUseCase.swift | 0 .../ClaimingCommentUseCase.swift | 0 .../DefaultClaimingCommentUseCase.swift | 0 .../DefaultDeletingMusicUseCase.swift | 0 .../DeletingMusicUseCase.swift | 0 .../DefaultDropMusicUseCase.swift} | 4 +- .../DropMusicUseCase.swift} | 4 +- .../DefaultEditCommentUseCase.swift | 0 .../EditCommentUseCase.swift | 0 .../DefaultFetchingLevelPolicyUseCase.swift | 0 .../FetchingLevelPolicyUseCase.swift | 0 .../DefaultFetchingMusicCountUseCase.swift | 0 .../FetchingMusicCountUseCase.swift | 0 ...faultFetchingMusicWithinAreaUseCase.swift} | 4 +- .../FetchingMusicWithinAreaUseCase.swift} | 2 +- .../DefaultFetchingMyDropListUseCase.swift | 24 ++ .../FetchingMyDropListUseCase.swift | 14 + .../DefaultFetchingMyInfoUseCase.swift | 0 .../FetchingMyInfoUseCase.swift | 0 .../DefaultFetchingMyLevelUseCase.swift | 28 ++ .../FetchingMyLevelUseCase.swift | 15 + .../DefaultFetchingMyLikeListUseCase.swift | 24 ++ .../FetchingMyLikeListUseCase.swift | 14 + .../{ => FetchingNotice}/NoticeUseCase.swift | 4 +- .../DefaultFetchingPOIUseCase.swift | 0 .../FetchingPOIUseCase.swift | 0 ...efaultFetchingPopUpInfomationUseCase.swift | 0 .../FetchingPopUpInfomationUseCase.swift | 0 .../DefaultFetchingSingleMusicUseCase.swift | 0 .../FetchingSingleMusicUseCase.swift | 0 ...faultFetchingUserCircleRadiusUsecase.swift | 0 .../FetchingUserCircleRadiusUsecase.swift | 0 .../{ => Liking}/DefaultLikingUseCase.swift | 0 .../UseCase/{ => Liking}/LikingUseCase.swift | 0 .../{ => MyInfo}/DefaultMyInfoUseCase.swift | 0 .../UseCase/{ => MyInfo}/MyInfoUseCase.swift | 0 ...efaultPostingPopUpUserReadingUseCase.swift | 0 .../PostingPopUpUserReadingUseCase.swift | 0 .../SearchMusicUsecase.swift | 0 .../{ => Settings}/SettingsUseCase.swift | 0 .../MainScene/ViewModel/MainViewModel.swift | 8 +- .../ViewModel/MusicDropViewModel.swift | 8 +- .../ViewModel/NoticeDetailViewModel.swift | 4 +- .../ViewModel/NoticeListViewModel.swift | 4 +- 46 files changed, 381 insertions(+), 70 deletions(-) rename StreetDrop/StreetDrop/Domain/UseCase/{ => BlockUser}/BlockUserUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => BlockUser}/DefaultBlockUserUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => ClaimingComment}/ClaimingCommentUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => ClaimingComment}/DefaultClaimingCommentUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => DeletingMusic}/DefaultDeletingMusicUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => DeletingMusic}/DeletingMusicUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{MusicDrop/DefaultMusicDropUseCase.swift => DropMusic/DefaultDropMusicUseCase.swift} (84%) rename StreetDrop/StreetDrop/Domain/UseCase/{MusicDrop/MusicDropUseCase.swift => DropMusic/DropMusicUseCase.swift} (75%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => EditComment}/DefaultEditCommentUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => EditComment}/EditCommentUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingLevelPolicy}/DefaultFetchingLevelPolicyUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingLevelPolicy}/FetchingLevelPolicyUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingMusicCount}/DefaultFetchingMusicCountUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingMusicCount}/FetchingMusicCountUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{DefaultFetchingMusicWithinArea.swift => FetchingMusicWithinArea/DefaultFetchingMusicWithinAreaUseCase.swift} (80%) rename StreetDrop/StreetDrop/Domain/UseCase/{FetchingMusicWithinArea.swift => FetchingMusicWithinArea/FetchingMusicWithinAreaUseCase.swift} (83%) create mode 100644 StreetDrop/StreetDrop/Domain/UseCase/FetchingMyDropList/DefaultFetchingMyDropListUseCase.swift create mode 100644 StreetDrop/StreetDrop/Domain/UseCase/FetchingMyDropList/FetchingMyDropListUseCase.swift rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingMyInfo}/DefaultFetchingMyInfoUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingMyInfo}/FetchingMyInfoUseCase.swift (100%) create mode 100644 StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLevel/DefaultFetchingMyLevelUseCase.swift create mode 100644 StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLevel/FetchingMyLevelUseCase.swift create mode 100644 StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLikeList/DefaultFetchingMyLikeListUseCase.swift create mode 100644 StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLikeList/FetchingMyLikeListUseCase.swift rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingNotice}/NoticeUseCase.swift (87%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingPOI}/DefaultFetchingPOIUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingPOI}/FetchingPOIUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingPopUpInfomation}/DefaultFetchingPopUpInfomationUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingPopUpInfomation}/FetchingPopUpInfomationUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingSingleMusic}/DefaultFetchingSingleMusicUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingSingleMusic}/FetchingSingleMusicUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingUserCircleRadius}/DefaultFetchingUserCircleRadiusUsecase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => FetchingUserCircleRadius}/FetchingUserCircleRadiusUsecase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => Liking}/DefaultLikingUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => Liking}/LikingUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => MyInfo}/DefaultMyInfoUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => MyInfo}/MyInfoUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => PostingPopUpUserReading}/DefaultPostingPopUpUserReadingUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => PostingPopUpUserReading}/PostingPopUpUserReadingUseCase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => SearchingMusic}/SearchMusicUsecase.swift (100%) rename StreetDrop/StreetDrop/Domain/UseCase/{ => Settings}/SettingsUseCase.swift (100%) diff --git a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj index bc9090e5..04c492ee 100644 --- a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj +++ b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj @@ -23,8 +23,8 @@ 049F50222A122C8A001528CB /* DropMusicRequestDTO+Mapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049F50212A122C8A001528CB /* DropMusicRequestDTO+Mapping.swift */; }; 04FB1F262A0215BC0064B3C8 /* MainViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FB1F252A0215BC0064B3C8 /* MainViewModel.swift */; }; 04FB1F322A021C330064B3C8 /* TestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FB1F312A021C330064B3C8 /* TestError.swift */; }; - 082F17062AB6DFEC00174D98 /* MusicDropUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082F17052AB6DFEC00174D98 /* MusicDropUseCase.swift */; }; - 082F17092AB6E41100174D98 /* DefaultMusicDropUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082F17082AB6E41100174D98 /* DefaultMusicDropUseCase.swift */; }; + 082F17062AB6DFEC00174D98 /* DropMusicUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082F17052AB6DFEC00174D98 /* DropMusicUseCase.swift */; }; + 082F17092AB6E41100174D98 /* DefaultDropMusicUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082F17082AB6E41100174D98 /* DefaultDropMusicUseCase.swift */; }; 082F171A2AB7454200174D98 /* EditCommentUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082F17192AB7454200174D98 /* EditCommentUseCase.swift */; }; 082F171C2AB7455400174D98 /* DefaultEditCommentUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082F171B2AB7455400174D98 /* DefaultEditCommentUseCase.swift */; }; 082F17242ADD60BB00174D98 /* UINavigation+Gesture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082F17232ADD60BB00174D98 /* UINavigation+Gesture.swift */; }; @@ -45,6 +45,12 @@ 08810C322BD3FC57004FC6C1 /* LevelPolicySubView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08810C312BD3FC57004FC6C1 /* LevelPolicySubView.swift */; }; 08B97EA52B44303C00084F66 /* UniviersialLinkKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08B97EA42B44303C00084F66 /* UniviersialLinkKey.swift */; }; 08BE57162BD4C887007EA949 /* UILabel+applyGradient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08BE57152BD4C887007EA949 /* UILabel+applyGradient.swift */; }; + 08F574512C4696AC00635B54 /* FetchingMyDropListUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F574502C4696AC00635B54 /* FetchingMyDropListUseCase.swift */; }; + 08F574532C4696C600635B54 /* DefaultFetchingMyDropListUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F574522C4696C600635B54 /* DefaultFetchingMyDropListUseCase.swift */; }; + 08F574562C4697E100635B54 /* FetchingMyLikeListUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F574552C4697E100635B54 /* FetchingMyLikeListUseCase.swift */; }; + 08F574582C46985300635B54 /* DefaultFetchingMyLikeListUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F574572C46985300635B54 /* DefaultFetchingMyLikeListUseCase.swift */; }; + 08F5745B2C4698B300635B54 /* FetchingMyLevelUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F5745A2C4698B300635B54 /* FetchingMyLevelUseCase.swift */; }; + 08F5745D2C46992500635B54 /* DefaultFetchingMyLevelUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08F5745C2C46992500635B54 /* DefaultFetchingMyLevelUseCase.swift */; }; 1816ED3C2A680608005009FC /* MusicListSectionHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1816ED3B2A680608005009FC /* MusicListSectionHeaderView.swift */; }; 1816ED3F2A68064E005009FC /* MyPageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1816ED3E2A68064E005009FC /* MyPageViewModel.swift */; }; 1816ED412A685704005009FC /* NicknameEditViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1816ED402A685704005009FC /* NicknameEditViewModel.swift */; }; @@ -165,8 +171,8 @@ C41972362ABDB3C000211222 /* DefaultFetchingPOIUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41972352ABDB3C000211222 /* DefaultFetchingPOIUseCase.swift */; }; C41972382ABDB49400211222 /* FetchingMusicCountUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41972372ABDB49400211222 /* FetchingMusicCountUseCase.swift */; }; C419723A2ABDB50B00211222 /* DefaultFetchingMusicCountUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41972392ABDB50B00211222 /* DefaultFetchingMusicCountUseCase.swift */; }; - C419723C2ABDB5AF00211222 /* FetchingMusicWithinArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = C419723B2ABDB5AF00211222 /* FetchingMusicWithinArea.swift */; }; - C419723E2ABDB5D600211222 /* DefaultFetchingMusicWithinArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = C419723D2ABDB5D600211222 /* DefaultFetchingMusicWithinArea.swift */; }; + C419723C2ABDB5AF00211222 /* FetchingMusicWithinAreaUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C419723B2ABDB5AF00211222 /* FetchingMusicWithinAreaUseCase.swift */; }; + C419723E2ABDB5D600211222 /* DefaultFetchingMusicWithinAreaUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C419723D2ABDB5D600211222 /* DefaultFetchingMusicWithinAreaUseCase.swift */; }; C41972402ABDC3B000211222 /* LikingUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C419723F2ABDC3B000211222 /* LikingUseCase.swift */; }; C41972422ABDC3D600211222 /* DefaultLikingUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41972412ABDC3D600211222 /* DefaultLikingUseCase.swift */; }; C41972442ABDC43C00211222 /* ClaimingCommentUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C41972432ABDC43C00211222 /* ClaimingCommentUseCase.swift */; }; @@ -314,8 +320,8 @@ 049F50212A122C8A001528CB /* DropMusicRequestDTO+Mapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DropMusicRequestDTO+Mapping.swift"; sourceTree = ""; }; 04FB1F252A0215BC0064B3C8 /* MainViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewModel.swift; sourceTree = ""; }; 04FB1F312A021C330064B3C8 /* TestError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestError.swift; sourceTree = ""; }; - 082F17052AB6DFEC00174D98 /* MusicDropUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicDropUseCase.swift; sourceTree = ""; }; - 082F17082AB6E41100174D98 /* DefaultMusicDropUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultMusicDropUseCase.swift; sourceTree = ""; }; + 082F17052AB6DFEC00174D98 /* DropMusicUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropMusicUseCase.swift; sourceTree = ""; }; + 082F17082AB6E41100174D98 /* DefaultDropMusicUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultDropMusicUseCase.swift; sourceTree = ""; }; 082F17192AB7454200174D98 /* EditCommentUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditCommentUseCase.swift; sourceTree = ""; }; 082F171B2AB7455400174D98 /* DefaultEditCommentUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultEditCommentUseCase.swift; sourceTree = ""; }; 082F17232ADD60BB00174D98 /* UINavigation+Gesture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigation+Gesture.swift"; sourceTree = ""; }; @@ -327,6 +333,12 @@ 08810C312BD3FC57004FC6C1 /* LevelPolicySubView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LevelPolicySubView.swift; sourceTree = ""; }; 08B97EA42B44303C00084F66 /* UniviersialLinkKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UniviersialLinkKey.swift; sourceTree = ""; }; 08BE57152BD4C887007EA949 /* UILabel+applyGradient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UILabel+applyGradient.swift"; sourceTree = ""; }; + 08F574502C4696AC00635B54 /* FetchingMyDropListUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchingMyDropListUseCase.swift; sourceTree = ""; }; + 08F574522C4696C600635B54 /* DefaultFetchingMyDropListUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingMyDropListUseCase.swift; sourceTree = ""; }; + 08F574552C4697E100635B54 /* FetchingMyLikeListUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchingMyLikeListUseCase.swift; sourceTree = ""; }; + 08F574572C46985300635B54 /* DefaultFetchingMyLikeListUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingMyLikeListUseCase.swift; sourceTree = ""; }; + 08F5745A2C4698B300635B54 /* FetchingMyLevelUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchingMyLevelUseCase.swift; sourceTree = ""; }; + 08F5745C2C46992500635B54 /* DefaultFetchingMyLevelUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingMyLevelUseCase.swift; sourceTree = ""; }; 1816ED3B2A680608005009FC /* MusicListSectionHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicListSectionHeaderView.swift; sourceTree = ""; }; 1816ED3E2A68064E005009FC /* MyPageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewModel.swift; sourceTree = ""; }; 1816ED402A685704005009FC /* NicknameEditViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NicknameEditViewModel.swift; sourceTree = ""; }; @@ -438,8 +450,8 @@ C41972352ABDB3C000211222 /* DefaultFetchingPOIUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingPOIUseCase.swift; sourceTree = ""; }; C41972372ABDB49400211222 /* FetchingMusicCountUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchingMusicCountUseCase.swift; sourceTree = ""; }; C41972392ABDB50B00211222 /* DefaultFetchingMusicCountUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingMusicCountUseCase.swift; sourceTree = ""; }; - C419723B2ABDB5AF00211222 /* FetchingMusicWithinArea.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchingMusicWithinArea.swift; sourceTree = ""; }; - C419723D2ABDB5D600211222 /* DefaultFetchingMusicWithinArea.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingMusicWithinArea.swift; sourceTree = ""; }; + C419723B2ABDB5AF00211222 /* FetchingMusicWithinAreaUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchingMusicWithinAreaUseCase.swift; sourceTree = ""; }; + C419723D2ABDB5D600211222 /* DefaultFetchingMusicWithinAreaUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingMusicWithinAreaUseCase.swift; sourceTree = ""; }; C419723F2ABDC3B000211222 /* LikingUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LikingUseCase.swift; sourceTree = ""; }; C41972412ABDC3D600211222 /* DefaultLikingUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultLikingUseCase.swift; sourceTree = ""; }; C41972432ABDC43C00211222 /* ClaimingCommentUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClaimingCommentUseCase.swift; sourceTree = ""; }; @@ -789,13 +801,13 @@ path = Error; sourceTree = ""; }; - 082F170A2AB6E42800174D98 /* MusicDrop */ = { + 082F170A2AB6E42800174D98 /* DropMusic */ = { isa = PBXGroup; children = ( - 082F17052AB6DFEC00174D98 /* MusicDropUseCase.swift */, - 082F17082AB6E41100174D98 /* DefaultMusicDropUseCase.swift */, + 082F17052AB6DFEC00174D98 /* DropMusicUseCase.swift */, + 082F17082AB6E41100174D98 /* DefaultDropMusicUseCase.swift */, ); - path = MusicDrop; + path = DropMusic; sourceTree = ""; }; 082F17182AB7451A00174D98 /* Domain */ = { @@ -810,50 +822,224 @@ 082F171D2AB7465A00174D98 /* UseCase */ = { isa = PBXGroup; children = ( - 082F17192AB7454200174D98 /* EditCommentUseCase.swift */, - 082F171B2AB7455400174D98 /* DefaultEditCommentUseCase.swift */, - C419722D2ABD9D6F00211222 /* MyInfoUseCase.swift */, - C419722F2ABDAB0200211222 /* DefaultMyInfoUseCase.swift */, - C4685B372B72605500F514C7 /* FetchingUserCircleRadiusUsecase.swift */, - C4685B392B72610600F514C7 /* DefaultFetchingUserCircleRadiusUsecase.swift */, - C41972332ABDB36600211222 /* FetchingPOIUseCase.swift */, - C41972352ABDB3C000211222 /* DefaultFetchingPOIUseCase.swift */, - C41972372ABDB49400211222 /* FetchingMusicCountUseCase.swift */, - C41972392ABDB50B00211222 /* DefaultFetchingMusicCountUseCase.swift */, - C419723B2ABDB5AF00211222 /* FetchingMusicWithinArea.swift */, - C419723D2ABDB5D600211222 /* DefaultFetchingMusicWithinArea.swift */, - C419723F2ABDC3B000211222 /* LikingUseCase.swift */, - C41972412ABDC3D600211222 /* DefaultLikingUseCase.swift */, - C41972432ABDC43C00211222 /* ClaimingCommentUseCase.swift */, - C41972452ABDC45000211222 /* DefaultClaimingCommentUseCase.swift */, - C41972472ABDC4C700211222 /* DeletingMusicUseCase.swift */, - C41972492ABDC94A00211222 /* DefaultDeletingMusicUseCase.swift */, - C419724B2ABDCA6100211222 /* BlockUserUseCase.swift */, - C419724D2ABDCABD00211222 /* DefaultBlockUserUseCase.swift */, - C41972542ABED3EC00211222 /* FetchingMyInfoUseCase.swift */, - C41972562ABED40100211222 /* DefaultFetchingMyInfoUseCase.swift */, - C434A4CD2A17970A00C63526 /* SearchMusicUsecase.swift */, - C4E4C6B72A5ADFDB00B1C84A /* SettingsUseCase.swift */, + 08F5746F2C469E7B00635B54 /* EditComment */, + 08F5746E2C469E7400635B54 /* MyInfo */, + 08F5746D2C469E5C00635B54 /* FetchingUserCircleRadius */, + 08F5746C2C469E5200635B54 /* FetchingPOI */, + 08F5746B2C469E4000635B54 /* FetchingMusicCount */, + 08F5746A2C469D9E00635B54 /* FetchingMusicWithinArea */, + 08F574692C469D9500635B54 /* Liking */, + 08F574682C469D8300635B54 /* ClaimingComment */, + 08F574672C469D7B00635B54 /* DeletingMusic */, + 08F574662C469D6F00635B54 /* BlockUser */, + 08F574652C469D6500635B54 /* FetchingMyInfo */, + 08F574712C469F2100635B54 /* SearchingMusic */, + 08F574722C469F2800635B54 /* Settings */, + 08F574642C469D4A00635B54 /* FetchingPopUpInfomation */, + 08F574632C469D2800635B54 /* PostingPopUpUserReading */, + 08F574622C469CFF00635B54 /* FetchingSingleMusic */, + 082F170A2AB6E42800174D98 /* DropMusic */, + 08F574702C469F1900635B54 /* FetchingNotice */, + 08F5745F2C46999800635B54 /* FetchingLevelPolicy */, + 08F5745E2C46993800635B54 /* FetchingMyLevel */, + 08F574592C46987B00635B54 /* FetchingMyLikeList */, + 08F574542C46979700635B54 /* FetchingMyDropList */, + ); + path = UseCase; + sourceTree = ""; + }; + 0856524E2AFA781E00FD9BCB /* SingleMusic */ = { + isa = PBXGroup; + children = ( + 0856524C2AFA77FD00FD9BCB /* SingleMusicResponseDTO.swift */, + ); + path = SingleMusic; + sourceTree = ""; + }; + 08F574542C46979700635B54 /* FetchingMyDropList */ = { + isa = PBXGroup; + children = ( + 08F574502C4696AC00635B54 /* FetchingMyDropListUseCase.swift */, + 08F574522C4696C600635B54 /* DefaultFetchingMyDropListUseCase.swift */, + ); + path = FetchingMyDropList; + sourceTree = ""; + }; + 08F574592C46987B00635B54 /* FetchingMyLikeList */ = { + isa = PBXGroup; + children = ( + 08F574552C4697E100635B54 /* FetchingMyLikeListUseCase.swift */, + 08F574572C46985300635B54 /* DefaultFetchingMyLikeListUseCase.swift */, + ); + path = FetchingMyLikeList; + sourceTree = ""; + }; + 08F5745E2C46993800635B54 /* FetchingMyLevel */ = { + isa = PBXGroup; + children = ( + 08F5745A2C4698B300635B54 /* FetchingMyLevelUseCase.swift */, + 08F5745C2C46992500635B54 /* DefaultFetchingMyLevelUseCase.swift */, + ); + path = FetchingMyLevel; + sourceTree = ""; + }; + 08F5745F2C46999800635B54 /* FetchingLevelPolicy */ = { + isa = PBXGroup; + children = ( + 6AAFD9AE2BCE567A001A6772 /* FetchingLevelPolicyUseCase.swift */, + 6AAFD9B02BCE56A6001A6772 /* DefaultFetchingLevelPolicyUseCase.swift */, + ); + path = FetchingLevelPolicy; + sourceTree = ""; + }; + 08F574622C469CFF00635B54 /* FetchingSingleMusic */ = { + isa = PBXGroup; + children = ( 6A26BF312B33D1E40007B6B7 /* FetchingSingleMusicUseCase.swift */, 6A26BF332B33D2210007B6B7 /* DefaultFetchingSingleMusicUseCase.swift */, - C44A54992BBC097E00354F8F /* FetchingPopUpInfomationUseCase.swift */, - C44A549B2BBC099E00354F8F /* DefaultFetchingPopUpInfomationUseCase.swift */, + ); + path = FetchingSingleMusic; + sourceTree = ""; + }; + 08F574632C469D2800635B54 /* PostingPopUpUserReading */ = { + isa = PBXGroup; + children = ( C449807B2BC3B07E0001E6C3 /* PostingPopUpUserReadingUseCase.swift */, C449807D2BC3B09F0001E6C3 /* DefaultPostingPopUpUserReadingUseCase.swift */, - 082F170A2AB6E42800174D98 /* MusicDrop */, - 6AAFD9AE2BCE567A001A6772 /* FetchingLevelPolicyUseCase.swift */, - 6AAFD9B02BCE56A6001A6772 /* DefaultFetchingLevelPolicyUseCase.swift */, + ); + path = PostingPopUpUserReading; + sourceTree = ""; + }; + 08F574642C469D4A00635B54 /* FetchingPopUpInfomation */ = { + isa = PBXGroup; + children = ( + C44A54992BBC097E00354F8F /* FetchingPopUpInfomationUseCase.swift */, + C44A549B2BBC099E00354F8F /* DefaultFetchingPopUpInfomationUseCase.swift */, + ); + path = FetchingPopUpInfomation; + sourceTree = ""; + }; + 08F574652C469D6500635B54 /* FetchingMyInfo */ = { + isa = PBXGroup; + children = ( + C41972542ABED3EC00211222 /* FetchingMyInfoUseCase.swift */, + C41972562ABED40100211222 /* DefaultFetchingMyInfoUseCase.swift */, + ); + path = FetchingMyInfo; + sourceTree = ""; + }; + 08F574662C469D6F00635B54 /* BlockUser */ = { + isa = PBXGroup; + children = ( + C419724B2ABDCA6100211222 /* BlockUserUseCase.swift */, + C419724D2ABDCABD00211222 /* DefaultBlockUserUseCase.swift */, + ); + path = BlockUser; + sourceTree = ""; + }; + 08F574672C469D7B00635B54 /* DeletingMusic */ = { + isa = PBXGroup; + children = ( + C41972472ABDC4C700211222 /* DeletingMusicUseCase.swift */, + C41972492ABDC94A00211222 /* DefaultDeletingMusicUseCase.swift */, + ); + path = DeletingMusic; + sourceTree = ""; + }; + 08F574682C469D8300635B54 /* ClaimingComment */ = { + isa = PBXGroup; + children = ( + C41972432ABDC43C00211222 /* ClaimingCommentUseCase.swift */, + C41972452ABDC45000211222 /* DefaultClaimingCommentUseCase.swift */, + ); + path = ClaimingComment; + sourceTree = ""; + }; + 08F574692C469D9500635B54 /* Liking */ = { + isa = PBXGroup; + children = ( + C419723F2ABDC3B000211222 /* LikingUseCase.swift */, + C41972412ABDC3D600211222 /* DefaultLikingUseCase.swift */, + ); + path = Liking; + sourceTree = ""; + }; + 08F5746A2C469D9E00635B54 /* FetchingMusicWithinArea */ = { + isa = PBXGroup; + children = ( + C419723B2ABDB5AF00211222 /* FetchingMusicWithinAreaUseCase.swift */, + C419723D2ABDB5D600211222 /* DefaultFetchingMusicWithinAreaUseCase.swift */, + ); + path = FetchingMusicWithinArea; + sourceTree = ""; + }; + 08F5746B2C469E4000635B54 /* FetchingMusicCount */ = { + isa = PBXGroup; + children = ( + C41972372ABDB49400211222 /* FetchingMusicCountUseCase.swift */, + C41972392ABDB50B00211222 /* DefaultFetchingMusicCountUseCase.swift */, + ); + path = FetchingMusicCount; + sourceTree = ""; + }; + 08F5746C2C469E5200635B54 /* FetchingPOI */ = { + isa = PBXGroup; + children = ( + C41972332ABDB36600211222 /* FetchingPOIUseCase.swift */, + C41972352ABDB3C000211222 /* DefaultFetchingPOIUseCase.swift */, + ); + path = FetchingPOI; + sourceTree = ""; + }; + 08F5746D2C469E5C00635B54 /* FetchingUserCircleRadius */ = { + isa = PBXGroup; + children = ( + C4685B372B72605500F514C7 /* FetchingUserCircleRadiusUsecase.swift */, + C4685B392B72610600F514C7 /* DefaultFetchingUserCircleRadiusUsecase.swift */, + ); + path = FetchingUserCircleRadius; + sourceTree = ""; + }; + 08F5746E2C469E7400635B54 /* MyInfo */ = { + isa = PBXGroup; + children = ( + C419722D2ABD9D6F00211222 /* MyInfoUseCase.swift */, + C419722F2ABDAB0200211222 /* DefaultMyInfoUseCase.swift */, + ); + path = MyInfo; + sourceTree = ""; + }; + 08F5746F2C469E7B00635B54 /* EditComment */ = { + isa = PBXGroup; + children = ( + 082F17192AB7454200174D98 /* EditCommentUseCase.swift */, + 082F171B2AB7455400174D98 /* DefaultEditCommentUseCase.swift */, + ); + path = EditComment; + sourceTree = ""; + }; + 08F574702C469F1900635B54 /* FetchingNotice */ = { + isa = PBXGroup; + children = ( F4C996A62C1EEC8600FF7B9A /* NoticeUseCase.swift */, ); - path = UseCase; + path = FetchingNotice; sourceTree = ""; }; - 0856524E2AFA781E00FD9BCB /* SingleMusic */ = { + 08F574712C469F2100635B54 /* SearchingMusic */ = { isa = PBXGroup; children = ( - 0856524C2AFA77FD00FD9BCB /* SingleMusicResponseDTO.swift */, + C434A4CD2A17970A00C63526 /* SearchMusicUsecase.swift */, ); - path = SingleMusic; + path = SearchingMusic; + sourceTree = ""; + }; + 08F574722C469F2800635B54 /* Settings */ = { + isa = PBXGroup; + children = ( + C4E4C6B72A5ADFDB00B1C84A /* SettingsUseCase.swift */, + ); + path = Settings; sourceTree = ""; }; 1816ED3D2A680640005009FC /* ViewModel */ = { @@ -1825,6 +2011,7 @@ F48DF73A2C1DD8F500F6DEA1 /* SettingPushNotificationCell.swift in Sources */, C4A445902A5EF225008279C1 /* FCMTokenRequestDTO.swift in Sources */, C46410F42A629820009DD88F /* MusicAppButton.swift in Sources */, + 08F574532C4696C600635B54 /* DefaultFetchingMyDropListUseCase.swift in Sources */, C41972512ABED0FE00211222 /* MyInfoRepository.swift in Sources */, C41972382ABDB49400211222 /* FetchingMusicCountUseCase.swift in Sources */, 41396D872A4EFA2900B69341 /* MyInfoResponseDTO.swift in Sources */, @@ -1839,10 +2026,12 @@ C419724A2ABDC94A00211222 /* DefaultDeletingMusicUseCase.swift in Sources */, C41972462ABDC45000211222 /* DefaultClaimingCommentUseCase.swift in Sources */, C45A4CB02A3710AC00EE9C36 /* ImageCacheError.swift in Sources */, + 08F5745D2C46992500635B54 /* DefaultFetchingMyLevelUseCase.swift in Sources */, C41972532ABED14200211222 /* DefaultMyInfoRepository.swift in Sources */, 6A7D73D92BB11A0E009340E3 /* LevelUpGuideView.swift in Sources */, 41396DA12A51B0DF00B69341 /* EditCommentViewController.swift in Sources */, C44A549A2BBC097E00354F8F /* FetchingPopUpInfomationUseCase.swift in Sources */, + 08F574562C4697E100635B54 /* FetchingMyLikeListUseCase.swift in Sources */, 41008EBA2A49B56F00FD4ABE /* ClaimModalViewController.swift in Sources */, C45BF3AC2A1EF64300CEDE74 /* RecentQueryButton.swift in Sources */, B4B9EE842ADBDFFB000A6507 /* RecommendMusicSearchCollectionView.swift in Sources */, @@ -1863,6 +2052,7 @@ 414345232A35B9A3003FEE2A /* LikeMusicRepository.swift in Sources */, 040685042A01539800377094 /* MainViewController.swift in Sources */, C4685B362B725FF500F514C7 /* UserCircleRadiusResponseDTO.swift in Sources */, + 08F574582C46985300635B54 /* DefaultFetchingMyLikeListUseCase.swift in Sources */, 040685002A01539800377094 /* AppDelegate.swift in Sources */, C47583A12A5F11BD00CA7335 /* Bundle+APIKeys.swift in Sources */, C472B1882AC5523300482B2D /* DroppingInfo.swift in Sources */, @@ -1895,6 +2085,7 @@ 040685002A01539800377094 /* AppDelegate.swift in Sources */, 18CB7BED2A359F53002B31FB /* MusicWithinAreaEntity.swift in Sources */, C41972482ABDC4C700211222 /* DeletingMusicUseCase.swift in Sources */, + 08F5745B2C4698B300635B54 /* FetchingMyLevelUseCase.swift in Sources */, C4E4C6B82A5ADFDB00B1C84A /* SettingsUseCase.swift in Sources */, 41396D912A4EFBF700B69341 /* DefaultEditCommentRepository.swift in Sources */, C419722E2ABD9D6F00211222 /* MyInfoUseCase.swift in Sources */, @@ -1936,7 +2127,7 @@ 085652522B00B68100FD9BCB /* BubbleCommentView.swift in Sources */, 41A3DDF62A5AD1C7004CFA2F /* BlockUserRepository.swift in Sources */, 085652502AFBB73100FD9BCB /* MyPageType.swift in Sources */, - C419723C2ABDB5AF00211222 /* FetchingMusicWithinArea.swift in Sources */, + C419723C2ABDB5AF00211222 /* FetchingMusicWithinAreaUseCase.swift in Sources */, C434A4CE2A17970A00C63526 /* SearchMusicUsecase.swift in Sources */, 414345252A35B9C3003FEE2A /* DefaultLikeMusicRepository.swift in Sources */, 1816ED412A685704005009FC /* NicknameEditViewModel.swift in Sources */, @@ -1970,7 +2161,7 @@ C45BF3A32A1D179C00CEDE74 /* RecentMusicQueriesStorage.swift in Sources */, 041038972A126E7B00BC5532 /* MusicCountByDongResponseDTO+Mapping.swift in Sources */, 41396D992A4F04D800B69341 /* UserDefaultsMyInfoStorage.swift in Sources */, - C419723E2ABDB5D600211222 /* DefaultFetchingMusicWithinArea.swift in Sources */, + C419723E2ABDB5D600211222 /* DefaultFetchingMusicWithinAreaUseCase.swift in Sources */, F4C996AA2C1EEF0B00FF7B9A /* DefaultNoticeRepository.swift in Sources */, 41396D972A4F04CB00B69341 /* MyInfoStorage.swift in Sources */, 1824F1372A349F3700A10320 /* MusicCountEntity.swift in Sources */, @@ -1982,10 +2173,10 @@ 1876F0412A66E5440064B887 /* MyLevelResponseDTO+Mapping.swift in Sources */, C4685B3D2B7261A000F514C7 /* SplashViewModel.swift in Sources */, F4AA84DF2C1F3B0200CADB1A /* Array+Extension.swift in Sources */, - 082F17062AB6DFEC00174D98 /* MusicDropUseCase.swift in Sources */, + 082F17062AB6DFEC00174D98 /* DropMusicUseCase.swift in Sources */, 18683FD92A2A251E005A94AC /* ViewModel.swift in Sources */, C41972442ABDC43C00211222 /* ClaimingCommentUseCase.swift in Sources */, - 082F17092AB6E41100174D98 /* DefaultMusicDropUseCase.swift in Sources */, + 082F17092AB6E41100174D98 /* DefaultDropMusicUseCase.swift in Sources */, 08810C2E2BD3FB00004FC6C1 /* LevelPolicyPopUpViewController.swift in Sources */, C449807A2BC3AF9F0001E6C3 /* PopUpUserReadingRequestDTO.swift in Sources */, 412D668A2A1E14B600BA4A1B /* CommunityViewController.swift in Sources */, @@ -1996,6 +2187,7 @@ 41E008CE2A1442A000F5D99C /* PoiResponseDTO+Mapping.swift in Sources */, 41008EB82A48891000FD4ABE /* UITextView+setLineSpacing.swift in Sources */, C434A4CC2A1796F300C63526 /* SearchingMusicViewModel.swift in Sources */, + 08F574512C4696AC00635B54 /* FetchingMyDropListUseCase.swift in Sources */, 0856525D2B1F29FD00FD9BCB /* ModalOption.swift in Sources */, C4E4C6B22A5ADC2C00B1C84A /* SettingsRepository.swift in Sources */, C4E0943B2A4DF002000B4513 /* VillageNameResponseDTO.swift in Sources */, diff --git a/StreetDrop/StreetDrop/Domain/UseCase/BlockUserUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/BlockUser/BlockUserUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/BlockUserUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/BlockUser/BlockUserUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultBlockUserUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/BlockUser/DefaultBlockUserUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultBlockUserUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/BlockUser/DefaultBlockUserUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/ClaimingCommentUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/ClaimingComment/ClaimingCommentUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/ClaimingCommentUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/ClaimingComment/ClaimingCommentUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultClaimingCommentUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/ClaimingComment/DefaultClaimingCommentUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultClaimingCommentUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/ClaimingComment/DefaultClaimingCommentUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultDeletingMusicUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/DeletingMusic/DefaultDeletingMusicUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultDeletingMusicUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/DeletingMusic/DefaultDeletingMusicUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DeletingMusicUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/DeletingMusic/DeletingMusicUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DeletingMusicUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/DeletingMusic/DeletingMusicUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/MusicDrop/DefaultMusicDropUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/DropMusic/DefaultDropMusicUseCase.swift similarity index 84% rename from StreetDrop/StreetDrop/Domain/UseCase/MusicDrop/DefaultMusicDropUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/DropMusic/DefaultDropMusicUseCase.swift index 131e2fd2..e00355f2 100644 --- a/StreetDrop/StreetDrop/Domain/UseCase/MusicDrop/DefaultMusicDropUseCase.swift +++ b/StreetDrop/StreetDrop/Domain/UseCase/DropMusic/DefaultDropMusicUseCase.swift @@ -1,5 +1,5 @@ // -// DefaultMusicDropUseCase.swift +// DefaultDropMusicUseCase.swift // StreetDrop // // Created by thoonk on 2023/09/17. @@ -9,7 +9,7 @@ import Foundation import RxSwift -final class DefaultMusicDropUseCase: MusicDropUseCase { +final class DefaultDropMusicUseCase: DropMusicUseCase { private let dropMusicRepository: DropMusicRepository init(dropMusicRepository: DropMusicRepository = DefaultDropMusicRepository()) { diff --git a/StreetDrop/StreetDrop/Domain/UseCase/MusicDrop/MusicDropUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/DropMusic/DropMusicUseCase.swift similarity index 75% rename from StreetDrop/StreetDrop/Domain/UseCase/MusicDrop/MusicDropUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/DropMusic/DropMusicUseCase.swift index 49e4f11c..bbcfea53 100644 --- a/StreetDrop/StreetDrop/Domain/UseCase/MusicDrop/MusicDropUseCase.swift +++ b/StreetDrop/StreetDrop/Domain/UseCase/DropMusic/DropMusicUseCase.swift @@ -1,5 +1,5 @@ // -// MusicDropUseCase.swift +// DropMusicUseCase.swift // StreetDrop // // Created by thoonk on 2023/09/17. @@ -9,6 +9,6 @@ import Foundation import RxSwift -protocol MusicDropUseCase { +protocol DropMusicUseCase { func drop(droppingInfo: DroppingInfo, content: String) -> Single } diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultEditCommentUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/EditComment/DefaultEditCommentUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultEditCommentUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/EditComment/DefaultEditCommentUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/EditCommentUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/EditComment/EditCommentUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/EditCommentUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/EditComment/EditCommentUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingLevelPolicyUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingLevelPolicy/DefaultFetchingLevelPolicyUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingLevelPolicyUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingLevelPolicy/DefaultFetchingLevelPolicyUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingLevelPolicyUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingLevelPolicy/FetchingLevelPolicyUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/FetchingLevelPolicyUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingLevelPolicy/FetchingLevelPolicyUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingMusicCountUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicCount/DefaultFetchingMusicCountUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingMusicCountUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicCount/DefaultFetchingMusicCountUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicCountUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicCount/FetchingMusicCountUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicCountUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicCount/FetchingMusicCountUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingMusicWithinArea.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicWithinArea/DefaultFetchingMusicWithinAreaUseCase.swift similarity index 80% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingMusicWithinArea.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicWithinArea/DefaultFetchingMusicWithinAreaUseCase.swift index a7497d94..a1597650 100644 --- a/StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingMusicWithinArea.swift +++ b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicWithinArea/DefaultFetchingMusicWithinAreaUseCase.swift @@ -1,5 +1,5 @@ // -// DefaultFetchingMusicWithinArea.swift +// DefaultFetchingMusicWithinAreaUseCase.swift // StreetDrop // // Created by 차요셉 on 2023/09/22. @@ -9,7 +9,7 @@ import Foundation import RxSwift -final class DefaultFetchingMusicWithinArea: FetchingMusicWithinArea { +final class DefaultFetchingMusicWithinAreaUseCase: FetchingMusicWithinAreaUseCase { private let mainRepository: MainRepository init(mainRepository: MainRepository = DefaultMainRepository( diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicWithinArea.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicWithinArea/FetchingMusicWithinAreaUseCase.swift similarity index 83% rename from StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicWithinArea.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicWithinArea/FetchingMusicWithinAreaUseCase.swift index fd5086a3..a9eb59ee 100644 --- a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicWithinArea.swift +++ b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMusicWithinArea/FetchingMusicWithinAreaUseCase.swift @@ -9,6 +9,6 @@ import Foundation import RxSwift -protocol FetchingMusicWithinArea { +protocol FetchingMusicWithinAreaUseCase { func execute(lat: Double, lon: Double, distance: Double) -> Single } diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyDropList/DefaultFetchingMyDropListUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyDropList/DefaultFetchingMyDropListUseCase.swift new file mode 100644 index 00000000..c943e88f --- /dev/null +++ b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyDropList/DefaultFetchingMyDropListUseCase.swift @@ -0,0 +1,24 @@ +// +// DefaultFetchingMyDropListUseCase.swift +// StreetDrop +// +// Created by thoonk on 7/16/24. +// + +import Foundation + +import RxSwift + +final class DefaultFetchingMyDropListUseCase { + private let repository: MyPageRepository + + init(repository: MyPageRepository = DefaultMyPageRepository()) { + self.repository = repository + } +} + +extension DefaultFetchingMyDropListUseCase: FetchingMyDropListUseCase { + func fetchMyDropList() -> Single { + return repository.fetchMyDropList() + } +} diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyDropList/FetchingMyDropListUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyDropList/FetchingMyDropListUseCase.swift new file mode 100644 index 00000000..3a190a1c --- /dev/null +++ b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyDropList/FetchingMyDropListUseCase.swift @@ -0,0 +1,14 @@ +// +// FetchingMyDropListUseCase.swift +// StreetDrop +// +// Created by thoonk on 7/16/24. +// + +import Foundation + +import RxSwift + +protocol FetchingMyDropListUseCase { + func fetchMyDropList() -> Single +} diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingMyInfoUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyInfo/DefaultFetchingMyInfoUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingMyInfoUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingMyInfo/DefaultFetchingMyInfoUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyInfoUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyInfo/FetchingMyInfoUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/FetchingMyInfoUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingMyInfo/FetchingMyInfoUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLevel/DefaultFetchingMyLevelUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLevel/DefaultFetchingMyLevelUseCase.swift new file mode 100644 index 00000000..fd466d07 --- /dev/null +++ b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLevel/DefaultFetchingMyLevelUseCase.swift @@ -0,0 +1,28 @@ +// +// DefaultFetchingMyLevelUseCase.swift +// StreetDrop +// +// Created by thoonk on 7/16/24. +// + +import Foundation + +import RxSwift + +final class DefaultFetchingMyLevelUseCase { + private let repository: MyPageRepository + + init(repository: MyPageRepository = DefaultMyPageRepository()) { + self.repository = repository + } +} + +extension DefaultFetchingMyLevelUseCase: FetchingMyLevelUseCase { + func fetchMyLevel() -> Single { + return repository.fetchMyLevel() + } + + func fetchMyLevelProgress() -> Single { + return repository.fetchMyLevelProgress() + } +} diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLevel/FetchingMyLevelUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLevel/FetchingMyLevelUseCase.swift new file mode 100644 index 00000000..1fe44ff5 --- /dev/null +++ b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLevel/FetchingMyLevelUseCase.swift @@ -0,0 +1,15 @@ +// +// FetchingMyLevelUseCase.swift +// StreetDrop +// +// Created by thoonk on 7/16/24. +// + +import Foundation + +import RxSwift + +protocol FetchingMyLevelUseCase { + func fetchMyLevel() -> Single + func fetchMyLevelProgress() -> Single +} diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLikeList/DefaultFetchingMyLikeListUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLikeList/DefaultFetchingMyLikeListUseCase.swift new file mode 100644 index 00000000..b311a3dd --- /dev/null +++ b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLikeList/DefaultFetchingMyLikeListUseCase.swift @@ -0,0 +1,24 @@ +// +// DefaultFetchingMyLikeListUseCase.swift +// StreetDrop +// +// Created by thoonk on 7/16/24. +// + +import Foundation + +import RxSwift + +final class DefaultFetchingMyLikeListUseCase { + private let repository: MyPageRepository + + init(repository: MyPageRepository = DefaultMyPageRepository()) { + self.repository = repository + } +} + +extension DefaultFetchingMyLikeListUseCase: FetchingMyLikeListUseCase { + func fetchMyLikeList() -> Single { + return repository.fetchMyLikeList() + } +} diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLikeList/FetchingMyLikeListUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLikeList/FetchingMyLikeListUseCase.swift new file mode 100644 index 00000000..cad675af --- /dev/null +++ b/StreetDrop/StreetDrop/Domain/UseCase/FetchingMyLikeList/FetchingMyLikeListUseCase.swift @@ -0,0 +1,14 @@ +// +// FetchingMyLikeListUseCase.swift +// StreetDrop +// +// Created by thoonk on 7/16/24. +// + +import Foundation + +import RxSwift + +protocol FetchingMyLikeListUseCase { + func fetchMyLikeList() -> Single +} diff --git a/StreetDrop/StreetDrop/Domain/UseCase/NoticeUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingNotice/NoticeUseCase.swift similarity index 87% rename from StreetDrop/StreetDrop/Domain/UseCase/NoticeUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingNotice/NoticeUseCase.swift index 4b6a900c..11bda8d3 100644 --- a/StreetDrop/StreetDrop/Domain/UseCase/NoticeUseCase.swift +++ b/StreetDrop/StreetDrop/Domain/UseCase/FetchingNotice/NoticeUseCase.swift @@ -9,12 +9,12 @@ import Foundation import RxSwift -protocol NoticeUseCase { +protocol FetchingNoticeUseCase { func fetchNoticeList() -> Single<[NoticeEntity]> func fetchNoticeDetail(id: Int) -> Single } -final class DefaultNoticeUseCase: NoticeUseCase { +final class DefaultFetchingNoticeUseCase: FetchingNoticeUseCase { private let noticeRepository: NoticeRepository init(noticeRepository: NoticeRepository = DefaultNoticeRepository()) { diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingPOIUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingPOI/DefaultFetchingPOIUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingPOIUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingPOI/DefaultFetchingPOIUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingPOIUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingPOI/FetchingPOIUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/FetchingPOIUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingPOI/FetchingPOIUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingPopUpInfomationUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingPopUpInfomation/DefaultFetchingPopUpInfomationUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingPopUpInfomationUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingPopUpInfomation/DefaultFetchingPopUpInfomationUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingPopUpInfomationUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingPopUpInfomation/FetchingPopUpInfomationUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/FetchingPopUpInfomationUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingPopUpInfomation/FetchingPopUpInfomationUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingSingleMusicUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingSingleMusic/DefaultFetchingSingleMusicUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingSingleMusicUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingSingleMusic/DefaultFetchingSingleMusicUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingSingleMusicUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingSingleMusic/FetchingSingleMusicUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/FetchingSingleMusicUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingSingleMusic/FetchingSingleMusicUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingUserCircleRadiusUsecase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingUserCircleRadius/DefaultFetchingUserCircleRadiusUsecase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultFetchingUserCircleRadiusUsecase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingUserCircleRadius/DefaultFetchingUserCircleRadiusUsecase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/FetchingUserCircleRadiusUsecase.swift b/StreetDrop/StreetDrop/Domain/UseCase/FetchingUserCircleRadius/FetchingUserCircleRadiusUsecase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/FetchingUserCircleRadiusUsecase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/FetchingUserCircleRadius/FetchingUserCircleRadiusUsecase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultLikingUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/Liking/DefaultLikingUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultLikingUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/Liking/DefaultLikingUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/LikingUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/Liking/LikingUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/LikingUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/Liking/LikingUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultMyInfoUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/MyInfo/DefaultMyInfoUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultMyInfoUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/MyInfo/DefaultMyInfoUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/MyInfoUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/MyInfo/MyInfoUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/MyInfoUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/MyInfo/MyInfoUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/DefaultPostingPopUpUserReadingUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/PostingPopUpUserReading/DefaultPostingPopUpUserReadingUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/DefaultPostingPopUpUserReadingUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/PostingPopUpUserReading/DefaultPostingPopUpUserReadingUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/PostingPopUpUserReadingUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/PostingPopUpUserReading/PostingPopUpUserReadingUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/PostingPopUpUserReadingUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/PostingPopUpUserReading/PostingPopUpUserReadingUseCase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/SearchMusicUsecase.swift b/StreetDrop/StreetDrop/Domain/UseCase/SearchingMusic/SearchMusicUsecase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/SearchMusicUsecase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/SearchingMusic/SearchMusicUsecase.swift diff --git a/StreetDrop/StreetDrop/Domain/UseCase/SettingsUseCase.swift b/StreetDrop/StreetDrop/Domain/UseCase/Settings/SettingsUseCase.swift similarity index 100% rename from StreetDrop/StreetDrop/Domain/UseCase/SettingsUseCase.swift rename to StreetDrop/StreetDrop/Domain/UseCase/Settings/SettingsUseCase.swift diff --git a/StreetDrop/StreetDrop/Presentation/MainScene/ViewModel/MainViewModel.swift b/StreetDrop/StreetDrop/Presentation/MainScene/ViewModel/MainViewModel.swift index f51b94ad..c80444c3 100644 --- a/StreetDrop/StreetDrop/Presentation/MainScene/ViewModel/MainViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/MainScene/ViewModel/MainViewModel.swift @@ -31,7 +31,7 @@ final class MainViewModel: ViewModel { private let myInfoUseCase: MyInfoUseCase private let fetchingPOIUseCase: FetchingPOIUseCase private let fetchingMusicCountUseCse: FetchingMusicCountUseCase - private let fetchingMusicWithinArea: FetchingMusicWithinArea + private let fetchingMusicWithinAreaUseCase: FetchingMusicWithinAreaUseCase private let fetchingPopUpInfomationUseCase: FetchingPopUpInfomationUseCase private let postingPopUpUserReadingUseCase: PostingPopUpUserReadingUseCase @@ -43,7 +43,7 @@ final class MainViewModel: ViewModel { myInfoUseCase: MyInfoUseCase = DefaultMyInfoUseCase(), fetchingPOIUseCase: FetchingPOIUseCase = DefaultFetchingPOIUseCase(), fetchingMusicCountUseCse: FetchingMusicCountUseCase = DefaultFetchingMusicCountUseCase(), - fetchingMusicWithinArea: FetchingMusicWithinArea = DefaultFetchingMusicWithinArea(), + fetchingMusicWithinAreaUseCase: FetchingMusicWithinAreaUseCase = DefaultFetchingMusicWithinAreaUseCase(), fetchingSingleMusicUseCase: FetchingSingleMusicUseCase = DefaultFetchingSingleMusicUseCase(), fetchingPopUpInfomationUseCase: FetchingPopUpInfomationUseCase = DefaultFetchingPopUpInfomationUseCase(), postingPopUpUserReadingUseCase: PostingPopUpUserReadingUseCase = DefaultPostingPopUpUserReadingUseCase() @@ -52,7 +52,7 @@ final class MainViewModel: ViewModel { self.myInfoUseCase = myInfoUseCase self.fetchingPOIUseCase = fetchingPOIUseCase self.fetchingMusicCountUseCse = fetchingMusicCountUseCse - self.fetchingMusicWithinArea = fetchingMusicWithinArea + self.fetchingMusicWithinAreaUseCase = fetchingMusicWithinAreaUseCase self.fetchingPopUpInfomationUseCase = fetchingPopUpInfomationUseCase self.postingPopUpUserReadingUseCase = postingPopUpUserReadingUseCase self.locationManager.delegate = self @@ -237,7 +237,7 @@ private extension MainViewModel { } func fetchMusicWithArea(output: Output, disposedBag: DisposeBag) { - fetchingMusicWithinArea.execute( + fetchingMusicWithinAreaUseCase.execute( lat: self.location.coordinate.latitude, lon: self.location.coordinate.longitude, distance: userCircleRadius diff --git a/StreetDrop/StreetDrop/Presentation/MusicDropView/ViewModel/MusicDropViewModel.swift b/StreetDrop/StreetDrop/Presentation/MusicDropView/ViewModel/MusicDropViewModel.swift index bec9eba9..9ae2d85b 100644 --- a/StreetDrop/StreetDrop/Presentation/MusicDropView/ViewModel/MusicDropViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/MusicDropView/ViewModel/MusicDropViewModel.swift @@ -36,15 +36,15 @@ class MusicDropViewModel: ViewModel { var state: State = .drop private let droppingInfo: DroppingInfo - private let musicDropUseCase: MusicDropUseCase + private let dropMusicUseCase: DropMusicUseCase private let disposeBag: DisposeBag = DisposeBag() init ( droppingInfo: DroppingInfo, - musicDropUseCase: MusicDropUseCase = DefaultMusicDropUseCase() + dropMusicUseCase: DropMusicUseCase = DefaultDropMusicUseCase() ) { self.droppingInfo = droppingInfo - self.musicDropUseCase = musicDropUseCase + self.dropMusicUseCase = dropMusicUseCase } func convert(input: Input, disposedBag: RxSwift.DisposeBag) -> Output { @@ -93,7 +93,7 @@ class MusicDropViewModel: ViewModel { var comment = "" input.comment.bind { comment = $0 }.disposed(by: DisposeBag()) - self.musicDropUseCase.drop(droppingInfo: self.droppingInfo, content: comment) + self.dropMusicUseCase.drop(droppingInfo: self.droppingInfo, content: comment) .subscribe(onSuccess: { response in if !(200...299).contains(response) { output.isSuccessDrop.accept( diff --git a/StreetDrop/StreetDrop/Presentation/Settings/Notice/ViewModel/NoticeDetailViewModel.swift b/StreetDrop/StreetDrop/Presentation/Settings/Notice/ViewModel/NoticeDetailViewModel.swift index c27cc260..95a33268 100644 --- a/StreetDrop/StreetDrop/Presentation/Settings/Notice/ViewModel/NoticeDetailViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/Settings/Notice/ViewModel/NoticeDetailViewModel.swift @@ -14,12 +14,12 @@ protocol NoticeDetailViewModel: ViewModel { } final class DefaultNoticeDetailViewModel: NoticeDetailViewModel { private let noticeId: Int - private let useCase: NoticeUseCase + private let useCase: FetchingNoticeUseCase private let dateManager: DateManager init( noticeId: Int, - useCase: NoticeUseCase = DefaultNoticeUseCase(), + useCase: FetchingNoticeUseCase = DefaultFetchingNoticeUseCase(), dateManager: DateManager = DefaultDateManager() ) { self.noticeId = noticeId diff --git a/StreetDrop/StreetDrop/Presentation/Settings/Notice/ViewModel/NoticeListViewModel.swift b/StreetDrop/StreetDrop/Presentation/Settings/Notice/ViewModel/NoticeListViewModel.swift index ffdce005..7697e841 100644 --- a/StreetDrop/StreetDrop/Presentation/Settings/Notice/ViewModel/NoticeListViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/Settings/Notice/ViewModel/NoticeListViewModel.swift @@ -13,11 +13,11 @@ import RxSwift protocol NoticeListViewModel: ViewModel { } final class DefaultNoticeListViewModel: NoticeListViewModel { - private let useCase: NoticeUseCase + private let useCase: FetchingNoticeUseCase private let dateManager: DateManager init( - useCase: NoticeUseCase = DefaultNoticeUseCase(), + useCase: FetchingNoticeUseCase = DefaultFetchingNoticeUseCase(), dateManager: DateManager = DefaultDateManager() ) { self.useCase = useCase From 6401074c55075f81326e9a55e148a6ab8f7c1e4d Mon Sep 17 00:00:00 2001 From: thoonk Date: Tue, 16 Jul 2024 21:50:39 +0900 Subject: [PATCH 11/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F#294:=20MyPageViewModel?= =?UTF-8?q?=20UseCase=20=EB=B3=80=EA=B2=BD=20=EC=9E=91=EC=97=85=20(?= =?UTF-8?q?=EA=B8=B0=EC=A1=B4=20MyPageModel=20=EC=A0=9C=EA=B1=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StreetDrop.xcodeproj/project.pbxproj | 4 -- .../MyPage/Model/MyPageModel.swift | 53 ------------------- .../MyPage/ViewModel/MyPageViewModel.swift | 36 +++++++++---- 3 files changed, 25 insertions(+), 68 deletions(-) delete mode 100644 StreetDrop/StreetDrop/Presentation/MyPage/Model/MyPageModel.swift diff --git a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj index 04c492ee..b54ff545 100644 --- a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj +++ b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj @@ -72,7 +72,6 @@ 1876F03F2A66E4E30064B887 /* MyLikeListResponseDTO+Mapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1876F03E2A66E4E30064B887 /* MyLikeListResponseDTO+Mapping.swift */; }; 1876F0412A66E5440064B887 /* MyLevelResponseDTO+Mapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1876F0402A66E5440064B887 /* MyLevelResponseDTO+Mapping.swift */; }; 1876F0442A66E6E00064B887 /* MyPageRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1876F0432A66E6E00064B887 /* MyPageRepository.swift */; }; - 1876F0472A66EDA20064B887 /* MyPageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1876F0462A66EDA20064B887 /* MyPageModel.swift */; }; 1876F04A2A66EDF10064B887 /* MyMusic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1876F0492A66EDF10064B887 /* MyMusic.swift */; }; 1876F04E2A66EE030064B887 /* MyLevel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1876F04D2A66EE030064B887 /* MyLevel.swift */; }; 1876F0502A66F7A30064B887 /* DefaultMyPageRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1876F04F2A66F7A30064B887 /* DefaultMyPageRepository.swift */; }; @@ -356,7 +355,6 @@ 1876F03E2A66E4E30064B887 /* MyLikeListResponseDTO+Mapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MyLikeListResponseDTO+Mapping.swift"; sourceTree = ""; }; 1876F0402A66E5440064B887 /* MyLevelResponseDTO+Mapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MyLevelResponseDTO+Mapping.swift"; sourceTree = ""; }; 1876F0432A66E6E00064B887 /* MyPageRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageRepository.swift; sourceTree = ""; }; - 1876F0462A66EDA20064B887 /* MyPageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageModel.swift; sourceTree = ""; }; 1876F0492A66EDF10064B887 /* MyMusic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyMusic.swift; sourceTree = ""; }; 1876F04D2A66EE030064B887 /* MyLevel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyLevel.swift; sourceTree = ""; }; 1876F04F2A66F7A30064B887 /* DefaultMyPageRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultMyPageRepository.swift; sourceTree = ""; }; @@ -1159,7 +1157,6 @@ isa = PBXGroup; children = ( 1876F0482A66EDE60064B887 /* Entites */, - 1876F0462A66EDA20064B887 /* MyPageModel.swift */, 1816ED422A685865005009FC /* NicknameEditModel.swift */, ); path = Model; @@ -2144,7 +2141,6 @@ F4C996AD2C1EEF2500FF7B9A /* NoticeRepository.swift in Sources */, F4AA84DB2C1F106300CADB1A /* NoticeDetailViewController.swift in Sources */, C47F02282A3864A500F48884 /* SettingElementCell.swift in Sources */, - 1876F0472A66EDA20064B887 /* MyPageModel.swift in Sources */, 18683FDC2A348B15005A94AC /* DefaultMainRepository.swift in Sources */, 1876F03F2A66E4E30064B887 /* MyLikeListResponseDTO+Mapping.swift in Sources */, 6A7D73DD2BB14015009340E3 /* GradientProgressBar.swift in Sources */, diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/Model/MyPageModel.swift b/StreetDrop/StreetDrop/Presentation/MyPage/Model/MyPageModel.swift deleted file mode 100644 index 9e5281f0..00000000 --- a/StreetDrop/StreetDrop/Presentation/MyPage/Model/MyPageModel.swift +++ /dev/null @@ -1,53 +0,0 @@ -// -// MyPageModel.swift -// StreetDrop -// -// Created by JoongkyuPark on 2023/07/19. -// - -import Foundation - -import RxSwift - -protocol MyPageModel { - func fetchMyDropList() -> Single - func fetchMyLikeList() -> Single - func fetchMyLevel() -> Single - func fetchMyLevelProgress() -> Single - func fetchLevelPolicy() -> Single<[LevelPolicy]> - func fetchMyDropMusic(itemID: Int) -> Single -} - -final class DefaultMyPageModel: MyPageModel { - private let repository: MyPageRepository - - init( - repository: MyPageRepository - ) { - self.repository = repository - } - - func fetchMyDropList() -> Single { - return repository.fetchMyDropList() - } - - func fetchMyLikeList() -> Single { - return repository.fetchMyLikeList() - } - - func fetchMyLevel() -> Single { - return repository.fetchMyLevel() - } - - func fetchMyLevelProgress() -> Single { - return repository.fetchMyLevelProgress() - } - - func fetchLevelPolicy() -> Single<[LevelPolicy]> { - return repository.fetchLevelPolicy() - } - - func fetchMyDropMusic(itemID: Int) -> Single { - return repository.fetchMyDropMusic(itemID: itemID) - } -} diff --git a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift index 42cde5d8..7f0b525d 100644 --- a/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift +++ b/StreetDrop/StreetDrop/Presentation/MyPage/ViewModel/MyPageViewModel.swift @@ -12,13 +12,27 @@ import RxRelay import RxSwift final class MyPageViewModel { - private let model = DefaultMyPageModel( - repository: DefaultMyPageRepository( - networkManager: NetworkManager() - ) - ) + private let fetchingMyLevelUseCase: FetchingMyLevelUseCase + private let fetchingLevelPolicyUseCase: FetchingLevelPolicyUseCase + private let fetchingMyDropListUseCase: FetchingMyDropListUseCase + private let fetchingMyLikeListUseCase: FetchingMyLikeListUseCase + private let fetchingSingleMusicUseCase: FetchingSingleMusicUseCase private var myMusicType: MyMusicType = .drop + + init( + fetchingMyLevelUseCase: FetchingMyLevelUseCase = DefaultFetchingMyLevelUseCase(), + fetchingLevelPolicyUseCase: FetchingLevelPolicyUseCase = DefaultFetchingLevelPolicyUseCase(), + fetchingMyDropListUseCase: FetchingMyDropListUseCase = DefaultFetchingMyDropListUseCase(), + fetchingMyLikeListUseCase: FetchingMyLikeListUseCase = DefaultFetchingMyLikeListUseCase(), + fetchingSingleMusicUseCase: FetchingSingleMusicUseCase = DefaultFetchingSingleMusicUseCase() + ) { + self.fetchingMyLevelUseCase = fetchingMyLevelUseCase + self.fetchingLevelPolicyUseCase = fetchingLevelPolicyUseCase + self.fetchingMyDropListUseCase = fetchingMyDropListUseCase + self.fetchingMyLikeListUseCase = fetchingMyLikeListUseCase + self.fetchingSingleMusicUseCase = fetchingSingleMusicUseCase + } } extension MyPageViewModel: ViewModel { @@ -102,7 +116,7 @@ extension MyPageViewModel: ViewModel { private extension MyPageViewModel { func fetchLevelItems(output: Output, disposedBag: DisposeBag) { - model.fetchMyLevel() + fetchingMyLevelUseCase.fetchMyLevel() .subscribe { result in switch result { case .success(let levelItem): @@ -117,7 +131,7 @@ private extension MyPageViewModel { } func fetchLevelProgress(output: Output, disposeBag: DisposeBag) { - model.fetchMyLevelProgress() + fetchingMyLevelUseCase.fetchMyLevelProgress() .subscribe(with: self, onSuccess: { owner, progress in output.isShowingLevelUpView.accept(progress.isShow) output.remainCountToLevelUp.accept(progress.remainCount) @@ -131,7 +145,7 @@ private extension MyPageViewModel { } func fetchLevelPolicy(output: Output, disposeBag: DisposeBag) { - model.fetchLevelPolicy() + fetchingLevelPolicyUseCase.fetchLevelPolicy() .subscribe(with: self, onSuccess: { owner, levelPolicies in output.levelPoliciesRelay.accept(levelPolicies) }, onFailure: { _, error in @@ -144,7 +158,7 @@ private extension MyPageViewModel { output: Output, disposedBag: DisposeBag ) { - model.fetchMyDropList() + fetchingMyDropListUseCase.fetchMyDropList() .subscribe(with: self, onSuccess: { owner, totalMusics in output.totalDropMusicsCount.accept(totalMusics.totalCount) let myMusicsSections = owner.convertToSectionTypes(from: totalMusics) @@ -157,7 +171,7 @@ private extension MyPageViewModel { } func fetchMyLikeMusicsSections(output: Output, disposedBag: DisposeBag) { - model.fetchMyLikeList() + fetchingMyLikeListUseCase.fetchMyLikeList() .subscribe(with: self, onSuccess: { owner, totalMusics in output.totalLikeMusicsCount.accept(totalMusics.totalCount) let myMusicsSections = owner.convertToSectionTypes(from: totalMusics) @@ -174,7 +188,7 @@ private extension MyPageViewModel { output: Output, disposedBag: DisposeBag ) { - model.fetchMyDropMusic(itemID: itemID) + fetchingSingleMusicUseCase.fetchSingleMusic(itemID: itemID) .subscribe(onSuccess: { musics in if musics.isEmpty == false { output.pushCommunityView.accept(musics)