Skip to content

Commit

Permalink
♻️#294: 마이페이지 리스트뷰 개선 작업
Browse files Browse the repository at this point in the history
- 기존 UITableView DataSource 에서 Diffable DataSource 로 변경 작업
- 기존 2개(드랍, 좋아요)의 UITableView(Hidden 처리)를 1개의 UICollectionView를 이용한 개선 작업
- Compositional Layout 적용
- 콘텐츠 수에 따른 CollectionView Height 업데이트를 통한 전체 스크롤뷰 높이 조정
  • Loading branch information
thoonk committed Jul 7, 2024
1 parent 8aa3b26 commit 5f485d9
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 275 deletions.
8 changes: 4 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 @@ -332,7 +332,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 @@ -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 */,
Expand Down Expand Up @@ -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 */,
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,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)
Expand Down Expand Up @@ -138,7 +139,9 @@ final class MusicTableViewCell: UITableViewCell {
}()
}

private extension MusicTableViewCell {
// MARK: - Private Methods

private extension MusicListCell {

// MARK: - UI

Expand All @@ -147,7 +150,6 @@ private extension MusicTableViewCell {
// MARK: - Cell

self.backgroundColor = UIColor.gray900
self.selectionStyle = .none

// MARK: - Container StackView

Expand Down Expand Up @@ -291,13 +293,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 @@ -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 = {
Expand All @@ -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)
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
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

0 comments on commit 5f485d9

Please sign in to comment.