diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 7c22d8c4..cda689a1 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -119,6 +119,9 @@ DA20D849296697B400F1581F /* CourseUploadVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D848296697B400F1581F /* CourseUploadVC.swift */; }; DA20D84E2966A9B300F1581F /* CourseSearchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D84D2966A9B300F1581F /* CourseSearchVC.swift */; }; DA20D8502966C0D500F1581F /* MapCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA20D84F2966C0D500F1581F /* MapCollectionViewController.swift */; }; + DAD5A3D8296C6D9600C8166B /* AdImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3D7296C6D9600C8166B /* AdImageCollectionViewCell.swift */; }; + DAD5A3DA296C6DA500C8166B /* TitleCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3D9296C6DA500C8166B /* TitleCollectionViewCell.swift */; }; + DAD5A3DC296C6DB800C8166B /* CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAD5A3DB296C6DB800C8166B /* CollectionViewCell.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -262,6 +265,9 @@ DA20D848296697B400F1581F /* CourseUploadVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseUploadVC.swift; sourceTree = ""; }; DA20D84D2966A9B300F1581F /* CourseSearchVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseSearchVC.swift; sourceTree = ""; }; DA20D84F2966C0D500F1581F /* MapCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapCollectionViewController.swift; sourceTree = ""; }; + DAD5A3D7296C6D9600C8166B /* AdImageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdImageCollectionViewCell.swift; sourceTree = ""; }; + DAD5A3D9296C6DA500C8166B /* TitleCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleCollectionViewCell.swift; sourceTree = ""; }; + DAD5A3DB296C6DB800C8166B /* CollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewCell.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 = ""; }; /* End PBXFileReference section */ @@ -1052,6 +1058,9 @@ DA20D83E296696A000F1581F /* MapModel.swift */, DA20D840296696C300F1581F /* MapCollectionViewCell.swift */, DA20D84F2966C0D500F1581F /* MapCollectionViewController.swift */, + DAD5A3D7296C6D9600C8166B /* AdImageCollectionViewCell.swift */, + DAD5A3D9296C6DA500C8166B /* TitleCollectionViewCell.swift */, + DAD5A3DB296C6DB800C8166B /* CollectionViewCell.swift */, ); path = Reuse; sourceTree = ""; @@ -1237,6 +1246,7 @@ CE14677C2965C1B100DCEA1B /* RunningRecordVC.swift in Sources */, CE6B63D829673450003F900F /* ListEmptyView.swift in Sources */, CE6655F6295D90B600C64E12 /* addToolBar.swift in Sources */, + DAD5A3DA296C6DA500C8166B /* TitleCollectionViewCell.swift in Sources */, CEC2A68A2962ADCD00160BF7 /* RNMapView.swift in Sources */, CE6655F0295D891B00C64E12 /* UITextView+.swift in Sources */, CEC2A6922962BE2900160BF7 /* DepartureSearchVC.swift in Sources */, @@ -1252,6 +1262,7 @@ CE6655D0295D85FF00C64E12 /* CancelBag.swift in Sources */, DA20D83F296696A000F1581F /* MapModel.swift in Sources */, A3BC2F432966A93100198261 /* CourseDetailVC.swift in Sources */, + DAD5A3D8296C6D9600C8166B /* AdImageCollectionViewCell.swift in Sources */, A3BC2F3D296468E500198261 /* UploadedCourseInfoModel.swift in Sources */, DA20D8502966C0D500F1581F /* MapCollectionViewController.swift in Sources */, CE6655DC295D873500C64E12 /* UIButton+.swift in Sources */, @@ -1273,6 +1284,7 @@ CE665608295D921500C64E12 /* setImage.swift in Sources */, CE146770296568DC00DCEA1B /* RunTrackingVC.swift in Sources */, DA20D849296697B400F1581F /* CourseUploadVC.swift in Sources */, + DAD5A3DC296C6DB800C8166B /* CollectionViewCell.swift in Sources */, CE665612295D92E400C64E12 /* UserDefaultWrapper.swift in Sources */, A3BC2F3A2963D0ED00198261 /* ActivityRecordInfoTVC.swift in Sources */, CE665610295D92C200C64E12 /* setTextLineHeight.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Reuse/AdImageCollectionViewCell.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Reuse/AdImageCollectionViewCell.swift new file mode 100644 index 00000000..94fa6071 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Reuse/AdImageCollectionViewCell.swift @@ -0,0 +1,46 @@ +// +// AdImageCollectionViewCell.swift +// Runnect-iOS +// +// Created by YEONOO on 2023/01/10. +// + +import UIKit +import SnapKit + +import Then + +class AdImageCollectionViewCell: UICollectionViewCell { + + // MARK: - Identifier + static let identifier = "AdImageCollectionViewCell" + // MARK: - UI Components + private let adImageView = UIImageView().then { + $0.image = UIImage(named: "adimage") + } + // MARK: - Life cycle + override init(frame: CGRect) { + super.init(frame: frame) + layout() + } + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} +// MARK: - Extensions + +extension AdImageCollectionViewCell { + + // MARK: - Layout Helpers + + func layout() { + contentView.backgroundColor = .clear + contentView.addSubview(adImageView) + adImageView.snp.makeConstraints { + $0.top.equalToSuperview() + $0.leading.trailing.equalTo(self.contentView.safeAreaLayoutGuide) + $0.height.equalTo(183) + } + + } +} diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Reuse/CollectionViewCell.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Reuse/CollectionViewCell.swift new file mode 100644 index 00000000..d76e3dae --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Reuse/CollectionViewCell.swift @@ -0,0 +1,114 @@ +// +// CollectionViewCell.swift +// Runnect-iOS +// +// Created by YEONOO on 2023/01/10. +// + +import UIKit +import SnapKit + +import Then + +class CollectionViewCell: UICollectionViewCell { + + // MARK: - Identifier + static let identifier = "CollectionViewCell" + // 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 = false + 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: - Life cycle + override init(frame: CGRect) { + super.init(frame: frame) + layout() + register() + setDelegate() + layout() + } + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + +extension CollectionViewCell { + + private func setDelegate() { + mapCollectionView.delegate = self + mapCollectionView.dataSource = self + } + private func register() { + mapCollectionView.register(CourseListCVC.self, + forCellWithReuseIdentifier: CourseListCVC.className) + } +} +// MARK: - Extensions + +extension CollectionViewCell { + + // MARK: - Layout Helpers + + func layout() { + contentView.backgroundColor = .clear + contentView.addSubview(mapCollectionView) + mapCollectionView.snp.makeConstraints { + $0.top.equalToSuperview() + $0.leading.trailing.equalTo(contentView.safeAreaLayoutGuide) + $0.bottom.equalToSuperview() + $0.height.equalTo(1000) + } + } +} +// MARK: - UICollectionViewDelegate, UICollectionViewDataSource + +extension CollectionViewCell: UICollectionViewDelegate, UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 15 + } + + 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 CollectionViewCell: 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/Reuse/TitleCollectionViewCell.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Reuse/TitleCollectionViewCell.swift new file mode 100644 index 00000000..97a60e4a --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Reuse/TitleCollectionViewCell.swift @@ -0,0 +1,64 @@ +// +// TitleCollectionViewCell.swift +// Runnect-iOS +// +// Created by YEONOO on 2023/01/10. +// + +import UIKit +import SnapKit + +import Then + +class TitleCollectionViewCell: UICollectionViewCell { + + // MARK: - Identifier + static let identifier = "TitleCollectionViewCell" + // MARK: - UI Components + private let titleView = UIView() + private let mainLabel: UILabel = { + let label = UILabel() + label.text = "코스 추천" + label.font = UIFont.h4 + label.textColor = UIColor.g1 + return label + }() + private let subLabel: UILabel = { + let label = UILabel() + label.text = "새로운 코스를 발견해나가요" + label.font = UIFont.b6 + label.textColor = UIColor.g1 + return label + }() + + // MARK: - Life cycle + + override init(frame: CGRect) { + super.init(frame: frame) + layout() + } + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} +// MARK: - Extensions + +extension TitleCollectionViewCell { + + // MARK: - Layout Helpers + + func layout() { + contentView.backgroundColor = .clear + contentView.addSubview(titleView) + + titleView.addSubviews(mainLabel, subLabel) + mainLabel.snp.makeConstraints { + $0.top.equalToSuperview().offset(9) + $0.leading.equalToSuperview().offset(16) + } + subLabel.snp.makeConstraints { + $0.top.equalTo(self.mainLabel.snp.bottom).offset(4) + $0.leading.equalToSuperview().offset(16) + } + } +}