Skip to content

Commit

Permalink
feat: 달력 화면에 요일 (weekdayCollectionViewCell) 추가 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
AhnSangHee committed Jun 11, 2022
1 parent b284924 commit f6bc80b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
39 changes: 37 additions & 2 deletions iOS/airbnb/Present/Main/Calendar/CalendarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,51 @@ final class CalendarViewController: UIViewController {
private var weekdayListCollectionView: UICollectionView! = nil
private var calendarCollectionView: UICollectionView! = nil

private var weekdayCollectionViewDataSource = WeekdayCollectionViewDataSource()

override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .white

self.navigationItem.title = "숙소 찾기"

configureCollectionView()
configureDataSource()
configure()
bind()
}

private func bind() {
// viewModel
}

private func configure() {
self.navigationItem.title = "숙소 찾기"

view.addSubview(weekdayListCollectionView)

weekdayListCollectionView.snp.makeConstraints {
$0.leading.trailing.top.equalTo(view.safeAreaLayoutGuide)
$0.height.equalTo(90)
}
}

private func configureCollectionView() {
let flowLayout = UICollectionViewFlowLayout()
flowLayout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
flowLayout.minimumLineSpacing = 10
flowLayout.itemSize = CGSize(width: view.bounds.width / 9, height: view.bounds.width / 9)

let collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectionView.translatesAutoresizingMaskIntoConstraints = false
collectionView.isScrollEnabled = false
collectionView.clipsToBounds = true
collectionView.showsVerticalScrollIndicator = false
collectionView.register(CalendarCollectionViewCell.self,
forCellWithReuseIdentifier: String(describing: CalendarCollectionViewCell.self))
weekdayListCollectionView = collectionView
}

private func configureDataSource() {
weekdayListCollectionView.dataSource = weekdayCollectionViewDataSource
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ final class CalendarCollectionViewCell: UICollectionViewCell {
contentView.backgroundColor = .white
contentView.addSubview(textLabel)

// addSubview(containerView)
setConstraints()
}

Expand All @@ -36,6 +37,10 @@ final class CalendarCollectionViewCell: UICollectionViewCell {
$0.edges.equalTo(self.safeAreaLayoutGuide)
}

// containerView.snp.makeConstraints {
// $0.edges.equalTo(contentView.safeAreaLayoutGuide)
// }

textLabel.snp.makeConstraints {
$0.center.equalTo(self.contentView)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ final class CalendarViewModel {
let totalDates = [String]() // dates를 담는 배열
let daysCountInMonth = 0 // 해당 월이 며칠까지 있는지
let weekdayStarting = 0 // 시작일


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit
final class WeekdayCollectionViewDataSource: NSObject, UICollectionViewDataSource {

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 7
return CalendarViewModel.weeks.count
}

func collectionView(_ collectionView: UICollectionView,
Expand Down

0 comments on commit f6bc80b

Please sign in to comment.