diff --git a/iOS/airbnb/Present/Main/Calendar/CalendarViewController.swift b/iOS/airbnb/Present/Main/Calendar/CalendarViewController.swift index 3ceb0af3f..45d672fbd 100644 --- a/iOS/airbnb/Present/Main/Calendar/CalendarViewController.swift +++ b/iOS/airbnb/Present/Main/Calendar/CalendarViewController.swift @@ -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 } } diff --git a/iOS/airbnb/Present/Main/Calendar/View/CalendarCollectionViewCell.swift b/iOS/airbnb/Present/Main/Calendar/View/CalendarCollectionViewCell.swift index 7fee4c302..89b178a20 100644 --- a/iOS/airbnb/Present/Main/Calendar/View/CalendarCollectionViewCell.swift +++ b/iOS/airbnb/Present/Main/Calendar/View/CalendarCollectionViewCell.swift @@ -28,6 +28,7 @@ final class CalendarCollectionViewCell: UICollectionViewCell { contentView.backgroundColor = .white contentView.addSubview(textLabel) +// addSubview(containerView) setConstraints() } @@ -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) } diff --git a/iOS/airbnb/Present/Main/Calendar/ViewModel/CalendarViewModel.swift b/iOS/airbnb/Present/Main/Calendar/ViewModel/CalendarViewModel.swift index 01b5753bc..795d29484 100644 --- a/iOS/airbnb/Present/Main/Calendar/ViewModel/CalendarViewModel.swift +++ b/iOS/airbnb/Present/Main/Calendar/ViewModel/CalendarViewModel.swift @@ -17,4 +17,6 @@ final class CalendarViewModel { let totalDates = [String]() // dates를 담는 배열 let daysCountInMonth = 0 // 해당 월이 며칠까지 있는지 let weekdayStarting = 0 // 시작일 + + } diff --git a/iOS/airbnb/Present/Main/Calendar/WeekdayCollectionViewDataSource.swift b/iOS/airbnb/Present/Main/Calendar/WeekdayCollectionViewDataSource.swift index fc1302616..85b61f582 100644 --- a/iOS/airbnb/Present/Main/Calendar/WeekdayCollectionViewDataSource.swift +++ b/iOS/airbnb/Present/Main/Calendar/WeekdayCollectionViewDataSource.swift @@ -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,