Skip to content

Commit

Permalink
[Feat] #455 - PageControl을 위한 FooterView 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwogus0128 committed Nov 28, 2024
1 parent 5547807 commit 0d05b0b
Showing 1 changed file with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// AnnouncementPageContolFooterView.swift
// HomeFeature
//
// Created by Jae Hyun Lee on 11/28/24.
// Copyright © 2024 SOPT-iOS. All rights reserved.
//

import UIKit
import Combine

import Core
import DSKit

final class AnnouncementPageContolFooterView: UICollectionViewCell {

// MARK: - Properties

private let cancelBag = CancelBag()

// MARK: - UI Components

private let cardPageControl = UIPageControl().then {
$0.currentPage = 0
$0.isUserInteractionEnabled = false
$0.backgroundStyle = .minimal
$0.currentPageIndicatorTintColor = DSKitAsset.Colors.white.color
$0.pageIndicatorTintColor = DSKitAsset.Colors.gray300.color
$0.hidesForSinglePage = true
$0.transform = .init(scaleX: 0.7, y: 0.7)
}

// MARK: - Initialization

override init(frame: CGRect) {
super.init(frame: frame)
setLayout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

// MARK: - UI & Layout

extension AnnouncementPageContolFooterView {
private func setLayout() {
self.addSubview(cardPageControl)

cardPageControl.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.leading.equalToSuperview().offset(-20)
}
}
}

// MARK: - Methods

extension AnnouncementPageContolFooterView {
func bind(input: PassthroughSubject<Int, Never>, pageNumber: Int) {
cardPageControl.numberOfPages = pageNumber
input
.withUnretained(self)
.sink { owner, currentPage in
owner.cardPageControl.currentPage = currentPage
}.store(in: cancelBag)
}
}

0 comments on commit 0d05b0b

Please sign in to comment.