Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum ImageLiterals {
static var icAlert: UIImage { .load(named: "ic_alert") }
static var icLocationOverlay: UIImage { .load(named: "ic_location_overlay") }
static var icLogoCircle: UIImage { .load(named: "ic_logo_circle") }
static var icMore: UIImage { .load(named: "ic_more") }

// img
static var imgBackground: UIImage { .load(named: "img_background") }
Expand Down Expand Up @@ -69,6 +70,7 @@ enum ImageLiterals {
static var imgAd: UIImage { .load(named: "img_ad") }
}


extension UIImage {
static func load(named imageName: String) -> UIImage {
guard let image = UIImage(named: imageName, in: nil, compatibleWith: nil) else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Frame 9479.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame 9479@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame 9479@3x.png",
"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.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum NaviType {
case title // 좌측 타이틀
case titleWithLeftButton // 뒤로가기 버튼 + 중앙 타이틀
case search // 검색창
case report // 신고
}

final class CustomNavigationBar: UIView {
Expand All @@ -30,13 +31,15 @@ final class CustomNavigationBar: UIView {
private var vc: UIViewController?
private var leftButtonClosure: (() -> Void)?
private var rightButtonClosure: (() -> Void)?
private var reportButtonClosure: (() -> Void)?

// MARK: - UI Components

private let leftTitleLabel = UILabel()
private let centerTitleLabel = UILabel()
private let leftButton = UIButton()
private let rightButton = UIButton()
private let reportButton = UIButton()
private let textField = UITextField()

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

private func setAddTarget() {
self.leftButton.addTarget(self, action: #selector(popToPreviousVC), for: .touchUpInside)
self.rightButton.addTarget(self, action: #selector(searchLocation), for: .touchUpInside)
self.reportButton.addTarget(self, action: #selector(reportLocation), for: .touchUpInside)
}

private func setDelegate() {
Expand Down Expand Up @@ -136,6 +140,24 @@ extension CustomNavigationBar {
self.textField.resignFirstResponder()
return self
}

@discardableResult
func resetReportButtonAction(_ closure: (() -> Void)? = nil) -> Self {
self.reportButtonClosure = closure
self.reportButton.removeTarget(self, action: nil, for: .touchUpInside)
if closure != nil {
self.reportButton.addTarget(self, action: #selector(reportButtonDidTap), for: .touchUpInside)
} else {
self.setAddTarget()
}
return self
}

@discardableResult
func hideReportButton() -> Self {
self.reportButton.isHidden = true
return self
}
}

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

@objc private func reportLocation() {
self.reportButtonClosure?()

}

@objc private func rightButtonDidTap() {
self.rightButtonClosure?()
}

@objc private func leftButtonDidTap() {
self.leftButtonClosure?()
}
@objc private func reportButtonDidTap() {
self.reportButtonClosure?()
}
}

// MARK: - UI & Layout
Expand Down Expand Up @@ -187,6 +217,10 @@ extension CustomNavigationBar {
textField.textColor = .g1
textField.addLeftPadding(width: 2)
rightButton.setImage(ImageLiterals.icSearch, for: .normal)

case .report:
reportButton.setImage(ImageLiterals.icArrowBack, for: .normal)
reportButton.isHidden = false
}
}

Expand All @@ -198,6 +232,8 @@ extension CustomNavigationBar {
setTitleWithLeftButtonLayout()
case .search:
setSearchLayout()
case .report:
setReportButtonLayout()
}
}

Expand Down Expand Up @@ -245,6 +281,21 @@ extension CustomNavigationBar {
make.trailing.equalTo(rightButton.snp.leading)
}
}

private func setReportButtonLayout() {
self.addSubviews(leftButton, reportButton)
leftButton.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.leading.equalToSuperview()
make.width.height.equalTo(48)
}
reportButton.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.trailing.equalToSuperview()
make.width.height.equalTo(48)
}

}
}

// MARK: - UITextFieldDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ final class CourseDetailVC: UIViewController {

// MARK: - UI Components
private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton)
private let moreButton = UIButton(type: .system).then {
$0.setImage(ImageLiterals.icMore, for: .normal)
$0.tintColor = .g1
}
private lazy var middleScorollView = UIScrollView().then {
$0.isScrollEnabled = true
$0.showsVerticalScrollIndicator = false
Expand Down Expand Up @@ -127,6 +131,22 @@ extension CourseDetailVC {
getCourseDetailWithPath(courseId: courseId)
}

@objc func moreButtonDidTap() {

let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

let saveAction = UIAlertAction(title: "저장하기", style: .default, handler: nil)
let reportAction = UIAlertAction(title: "신고하기", style: .destructive, handler: {(_: UIAlertAction!) in
//report action
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

신고폼은 슬랙에 시원님이 올려주신 구글 폼 링크를 연결하면 됩니다. 신고하기 버튼 클릭하면 사파리가 열리면서 해당 구글폼으로 가지도록!

})
let cancelAction = UIAlertAction(title: "닫기", style: .cancel, handler: nil)

[ saveAction, reportAction, cancelAction ].forEach { alertController.addAction($0) }

present(alertController, animated: true, completion: nil)

}

private func pushToCountDownVC() {
guard let courseModel = self.courseModel,
let path = courseModel.path,
Expand Down Expand Up @@ -176,6 +196,8 @@ extension CourseDetailVC {

private func setAddTarget() {
likeButton.addTarget(self, action: #selector(likeButtonDidTap), for: .touchUpInside)

moreButton.addTarget(self, action: #selector(moreButtonDidTap), for: .touchUpInside)
}
}

Expand All @@ -184,11 +206,16 @@ extension CourseDetailVC {
// MARK: - Layout Helpers
private func setNavigationBar() {
view.addSubview(navibar)

view.addSubview(moreButton)
navibar.snp.makeConstraints { make in
make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide)
make.height.equalTo(48)
}
moreButton.snp.makeConstraints { make in
make.trailing.equalTo(self.view.safeAreaLayoutGuide).inset(16)
make.centerY.equalTo(navibar)
}

}

private func setUI() {
Expand Down