Skip to content

Commit 469a8a0

Browse files
committed
✨ [feat] 게시글 신고 리스트엔 사진이 보이게 구현
1 parent a7a9e51 commit 469a8a0

File tree

8 files changed

+101
-30
lines changed

8 files changed

+101
-30
lines changed

Fitfty/Projects/Coordinator/Sources/Setting/ReportListCoordinator.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,34 @@ import Core
1515
final class ReportListCoordinator: Coordinator {
1616

1717
var type: CoordinatorType { .reportList }
18+
var reportType: ReportType
1819
weak var finishDelegate: CoordinatorFinishDelegate?
1920

2021
var parentCoordinator: Coordinator?
2122
var childCoordinators: [Coordinator] = []
2223
var navigationController: BaseNavigationController
2324

24-
init(navigationController: BaseNavigationController = BaseNavigationController()) {
25+
init(
26+
navigationController: BaseNavigationController = BaseNavigationController(),
27+
reportType: ReportType
28+
) {
2529
self.navigationController = navigationController
30+
self.reportType = reportType
2631
}
2732

2833
func start() {
29-
let viewController = makeReportListViewController()
34+
let viewController = makeReportListViewController(reportType: reportType)
3035
navigationController.pushViewController(viewController, animated: true)
3136
}
3237
}
3338

3439
private extension ReportListCoordinator {
3540

36-
func makeReportListViewController() -> UIViewController {
41+
func makeReportListViewController(reportType: ReportType) -> UIViewController {
3742
let viewController = ReportListViewController(
3843
coordinator: self,
39-
viewModel: ReportListViewModel(reportType: .userReport, fitftyRepository: DefaultFitftyRepository())
44+
viewModel: ReportListViewModel(reportType: reportType, fitftyRepository: DefaultFitftyRepository()),
45+
reportType: reportType
4046
)
4147
return viewController
4248
}

Fitfty/Projects/Coordinator/Sources/Setting/SettingCoordinator.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ private extension SettingCoordinator {
7676
return coordinator
7777
}
7878

79-
func makeReportListCoordinator() -> Coordinator {
80-
let coordinator = ReportListCoordinator(navigationController: navigationController)
79+
func makeReportListCoordinator(reportType: ReportType) -> Coordinator {
80+
let coordinator = ReportListCoordinator(
81+
navigationController: navigationController,
82+
reportType: reportType
83+
)
8184
coordinator.parentCoordinator = self
8285
coordinator.finishDelegate = self
8386
childCoordinators.append(coordinator)
@@ -115,8 +118,8 @@ extension SettingCoordinator: SettingCoordinatorInterface {
115118
navigationController.present(webViewController, animated: true)
116119
}
117120

118-
func showReportList() {
119-
let coordinator = makeReportListCoordinator()
121+
func showReportList(reportType: ReportType) {
122+
let coordinator = makeReportListCoordinator(reportType: reportType)
120123
coordinator.start()
121124
}
122125

Fitfty/Projects/Setting/Sources/Admin/VewController/ReportListViewController.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ final public class ReportListViewController: UIViewController {
1414

1515
private let menuView = ReportMenuView()
1616
private var coordinator: ReportListCoordinatorInterface
17-
let viewModel: ReportListViewModel
17+
private var viewModel: ReportListViewModel
18+
private var reportType: ReportType
1819
private var cancellables: Set<AnyCancellable> = .init()
1920

2021
private lazy var tableView: UITableView = {
@@ -29,10 +30,12 @@ final public class ReportListViewController: UIViewController {
2930

3031
public init(
3132
coordinator: ReportListCoordinatorInterface,
32-
viewModel: ReportListViewModel
33+
viewModel: ReportListViewModel,
34+
reportType: ReportType
3335
) {
3436
self.coordinator = coordinator
3537
self.viewModel = viewModel
38+
self.reportType = reportType
3639
super.init(nibName: nil, bundle: nil)
3740
}
3841

@@ -51,6 +54,7 @@ final public class ReportListViewController: UIViewController {
5154
setConstraintsLayout()
5255
setNavigationBar()
5356
setDataSource()
57+
menuView.setUp(reportType: reportType)
5458
}
5559

5660
@objc func didTapBackButton(_ sender: Any?) {
@@ -105,10 +109,11 @@ private extension ReportListViewController {
105109
dataSource = UITableViewDiffableDataSource<ReportListSectionKind, ReportListCellModel>(
106110
tableView: tableView, cellProvider: { tableView, indexPath, item in
107111
switch item {
108-
case .report(let account, let detailReport, let count):
112+
case .report(let account, let detailReport, let count, let filepath):
109113
let cell = tableView.dequeueReusableCell(withIdentifier: ReportListCell.className, for: indexPath) as? ReportListCell
114+
cell?.setReportType(self.reportType)
110115
cell?.selectionStyle = .none
111-
cell?.setUp(account: account, detailReport: detailReport, count: count)
116+
cell?.setUp(account: account, detailReport: detailReport, count: count, filePath: filepath)
112117
return cell
113118
}
114119
})
@@ -128,7 +133,12 @@ private extension ReportListViewController {
128133
extension ReportListViewController: UITableViewDelegate {
129134

130135
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
131-
return 44
136+
switch reportType {
137+
case .userReport:
138+
return 44
139+
case .postReport:
140+
return 120
141+
}
132142
}
133143

134144
}

Fitfty/Projects/Setting/Sources/Admin/ViewModel/ReportListViewModel.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ protocol ReportListViewModelInput {
2020
}
2121

2222
public final class ReportListViewModel {
23+
2324
private var currentState: CurrentValueSubject<ViewModelState?, Never> = .init(nil)
2425
private var cancellables: Set<AnyCancellable> = .init()
2526
private var reportType: ReportType
@@ -70,7 +71,7 @@ extension ReportListViewModel {
7071
}
7172
var cellModels = [ReportListCellModel]()
7273
for i in 0..<data.count {
73-
cellModels.append(ReportListCellModel.report(data[i].reportUserEmail, data[i].type[0], String(data[i].reportedCount)))
74+
cellModels.append(ReportListCellModel.report(data[i].reportUserEmail, getKoreanDetailReport(data[i].type[0]), String(data[i].reportedCount+1), data[i].reportedBoardFilePath))
7475
}
7576
self.currentState.send(.sections([ReportListSection(sectionKind: .report, items: cellModels)]))
7677
case .userReport:
@@ -82,7 +83,7 @@ extension ReportListViewModel {
8283
}
8384
var cellModels = [ReportListCellModel]()
8485
for i in 0..<data.count {
85-
cellModels.append(ReportListCellModel.report(data[i].reportedUserEmail, data[i].type[0], String(data[i].reportedCount)))
86+
cellModels.append(ReportListCellModel.report(data[i].reportedUserEmail, getKoreanDetailReport(data[i].type[0]), String(data[i].reportedCount+1), nil))
8687
}
8788
self.currentState.send(.sections([ReportListSection(sectionKind: .report, items: cellModels)]))
8889
}
@@ -92,4 +93,16 @@ extension ReportListViewModel {
9293
}
9394
}
9495
}
96+
97+
private func getKoreanDetailReport(_ english: String) -> String {
98+
switch english {
99+
case "OBSCENE": return "음란성/선정성"
100+
case "WEATHER": return "날씨와맞지않음"
101+
case "COPYRIGHT": return "지적재산권침해"
102+
case "INSULT": return "혐오/욕설/인신공격"
103+
case "REPEAT": return "같은내용반복"
104+
default: return "기타"
105+
}
106+
}
107+
95108
}

Fitfty/Projects/Setting/Sources/Admin/Views/ReportListCell.swift

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import UIKit
1010
import Common
11+
import Kingfisher
1112

1213
final class ReportListCell: UITableViewCell {
1314

@@ -23,26 +24,30 @@ final class ReportListCell: UITableViewCell {
2324
let label = UILabel()
2425
label.textColor = CommonAsset.Colors.gray06.color
2526
label.font = FitftyFont.appleSDMedium(size: 15).font
26-
label.text = "[email protected]"
2727
return label
2828
}()
2929

3030
private lazy var detailReportLabel: UILabel = {
3131
let label = UILabel()
3232
label.textColor = CommonAsset.Colors.gray06.color
3333
label.font = FitftyFont.appleSDMedium(size: 15).font
34-
label.text = "불쾌"
3534
return label
3635
}()
3736

3837
private lazy var countLabel: UILabel = {
3938
let label = UILabel()
4039
label.textColor = CommonAsset.Colors.gray06.color
4140
label.font = FitftyFont.appleSDMedium(size: 15).font
42-
label.text = "13"
4341
return label
4442
}()
4543

44+
private lazy var postImageView: UIImageView = {
45+
let imageView = UIImageView()
46+
imageView.contentMode = .scaleAspectFill
47+
imageView.clipsToBounds = true
48+
return imageView
49+
}()
50+
4651
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
4752
super.init(style: style, reuseIdentifier: reuseIdentifier)
4853
setConstraintsLayout()
@@ -53,24 +58,29 @@ final class ReportListCell: UITableViewCell {
5358
}
5459

5560
private func setConstraintsLayout() {
56-
addSubviews(checkBoxButton, accountLabel, detailReportLabel, countLabel)
61+
addSubviews(checkBoxButton, accountLabel, detailReportLabel, countLabel, postImageView)
5762
NSLayoutConstraint.activate([
5863
checkBoxButton.centerYAnchor.constraint(equalTo: centerYAnchor),
5964
checkBoxButton.widthAnchor.constraint(equalToConstant: 20),
6065
checkBoxButton.heightAnchor.constraint(equalToConstant: 20),
61-
checkBoxButton.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -20),
66+
checkBoxButton.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -5),
6267

6368
accountLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
6469
accountLabel.leadingAnchor.constraint(equalTo: leadingAnchor),
65-
accountLabel.widthAnchor.constraint(equalToConstant: 120),
70+
accountLabel.widthAnchor.constraint(equalToConstant: 150),
6671

6772
detailReportLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
6873
detailReportLabel.leadingAnchor.constraint(equalTo: accountLabel.trailingAnchor, constant: 10),
6974
detailReportLabel.widthAnchor.constraint(equalToConstant: 120),
7075

7176
countLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
7277
countLabel.leadingAnchor.constraint(equalTo: detailReportLabel.trailingAnchor, constant: 10),
73-
countLabel.widthAnchor.constraint(equalToConstant: 50)
78+
countLabel.widthAnchor.constraint(equalToConstant: 10),
79+
80+
postImageView.widthAnchor.constraint(equalToConstant: 100),
81+
postImageView.heightAnchor.constraint(equalToConstant: 100),
82+
postImageView.centerYAnchor.constraint(equalTo: centerYAnchor),
83+
postImageView.leadingAnchor.constraint(equalTo: leadingAnchor)
7484
])
7585
}
7686

@@ -86,10 +96,25 @@ final class ReportListCell: UITableViewCell {
8696

8797
extension ReportListCell {
8898

89-
func setUp(account: String, detailReport: String, count: String) {
99+
func setUp(account: String, detailReport: String, count: String, filePath: String?) {
90100
accountLabel.text = account
91101
detailReportLabel.text = detailReport
92102
countLabel.text = count
103+
guard let filePath = filePath else {
104+
return
105+
}
106+
let url = URL(string: filePath)
107+
postImageView.kf.setImage(with: url)
93108
}
94109

110+
func setReportType(_ reportType: ReportType) {
111+
switch reportType {
112+
case .userReport:
113+
postImageView.isHidden = true
114+
case.postReport:
115+
accountLabel.isHidden = true
116+
}
117+
118+
}
119+
95120
}

Fitfty/Projects/Setting/Sources/Admin/Views/ReportMenuView.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ final class ReportMenuView: UIView {
1313

1414
private lazy var emailLabel: UILabel = {
1515
let label = UILabel()
16-
label.text = "계정"
1716
label.font = FitftyFont.SFProDisplayBlack(size: 15).font
1817
return label
1918
}()
@@ -47,9 +46,21 @@ final class ReportMenuView: UIView {
4746
emailLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
4847
emailLabel.leadingAnchor.constraint(equalTo: leadingAnchor),
4948
detailReportLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
50-
detailReportLabel.leadingAnchor.constraint(equalTo: emailLabel.trailingAnchor, constant: 50),
49+
detailReportLabel.leadingAnchor.constraint(equalTo: emailLabel.trailingAnchor, constant: 130),
5150
countLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
52-
countLabel.leadingAnchor.constraint(equalTo: detailReportLabel.trailingAnchor, constant: 40)
51+
countLabel.leadingAnchor.constraint(equalTo: detailReportLabel.trailingAnchor, constant: 50)
5352
])
5453
}
5554
}
55+
56+
extension ReportMenuView {
57+
58+
func setUp(reportType: ReportType) {
59+
switch reportType {
60+
case .postReport:
61+
emailLabel.text = "사진"
62+
case .userReport:
63+
emailLabel.text = "계정"
64+
}
65+
}
66+
}

Fitfty/Projects/Setting/Sources/Home/ViewController/SettingViewController.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ extension SettingViewController: UICollectionViewDelegate {
156156
case .privacyRule:
157157
coordinator?.showPrivacyRule()
158158

159-
case .userReport,
160-
.postReport:
161-
coordinator?.showReportList()
159+
case .userReport:
160+
coordinator?.showReportList(reportType: .userReport)
161+
162+
case .postReport:
163+
coordinator?.showReportList(reportType: .postReport)
162164

163165
default: break
164166
}

Fitfty/Projects/Setting/Sources/SettingCoordinatorInterface.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
//
88

99
import Foundation
10+
import Common
1011

1112
public protocol SettingCoordinatorInterface: AnyObject {
1213
func showProfileSetting()
1314
func showFeedSetting()
1415
func showMyInfoSetting()
1516
func showTermsOfUse()
1617
func showPrivacyRule()
17-
func showReportList()
18+
func showReportList(reportType: ReportType)
1819
func finished()
1920
}

0 commit comments

Comments
 (0)