Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ 마이페이지 리스트뷰 리펙토링 #295

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions StreetDrop/StreetDrop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -140,6 +140,9 @@
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 */; };
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 */; };
Expand Down Expand Up @@ -332,7 +335,7 @@
1816ED482A68591F005009FC /* DefaultNicknameEditRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultNicknameEditRepository.swift; sourceTree = "<group>"; };
1824F1362A349F3700A10320 /* MusicCountEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicCountEntity.swift; sourceTree = "<group>"; };
1867C81F2A4DDB8C00F8EC48 /* MyPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewController.swift; sourceTree = "<group>"; };
1867C8232A4FFCDF00F8EC48 /* MusicTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicTableViewCell.swift; sourceTree = "<group>"; };
1867C8232A4FFCDF00F8EC48 /* MusicListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicListCell.swift; sourceTree = "<group>"; };
18683FD82A2A251E005A94AC /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = "<group>"; };
18683FDB2A348B15005A94AC /* DefaultMainRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultMainRepository.swift; sourceTree = "<group>"; };
18683FDE2A348B25005A94AC /* MainRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainRepository.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -410,6 +413,9 @@
6A26BF312B33D1E40007B6B7 /* FetchingSingleMusicUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchingSingleMusicUseCase.swift; sourceTree = "<group>"; };
6A26BF332B33D2210007B6B7 /* DefaultFetchingSingleMusicUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingSingleMusicUseCase.swift; sourceTree = "<group>"; };
6A3AFB572B8DB399003BD144 /* GADUnitID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GADUnitID.swift; sourceTree = "<group>"; };
6A51EC3B2C3E52FE00DEF6F3 /* UIViewController+Rx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Rx.swift"; sourceTree = "<group>"; };
6A51EC3D2C3E536000DEF6F3 /* Map+Rx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Map+Rx.swift"; sourceTree = "<group>"; };
6A51EC3F2C411FB000DEF6F3 /* MusicListTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicListTableView.swift; sourceTree = "<group>"; };
6A7D73D82BB11A0E009340E3 /* LevelUpGuideView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LevelUpGuideView.swift; sourceTree = "<group>"; };
6A7D73DC2BB14015009340E3 /* GradientProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientProgressBar.swift; sourceTree = "<group>"; };
6A7D73DE2BB15826009340E3 /* UIView+RoundCorners.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+RoundCorners.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -902,12 +908,13 @@
isa = PBXGroup;
children = (
1867C81F2A4DDB8C00F8EC48 /* MyPageViewController.swift */,
1867C8232A4FFCDF00F8EC48 /* MusicTableViewCell.swift */,
1867C8232A4FFCDF00F8EC48 /* MusicListCell.swift */,
18EF9FC82A5C51FB00266D27 /* NicknameEditViewController.swift */,
1816ED3B2A680608005009FC /* MusicListSectionHeaderView.swift */,
0856524F2AFBB73100FD9BCB /* MyPageType.swift */,
6A7D73D82BB11A0E009340E3 /* LevelUpGuideView.swift */,
6A7D73DC2BB14015009340E3 /* GradientProgressBar.swift */,
6A51EC3F2C411FB000DEF6F3 /* MusicListTableView.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -1475,6 +1482,8 @@
6A1386AA2B4F8A5000E49BB5 /* String+Base64.swift */,
C49EDACD2BBD7EFE0025DB55 /* GradientLabel.swift */,
F4AA84DE2C1F3B0200CADB1A /* Array+Extension.swift */,
6A51EC3B2C3E52FE00DEF6F3 /* UIViewController+Rx.swift */,
6A51EC3D2C3E536000DEF6F3 /* Map+Rx.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -1869,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 */,
Expand All @@ -1880,7 +1890,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 */,
Expand Down Expand Up @@ -1954,6 +1964,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 */,
Expand Down Expand Up @@ -2002,6 +2013,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import SnapKit
import RxCocoa
import RxSwift

final class MusicTableViewCell: UITableViewCell {
static let identifier = "MusicTableViewCell"
final class MusicListCell: UITableViewCell {
static let identifier = "MusicListCell"
private var disposeBag: DisposeBag = DisposeBag()

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

self.configureUI()
}

Expand Down Expand Up @@ -138,7 +139,9 @@ final class MusicTableViewCell: UITableViewCell {
}()
}

private extension MusicTableViewCell {
// MARK: - Private Methods

private extension MusicListCell {

// MARK: - UI

Expand Down Expand Up @@ -265,9 +268,9 @@ private extension MusicTableViewCell {
// 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)
}
}
Expand All @@ -291,13 +294,3 @@ struct UIViewPreview<View: UIView>: 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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final class MusicListSectionHeaderView: UITableViewHeaderFooterView {

override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)

self.configureUI()
}

Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading