Skip to content

Commit 83087a4

Browse files
committed
✨ [feat] ReportListCoordinator 구현
- ReportMenuView 추가
1 parent 8a2606c commit 83087a4

File tree

9 files changed

+217
-5
lines changed

9 files changed

+217
-5
lines changed

Fitfty/Projects/Coordinator/Sources/Coordinator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ enum CoordinatorType {
6969
case onboarding
7070
case detailReport
7171
case report
72+
case reportList
7273
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// ReportListCoordinator.swift
3+
// Coordinator
4+
//
5+
// Created by 임영선 on 2023/02/16.
6+
// Copyright © 2023 Fitfty. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import UIKit
11+
import Common
12+
import Setting
13+
14+
final class ReportListCoordinator: Coordinator {
15+
16+
var type: CoordinatorType { .reportList }
17+
weak var finishDelegate: CoordinatorFinishDelegate?
18+
19+
var parentCoordinator: Coordinator?
20+
var childCoordinators: [Coordinator] = []
21+
var navigationController: BaseNavigationController
22+
23+
init(navigationController: BaseNavigationController = BaseNavigationController()) {
24+
self.navigationController = navigationController
25+
}
26+
27+
func start() {
28+
let viewController = makeReportListViewController()
29+
navigationController.pushViewController(viewController, animated: true)
30+
}
31+
}
32+
33+
private extension ReportListCoordinator {
34+
35+
func makeReportListViewController() -> UIViewController {
36+
let viewController = ReportListViewController(coordinator: self)
37+
return viewController
38+
}
39+
40+
}
41+
42+
extension ReportListCoordinator: ReportListCoordinatorInterface {
43+
44+
func dismiss() {
45+
navigationController.popViewController(animated: true)
46+
}
47+
48+
}

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ private extension SettingCoordinator {
4646
childCoordinators.append(coordinator)
4747
coordinator.start()
4848
coordinator.finishDelegate = self
49-
coordinator.parentCoordinator = self
5049
let bottomSheetViewController = BottomSheetViewController(
5150
style: .custom(UIScreen.main.bounds.height - 70),
5251
contentViewController: coordinator.navigationController
@@ -61,7 +60,6 @@ private extension SettingCoordinator {
6160
childCoordinators.append(coordinator)
6261
coordinator.start()
6362
coordinator.finishDelegate = self
64-
coordinator.parentCoordinator = self
6563
let bottomSheetViewController = BottomSheetViewController(
6664
style: .custom(450),
6765
contentViewController: coordinator.navigationController
@@ -77,6 +75,15 @@ private extension SettingCoordinator {
7775
childCoordinators.append(coordinator)
7876
return coordinator
7977
}
78+
79+
func makeReportListCoordinator() -> Coordinator {
80+
let coordinator = ReportListCoordinator(navigationController: navigationController)
81+
coordinator.parentCoordinator = self
82+
coordinator.finishDelegate = self
83+
childCoordinators.append(coordinator)
84+
return coordinator
85+
}
86+
8087
}
8188

8289
extension SettingCoordinator: SettingCoordinatorInterface {
@@ -108,6 +115,11 @@ extension SettingCoordinator: SettingCoordinatorInterface {
108115
navigationController.present(webViewController, animated: true)
109116
}
110117

118+
func showReportList() {
119+
let coordinator = makeReportListCoordinator()
120+
coordinator.start()
121+
}
122+
111123
func finished() {
112124
navigationController.popViewController(animated: true)
113125
finishDelegate?.coordinatorDidFinish(childCoordinator: self)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// ReportListViewController.swift
3+
// Setting
4+
//
5+
// Created by 임영선 on 2023/02/16.
6+
// Copyright © 2023 Fitfty. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import Common
11+
12+
final public class ReportListViewController: UIViewController {
13+
14+
private let menuView = ReportMenuView()
15+
private var coordinator: ReportListCoordinatorInterface
16+
17+
public init(coordinator: ReportListCoordinatorInterface) {
18+
self.coordinator = coordinator
19+
super.init(nibName: nil, bundle: nil)
20+
}
21+
22+
required init?(coder: NSCoder) {
23+
fatalError("init(coder:) has not been implemented")
24+
}
25+
26+
public override func viewDidLoad() {
27+
super.viewDidLoad()
28+
setUp()
29+
}
30+
31+
private func setUp() {
32+
setConstraintsLayout()
33+
setNavigationBar()
34+
}
35+
36+
@objc func didTapBackButton(_ sender: Any?) {
37+
coordinator.dismiss()
38+
}
39+
40+
}
41+
42+
private extension ReportListViewController {
43+
44+
func setConstraintsLayout() {
45+
view.addSubviews(menuView)
46+
NSLayoutConstraint.activate([
47+
menuView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 5),
48+
menuView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 20),
49+
menuView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
50+
menuView.heightAnchor.constraint(equalToConstant: 20)
51+
])
52+
}
53+
54+
func setNavigationBar() {
55+
navigationController?.navigationBar.prefersLargeTitles = false
56+
navigationController?.navigationBar.isHidden = false
57+
58+
let cancelButton = UIBarButtonItem(
59+
image: CommonAsset.Images.btnArrowleft.image,
60+
style: .plain,
61+
target: self,
62+
action: #selector(didTapBackButton(_:))
63+
)
64+
navigationItem.leftBarButtonItem = cancelButton
65+
}
66+
67+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// ReportMenuView.swift
3+
// Setting
4+
//
5+
// Created by 임영선 on 2023/02/16.
6+
// Copyright © 2023 Fitfty. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import Common
11+
12+
final class ReportMenuView: UIView {
13+
14+
private lazy var emailLabel: UILabel = {
15+
let label = UILabel()
16+
label.text = "계정"
17+
label.font = FitftyFont.SFProDisplayBlack(size: 15).font
18+
return label
19+
}()
20+
21+
private lazy var detailReportLabel: UILabel = {
22+
let label = UILabel()
23+
label.text = "신고 사유"
24+
label.font = FitftyFont.SFProDisplayBlack(size: 15).font
25+
return label
26+
}()
27+
28+
private lazy var countLabel: UILabel = {
29+
let label = UILabel()
30+
label.text = "신고 횟수"
31+
label.font = FitftyFont.SFProDisplayBlack(size: 15).font
32+
return label
33+
}()
34+
35+
override init(frame: CGRect) {
36+
super.init(frame: frame)
37+
setConstraintsLayout()
38+
}
39+
40+
required init?(coder: NSCoder) {
41+
fatalError("init(coder:) has not been implemented")
42+
}
43+
44+
private func setConstraintsLayout() {
45+
addSubviews(emailLabel, detailReportLabel, countLabel)
46+
NSLayoutConstraint.activate([
47+
emailLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
48+
emailLabel.leadingAnchor.constraint(equalTo: leadingAnchor),
49+
detailReportLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
50+
detailReportLabel.leadingAnchor.constraint(equalTo: emailLabel.trailingAnchor, constant: 50),
51+
countLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
52+
countLabel.leadingAnchor.constraint(equalTo: detailReportLabel.trailingAnchor, constant: 40)
53+
])
54+
}
55+
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private extension SettingViewController {
132132
private func applySnapshot() {
133133
var snapshot = NSDiffableDataSourceSnapshot<SettingViewSection, Setting>()
134134
snapshot.appendSections([.setting])
135-
snapshot.appendItems(Setting.settings())
135+
snapshot.appendItems(Setting.adminSettings())
136136
dataSource?.apply(snapshot)
137137
}
138138
}
@@ -156,6 +156,10 @@ extension SettingViewController: UICollectionViewDelegate {
156156
case .privacyRule:
157157
coordinator?.showPrivacyRule()
158158

159+
case .userReport,
160+
.postReport:
161+
coordinator?.showReportList()
162+
159163
default: break
160164
}
161165
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// ReportListCoordinatorInterface.swift
3+
// Setting
4+
//
5+
// Created by 임영선 on 2023/02/16.
6+
// Copyright © 2023 Fitfty. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public protocol ReportListCoordinatorInterface: AnyObject {
12+
13+
func dismiss()
14+
15+
}

Fitfty/Projects/Setting/Sources/SettingCoordinatorInterface.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ public protocol SettingCoordinatorInterface: AnyObject {
1414
func showMyInfoSetting()
1515
func showTermsOfUse()
1616
func showPrivacyRule()
17+
func showReportList()
1718
func finished()
1819
}

Fitfty/Projects/Setting/Sources/Utility/Model/Setting.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ enum Setting {
2525
case gender
2626
case male
2727
case female
28+
29+
case userReport
30+
case postReport
2831
}
2932

3033
extension Setting {
@@ -46,20 +49,26 @@ extension Setting {
4649
case .gender: return "성별"
4750
case .male: return "남성"
4851
case .female: return "여성"
52+
case .userReport: return "계정 신고 목록"
53+
case .postReport: return "게시글 신고 목록"
4954
}
5055
}
5156

5257
var isNextPage: Bool {
5358
switch self {
54-
case .profile, .myInfo, .termsOfUse, .privacyRule: return true
59+
case .profile, .myInfo, .termsOfUse, .privacyRule, .postReport, .userReport: return true
5560
default: return false
5661
}
5762
}
5863

59-
static func settings() -> [Setting] {
64+
static func userSettings() -> [Setting] {
6065
return [.profile, .myInfo, .termsOfUse, .privacyRule]
6166
}
6267

68+
static func adminSettings() -> [Setting] {
69+
return [.profile, .myInfo, .termsOfUse, .privacyRule, .userReport, .postReport]
70+
}
71+
6372
static func etc() -> [Setting] {
6473
return [.logout, .membershipWithdrawal]
6574
}

0 commit comments

Comments
 (0)