From 9ac2552f41383f4fea453d67047d72e6a94de3e2 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 6 Jan 2023 14:22:16 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[Fix]=20#49=20-=20=ED=8F=B4=EB=8D=94?= =?UTF-8?q?=EB=AA=85=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS.xcodeproj/project.pbxproj | 36 +++++++++---------- .../{UploadVC.swift => CourseUploadVC.swift} | 2 +- .../Views/DiscoveryDetailViewController.swift | 16 --------- ...sDetailVC.swift => MyCourseSelectVC.swift} | 12 +++---- .../Views/PlusDetailViewController.swift | 29 --------------- ...wController.swift => SearchResultVC.swift} | 0 ...wController.swift => UploadResultVC.swift} | 0 7 files changed, 23 insertions(+), 72 deletions(-) rename Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/{UploadVC.swift => CourseUploadVC.swift} (81%) delete mode 100644 Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/DiscoveryDetailViewController.swift rename Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/{PlusDetailVC.swift => MyCourseSelectVC.swift} (96%) delete mode 100644 Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/PlusDetailViewController.swift rename Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/{SearchResultViewController.swift => SearchResultVC.swift} (100%) rename Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/{UploadResultViewController.swift => UploadResultVC.swift} (100%) diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 513a368f..cd7c1d1f 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -106,11 +106,10 @@ 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 */; }; + DA20D84B296697C600F1581F /* UploadResultVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D84A296697C600F1581F /* UploadResultVC.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 */ @@ -227,11 +226,10 @@ 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 = ""; }; + DA20D84A296697C600F1581F /* UploadResultVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadResultVC.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 = ""; }; @@ -470,11 +468,10 @@ 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 */, + DA20D84A296697C600F1581F /* UploadResultVC.swift */, DA20D84D2966A9B300F1581F /* SearchVC.swift */, ); path = Views; @@ -994,7 +991,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 */, @@ -1006,7 +1003,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 */, @@ -1047,15 +1043,15 @@ 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 */, + DA20D84B296697C600F1581F /* UploadResultVC.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/Views/UploadVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift similarity index 81% rename from Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadVC.swift rename to Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift index 84b4a2a6..f8d14dfd 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift @@ -7,7 +7,7 @@ import UIKit -class UploadVC: UIViewController { +class CourseUploadVC: UIViewController { override func viewDidLoad() { super.viewDidLoad() 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/PlusDetailVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift similarity index 96% rename from Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/PlusDetailVC.swift rename to Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift index 58eaa676..9f1cfb26 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/PlusDetailVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift @@ -8,7 +8,7 @@ import UIKit import Then -class PlusDetailVC: UIViewController { +class MyCourseSelectVC: UIViewController { // MARK: - UI Components @@ -65,14 +65,14 @@ class PlusDetailVC: UIViewController { } // MARK: - Methods -extension PlusDetailVC { +extension MyCourseSelectVC { private func setAddTarget() { self.selectButton.addTarget(self, action: #selector(presentToUploadVC), for: .touchUpInside) } } // MARK: - @objc Function - extension PlusDetailVC { + extension MyCourseSelectVC { @objc private func presentToUploadVC() { let nextVC = UploadVC() self.navigationController?.pushViewController(nextVC, animated: true) @@ -80,7 +80,7 @@ extension PlusDetailVC { } // MARK: - naviVar Layout -extension PlusDetailVC { +extension MyCourseSelectVC { private func setNavigationBar() { view.addSubview(navibar) navibar.snp.makeConstraints { make in @@ -124,7 +124,7 @@ extension PlusDetailVC { } // MARK: - UICollectionViewDelegateFlowLayout -extension PlusDetailVC: UICollectionViewDelegateFlowLayout { +extension MyCourseSelectVC: 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 @@ -150,7 +150,7 @@ extension PlusDetailVC: UICollectionViewDelegateFlowLayout { } // MARK: - UICollectionViewDataSource -extension PlusDetailVC: UICollectionViewDataSource { +extension MyCourseSelectVC: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return mapList.count } 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/UploadResultVC.swift similarity index 100% rename from Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadResultViewController.swift rename to Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadResultVC.swift From 5f3dc1051f4625b16cd9143fb0e3102071847213 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 6 Jan 2023 15:37:37 +0900 Subject: [PATCH 2/8] =?UTF-8?q?[feat]=20#49=20-=20textfield=20=EA=B9=8C?= =?UTF-8?q?=EC=A7=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VC/CourseDiscoveryVC.swift | 13 +-- .../Views/CourseUploadVC.swift | 107 +++++++++++++++++- .../Views/MyCourseSelectVC.swift | 8 +- 3 files changed, 117 insertions(+), 11 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift index 897a2279..8042d908 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift @@ -85,21 +85,20 @@ final class CourseDiscoveryVC: UIViewController { extension CourseDiscoveryVC { 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) } } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift index f8d14dfd..b57743b9 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift @@ -8,9 +8,114 @@ import UIKit class CourseUploadVC: UIViewController { - + + // MARK: - UI Components + + private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("코스 업로드") + private let buttonContainerView = UIView() + private let uploadButton = CustomButton(title: "업로드하기").setColor(bgColor: .g3, disableColor: .g3, textColor: .w1) + 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 distanceInfoView = CourseDetailInfoView(title: "거리",description: "0.0km") + + private let departureInfoView = CourseDetailInfoView(title: "출발지", description: "패스트파이브 을지로점") + + // MARK: - Life Cycle + override func viewDidLoad() { super.viewDidLoad() + setNavigationBar() + setUI() + setLayout() + + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + self.tabBarController?.tabBar.isHidden = false + } + +} + +// MARK: - Methods + + +// MARK: - @objc Function + + + +// MARK: - naviVar Layout + +extension CourseUploadVC { + 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 + buttonContainerView.backgroundColor = .w1 + mapImageView.backgroundColor = .systemGray4 + } + + // MARK: - Layout Helpers + private func setLayout() { + view.addSubviews(mapImageView, + courseTitleTextField, + distanceInfoView, + departureInfoView, + buttonContainerView) + buttonContainerView.addSubview(uploadButton) + self.view.bringSubviewToFront(uploadButton) + + mapImageView.snp.makeConstraints { make in + make.top.equalTo(self.navibar.snp.bottom) + make.leading.trailing.equalTo(self.view.safeAreaLayoutGuide) + make.height.equalTo(313) + } + courseTitleTextField.snp.makeConstraints { make in + make.top.equalTo(mapImageView.snp.bottom).offset(28) + make.leading.trailing.equalToSuperview().inset(16) + make.height.equalTo(35) + } + + distanceInfoView.snp.makeConstraints { make in + make.top.equalTo(courseTitleTextField.snp.bottom).offset(22) + make.leading.trailing.equalToSuperview().inset(16) + make.height.equalTo(16) + } + departureInfoView.snp.makeConstraints { make in + make.top.equalTo(distanceInfoView.snp.bottom).offset(6) + make.leading.trailing.equalToSuperview().inset(16) + make.height.equalTo(16) + } + buttonContainerView.snp.makeConstraints { make in + make.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.height.equalTo(86) + make.bottom.equalToSuperview() + } + uploadButton.snp.makeConstraints { make in + make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16) + make.height.equalTo(44) + make.bottom.equalToSuperview().inset(34) + } + } + private func setTextFieldBottomBorder() { + courseTitleTextField.addBottomBorder(height: 2) } } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift index 9f1cfb26..8cf5060d 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift @@ -56,6 +56,7 @@ class MyCourseSelectVC: UIViewController { setUI() setLayout() setAddTarget() + } override func viewWillDisappear(_ animated: Bool) { @@ -67,17 +68,18 @@ class MyCourseSelectVC: UIViewController { extension MyCourseSelectVC { private func setAddTarget() { - self.selectButton.addTarget(self, action: #selector(presentToUploadVC), for: .touchUpInside) + self.selectButton.addTarget(self, action: #selector(pushToUploadVC), for: .touchUpInside) } } // MARK: - @objc Function extension MyCourseSelectVC { - @objc private func presentToUploadVC() { - let nextVC = UploadVC() + @objc private func pushToUploadVC() { + let nextVC = CourseUploadVC() self.navigationController?.pushViewController(nextVC, animated: true) } } + // MARK: - naviVar Layout extension MyCourseSelectVC { From a2715f7caa79ec1917a3aae8e6f8b9cc41deb25d Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 6 Jan 2023 16:30:55 +0900 Subject: [PATCH 3/8] =?UTF-8?q?[Feat]=20#49=20-=20textView=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/CourseUploadVC.swift | 59 +++++++++++++++++-- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift index b57743b9..2659bade 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift @@ -7,6 +7,9 @@ import UIKit +import SnapKit +import Then + class CourseUploadVC: UIViewController { // MARK: - UI Components @@ -26,9 +29,16 @@ class CourseUploadVC: UIViewController { $0.textColor = .g1 $0.addLeftPadding(width: 2) } - private let distanceInfoView = CourseDetailInfoView(title: "거리",description: "0.0km") - + 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 @@ -37,6 +47,7 @@ class CourseUploadVC: UIViewController { setNavigationBar() setUI() setLayout() + setupTextView() } @@ -79,7 +90,8 @@ extension CourseUploadVC { courseTitleTextField, distanceInfoView, departureInfoView, - buttonContainerView) + buttonContainerView, + activityTextView) buttonContainerView.addSubview(uploadButton) self.view.bringSubviewToFront(uploadButton) @@ -104,6 +116,11 @@ extension CourseUploadVC { make.leading.trailing.equalToSuperview().inset(16) make.height.equalTo(16) } + activityTextView.snp.makeConstraints { make in + make.top.equalTo(departureInfoView.snp.bottom).offset(34) + make.leading.trailing.equalToSuperview().inset(16) + make.bottom.equalTo(buttonContainerView.snp.top).offset(-13) + } buttonContainerView.snp.makeConstraints { make in make.leading.trailing.equalTo(view.safeAreaLayoutGuide) make.height.equalTo(86) @@ -115,7 +132,39 @@ extension CourseUploadVC { make.bottom.equalToSuperview().inset(34) } } - private func setTextFieldBottomBorder() { - courseTitleTextField.addBottomBorder(height: 2) + + func setupTextView() { + activityTextView.delegate = self + activityTextView.text = placeholder + activityTextView.textColor = .g3 + } + override func touchesBegan(_ touches: Set, 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 + } + } + + 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) + } } } From bc9e3dc4c6595f5815abb259d369ee7a2b47a0b8 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 6 Jan 2023 18:57:31 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[Feat]=20#49=20-=20CourseListCVC=EC=97=90?= =?UTF-8?q?=20select=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/CourseUploadVC.swift | 71 +++++--- .../Views/MyCourseSelectVC.swift | 162 ++++++++++-------- .../Views/CVC/CourseListCVC.swift | 9 + 3 files changed, 139 insertions(+), 103 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift index 2659bade..7a6c137a 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift @@ -16,7 +16,9 @@ class CourseUploadVC: UIViewController { private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton).setTitle("코스 업로드") private let buttonContainerView = UIView() - private let uploadButton = CustomButton(title: "업로드하기").setColor(bgColor: .g3, disableColor: .g3, textColor: .w1) + private let uploadButton = CustomButton(title: "업로드하기").setEnabled(false) + + private lazy var containerView = UIScrollView() private let mapImageView = UIImageView().then { $0.image = UIImage(named: "") } @@ -58,13 +60,6 @@ class CourseUploadVC: UIViewController { } -// MARK: - Methods - - - -// MARK: - @objc Function - - // MARK: - naviVar Layout @@ -80,23 +75,48 @@ extension CourseUploadVC { private func setUI() { view.backgroundColor = .w1 + containerView.backgroundColor = .clear buttonContainerView.backgroundColor = .w1 mapImageView.backgroundColor = .systemGray4 + } // MARK: - Layout Helpers private func setLayout() { - view.addSubviews(mapImageView, - courseTitleTextField, - distanceInfoView, - departureInfoView, - buttonContainerView, - activityTextView) - buttonContainerView.addSubview(uploadButton) + view.addSubview(buttonContainerView) self.view.bringSubviewToFront(uploadButton) + buttonContainerView.addSubview(uploadButton) + + buttonContainerView.snp.makeConstraints { make in + make.leading.trailing.equalTo(view.safeAreaLayoutGuide) + make.height.equalTo(86) + make.bottom.equalToSuperview() + } + uploadButton.snp.makeConstraints { make in + make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16) + make.height.equalTo(44) + make.bottom.equalToSuperview().inset(34) + } + + + view.addSubview(containerView) + [mapImageView, + courseTitleTextField, + distanceInfoView, + departureInfoView, + activityTextView].forEach { + containerView.addSubview($0) + } + + + containerView.snp.makeConstraints { + $0.top.equalTo(navibar.snp.bottom) + $0.leading.trailing.equalTo(view.safeAreaLayoutGuide) + $0.bottom.equalTo(uploadButton.snp.top).inset(-25) + } mapImageView.snp.makeConstraints { make in - make.top.equalTo(self.navibar.snp.bottom) + make.top.equalToSuperview() make.leading.trailing.equalTo(self.view.safeAreaLayoutGuide) make.height.equalTo(313) } @@ -118,19 +138,11 @@ extension CourseUploadVC { } activityTextView.snp.makeConstraints { make in make.top.equalTo(departureInfoView.snp.bottom).offset(34) - make.leading.trailing.equalToSuperview().inset(16) - make.bottom.equalTo(buttonContainerView.snp.top).offset(-13) - } - buttonContainerView.snp.makeConstraints { make in - make.leading.trailing.equalTo(view.safeAreaLayoutGuide) - make.height.equalTo(86) - make.bottom.equalToSuperview() - } - uploadButton.snp.makeConstraints { make in make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16) - make.height.equalTo(44) - make.bottom.equalToSuperview().inset(34) + make.bottom.equalToSuperview() + make.height.equalTo(187) } + } func setupTextView() { @@ -140,6 +152,8 @@ extension CourseUploadVC { } override func touchesBegan(_ touches: Set, with event: UIEvent?) { self.view.endEditing(true) + + } } @@ -152,6 +166,7 @@ extension CourseUploadVC: UITextViewDelegate { } else if textView.text == placeholder { activityTextView.textColor = .g1 activityTextView.text = nil + self.uploadButton.setEnabled(true) } } @@ -167,4 +182,6 @@ extension CourseUploadVC: UITextViewDelegate { uploadButton.setColor(bgColor: .m3, disableColor: .g3) } } + + } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift index 8cf5060d..ad24f9f2 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift @@ -10,13 +10,17 @@ 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: "선택하기").setColor(bgColor: .g3, disableColor: .g3, textColor: .w1) + private let selectButton = CustomButton(title: "선택하기").setEnabled(false) // MARK: - collectionview - private lazy var containerView = UIScrollView() + private lazy var mapCollectionView: UICollectionView = { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .vertical @@ -30,43 +34,42 @@ class MyCourseSelectVC: UIViewController { 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 + final let collectionViewInset = UIEdgeInsets(top: 28, left: 16, bottom: 28, right: 16) + final let itemSpacing: CGFloat = 10 + final let lineSpacing: CGFloat = 20 - override func viewDidLoad () { + // MARK: - View Life Cycle + + override func viewDidLoad() { super.viewDidLoad() - register() - setNavigationBar() - setUI() - setLayout() - setAddTarget() - + self.setUI() + self.setNavigationBar() + self.setLayout() + self.setDelegate() + self.register() + self.setAddTarget() } - override func viewWillDisappear(_ animated: Bool) { - super.viewWillDisappear(animated) - self.tabBarController?.tabBar.isHidden = false + 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) } @@ -91,78 +94,85 @@ extension MyCourseSelectVC { } } // 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) + view.addSubviews(selectButton, mapCollectionView) 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) + + 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: - UICollectionViewDelegateFlowLayout +// MARK: - UICollectionViewDelegate, UICollectionViewDataSource -extension MyCourseSelectVC: 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 +extension MyCourseSelectVC: UICollectionViewDelegate, UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 15 } - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { - return interItemSpacing + 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, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { - return inset + 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, didSelectItemAt indexPath: IndexPath) { - let cell = collectionView.cellForItem(at: indexPath) as! MapCollectionViewCell - if cell.clickCount == 1 { - cell.clickCount = 0 + + 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.clickCount += 1 + cell.selectCell(didSelect: false) } + + return cell } } -// MARK: - UICollectionViewDataSource -extension MyCourseSelectVC: 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 +// MARK: - UICollectionViewDelegateFlowLayout - return mapCell +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/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 From 88eb4a027b0e6f4b0908649c8987a81faf0b4a6a Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 6 Jan 2023 19:34:11 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[Fix]=20#49=20-=20CourseDiscoveryVC=20?= =?UTF-8?q?=EC=85=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VC/CourseDiscoveryVC.swift | 103 +++++++++--------- .../Views/CourseUploadVC.swift | 29 +++++ .../Views/MyCourseSelectVC.swift | 2 - 3 files changed, 81 insertions(+), 53 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift index 8042d908..a3156c7b 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/VC/CourseDiscoveryVC.swift @@ -49,41 +49,41 @@ 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(pushToSearchVC), for: .touchUpInside) self.plusButton.addTarget(self, action: #selector(pushToDiscoveryVC), for: .touchUpInside) @@ -164,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 index 7a6c137a..1fc8fcaf 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift @@ -31,6 +31,9 @@ class CourseUploadVC: UIViewController { $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 = "코스에 대한 소개를 적어주세요.(난이도/풍경/지형)" @@ -50,6 +53,7 @@ class CourseUploadVC: UIViewController { setUI() setLayout() setupTextView() + setAddTarget() } @@ -60,6 +64,24 @@ class CourseUploadVC: UIViewController { } +// MARK: - Methods + +extension CourseUploadVC { + private func setAddTarget() { + self.uploadButton.addTarget(self, action: #selector(pushToCourseDiscoveryVC), for: .touchUpInside) + } +} + +// MARK: - @objc Function + +extension CourseUploadVC { + @objc private func pushToCourseDiscoveryVC() { + let nextVC = CourseDiscoveryVC() + self.navigationController?.pushViewController(nextVC, animated: true) + } +} + + // MARK: - naviVar Layout @@ -102,6 +124,7 @@ extension CourseUploadVC { view.addSubview(containerView) [mapImageView, courseTitleTextField, + dividerView, distanceInfoView, departureInfoView, activityTextView].forEach { @@ -126,6 +149,12 @@ extension CourseUploadVC { make.height.equalTo(35) } + dividerView.snp.makeConstraints { make in + make.top.equalTo(courseTitleTextField.snp.bottom).offset(0) + make.leading.trailing.equalTo(self.view.safeAreaLayoutGuide).inset(16) + make.height.equalTo(2) + } + distanceInfoView.snp.makeConstraints { make in make.top.equalTo(courseTitleTextField.snp.bottom).offset(22) make.leading.trailing.equalToSuperview().inset(16) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift index ad24f9f2..5a0f4a5d 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MyCourseSelectVC.swift @@ -30,8 +30,6 @@ class MyCourseSelectVC: UIViewController { collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.isScrollEnabled = true collectionView.showsVerticalScrollIndicator = false - collectionView.delegate = self - collectionView.dataSource = self return collectionView }() From b21db7a48c85fff8de2a06933782621777805f74 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 6 Jan 2023 20:06:42 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[Fix]=20#49=20-=20CourseUploadVC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS.xcodeproj/project.pbxproj | 4 -- .../Views/CourseUploadVC.swift | 61 +++++++++++++++++-- .../Views/UploadResultVC.swift | 16 ----- 3 files changed, 57 insertions(+), 24 deletions(-) delete mode 100644 Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadResultVC.swift diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index cd7c1d1f..7705460f 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -109,7 +109,6 @@ 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 */; }; - DA20D84B296697C600F1581F /* UploadResultVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D84A296697C600F1581F /* UploadResultVC.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 */ @@ -229,7 +228,6 @@ 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 = ""; }; - DA20D84A296697C600F1581F /* UploadResultVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadResultVC.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 = ""; }; @@ -471,7 +469,6 @@ DA20D8422966977D00F1581F /* SearchResultVC.swift */, DA20D846296697A600F1581F /* MyCourseSelectVC.swift */, DA20D848296697B400F1581F /* CourseUploadVC.swift */, - DA20D84A296697C600F1581F /* UploadResultVC.swift */, DA20D84D2966A9B300F1581F /* SearchVC.swift */, ); path = Views; @@ -1050,7 +1047,6 @@ CE6655E2295D87EB00C64E12 /* UIImage+.swift in Sources */, A3BC2F322962E0DB00198261 /* GoalRewardInfoModel.swift in Sources */, CEC2A68C2962AE1B00160BF7 /* RNStartMarker.swift in Sources */, - DA20D84B296697C600F1581F /* UploadResultVC.swift in Sources */, DA20D8432966977D00F1581F /* SearchResultVC.swift in Sources */, CE5875A4296015D2005D967E /* Encodable+.swift in Sources */, A3BC2F4129667A0D00198261 /* NicknameEditorVC.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift index 1fc8fcaf..d2b7f2f3 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift @@ -11,7 +11,9 @@ 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("코스 업로드") @@ -67,18 +69,71 @@ class CourseUploadVC: UIViewController { // 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.. 150 { activityTextView.deleteBackward() @@ -211,6 +266,4 @@ extension CourseUploadVC: UITextViewDelegate { uploadButton.setColor(bgColor: .m3, disableColor: .g3) } } - - } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadResultVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadResultVC.swift deleted file mode 100644 index 79218818..00000000 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadResultVC.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() - } - -} From 3a3d439fb63e913e6996dfa7ec503c36703928d1 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 6 Jan 2023 20:10:15 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[Fix]=20#49=20-=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=ED=8C=8C=EC=9D=BC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/CourseUploadVC.swift | 10 ++----- .../Views/UploadViewController.swift | 29 ------------------- 2 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/UploadViewController.swift diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift index d2b7f2f3..1a510154 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift @@ -136,8 +136,6 @@ extension CourseUploadVC { } } - - // MARK: - naviVar Layout extension CourseUploadVC { @@ -161,21 +159,19 @@ extension CourseUploadVC { // MARK: - Layout Helpers private func setLayout() { view.addSubview(buttonContainerView) - self.view.bringSubviewToFront(uploadButton) + view.bringSubviewToFront(uploadButton) buttonContainerView.addSubview(uploadButton) buttonContainerView.snp.makeConstraints { make in make.leading.trailing.equalTo(view.safeAreaLayoutGuide) make.height.equalTo(86) make.bottom.equalToSuperview() - } + } uploadButton.snp.makeConstraints { make in make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16) make.height.equalTo(44) make.bottom.equalToSuperview().inset(34) } - - view.addSubview(containerView) [mapImageView, courseTitleTextField, @@ -186,7 +182,6 @@ extension CourseUploadVC { containerView.addSubview($0) } - containerView.snp.makeConstraints { $0.top.equalTo(navibar.snp.bottom) $0.leading.trailing.equalTo(view.safeAreaLayoutGuide) @@ -242,7 +237,6 @@ extension CourseUploadVC { } extension CourseUploadVC: UITextViewDelegate { - func textViewDidBeginEditing(_ textView: UITextView) { if textView.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { activityTextView.textColor = .g3 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. - } - */ - -} From 4deb8374de5fd4cbbe3a10cca8d0fca83ed6a2e5 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 6 Jan 2023 20:12:47 +0900 Subject: [PATCH 8/8] =?UTF-8?q?[Fix]=20#49=20-=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EA=B3=B5=EB=B0=B1=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/CourseDiscovery/Views/CourseUploadVC.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift index 1a510154..c632e7f8 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/CourseUploadVC.swift @@ -157,6 +157,7 @@ extension CourseUploadVC { } // MARK: - Layout Helpers + private func setLayout() { view.addSubview(buttonContainerView) view.bringSubviewToFront(uploadButton) @@ -222,7 +223,7 @@ extension CourseUploadVC { make.height.equalTo(187) } - } +} func setupTextView() { activityTextView.delegate = self @@ -231,8 +232,6 @@ extension CourseUploadVC { } override func touchesBegan(_ touches: Set, with event: UIEvent?) { self.view.endEditing(true) - - } }