diff --git a/Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift b/Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift index 2c61a6e8..1bcbf738 100644 --- a/Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift +++ b/Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift @@ -49,6 +49,9 @@ enum ImageLiterals { static var icFollowButton: UIImage {.load(named: "ic_follow_button")} static var icFollowedButton: UIImage {.load(named: "ic_followed_button")} static var icShareButton: UIImage {.load(named: "ic_share")} + static var icModify: UIImage {.load(named: "ic_modify")} + static var icRemove: UIImage {.load(named: "ic_remove")} + static var icReport: UIImage {.load(named: "ic_report")} // img static var imgBackground: UIImage { .load(named: "img_background") } diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Contents.json b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Contents.json new file mode 100644 index 00000000..df240cf1 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "Vector.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Vector@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Vector@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Vector.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Vector.png new file mode 100644 index 00000000..002713a2 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Vector.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Vector@2x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Vector@2x.png new file mode 100644 index 00000000..949309a5 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Vector@2x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Vector@3x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Vector@3x.png new file mode 100644 index 00000000..b6ceced0 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_modify.imageset/Vector@3x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Contents.json b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Contents.json new file mode 100644 index 00000000..df240cf1 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "Vector.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Vector@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Vector@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Vector.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Vector.png new file mode 100644 index 00000000..508320ed Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Vector.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Vector@2x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Vector@2x.png new file mode 100644 index 00000000..6cd5a2b1 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Vector@2x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Vector@3x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Vector@3x.png new file mode 100644 index 00000000..b2f60d42 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_remove.imageset/Vector@3x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Contents.json b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Contents.json new file mode 100644 index 00000000..b4671c4f --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "Group 9565.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Group 9565@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Group 9565@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Group 9565.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Group 9565.png new file mode 100644 index 00000000..e4ddd726 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Group 9565.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Group 9565@2x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Group 9565@2x.png new file mode 100644 index 00000000..596dad0d Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Group 9565@2x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Group 9565@3x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Group 9565@3x.png new file mode 100644 index 00000000..8a4a084e Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_report.imageset/Group 9565@3x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift index bab77f65..ab2aa6c6 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift @@ -17,6 +17,7 @@ import FirebaseCore import FirebaseDynamicLinks import KakaoSDKShare import KakaoSDKTemplate +import DropDown final class CourseDetailVC: UIViewController { @@ -195,39 +196,33 @@ extension CourseDetailVC { @objc func moreButtonDidTap() { guard let isMyCourse = self.isMyCourse, let uploadedCourseDetailModel = self.uploadedCourseDetailModel else { return } - let cancelAction = UIAlertAction(title: "닫기", style: .cancel, handler: nil) + let items = isMyCourse ? ["수정하기", "삭제하기"] : ["신고하기"] + let imageArray: [UIImage] = isMyCourse ? [ImageLiterals.icModify, ImageLiterals.icRemove] : [ImageLiterals.icReport] - if isMyCourse == true { - let editAlertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) - - let editAction = UIAlertAction(title: "수정하기", style: .default, handler: {(_: UIAlertAction!) in - let courseEditVC = CourseEditVC() - courseEditVC.loadData(model: uploadedCourseDetailModel) - courseEditVC.publicCourseId = self.publicCourseId - self.navigationController?.pushViewController(courseEditVC, animated: false) - }) - let deleteAlertVC = RNAlertVC(description: "러닝 기록을 정말로 삭제하시겠어요?").setButtonTitle("취소", "삭제하기") - deleteAlertVC.rightButtonTapAction = { [weak self] in - deleteAlertVC.dismiss(animated: false) - self?.deleteCourse() - } - deleteAlertVC.modalPresentationStyle = .overFullScreen - let deleteAction = UIAlertAction(title: "삭제하기", style: .destructive, handler: {(_: UIAlertAction!) in - self.present(deleteAlertVC, animated: false, completion: nil) - }) - [ editAction, deleteAction, cancelAction].forEach { editAlertController.addAction($0) } - present(editAlertController, animated: false, completion: nil) - } else { - // 신고폼 올라오는 거(유저아이디가 내가 아닌 경우) - let reportAlertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) - let formUrl = NSURL(string: "https://docs.google.com/forms/d/e/1FAIpQLSek2rkClKfGaz1zwTEHX3Oojbq_pbF3ifPYMYezBU0_pe-_Tg/viewform") - let formSafariView: SFSafariViewController = SFSafariViewController(url: formUrl! as URL) - let reportAction = UIAlertAction(title: "신고하기", style: .destructive, handler: {(_: UIAlertAction!) in - self.present(formSafariView, animated: true, completion: nil) - }) - [ reportAction, cancelAction ].forEach { reportAlertController.addAction($0) } - present(reportAlertController, animated: true, completion: nil) + let menu = DropDown().then { + $0.anchorView = moreButton + $0.backgroundColor = .w1 + $0.bottomOffset = CGPoint(x: -136, y: moreButton.bounds.height - 10) + $0.width = 170 + $0.cellHeight = 40 + $0.cornerRadius = 12 + $0.dismissMode = .onTap + $0.separatorColor = UIColor(hex: "#EBEBEB") + $0.dataSource = items + $0.textFont = .b3 } + + menu.customCellConfiguration = { (index: Index, _: String, cell: DropDownCell) -> Void in + let lastDividerLineRemove = UIView(frame: CGRect(origin: CGPoint(x: 0, y: isMyCourse ? 79 : 39), size: CGSize(width: 170, height: 10))) + lastDividerLineRemove.backgroundColor = .white + cell.separatorInset = .zero + cell.dropDownImage.image = imageArray[index] + cell.addSubview(lastDividerLineRemove) + } + + dropDownTouchAction(menu: menu, uploadedCourseDetailModel: uploadedCourseDetailModel, isMyCourse: isMyCourse) + + menu.show() } private func pushToCountDownVC() { @@ -534,3 +529,45 @@ extension CourseDetailVC { } } } + +// MARK: - DropDown + +extension CourseDetailVC { + private func dropDownTouchAction(menu: DropDown, uploadedCourseDetailModel: UploadedCourseDetailResponseDto, isMyCourse: Bool) { + + DropDown.appearance().textColor = .g1 + DropDown.appearance().selectionBackgroundColor = .w1 + DropDown.appearance().shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.2) + DropDown.appearance().shadowOpacity = 1 + DropDown.appearance().shadowRadius = 10 + + menu.selectionAction = { [unowned self] (_, item) in + menu.clearSelection() + + switch item { + case "수정하기": + let courseEditVC = CourseEditVC() + courseEditVC.loadData(model: uploadedCourseDetailModel) + courseEditVC.publicCourseId = self.publicCourseId + self.navigationController?.pushViewController(courseEditVC, animated: false) + case "삭제하기": + let deleteAlertVC = RNAlertVC(description: "러닝 기록을 정말로 삭제하시겠어요?").setButtonTitle("취소", "삭제하기") + deleteAlertVC.modalPresentationStyle = .overFullScreen + deleteAlertVC.rightButtonTapAction = { + deleteAlertVC.dismiss(animated: false) + self.deleteCourse() + self.navigationController?.popViewController(animated: true) + } + self.present(deleteAlertVC, animated: false) + case "신고하기": + if !isMyCourse { + let formUrl = NSURL(string: "https://docs.google.com/forms/d/e/1FAIpQLSek2rkClKfGaz1zwTEHX3Oojbq_pbF3ifPYMYezBU0_pe-_Tg/viewform") + let formSafariView: SFSafariViewController = SFSafariViewController(url: formUrl! as URL) + self.present(formSafariView, animated: true, completion: nil) + } + default: + self.showToast(message: "없는 명령어 입니다.") + } + } + } +} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseEditVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseEditVC.swift index 4a5176db..c175793f 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseEditVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseEditVC.swift @@ -392,7 +392,8 @@ extension CourseEditVC { case .success(let result): let status = result.statusCode if 200..<300 ~= status { - self.showToast(message: "게시글 수정이 완료되었어요") + self.navigationController?.popViewController(animated: true) /// 추가한 부분 수정 필요 + showToast(message: "게시글 수정이 완료되었어요") } if status >= 400 { print("400 error") diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/UploadedCourseInfoVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/UploadedCourseInfoVC.swift index 4a990933..405115cc 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/UploadedCourseInfoVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/UploadedCourseInfoVC.swift @@ -342,6 +342,7 @@ extension UploadedCourseInfoVC { let responseDto = try result.map(BaseResponse.self) guard let data = responseDto.data else { return } self.setData(courseList: data.publicCourses) + UploadedCourseInfoCollectionView.reloadData() } catch { print(error.localizedDescription) }