feature/v1
swift 53 lines 1.3 KB
Raw
1 //
2 // HeroSection.swift
3 // JomloCollectionView Example
4 //
5 // Created by Seto Elkahfi on 2026-01-27.
6 // Copyright © 2026 Seto Elkahfi. All rights reserved.
7 //
8
9 import JomloCollectionView
10 import UIKit
11
12 @MainActor
13 final class HeroSection: JomloSection {
14
15 let identifier = JomloSectionID("hero")
16 var onReloadNeeded: (@MainActor @Sendable () -> Void)?
17
18 private let heroItems: [HeroItem]
19
20 init(items: [HeroItem]) {
21 self.heroItems = items
22 }
23
24 func items() -> [any JomloItem] {
25 heroItems
26 }
27
28 func layoutSection(
29 environment: NSCollectionLayoutEnvironment,
30 sectionIndex: Int
31 ) -> NSCollectionLayoutSection {
32 JomloLayoutFactory.hero(
33 height: .fractionalWidth(0.56),
34 isPaging: true,
35 interItemSpacing: 12
36 )
37 }
38
39 func cell(
40 for item: any JomloItem,
41 in collectionView: UICollectionView,
42 at indexPath: IndexPath
43 ) -> UICollectionViewCell {
44 guard let heroItem = item as? HeroItem else {
45 return UICollectionViewCell()
46 }
47 return collectionView.dequeueJomloCell(HeroCell.self, for: indexPath, item: heroItem)
48 }
49
50 var displayAnimation: JomloAnimator.Animation? {
51 JomloAnimator.scaleUp(initialScale: 0.9, duration: 0.5, delayFactor: 0.1)
52 }
53 }