From b1f44108b73ca5bf273fe2d49124b594494bcf75 Mon Sep 17 00:00:00 2001 From: taipaise Date: Sun, 1 Feb 2026 18:47:44 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EA=B0=90=EC=A0=95=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=20=ED=99=94=EB=A9=B4=20QA=20=EB=8C=80=EC=9D=91=20(=EB=AC=B4?= =?UTF-8?q?=ED=95=9C=20=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EB=81=8A=EA=B9=80,?= =?UTF-8?q?=20=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EA=B0=80=EB=8A=A5=20=EC=98=81?= =?UTF-8?q?=EC=97=AD=20=ED=99=95=EC=9E=A5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 구슬 collectionView 하단의 안내 문구에서도 collectionView의 스크롤이 가능하도록 수정 - 무한 스크롤이 끊기는 현상 개선 - 구슬 스크롤 시 진동 피드백으로 사용자경험 향상 --- .../View/EmotionCollectionViewLayout.swift | 30 ++++++++-- .../EmotionRegistrationViewController.swift | 60 ++++++++++++++++--- 2 files changed, 75 insertions(+), 15 deletions(-) diff --git a/Projects/Presentation/Sources/EmotionRegister/View/EmotionCollectionViewLayout.swift b/Projects/Presentation/Sources/EmotionRegister/View/EmotionCollectionViewLayout.swift index c397b00..6330cee 100644 --- a/Projects/Presentation/Sources/EmotionRegister/View/EmotionCollectionViewLayout.swift +++ b/Projects/Presentation/Sources/EmotionRegister/View/EmotionCollectionViewLayout.swift @@ -8,8 +8,12 @@ import UIKit final class EmotionCollectionViewLayout: UICollectionViewFlowLayout { - private let itemWidthRatio: CGFloat = 0.5 - private let lineSpacing: CGFloat = 16 + private enum Layout { + static let itemWidthRatio: CGFloat = 0.5 + static let lineSpacing: CGFloat = 16 + static let bottomSpacing: CGFloat = 100 + } + private var baseDistance: CGFloat { itemSize.width + minimumLineSpacing } override class var layoutAttributesClass: AnyClass { EmotionCollectionViewLayoutAttributes.self } @@ -19,14 +23,18 @@ final class EmotionCollectionViewLayout: UICollectionViewFlowLayout { guard let collectionView else { return } scrollDirection = .horizontal - minimumLineSpacing = lineSpacing + minimumLineSpacing = Layout.lineSpacing - let itemWidth = floor(collectionView.bounds.width * itemWidthRatio) - let itemHeight = collectionView.bounds.height + let itemWidth = floor(collectionView.bounds.width * Layout.itemWidthRatio) + let itemHeight = collectionView.bounds.height - Layout.bottomSpacing itemSize = CGSize(width: itemWidth, height: itemHeight) let insetX = (collectionView.bounds.width - itemWidth) / 2 - sectionInset = UIEdgeInsets(top: 0, left: insetX, bottom: 0, right: insetX) + sectionInset = UIEdgeInsets( + top: 0, + left: insetX, + bottom: Layout.bottomSpacing, + right: insetX) collectionView.decelerationRate = .fast } @@ -75,4 +83,14 @@ final class EmotionCollectionViewLayout: UICollectionViewFlowLayout { override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool { return true } + + func fetchcurrentIndex() -> Int? { + guard let collectionView else { return nil } + + let centerX = collectionView.contentOffset.x + (collectionView.bounds.width / 2) + let insetX = (collectionView.bounds.width - itemSize.width) / 2 + + let relativeX = centerX - insetX + return Int(round(relativeX / baseDistance)) + } } diff --git a/Projects/Presentation/Sources/EmotionRegister/View/EmotionRegistrationViewController.swift b/Projects/Presentation/Sources/EmotionRegister/View/EmotionRegistrationViewController.swift index 185f193..25cd27b 100644 --- a/Projects/Presentation/Sources/EmotionRegister/View/EmotionRegistrationViewController.swift +++ b/Projects/Presentation/Sources/EmotionRegister/View/EmotionRegistrationViewController.swift @@ -18,7 +18,7 @@ final class EmotionRegistrationViewController: BaseViewController? private var cancellables: Set + private var lastMarbleCellIndex: Int = 0 + var itemCount: Int { - return (dataSource?.snapshot().numberOfItems ?? 0) / 3 + return (dataSource?.snapshot().numberOfItems ?? 0) / itemSetCount } @@ -121,6 +128,10 @@ final class EmotionRegistrationViewController: BaseViewController() snapshot.appendSections([0]) - snapshot.appendItems(tripledEmotions) + snapshot.appendItems(multipliedEmotions) self.dataSource?.apply(snapshot, animatingDifferences: false) self.scrollToIndex(index: originalEmotionCount) @@ -350,8 +379,7 @@ final class EmotionRegistrationViewController: BaseViewController= itemCount * 2 / 3 { + if indexPath.row < itemCount / itemSetCount || indexPath.row >= itemCount * (itemSetCount / 2 + 1) / itemSetCount { scrollToIndex(index: index) } viewModel.action(input: .selectEmotion(index: index)) From 4458061ccdafd1ef1ef13541ea8b14bdaf1ba700 Mon Sep 17 00:00:00 2001 From: taipaise Date: Sun, 1 Feb 2026 19:03:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20print=20=EB=AC=B8=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=B0=8F=20=EB=A7=A4=EC=A7=81=20=EB=84=98=EB=B2=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/EmotionRegistrationViewController.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Projects/Presentation/Sources/EmotionRegister/View/EmotionRegistrationViewController.swift b/Projects/Presentation/Sources/EmotionRegister/View/EmotionRegistrationViewController.swift index 25cd27b..84c0a18 100644 --- a/Projects/Presentation/Sources/EmotionRegister/View/EmotionRegistrationViewController.swift +++ b/Projects/Presentation/Sources/EmotionRegister/View/EmotionRegistrationViewController.swift @@ -62,7 +62,6 @@ final class EmotionRegistrationViewController: BaseViewController? private var cancellables: Set @@ -130,7 +129,6 @@ final class EmotionRegistrationViewController: BaseViewController() snapshot.appendSections([0])