|
1 | | -// |
2 | | -// ImageBannerSectionCell.swift |
3 | | -// Poppool |
4 | | -// |
5 | | -// Created by SeoJunYoung on 11/28/24. |
6 | | -// |
7 | | - |
8 | 1 | import UIKit |
9 | 2 |
|
10 | 3 | import RxSwift |
@@ -91,6 +84,8 @@ final class ImageBannerSectionCell: UICollectionViewCell { |
91 | 84 | autoScrollTimer = nil |
92 | 85 | } |
93 | 86 |
|
| 87 | + // FIXME: (ํ -> ์์ธ) ์ด๋ ์ ํ์ ์๋ ์คํฌ๋กค์ด ๊ณ์ ๋์๊ฐ. |
| 88 | + // FIXME: ๋ํ ์คํ ์คํฌ๋กค์ ํ๋ฒ๋ง ์คํํ๋ฉด ๋๋๋ฐ, ์ฌ์ง์ด ๋์ด๊ฐ ๋ ๋ง๋ค ์คํ๋๋๊ฒ์ผ๋ก ๋ณด์ |
94 | 89 | func startAutoScroll(interval: TimeInterval = 3.0) { |
95 | 90 | stopAutoScroll() // ๊ธฐ์กด ํ์ด๋จธ๋ฅผ ์ค์ง |
96 | 91 | stopButton.isHidden = false |
@@ -206,16 +201,20 @@ extension ImageBannerSectionCell: Inputable { |
206 | 201 | if imageSection.isEmpty { |
207 | 202 | pageControl.setNumberOfPages(input.imagePaths.count) |
208 | 203 | let datas = zip(input.imagePaths, input.idList) |
209 | | - let backContents = datas.suffix(1) |
210 | | - let frontContents = datas.prefix(1) |
211 | | - imageSection.inputDataList = datas.map { .init(imagePath: $0.0, id: $0.1) } |
212 | | - imageSection.inputDataList.append(contentsOf: frontContents.map { .init(imagePath: $0.0, id: $0.1) }) |
213 | | - imageSection.inputDataList = backContents.map {.init(imagePath: $0.0, id: $0.1) } + imageSection.inputDataList |
214 | | - DispatchQueue.main.async { [weak self] in |
215 | | - self?.contentCollectionView.scrollToItem( |
216 | | - at: .init(row: 1, section: 0), |
217 | | - at: .centeredHorizontally, animated: false |
218 | | - ) |
| 204 | + if input.imagePaths.count > 1 { |
| 205 | + let backContents = datas.suffix(1) |
| 206 | + let frontContents = datas.prefix(1) |
| 207 | + imageSection.inputDataList = datas.map { .init(imagePath: $0.0, id: $0.1) } |
| 208 | + imageSection.inputDataList.append(contentsOf: frontContents.map { .init(imagePath: $0.0, id: $0.1) }) |
| 209 | + imageSection.inputDataList = backContents.map { .init(imagePath: $0.0, id: $0.1) } + imageSection.inputDataList |
| 210 | + DispatchQueue.main.async { [weak self] in |
| 211 | + self?.contentCollectionView.scrollToItem( |
| 212 | + at: .init(row: 1, section: 0), |
| 213 | + at: .centeredHorizontally, animated: false |
| 214 | + ) |
| 215 | + } |
| 216 | + } else { |
| 217 | + imageSection.inputDataList = datas.map { .init(imagePath: $0.0, id: $0.1) } |
219 | 218 | } |
220 | 219 | } |
221 | 220 |
|
@@ -264,6 +263,8 @@ extension ImageBannerSectionCell: UICollectionViewDelegate, UICollectionViewData |
264 | 263 | } |
265 | 264 |
|
266 | 265 | func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { |
| 266 | + guard imageSection.dataCount > 1 else { return } |
| 267 | + |
267 | 268 | if currentIndex == 0 { |
268 | 269 | contentCollectionView.scrollToItem( |
269 | 270 | at: .init(row: imageSection.dataCount - 2, section: 0), |
|
0 commit comments