67 lines
2.4 KiB
Swift
67 lines
2.4 KiB
Swift
//
|
|
// PaginationCollectionView.swift
|
|
// VDS
|
|
//
|
|
// Created by Bandaru, Krishna Kishore on 12/03/24.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
///PaginationCollectionView is a container view that holds collectionview for displaying page indexes
|
|
final class PaginationCollectionView: View {
|
|
|
|
//--------------------------------------------------
|
|
// MARK: - Internal Properties
|
|
//--------------------------------------------------
|
|
///Notifies when accessibility increment is happend when user swipes up
|
|
var onAccessibilityIncrement: (() -> Void)?
|
|
///Notifies when accessibility decrement is happend when user swipes down
|
|
var onAccessibilityDecrement: (() -> Void)?
|
|
///Collectionview to render pagination indexes
|
|
lazy var collectionView: UICollectionView = {
|
|
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
|
|
collectionView.isScrollEnabled = false
|
|
collectionView.translatesAutoresizingMaskIntoConstraints = false
|
|
collectionView.showsHorizontalScrollIndicator = false
|
|
collectionView.showsVerticalScrollIndicator = false
|
|
collectionView.isAccessibilityElement = true
|
|
collectionView.register(PaginationCellItem.self, forCellWithReuseIdentifier: PaginationCellItem.identifier)
|
|
collectionView.backgroundColor = .clear
|
|
return collectionView
|
|
}()
|
|
|
|
//--------------------------------------------------
|
|
// MARK: - Private Properties
|
|
//--------------------------------------------------
|
|
///Custom flow layout defined for the Pagination
|
|
private let flowLayout = PaginationFlowLayout()
|
|
|
|
//--------------------------------------------------
|
|
// MARK: - Overrides
|
|
//--------------------------------------------------
|
|
///Accessibilty traits for the Pagination view
|
|
override var accessibilityTraits: UIAccessibilityTraits {
|
|
get { [.adjustable] }
|
|
set { }
|
|
}
|
|
|
|
///Accessibilty increment
|
|
override func accessibilityIncrement() {
|
|
onAccessibilityIncrement?()
|
|
}
|
|
|
|
///Accessibilty decrement
|
|
override func accessibilityDecrement() {
|
|
onAccessibilityDecrement?()
|
|
}
|
|
|
|
/// Executed on initialization for this View.
|
|
override func setup() {
|
|
super.setup()
|
|
addSubview(collectionView)
|
|
collectionView.pinToSuperView()
|
|
isAccessibilityElement = true
|
|
accessibilityElements = [collectionView]
|
|
}
|
|
}
|