From 86bf5deca1cb7faaaf5e1ed7090d08695d3134b9 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 19 May 2023 22:03:35 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[Fix]=20#134=20-=20=EB=B0=B0=EB=84=88=20?= =?UTF-8?q?=EC=8A=AC=EB=9D=BC=EC=9D=B4=EB=93=9C=20=EC=9E=90=EB=8F=99?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/AdImageCollectionViewCell.swift | 50 ++++++------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/AdImageCollectionViewCell.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/AdImageCollectionViewCell.swift index d7a689ae..14e594a6 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/AdImageCollectionViewCell.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/AdImageCollectionViewCell.swift @@ -20,7 +20,7 @@ class AdImageCollectionViewCell: UICollectionViewCell { let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.backgroundColor = .clear collectionView.translatesAutoresizingMaskIntoConstraints = false - collectionView.isScrollEnabled = false + collectionView.isScrollEnabled = true collectionView.showsVerticalScrollIndicator = false return collectionView }() @@ -31,6 +31,7 @@ class AdImageCollectionViewCell: UICollectionViewCell { // MARK: - UI Components var imgBanners: [UIImage] = [ImageLiterals.imgBanner1, ImageLiterals.imgBanner2, ImageLiterals.imgBanner3] var currentPage: Int = 0 + private var timer: Timer? private var pageControl = UIPageControl() // MARK: - Life cycle @@ -58,46 +59,27 @@ extension AdImageCollectionViewCell { // 초기 페이지 설정 currentPage = imgBanners.count + timer = Timer.scheduledTimer(timeInterval: 5.0, target: self, selector: #selector(animateBannerSlide), userInfo: nil, repeats: true) - // 제스처 인식기 추가 - let swipeLeftGesture = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipeGesture(_:))) - swipeLeftGesture.direction = .left - bannerCollectionView.addGestureRecognizer(swipeLeftGesture) - - let swipeRightGesture = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipeGesture(_:))) - swipeRightGesture.direction = .right - bannerCollectionView.addGestureRecognizer(swipeRightGesture) - // 페이지 컨트롤 설정 pageControl.currentPage = 0 pageControl.numberOfPages = imgBanners.count pageControl.pageIndicatorTintColor = .lightGray // 페이지를 암시하는 동그란 점의 색상 pageControl.currentPageIndicatorTintColor = .white } - - @objc func handleSwipeGesture(_ gesture: UISwipeGestureRecognizer) { - // 배너를 스와이프하여 수동으로 슬라이드 - if gesture.direction == .left { - currentPage += 1 - } else if gesture.direction == .right { - currentPage -= 1 - } - // 첫 번째 배너에서 이전으로 스와이프하면 마지막 배너로 이동 - if currentPage < 0 { - currentPage = imgBanners.count * 2 - 1 - } - - // 마지막 배너에서 다음으로 스와이프하면 첫 번째 배너로 이동 - if currentPage >= imgBanners.count * 2 { - currentPage = 0 - } - - let indexPath = IndexPath(item: currentPage, section: 0) - bannerCollectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) - - updatePageControl() - } - + @objc func animateBannerSlide() { + currentPage += 1 + + if currentPage >= imgBanners.count { + currentPage = 0 + } + + let indexPath = IndexPath(item: currentPage, section: 0) + bannerCollectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) + + pageControl.currentPage = currentPage + } + // 페이지 컨트롤 업데이트 func updatePageControl() { let currentIndex = currentPage % imgBanners.count From 04f312631b4d13112d02ee837962bbc66d10ab67 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 19 May 2023 23:10:16 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[Fix]=20#134=20-=20=EB=A6=B0=ED=8A=B8=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CourseDiscovery/Views/MapCollectionViewCell.swift | 3 +-- .../CourseDiscovery/Views/VC/CourseDiscoveryVC.swift | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MapCollectionViewCell.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MapCollectionViewCell.swift index 4c01ae6e..7bf86702 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MapCollectionViewCell.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MapCollectionViewCell.swift @@ -11,8 +11,7 @@ import SnapKit import Then class MapCollectionViewCell: UICollectionViewCell { - - + // MARK: - collectionview private lazy var mapCollectionView: UICollectionView = { diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift index 743e78ec..96c526fb 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift @@ -22,7 +22,6 @@ final class CourseDiscoveryVC: UIViewController { private var courseList = [PublicCourse]() - // MARK: - UIComponents private lazy var naviBar = CustomNavigationBar(self, type: .title).setTitle("코스 발견") From 5105159385e8b0d0ffca54346e0eef7ea0a869a7 Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 19 May 2023 23:10:16 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[Fix]=20#146=20-=20=EB=A6=B0=ED=8A=B8=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CourseDiscovery/Views/MapCollectionViewCell.swift | 3 +-- .../CourseDiscovery/Views/VC/CourseDiscoveryVC.swift | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MapCollectionViewCell.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MapCollectionViewCell.swift index 4c01ae6e..7bf86702 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MapCollectionViewCell.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/MapCollectionViewCell.swift @@ -11,8 +11,7 @@ import SnapKit import Then class MapCollectionViewCell: UICollectionViewCell { - - + // MARK: - collectionview private lazy var mapCollectionView: UICollectionView = { diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift index 743e78ec..96c526fb 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDiscovery/Views/VC/CourseDiscoveryVC.swift @@ -22,7 +22,6 @@ final class CourseDiscoveryVC: UIViewController { private var courseList = [PublicCourse]() - // MARK: - UIComponents private lazy var naviBar = CustomNavigationBar(self, type: .title).setTitle("코스 발견") From b4b5d25c628fcf7388beb7f83f9b3f0e6887595b Mon Sep 17 00:00:00 2001 From: yeonwoo Date: Fri, 19 May 2023 23:30:07 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[Fix]=20#146=20-=20handlevisitor=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/CourseDetail/VC/CourseDetailVC.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift index 23224506..48a252e3 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/CourseDetail/VC/CourseDetailVC.swift @@ -130,6 +130,7 @@ extension CourseDetailVC { } @objc func startButtonDidTap() { + guard handleVisitor() else { return } guard let courseId = self.courseId else { return } getCourseDetailWithPath(courseId: courseId) }