From 23b6286da009280c6d72913c72b919fbdd8fbc1c Mon Sep 17 00:00:00 2001 From: doyeonk429 <80318425+doyeonk429@users.noreply.github.com> Date: Fri, 16 Aug 2024 16:22:39 +0900 Subject: [PATCH] =?UTF-8?q?#43=20Feat=20:=20=EC=B9=B4=EB=93=9C=20=EB=B7=B0?= =?UTF-8?q?=20=EC=A0=9C=EC=9E=91=201/2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Drink-EG/Drink-EG.xcodeproj/project.pbxproj | 32 +++ .../WineClassMainViewController.swift | 190 ++---------------- 2 files changed, 51 insertions(+), 171 deletions(-) diff --git a/Drink-EG/Drink-EG.xcodeproj/project.pbxproj b/Drink-EG/Drink-EG.xcodeproj/project.pbxproj index 5ef4af3..b25a8c0 100644 --- a/Drink-EG/Drink-EG.xcodeproj/project.pbxproj +++ b/Drink-EG/Drink-EG.xcodeproj/project.pbxproj @@ -33,6 +33,12 @@ 165401112C6E2B79008A9DBF /* WineNewsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 165401102C6E2B79008A9DBF /* WineNewsViewController.swift */; }; 165401132C6E2BAA008A9DBF /* WineKnowledgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 165401122C6E2BAA008A9DBF /* WineKnowledgeViewController.swift */; }; 165401162C6E3858008A9DBF /* CardSlider in Frameworks */ = {isa = PBXBuildFile; productRef = 165401152C6E3858008A9DBF /* CardSlider */; }; + 165401192C6E555A008A9DBF /* CardSliderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 165401182C6E555A008A9DBF /* CardSliderViewController.swift */; }; + 1654011B2C6E5661008A9DBF /* CardTitleview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1654011A2C6E5661008A9DBF /* CardTitleview.swift */; }; + 1654011D2C6E5681008A9DBF /* CardsLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1654011C2C6E5681008A9DBF /* CardsLayout.swift */; }; + 1654011F2C6E56A9008A9DBF /* UIViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1654011E2C6E56A9008A9DBF /* UIViewExtension.swift */; }; + 165401212C6E56BD008A9DBF /* RatingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 165401202C6E56BD008A9DBF /* RatingView.swift */; }; + 165401232C6E57BC008A9DBF /* CardSliderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 165401222C6E57BC008A9DBF /* CardSliderCell.swift */; }; 16752F9D2C5A7FB90001907D /* HexCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16752F9C2C5A7FB90001907D /* HexCode.swift */; }; 16B97CD42C4BEB0900D8B453 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16B97CD32C4BEB0900D8B453 /* AppDelegate.swift */; }; 16B97CD62C4BEB0900D8B453 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16B97CD52C4BEB0900D8B453 /* SceneDelegate.swift */; }; @@ -136,6 +142,12 @@ 1654010E2C6E2B4B008A9DBF /* MyCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCollectionViewController.swift; sourceTree = ""; }; 165401102C6E2B79008A9DBF /* WineNewsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WineNewsViewController.swift; sourceTree = ""; }; 165401122C6E2BAA008A9DBF /* WineKnowledgeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WineKnowledgeViewController.swift; sourceTree = ""; }; + 165401182C6E555A008A9DBF /* CardSliderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CardSliderViewController.swift; path = ../../../../../../../../Downloads/CardSliderViewController.swift; sourceTree = ""; }; + 1654011A2C6E5661008A9DBF /* CardTitleview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CardTitleview.swift; path = ../../../../../../../../Downloads/CardTitleview.swift; sourceTree = ""; }; + 1654011C2C6E5681008A9DBF /* CardsLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CardsLayout.swift; path = ../../../../../../../../Downloads/CardsLayout.swift; sourceTree = ""; }; + 1654011E2C6E56A9008A9DBF /* UIViewExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = UIViewExtension.swift; path = ../../../../../../../../Downloads/UIViewExtension.swift; sourceTree = ""; }; + 165401202C6E56BD008A9DBF /* RatingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RatingView.swift; path = ../../../../../../../../Downloads/RatingView.swift; sourceTree = ""; }; + 165401222C6E57BC008A9DBF /* CardSliderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CardSliderCell.swift; path = ../../../../../../../../Downloads/CardSliderCell.swift; sourceTree = ""; }; 16752F9C2C5A7FB90001907D /* HexCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HexCode.swift; sourceTree = ""; }; 16B97CD02C4BEB0900D8B453 /* Drink-EG.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Drink-EG.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 16B97CD32C4BEB0900D8B453 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -267,6 +279,19 @@ path = APIResponseModels; sourceTree = ""; }; + 165401172C6E5545008A9DBF /* CustomCardSlider */ = { + isa = PBXGroup; + children = ( + 165401182C6E555A008A9DBF /* CardSliderViewController.swift */, + 1654011A2C6E5661008A9DBF /* CardTitleview.swift */, + 1654011C2C6E5681008A9DBF /* CardsLayout.swift */, + 1654011E2C6E56A9008A9DBF /* UIViewExtension.swift */, + 165401202C6E56BD008A9DBF /* RatingView.swift */, + 165401222C6E57BC008A9DBF /* CardSliderCell.swift */, + ); + path = CustomCardSlider; + sourceTree = ""; + }; 16B97CC72C4BEB0900D8B453 = { isa = PBXGroup; children = ( @@ -392,6 +417,7 @@ 16B97CF32C4BF40100D8B453 /* Protocols */ = { isa = PBXGroup; children = ( + 165401172C6E5545008A9DBF /* CustomCardSlider */, ); path = Protocols; sourceTree = ""; @@ -625,7 +651,9 @@ 5E2219552C69D5E7005849FB /* CustomSlider.swift in Sources */, 1654010B2C6BACDC008A9DBF /* SelectionManager.swift in Sources */, 16752F9D2C5A7FB90001907D /* HexCode.swift in Sources */, + 165401192C6E555A008A9DBF /* CardSliderViewController.swift in Sources */, 1F598F0B2C5CBD9E000CE79F /* EnterTasteTestViewController.swift in Sources */, + 165401212C6E56BD008A9DBF /* RatingView.swift in Sources */, 5E22196E2C6B2EA0005849FB /* RatingViewController.swift in Sources */, 1F205A432C6B66EB00E80659 /* TasteTestThirdCollectionViewCell.swift in Sources */, 5E23147F2C5901BB004E2013 /* (null) in Sources */, @@ -639,11 +667,15 @@ 1F598EFD2C58150E000CE79F /* JoinViewController.swift in Sources */, 165400E32C69D6B9008A9DBF /* CallMoyaExample.swift in Sources */, 165400E72C69DDBE008A9DBF /* TastingNoteAPI.swift in Sources */, + 1654011F2C6E56A9008A9DBF /* UIViewExtension.swift in Sources */, 1654010F2C6E2B4B008A9DBF /* MyCollectionViewController.swift in Sources */, + 1654011D2C6E5681008A9DBF /* CardsLayout.swift in Sources */, 16B97CEC2C4BF37E00D8B453 /* Constant.swift in Sources */, 16B97D182C4C0F6E00D8B453 /* SearchVideoViewController.swift in Sources */, 1F598EEC2C524D2E000CE79F /* RecomCollectionViewCell.swift in Sources */, + 165401232C6E57BC008A9DBF /* CardSliderCell.swift in Sources */, 1654010D2C6C7FBB008A9DBF /* APIResponseMemberResponse.swift in Sources */, + 1654011B2C6E5661008A9DBF /* CardTitleview.swift in Sources */, 165401072C6BA5D8008A9DBF /* MemberInfoRequest.swift in Sources */, 1F205A372C6A71BC00E80659 /* APIResponseLoginResponse.swift in Sources */, 165400FA2C69F15D008A9DBF /* APIResponseWineNewsResponse.swift in Sources */, diff --git a/Drink-EG/Drink-EG/Sources/VCs/WineClass/WineClassMainViewController.swift b/Drink-EG/Drink-EG/Sources/VCs/WineClass/WineClassMainViewController.swift index ec7bb86..512cf6b 100644 --- a/Drink-EG/Drink-EG/Sources/VCs/WineClass/WineClassMainViewController.swift +++ b/Drink-EG/Drink-EG/Sources/VCs/WineClass/WineClassMainViewController.swift @@ -8,188 +8,36 @@ import UIKit import SnapKit -class WineClassMainViewController : UIViewController { - - // "VINO 클래스" 타이틀 - private let titleLabel: UILabel = { - let label = UILabel() - label.text = "VINO 클래스" - label.font = UIFont.boldSystemFont(ofSize: 28) - label.textColor = .black - return label - }() - - // 검색창 - private let searchBar: UISearchBar = { - let searchBar = UISearchBar() - searchBar.placeholder = "제목, 연관내용 검색" - searchBar.backgroundImage = UIImage() // 배경을 없앰 - return searchBar - }() - - // "내 보관함" 버튼 - private let myCollectionButton: UIButton = { - let button = UIButton(type: .system) - button.setTitle("내 보관함", for: .normal) - button.setTitleColor(.black, for: .normal) - button.backgroundColor = UIColor.white - button.layer.cornerRadius = 15 - button.addTarget(WineClassMainViewController.self, action: #selector(didTapMyCollectionButton), for: .touchUpInside) - return button - }() - - - - // "15초만에 알아가는 와인 지식" 카드 뷰 - private let wineKnowledgeCardView: UIView = { - let view = UIView() - view.backgroundColor = UIColor.white - view.layer.cornerRadius = 10 - view.layer.shadowColor = UIColor.black.cgColor - view.layer.shadowOpacity = 0.1 - view.layer.shadowOffset = CGSize(width: 0, height: 2) - view.layer.shadowRadius = 4 - let tapGesture = UITapGestureRecognizer(target: WineClassMainViewController.self, action: #selector(didTapWineKnowledgeCard)) - view.addGestureRecognizer(tapGesture) - view.isUserInteractionEnabled = true - return view - }() - - // 카드 이미지뷰 - private let cardImageView: UIImageView = { - let imageView = UIImageView(image: UIImage(named: "ClassSampleImage")) - imageView.contentMode = .scaleAspectFill - imageView.layer.cornerRadius = 10 - imageView.layer.masksToBounds = true - return imageView - }() - - // "15초만에 알아가는 와인 지식" 라벨 - private let wineKnowledgeLabel: UILabel = { - let label = UILabel() - label.text = "15초만에 알아가는 와인 지식" - label.font = UIFont.systemFont(ofSize: 20, weight: .bold) - label.textColor = .black - return label - }() - - // "이번 달 와인뉴스" 카드 뷰 - private let wineNewsCardView: UIView = { - let view = UIView() - view.backgroundColor = UIColor.white - view.layer.cornerRadius = 10 - view.layer.shadowColor = UIColor.black.cgColor - view.layer.shadowOpacity = 0.1 - view.layer.shadowOffset = CGSize(width: 0, height: 2) - view.layer.shadowRadius = 4 - let tapGesture = UITapGestureRecognizer(target: WineClassMainViewController.self, action: #selector(didTapWineNewsCard)) - view.addGestureRecognizer(tapGesture) - view.isUserInteractionEnabled = true - return view - }() - - // "이번 달 와인뉴스" 카드 이미지뷰 - private let newsImageView: UIImageView = { - let imageView = UIImageView(image: UIImage(named: "ClassSampleImage")) - imageView.contentMode = .scaleAspectFill - imageView.layer.cornerRadius = 10 - imageView.layer.masksToBounds = true - return imageView - }() - - // "이번 달 와인뉴스" 라벨 - private let wineNewsLabel: UILabel = { - let label = UILabel() - label.text = "이번 달 와인뉴스" - label.font = UIFont.systemFont(ofSize: 20, weight: .bold) - label.textColor = .black - return label - }() +struct Item: CardSliderItem { + var image: UIImage + var rating: Int? + var title: String + var subtitle: String? + var description: String? +} + +class WineClassMainViewController : CardSliderViewController, CardSliderDataSource { + var datas = [Item]() override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .white - setupUI() - } + datas.append(Item(image: UIImage(named: "ClassSampleImage")!, title: "First Wine Class")) + datas.append(Item(image: UIImage(named: "ClassSampleImage")!, title: "Second Wine Class")) + datas.append(Item(image: UIImage(named: "ClassSampleImage")!, title: "Third Wine Class")) - private func setupUI() { - // Add subviews - view.addSubview(titleLabel) - view.addSubview(searchBar) - view.addSubview(wineKnowledgeCardView) - view.addSubview(myCollectionButton) - view.addSubview(wineNewsCardView) - - wineKnowledgeCardView.addSubview(cardImageView) - wineKnowledgeCardView.addSubview(wineKnowledgeLabel) - - wineNewsCardView.addSubview(newsImageView) - wineNewsCardView.addSubview(wineNewsLabel) - - // Layout constraints using SnapKit - titleLabel.snp.makeConstraints { make in - make.top.equalTo(view.safeAreaLayoutGuide).offset(20) - make.leading.equalToSuperview().offset(16) - } - - searchBar.snp.makeConstraints { make in - make.top.equalTo(titleLabel.snp.bottom).offset(10) - make.leading.trailing.equalToSuperview().inset(16) - } - - wineKnowledgeCardView.snp.makeConstraints { make in - make.top.equalTo(searchBar.snp.bottom).offset(20) - make.leading.trailing.equalToSuperview().inset(16) - make.height.equalTo(200) - } - - cardImageView.snp.makeConstraints { make in - make.edges.equalToSuperview() - } - - wineKnowledgeLabel.snp.makeConstraints { make in - make.bottom.equalToSuperview().inset(10) - make.leading.equalToSuperview().offset(10) - } - - myCollectionButton.snp.makeConstraints { make in - make.trailing.equalTo(wineKnowledgeCardView.snp.trailing).inset(16) - make.centerY.equalTo(wineKnowledgeCardView.snp.centerY) - make.height.equalTo(30) - make.width.equalTo(100) - } - - wineNewsCardView.snp.makeConstraints { make in - make.top.equalTo(wineKnowledgeCardView.snp.bottom).offset(40) - make.leading.trailing.equalToSuperview().inset(16) - make.height.equalTo(200) - } + view.backgroundColor = .white - newsImageView.snp.makeConstraints { make in - make.edges.equalToSuperview() - } + self.dataSource = self - wineNewsLabel.snp.makeConstraints { make in - make.bottom.equalToSuperview().inset(10) - make.leading.equalToSuperview().offset(10) - } } - // MARK: - Actions - - @objc private func didTapMyCollectionButton() { - let myCollectionViewController = MyCollectionViewController() - navigationController?.pushViewController(myCollectionViewController, animated: true) + func item(for index: Int) -> any CardSliderItem { + datas[index] } - @objc private func didTapWineKnowledgeCard() { - let wineKnowledgeViewController = WineKnowledgeViewController() - navigationController?.pushViewController(wineKnowledgeViewController, animated: true) + func numberOfItems() -> Int { + datas.count } - @objc private func didTapWineNewsCard() { - let wineNewsViewController = WineNewsViewController() - navigationController?.pushViewController(wineNewsViewController, animated: true) - } }