Skip to content

Commit 4f9bf52

Browse files
authored
Merge pull request #125 from lee-yeonwoo/#117-삭제기능구현
[Feat] #117 �- 신고폼 구현
2 parents 9225169 + ac66b80 commit 4f9bf52

7 files changed

Lines changed: 105 additions & 2 deletions

File tree

Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum ImageLiterals {
4242
static var icAlert: UIImage { .load(named: "ic_alert") }
4343
static var icLocationOverlay: UIImage { .load(named: "ic_location_overlay") }
4444
static var icLogoCircle: UIImage { .load(named: "ic_logo_circle") }
45+
static var icMore: UIImage { .load(named: "ic_more") }
4546

4647
// img
4748
static var imgBackground: UIImage { .load(named: "img_background") }
@@ -71,6 +72,7 @@ enum ImageLiterals {
7172
static var imgKakaoLogin: UIImage { .load(named: "img_kakao_login")}
7273
}
7374

75+
7476
extension UIImage {
7577
static func load(named imageName: String) -> UIImage {
7678
guard let image = UIImage(named: imageName, in: nil, compatibleWith: nil) else {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "Frame 9479.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"filename" : "Frame 9479@2x.png",
10+
"idiom" : "universal",
11+
"scale" : "2x"
12+
},
13+
{
14+
"filename" : "Frame 9479@3x.png",
15+
"idiom" : "universal",
16+
"scale" : "3x"
17+
}
18+
],
19+
"info" : {
20+
"author" : "xcode",
21+
"version" : 1
22+
}
23+
}
203 Bytes
Loading
313 Bytes
Loading
482 Bytes
Loading

Runnect-iOS/Runnect-iOS/Global/UIComponents/CustomNavigationBar.swift

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ enum NaviType {
1919
case title // 좌측 타이틀
2020
case titleWithLeftButton // 뒤로가기 버튼 + 중앙 타이틀
2121
case search // 검색창
22+
case report // 신고
2223
}
2324

2425
final class CustomNavigationBar: UIView {
@@ -30,13 +31,15 @@ final class CustomNavigationBar: UIView {
3031
private var vc: UIViewController?
3132
private var leftButtonClosure: (() -> Void)?
3233
private var rightButtonClosure: (() -> Void)?
34+
private var reportButtonClosure: (() -> Void)?
3335

3436
// MARK: - UI Components
3537

3638
private let leftTitleLabel = UILabel()
3739
private let centerTitleLabel = UILabel()
3840
private let leftButton = UIButton()
3941
private let rightButton = UIButton()
42+
private let reportButton = UIButton()
4043
private let textField = UITextField()
4144

4245
// MARK: - initialization
@@ -62,13 +65,14 @@ extension CustomNavigationBar {
6265
UIView.animate(withDuration: 0.1,
6366
delay: 0,
6467
options: .curveEaseInOut) {
65-
[self.leftTitleLabel, self.centerTitleLabel, self.leftButton, self.rightButton].forEach { $0.alpha = isHidden ? 0 : 1 }
68+
[self.leftTitleLabel, self.centerTitleLabel, self.leftButton, self.rightButton, self.reportButton].forEach { $0.alpha = isHidden ? 0 : 1 }
6669
}
6770
}
6871

6972
private func setAddTarget() {
7073
self.leftButton.addTarget(self, action: #selector(popToPreviousVC), for: .touchUpInside)
7174
self.rightButton.addTarget(self, action: #selector(searchLocation), for: .touchUpInside)
75+
self.reportButton.addTarget(self, action: #selector(reportLocation), for: .touchUpInside)
7276
}
7377

7478
private func setDelegate() {
@@ -136,6 +140,24 @@ extension CustomNavigationBar {
136140
self.textField.resignFirstResponder()
137141
return self
138142
}
143+
144+
@discardableResult
145+
func resetReportButtonAction(_ closure: (() -> Void)? = nil) -> Self {
146+
self.reportButtonClosure = closure
147+
self.reportButton.removeTarget(self, action: nil, for: .touchUpInside)
148+
if closure != nil {
149+
self.reportButton.addTarget(self, action: #selector(reportButtonDidTap), for: .touchUpInside)
150+
} else {
151+
self.setAddTarget()
152+
}
153+
return self
154+
}
155+
156+
@discardableResult
157+
func hideReportButton() -> Self {
158+
self.reportButton.isHidden = true
159+
return self
160+
}
139161
}
140162

141163
// MARK: - @objc Function
@@ -151,13 +173,21 @@ extension CustomNavigationBar {
151173
delegate?.searchButtonDidTap(text: text)
152174
}
153175

176+
@objc private func reportLocation() {
177+
self.reportButtonClosure?()
178+
179+
}
180+
154181
@objc private func rightButtonDidTap() {
155182
self.rightButtonClosure?()
156183
}
157184

158185
@objc private func leftButtonDidTap() {
159186
self.leftButtonClosure?()
160187
}
188+
@objc private func reportButtonDidTap() {
189+
self.reportButtonClosure?()
190+
}
161191
}
162192

163193
// MARK: - UI & Layout
@@ -187,6 +217,10 @@ extension CustomNavigationBar {
187217
textField.textColor = .g1
188218
textField.addLeftPadding(width: 2)
189219
rightButton.setImage(ImageLiterals.icSearch, for: .normal)
220+
221+
case .report:
222+
reportButton.setImage(ImageLiterals.icArrowBack, for: .normal)
223+
reportButton.isHidden = false
190224
}
191225
}
192226

@@ -198,6 +232,8 @@ extension CustomNavigationBar {
198232
setTitleWithLeftButtonLayout()
199233
case .search:
200234
setSearchLayout()
235+
case .report:
236+
setReportButtonLayout()
201237
}
202238
}
203239

@@ -245,6 +281,21 @@ extension CustomNavigationBar {
245281
make.trailing.equalTo(rightButton.snp.leading)
246282
}
247283
}
284+
285+
private func setReportButtonLayout() {
286+
self.addSubviews(leftButton, reportButton)
287+
leftButton.snp.makeConstraints { make in
288+
make.centerY.equalToSuperview()
289+
make.leading.equalToSuperview()
290+
make.width.height.equalTo(48)
291+
}
292+
reportButton.snp.makeConstraints { make in
293+
make.centerY.equalToSuperview()
294+
make.trailing.equalToSuperview()
295+
make.width.height.equalTo(48)
296+
}
297+
298+
}
248299
}
249300

250301
// MARK: - UITextFieldDelegate

Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ final class CourseDetailVC: UIViewController {
2929

3030
// MARK: - UI Components
3131
private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton)
32+
private let moreButton = UIButton(type: .system).then {
33+
$0.setImage(ImageLiterals.icMore, for: .normal)
34+
$0.tintColor = .g1
35+
}
3236
private lazy var middleScorollView = UIScrollView().then {
3337
$0.isScrollEnabled = true
3438
$0.showsVerticalScrollIndicator = false
@@ -121,6 +125,22 @@ extension CourseDetailVC {
121125
getCourseDetailWithPath(courseId: courseId)
122126
}
123127

128+
@objc func moreButtonDidTap() {
129+
130+
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
131+
132+
let saveAction = UIAlertAction(title: "저장하기", style: .default, handler: nil)
133+
let reportAction = UIAlertAction(title: "신고하기", style: .destructive, handler: {(_: UIAlertAction!) in
134+
//report action
135+
})
136+
let cancelAction = UIAlertAction(title: "닫기", style: .cancel, handler: nil)
137+
138+
[ saveAction, reportAction, cancelAction ].forEach { alertController.addAction($0) }
139+
140+
present(alertController, animated: true, completion: nil)
141+
142+
}
143+
124144
private func pushToCountDownVC() {
125145
guard let courseModel = self.courseModel,
126146
let path = courseModel.path,
@@ -170,6 +190,8 @@ extension CourseDetailVC {
170190

171191
private func setAddTarget() {
172192
likeButton.addTarget(self, action: #selector(likeButtonDidTap), for: .touchUpInside)
193+
194+
moreButton.addTarget(self, action: #selector(moreButtonDidTap), for: .touchUpInside)
173195
}
174196
}
175197

@@ -178,11 +200,16 @@ extension CourseDetailVC {
178200
// MARK: - Layout Helpers
179201
private func setNavigationBar() {
180202
view.addSubview(navibar)
181-
203+
view.addSubview(moreButton)
182204
navibar.snp.makeConstraints { make in
183205
make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide)
184206
make.height.equalTo(48)
185207
}
208+
moreButton.snp.makeConstraints { make in
209+
make.trailing.equalTo(self.view.safeAreaLayoutGuide).inset(16)
210+
make.centerY.equalTo(navibar)
211+
}
212+
186213
}
187214

188215
private func setUI() {

0 commit comments

Comments
 (0)