Skip to content

Commit

Permalink
Merge pull request #19 from NAGAZA-Team/Feature/mypage
Browse files Browse the repository at this point in the history
Feat: 마이페이지 UI 구현
  • Loading branch information
hililyy authored Mar 13, 2024
2 parents 147ac42 + bee5bf4 commit 0114177
Show file tree
Hide file tree
Showing 10 changed files with 464 additions and 33 deletions.
23 changes: 23 additions & 0 deletions Nagaza/Resources/Images.xcassets/ic_Info.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic_Info.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions Nagaza/Sources/Domain/Entities/MypageInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// MypageInfo.swift
// Nagaza
//
// Created by 강조은 on 3/10/24.
//

import Foundation

enum MyPageInfoSection: Hashable {
case myData([MyPageInfo])
case appSetting([MyPageInfo])
case inquiry([MyPageInfo])

var list: [MyPageInfo] {
switch self {
case .myData(let list), .appSetting(let list), .inquiry(let list):
return list
}
}
}

struct MyPageInfo: Hashable {
let identifier = UUID()
let title: String
var count: Int? = nil
}

extension MyPageInfo {
public static func == (lhs: MyPageInfo, rhs: MyPageInfo) -> Bool {
lhs.identifier == rhs.identifier
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class HomeViewController: NagazaBaseViewController {

private var viewModel: HomeViewModel!

private var dataSource: UICollectionViewDiffableDataSource<HomeSectionType, Room>? = nil
private var dataSource: DataSource!

private lazy var recommendedThemeViewController: RecommendThemeViewController = {
let vc = RecommendThemeViewController.create(with: viewModel)
Expand Down Expand Up @@ -84,7 +84,7 @@ final class HomeViewController: NagazaBaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
self.configureDataSource()
self.setDataSource()
}

override func navigationSetting() {
Expand Down Expand Up @@ -140,7 +140,7 @@ final class HomeViewController: NagazaBaseViewController {

output.roomsList
.drive(with: self, onNext: { this, roomslist in
var snapshot = NSDiffableDataSourceSnapshot<HomeSectionType, Room>()
var snapshot = Snapshot()
snapshot.appendSections([.horror, .fantasy, .suspense, .comic, .drama, .sf, .rRtated])
for (index, list) in roomslist.enumerated() {
let homeSectionType = HomeSectionType(rawValue: index) ?? .comic
Expand All @@ -160,8 +160,8 @@ final class HomeViewController: NagazaBaseViewController {
case .rRtated:
snapshot.appendItems(list, toSection: .rRtated)
}
this.dataSource?.apply(snapshot)
}
this.dataSource.apply(snapshot)
})
.disposed(by: disposeBag)

Expand Down Expand Up @@ -211,8 +211,14 @@ extension Reactive where Base: HomeViewController {
}

extension HomeViewController {
private func configureDataSource() {
let roomCellRegistraition = UICollectionView.CellRegistration<ThemeCell, Room> { [weak self] cell, indexPath, item in
typealias CellType = ThemeCell
typealias ModelType = Room
typealias SectionType = HomeSectionType
typealias DataSource = UICollectionViewDiffableDataSource<SectionType, ModelType>
typealias Snapshot = NSDiffableDataSourceSnapshot<SectionType, ModelType>

private func setDataSource() {
let roomCellRegistraition = UICollectionView.CellRegistration<CellType, ModelType> { [weak self] cell, indexPath, item in

cell.bind(with: item)
// cell.delegate = self
Expand All @@ -223,11 +229,11 @@ extension HomeViewController {
supplementaryView.themeLabel.text = sectionType.title
}

dataSource = UICollectionViewDiffableDataSource<HomeSectionType, Room>(collectionView: themesViewController.collectionView, cellProvider: { collectionView, indexPath, itemIdentifier in
dataSource = DataSource(collectionView: themesViewController.collectionView, cellProvider: { collectionView, indexPath, itemIdentifier in
return collectionView.dequeueConfiguredReusableCell(using: roomCellRegistraition, for: indexPath, item: itemIdentifier)
})

dataSource?.supplementaryViewProvider = { (view, kind, index) in
dataSource.supplementaryViewProvider = { (view, kind, index) in
return self.themesViewController.collectionView.dequeueConfiguredReusableSupplementary(
using: headerRegistration,
for: index
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// MyPageTableViewCell.swift
// Nagaza
//
// Created by 강조은 on 3/10/24.
//

import UIKit

final class MyPageTableViewCell: UITableViewCell {

static let identifier = MyPageTableViewCell.description()

private let titleLabel: UILabel = {

let label = UILabel()
label.font = NagazaFontFamily.Pretendard.regular.font(size: 16)
label.textColor = NagazaAsset.Colors.black1.color

return label
}()

private let countLabel: UILabel = {
let label = UILabel()

label.font = NagazaFontFamily.Pretendard.regular.font(size: 15)
label.textColor = NagazaAsset.Colors.mainOrange.color

return label
}()

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

setup()
initConstraints()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setup() {
contentView.addSubviews([titleLabel, countLabel])
}

private func initConstraints() {
titleLabel.snp.makeConstraints { make in
make.top.equalToSuperview().inset(20)
make.leading.equalToSuperview().inset(24)
make.centerY.equalToSuperview()
}

countLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.trailing.equalToSuperview().inset(24)
}
}

func config(item: MyPageInfo) {
titleLabel.text = item.title
if let count = item.count {
countLabel.text = "\(count)"
} else { countLabel.text = nil }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// MyPageTableViewHeader.swift
// Nagaza
//
// Created by 강조은 on 3/10/24.
//

import UIKit

final class MyPageTableViewHeader: UITableViewHeaderFooterView {

static let identifier = MyPageTableViewHeader.description()

private let background: UIView = {
let view = UIView()

view.backgroundColor = NagazaAsset.Colors.gray8.color

return view
}()

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

makeUI()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
}

private func makeUI() {
addSubview(background)

background.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
}
Loading

0 comments on commit 0114177

Please sign in to comment.