diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index a0f0103a..17976884 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -108,11 +108,9 @@ CEEC6B4B2961D89700D00E1E /* CustomNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEEC6B4A2961D89700D00E1E /* CustomNavigationBar.swift */; }; DA20D83F296696A000F1581F /* MapModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D83E296696A000F1581F /* MapModel.swift */; }; DA20D841296696C300F1581F /* MapCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D840296696C300F1581F /* MapCollectionViewCell.swift */; }; - DA20D8432966977D00F1581F /* SearchResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D8422966977D00F1581F /* SearchResultViewController.swift */; }; - DA20D8452966979100F1581F /* DiscoveryDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D8442966979100F1581F /* DiscoveryDetailViewController.swift */; }; - DA20D847296697A600F1581F /* PlusDetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D846296697A600F1581F /* PlusDetailVC.swift */; }; - DA20D849296697B400F1581F /* UploadVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D848296697B400F1581F /* UploadVC.swift */; }; - DA20D84B296697C600F1581F /* UploadResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D84A296697C600F1581F /* UploadResultViewController.swift */; }; + DA20D8432966977D00F1581F /* SearchResultVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D8422966977D00F1581F /* SearchResultVC.swift */; }; + DA20D847296697A600F1581F /* MyCourseSelectVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D846296697A600F1581F /* MyCourseSelectVC.swift */; }; + DA20D849296697B400F1581F /* CourseUploadVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D848296697B400F1581F /* CourseUploadVC.swift */; }; DA20D84E2966A9B300F1581F /* SearchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D84D2966A9B300F1581F /* SearchVC.swift */; }; DA20D8502966C0D500F1581F /* MapCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D84F2966C0D500F1581F /* MapCollectionViewController.swift */; }; /* End PBXBuildFile section */ @@ -231,11 +229,9 @@ CEEC6B4A2961D89700D00E1E /* CustomNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomNavigationBar.swift; sourceTree = ""; }; DA20D83E296696A000F1581F /* MapModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapModel.swift; sourceTree = ""; }; DA20D840296696C300F1581F /* MapCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapCollectionViewCell.swift; sourceTree = ""; }; - DA20D8422966977D00F1581F /* SearchResultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultViewController.swift; sourceTree = ""; }; - DA20D8442966979100F1581F /* DiscoveryDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoveryDetailViewController.swift; sourceTree = ""; }; - DA20D846296697A600F1581F /* PlusDetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlusDetailVC.swift; sourceTree = ""; }; - DA20D848296697B400F1581F /* UploadVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadVC.swift; sourceTree = ""; }; - DA20D84A296697C600F1581F /* UploadResultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadResultViewController.swift; sourceTree = ""; }; + DA20D8422966977D00F1581F /* SearchResultVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultVC.swift; sourceTree = ""; }; + DA20D846296697A600F1581F /* MyCourseSelectVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCourseSelectVC.swift; sourceTree = ""; }; + DA20D848296697B400F1581F /* CourseUploadVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseUploadVC.swift; sourceTree = ""; }; DA20D84D2966A9B300F1581F /* SearchVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchVC.swift; sourceTree = ""; }; DA20D84F2966C0D500F1581F /* MapCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapCollectionViewController.swift; sourceTree = ""; }; E837271A78E1C0A0C30789BF /* Pods-Runnect-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runnect-iOS.release.xcconfig"; path = "Target Support Files/Pods-Runnect-iOS/Pods-Runnect-iOS.release.xcconfig"; sourceTree = ""; }; @@ -475,11 +471,9 @@ isa = PBXGroup; children = ( CEEC6B432961C59F00D00E1E /* .gitkeep */, - DA20D8422966977D00F1581F /* SearchResultViewController.swift */, - DA20D8442966979100F1581F /* DiscoveryDetailViewController.swift */, - DA20D846296697A600F1581F /* PlusDetailVC.swift */, - DA20D848296697B400F1581F /* UploadVC.swift */, - DA20D84A296697C600F1581F /* UploadResultViewController.swift */, + DA20D8422966977D00F1581F /* SearchResultVC.swift */, + DA20D846296697A600F1581F /* MyCourseSelectVC.swift */, + DA20D848296697B400F1581F /* CourseUploadVC.swift */, DA20D84D2966A9B300F1581F /* SearchVC.swift */, ); path = Views; @@ -1000,7 +994,7 @@ A3BC2F2B2962C3D500198261 /* GoalRewardInfoVC.swift in Sources */, CE665606295D91C500C64E12 /* makeVibrate.swift in Sources */, CE66560A295D924A00C64E12 /* Result+.swift in Sources */, - DA20D847296697A600F1581F /* PlusDetailVC.swift in Sources */, + DA20D847296697A600F1581F /* MyCourseSelectVC.swift in Sources */, CE66560E295D92A500C64E12 /* setStatusBarBackgroundColor.swift in Sources */, CE9291292965E01D0010959C /* RNTimeFormatter.swift in Sources */, CE0C23792966D6AF00B45063 /* ViewPager.swift in Sources */, @@ -1012,7 +1006,6 @@ CE4545C9295D7AF4003201E1 /* AppDelegate.swift in Sources */, CE6655C8295D849F00C64E12 /* StringLiterals.swift in Sources */, CEEC6B3E2961C53700D00E1E /* CourseDiscoveryVC.swift in Sources */, - DA20D8452966979100F1581F /* DiscoveryDetailViewController.swift in Sources */, CE6655E0295D87D200C64E12 /* UIDevice+.swift in Sources */, CE17F0382961BF8B00E1DED0 /* FontLiterals.swift in Sources */, CE6655E8295D889600C64E12 /* UISwitch+.swift in Sources */, @@ -1055,15 +1048,14 @@ CEEC6B402961C55000D00E1E /* MyPageVC.swift in Sources */, CE665608295D921500C64E12 /* setImage.swift in Sources */, CE146770296568DC00DCEA1B /* RunTrackingVC.swift in Sources */, - DA20D849296697B400F1581F /* UploadVC.swift in Sources */, + DA20D849296697B400F1581F /* CourseUploadVC.swift in Sources */, CE665612295D92E400C64E12 /* UserDefaultWrapper.swift in Sources */, A3BC2F3A2963D0ED00198261 /* ActivityRecordInfoTVC.swift in Sources */, CE665610295D92C200C64E12 /* setTextLineHeight.swift in Sources */, CE6655E2295D87EB00C64E12 /* UIImage+.swift in Sources */, A3BC2F322962E0DB00198261 /* GoalRewardInfoModel.swift in Sources */, CEC2A68C2962AE1B00160BF7 /* RNStartMarker.swift in Sources */, - DA20D84B296697C600F1581F /* UploadResultViewController.swift in Sources */, - DA20D8432966977D00F1581F /* SearchResultViewController.swift in Sources */, + DA20D8432966977D00F1581F /* SearchResultVC.swift in Sources */, CE5875A4296015D2005D967E /* Encodable+.swift in Sources */, A3BC2F4129667A0D00198261 /* NicknameEditorVC.swift in Sources */, CE0C23742966D62A00B45063 /* PagedView.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift index 897a2279..a3156c7b 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift @@ -49,57 +49,56 @@ final class CourseDiscoveryVC: UIViewController { let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.backgroundColor = .clear collectionView.translatesAutoresizingMaskIntoConstraints = false - collectionView.isScrollEnabled = true + collectionView.isScrollEnabled = false collectionView.showsVerticalScrollIndicator = false - collectionView.delegate = self - collectionView.dataSource = self return collectionView }() // MARK: - Constants - var mapList: [MapModel] = [ - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구") - ] - final let inset: UIEdgeInsets = UIEdgeInsets(top: 10, left: 16, bottom: 0, right: 16) - final let lineSpacing: CGFloat = 10 - final let interItemSpacing: CGFloat = 20 - final let height: CGFloat = 164 + final let collectionViewInset = UIEdgeInsets(top: 28, left: 16, bottom: 28, right: 16) + final let itemSpacing: CGFloat = 10 + final let lineSpacing: CGFloat = 20 + + // MARK: - View Life Cycle override func viewDidLoad () { super.viewDidLoad() register() setNavigationBar() + setDelegate() layout() setAddTarget() + self.tabBarController?.tabBar.isHidden = false } } // MARK: - Methods extension CourseDiscoveryVC { + + private func setDelegate() { + mapCollectionView.delegate = self + mapCollectionView.dataSource = self + } + private func register() { + mapCollectionView.register(CourseListCVC.self, + forCellWithReuseIdentifier: CourseListCVC.className) + } private func setAddTarget() { - self.searchButton.addTarget(self, action: #selector(presentToSearchVC), for: .touchUpInside) - self.plusButton.addTarget(self, action: #selector(presentToDiscoveryVC), for: .touchUpInside) + self.searchButton.addTarget(self, action: #selector(pushToSearchVC), for: .touchUpInside) + self.plusButton.addTarget(self, action: #selector(pushToDiscoveryVC), for: .touchUpInside) } } // MARK: - @objc Function extension CourseDiscoveryVC { - @objc private func presentToSearchVC() { + @objc private func pushToSearchVC() { let nextVC = SearchVC() - nextVC.modalPresentationStyle = .overFullScreen - self.present(nextVC, animated: true) + self.navigationController?.pushViewController(nextVC, animated: true) } - @objc private func presentToDiscoveryVC() { - let nextVC = PlusDetailVC() + @objc private func pushToDiscoveryVC() { + let nextVC = MyCourseSelectVC() self.navigationController?.pushViewController(nextVC, animated: true) } } @@ -165,43 +164,44 @@ extension CourseDiscoveryVC { make.bottom.equalTo(self.view.safeAreaLayoutGuide).inset(20) } } - // MARK: - register - - private func register() { - mapCollectionView.register(MapCollectionViewCell.self, forCellWithReuseIdentifier: MapCollectionViewCell.identifier) - } } - // MARK: - UICollectionViewDelegateFlowLayout +// MARK: - UICollectionViewDelegate, UICollectionViewDataSource - extension CourseDiscoveryVC: UICollectionViewDelegateFlowLayout { - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let screenWidth = UIScreen.main.bounds.width - let doubleCellWidth = screenWidth - inset.left - inset.right - interItemSpacing - return CGSize(width: doubleCellWidth / 2, height: 164) - } - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { - return lineSpacing - } - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { - return interItemSpacing - } - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - return inset - } +extension CourseDiscoveryVC: UICollectionViewDelegate, UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 15 } - // MARK: - UICollectionViewDataSource -extension CourseDiscoveryVC: UICollectionViewDataSource { - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return mapList.count - } - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let mapCell = collectionView.dequeueReusableCell( - withReuseIdentifier: MapCollectionViewCell.identifier, for: indexPath) - as? MapCollectionViewCell else { return UICollectionViewCell() } - mapCell.dataBind(model: mapList[indexPath.item]) - - return mapCell - } + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CourseListCVC.className, + for: indexPath) + as? CourseListCVC else { return UICollectionViewCell() } + cell.setCellType(type: .all) + return cell + } +} + +// MARK: - UICollectionViewDelegateFlowLayout + +extension CourseDiscoveryVC: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let cellWidth = (UIScreen.main.bounds.width - (self.itemSpacing + 2*self.collectionViewInset.left)) / 2 + let cellHeight = CourseListCVCType.getCellHeight(type: .all, cellWidth: cellWidth) + + return CGSize(width: cellWidth, height: cellHeight) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return self.collectionViewInset + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return self.itemSpacing } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return self.lineSpacing + } + +} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift new file mode 100644 index 00000000..c632e7f8 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift @@ -0,0 +1,262 @@ +// +// UploadViewController.swift +// Runnect-iOS +// +// Created by YEONOO on 2023/01/05. +// + +import UIKit + +import SnapKit +import Then + +class CourseUploadVC: UIViewController { + // MARK: - Properties + + private let courseTitleMaxLength = 20 + // MARK: - UI Components + + private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("코스 업로드") + private let buttonContainerView = UIView() + private let uploadButton = CustomButton(title: "업로드하기").setEnabled(false) + + private lazy var containerView = UIScrollView() + private let mapImageView = UIImageView().then { + $0.image = UIImage(named: "") + } + private let courseTitleTextField = UITextField().then { + $0.attributedPlaceholder = NSAttributedString( + string: "글 제목", + attributes: [.font: UIFont.h4, .foregroundColor: UIColor.g3] + ) + $0.font = .h4 + $0.textColor = .g1 + $0.addLeftPadding(width: 2) + } + private let dividerView = UIView().then { + $0.backgroundColor = .g5 + } + private let distanceInfoView = CourseDetailInfoView(title: "거리", description: "0.0km") + private let departureInfoView = CourseDetailInfoView(title: "출발지", description: "패스트파이브 을지로점") + private let placeholder = "코스에 대한 소개를 적어주세요.(난이도/풍경/지형)" + + let activityTextView = UITextView().then { + $0.font = .b4 + $0.backgroundColor = .m3 + $0.tintColor = .m1 + $0.textContainerInset = UIEdgeInsets(top: 14, left: 12, bottom: 14, right: 12) + } + + // MARK: - Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + setNavigationBar() + setUI() + setLayout() + setupTextView() + setAddTarget() + + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + self.tabBarController?.tabBar.isHidden = false + } + +} + +// MARK: - Methods + +extension CourseUploadVC { + + private func setAddTarget() { + self.uploadButton.addTarget(self, action: #selector(pushToCourseDiscoveryVC), for: .touchUpInside) + self.courseTitleTextField.addTarget(self, action: #selector(textFieldTextDidChange), for: .editingChanged) + } + private func setKeyboardNotification() { + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillShow), + name: UIResponder.keyboardWillShowNotification, + object: nil) + + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillHide), + name: UIResponder.keyboardWillHideNotification, + object: nil) + } + // 화면 터치 시 키보드 내리기 + private func setTapGesture() { + let tap = UITapGestureRecognizer(target: view, action: #selector(UIView.endEditing)) + tap.cancelsTouchesInView = false + view.addGestureRecognizer(tap) + } +} + +// MARK: - @objc Function + +extension CourseUploadVC { + @objc private func textFieldTextDidChange() { + guard let text = courseTitleTextField.text else { return } + + uploadButton.isEnabled = !text.isEmpty + + if text.count > courseTitleMaxLength { + let index = text.index(text.startIndex, offsetBy: courseTitleMaxLength) + let newString = text[text.startIndex.., with event: UIEvent?) { + self.view.endEditing(true) + } +} + +extension CourseUploadVC: UITextViewDelegate { + func textViewDidBeginEditing(_ textView: UITextView) { + if textView.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { + activityTextView.textColor = .g3 + activityTextView.text = placeholder + } else if textView.text == placeholder { + activityTextView.textColor = .g1 + activityTextView.text = nil + self.uploadButton.setEnabled(true) + } + } + + func textViewDidChange(_ textView: UITextView) { + if activityTextView.text.count > 150 { + activityTextView.deleteBackward() + } + } + func textViewDidEndEditing(_ textView: UITextView) { + if textView.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || textView.text == placeholder { + activityTextView.textColor = .g3 + activityTextView.text = placeholder + uploadButton.setColor(bgColor: .m3, disableColor: .g3) + } + } +} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/DiscoveryDetailViewController.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/DiscoveryDetailViewController.swift deleted file mode 100644 index 55b975cd..00000000 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/DiscoveryDetailViewController.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// DiscoveryDetailViewController.swift -// Runnect-iOS -// -// Created by YEONOO on 2023/01/05. -// - -import UIKit - -class DiscoveryDetailViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - - } -} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift new file mode 100644 index 00000000..5a0f4a5d --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift @@ -0,0 +1,176 @@ +// +// PlusDetailViewController.swift +// Runnect-iOS +// +// Created by YEONOO on 2023/01/05. +// + +import UIKit +import Then + +class MyCourseSelectVC: UIViewController { + + // MARK: - Properties + + private var selectedIndex: Int? + + // MARK: - UI Components + + private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("불러오기") + private let selectButton = CustomButton(title: "선택하기").setEnabled(false) + + // MARK: - collectionview + + private lazy var mapCollectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + layout.scrollDirection = .vertical + + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + collectionView.backgroundColor = .clear + collectionView.translatesAutoresizingMaskIntoConstraints = false + collectionView.isScrollEnabled = true + collectionView.showsVerticalScrollIndicator = false + return collectionView + }() + + // MARK: - Constants + + final let collectionViewInset = UIEdgeInsets(top: 28, left: 16, bottom: 28, right: 16) + final let itemSpacing: CGFloat = 10 + final let lineSpacing: CGFloat = 20 + + // MARK: - View Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + self.setUI() + self.setNavigationBar() + self.setLayout() + self.setDelegate() + self.register() + self.setAddTarget() + } + + override func viewWillAppear(_ animated: Bool) { + self.tabBarController?.tabBar.isHidden = true + } +} +// MARK: - Methods + +extension MyCourseSelectVC { + private func setDelegate() { + mapCollectionView.delegate = self + mapCollectionView.dataSource = self + } + + private func register() { + mapCollectionView.register(CourseListCVC.self, + forCellWithReuseIdentifier: CourseListCVC.className) + } + + private func setAddTarget() { + self.selectButton.addTarget(self, action: #selector(pushToUploadVC), for: .touchUpInside) + } +} + // MARK: - @objc Function + + extension MyCourseSelectVC { + @objc private func pushToUploadVC() { + let nextVC = CourseUploadVC() + self.navigationController?.pushViewController(nextVC, animated: true) + } + } + + // MARK: - naviVar Layout + +extension MyCourseSelectVC { + private func setNavigationBar() { + view.addSubview(navibar) + navibar.snp.makeConstraints { make in + make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.height.equalTo(48) + } +} + // MARK: - setUI + + private func setUI() { + view.backgroundColor = .w1 + self.tabBarController?.tabBar.isHidden = true + } + + // MARK: - Layout Helpers + + private func setLayout() { + view.addSubviews(selectButton, mapCollectionView) + self.view.bringSubviewToFront(selectButton) + + selectButton.snp.makeConstraints { make in + make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16) + make.height.equalTo(44) + make.bottom.equalToSuperview().inset(34) + } + + mapCollectionView.snp.makeConstraints { make in + make.top.equalTo(navibar.snp.bottom) + make.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.bottom.equalTo(selectButton.snp.top).inset(-25) + } + } +} +// MARK: - UICollectionViewDelegate, UICollectionViewDataSource + +extension MyCourseSelectVC: UICollectionViewDelegate, UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 15 + } + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + guard let cell = collectionView.cellForItem(at: indexPath) as? CourseListCVC else { return } + self.selectedIndex = indexPath.item + self.selectButton.setEnabled(true) + cell.selectCell(didSelect: true) + } + func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { + guard let cell = collectionView.cellForItem(at: indexPath) as? CourseListCVC else { return } + self.selectedIndex = nil + cell.selectCell(didSelect: false) + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CourseListCVC.className, + for: indexPath) + as? CourseListCVC else { return UICollectionViewCell() } + cell.setCellType(type: .title) + + if let selectedIndex = selectedIndex, selectedIndex == indexPath.item { + cell.selectCell(didSelect: true) + } else { + cell.selectCell(didSelect: false) + } + + return cell + } +} + +// MARK: - UICollectionViewDelegateFlowLayout + +extension MyCourseSelectVC: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let cellWidth = (UIScreen.main.bounds.width - (self.itemSpacing + 2*self.collectionViewInset.left)) / 2 + let cellHeight = CourseListCVCType.getCellHeight(type: .title, cellWidth: cellWidth) + + return CGSize(width: cellWidth, height: cellHeight) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return self.collectionViewInset + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return self.itemSpacing + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return self.lineSpacing + } + +} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/PlusDetailVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/PlusDetailVC.swift deleted file mode 100644 index 58eaa676..00000000 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/PlusDetailVC.swift +++ /dev/null @@ -1,166 +0,0 @@ -// -// PlusDetailViewController.swift -// Runnect-iOS -// -// Created by YEONOO on 2023/01/05. -// - -import UIKit -import Then - -class PlusDetailVC: UIViewController { - - // MARK: - UI Components - - private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("불러오기") - private let selectButton = CustomButton(title: "선택하기").setColor(bgColor: .g3, disableColor: .g3, textColor: .w1) - - // MARK: - collectionview - private lazy var containerView = UIScrollView() - private lazy var mapCollectionView: UICollectionView = { - let layout = UICollectionViewFlowLayout() - layout.scrollDirection = .vertical - - let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) - collectionView.backgroundColor = .clear - collectionView.translatesAutoresizingMaskIntoConstraints = false - collectionView.isScrollEnabled = true - collectionView.showsVerticalScrollIndicator = false - collectionView.delegate = self - collectionView.dataSource = self - return collectionView - }() - // MARK: - Constants - - var mapList: [MapModel] = [ - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구"), - MapModel(mapImage: "", title: "제목제목제목제목", location: "00동00구") - ] - final let inset: UIEdgeInsets = UIEdgeInsets(top: 10, left: 16, bottom: 0, right: 16) - final let lineSpacing: CGFloat = 10 - final let interItemSpacing: CGFloat = 20 - final let height: CGFloat = 164 - - // MARK: - Life Cycle - - override func viewDidLoad () { - super.viewDidLoad() - register() - setNavigationBar() - setUI() - setLayout() - setAddTarget() - } - - override func viewWillDisappear(_ animated: Bool) { - super.viewWillDisappear(animated) - self.tabBarController?.tabBar.isHidden = false - } -} -// MARK: - Methods - -extension PlusDetailVC { - private func setAddTarget() { - self.selectButton.addTarget(self, action: #selector(presentToUploadVC), for: .touchUpInside) - } -} - // MARK: - @objc Function - - extension PlusDetailVC { - @objc private func presentToUploadVC() { - let nextVC = UploadVC() - self.navigationController?.pushViewController(nextVC, animated: true) - } - } - // MARK: - naviVar Layout - -extension PlusDetailVC { - private func setNavigationBar() { - view.addSubview(navibar) - navibar.snp.makeConstraints { make in - make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide) - make.height.equalTo(48) - } -} - // MARK: - setUI - private func setUI() { - view.backgroundColor = .w1 - containerView.backgroundColor = .clear - self.tabBarController?.tabBar.isHidden = true - } - // MARK: - Layout Helpers - private func setLayout() { - view.addSubview(containerView) - view.addSubview(selectButton) - self.view.bringSubviewToFront(selectButton) - containerView.addSubview(mapCollectionView) - - containerView.snp.makeConstraints { - $0.top.equalTo(self.navibar.snp.bottom) - $0.leading.trailing.bottom.equalTo(self.view.safeAreaLayoutGuide) - } - mapCollectionView.snp.makeConstraints { make in - make.top.equalToSuperview() - make.leading.trailing.equalTo(view.safeAreaLayoutGuide) - make.bottom.equalToSuperview() - make.height.equalTo(1000) - } - - selectButton.snp.makeConstraints { make in - make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16) - make.height.equalTo(44) - make.bottom.equalToSuperview().inset(34) - } - } - private func register() { - mapCollectionView.register(MapCollectionViewCell.self, forCellWithReuseIdentifier: MapCollectionViewCell.identifier) - } -} -// MARK: - UICollectionViewDelegateFlowLayout - -extension PlusDetailVC: UICollectionViewDelegateFlowLayout { - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let screenWidth = UIScreen.main.bounds.width - let doubleCellWidth = screenWidth - inset.left - inset.right - interItemSpacing - return CGSize(width: doubleCellWidth / 2, height: 164) - } - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { - return lineSpacing - } - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { - return interItemSpacing - } - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - return inset - } - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let cell = collectionView.cellForItem(at: indexPath) as! MapCollectionViewCell - if cell.clickCount == 1 { - cell.clickCount = 0 - } else { - cell.clickCount += 1 - } - } -} -// MARK: - UICollectionViewDataSource - -extension PlusDetailVC: UICollectionViewDataSource { - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return mapList.count - } - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let mapCell = collectionView.dequeueReusableCell( - withReuseIdentifier: MapCollectionViewCell.identifier, for: indexPath) - as? MapCollectionViewCell else { return UICollectionViewCell() } - mapCell.dataBind(model: mapList[indexPath.item]) - mapCell.heartButton.isHidden = true - - return mapCell - } -} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/PlusDetailViewController.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/PlusDetailViewController.swift deleted file mode 100644 index 6e26c380..00000000 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/PlusDetailViewController.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// PlusDetailViewController.swift -// Runnect-iOS -// -// Created by YEONOO on 2023/01/05. -// - -import UIKit - -class PlusDetailViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. - } - - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destination. - // Pass the selected object to the new view controller. - } - */ - -} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/SearchResultViewController.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/SearchResultVC.swift similarity index 100% rename from Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/SearchResultViewController.swift rename to Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/SearchResultVC.swift diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadResultViewController.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadResultViewController.swift deleted file mode 100644 index 79218818..00000000 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadResultViewController.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// UploadResultViewController.swift -// Runnect-iOS -// -// Created by YEONOO on 2023/01/05. -// - -import UIKit - -class UploadResultViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - } - -} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadVC.swift deleted file mode 100644 index 84b4a2a6..00000000 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadVC.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// UploadViewController.swift -// Runnect-iOS -// -// Created by YEONOO on 2023/01/05. -// - -import UIKit - -class UploadVC: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - - } -} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadViewController.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadViewController.swift deleted file mode 100644 index 0db0e460..00000000 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadViewController.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// UploadViewController.swift -// Runnect-iOS -// -// Created by YEONOO on 2023/01/05. -// - -import UIKit - -class UploadViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. - } - - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destination. - // Pass the selected object to the new view controller. - } - */ - -} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/Views/CVC/CourseListCVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/Views/CVC/CourseListCVC.swift index 8dca7b92..82a62f4d 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/Views/CVC/CourseListCVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseStorage/Views/CVC/CourseListCVC.swift @@ -101,6 +101,15 @@ extension CourseListCVC { self.likeButton.isSelected = didLike } } + + func selectCell(didSelect: Bool) { + if didSelect { + courseImageView.layer.borderColor = UIColor.m1.cgColor + courseImageView.layer.borderWidth = 2 + } else { + courseImageView.layer.borderColor = UIColor.clear.cgColor + } + } } // MARK: - @objc Function