Created
May 18, 2020 17:40
-
-
Save wdchris/65df03050531a88f6df56dd01ab1302c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func numberOfSections(in collectionView: UICollectionView) -> Int { | |
return calendarRange.count | |
} | |
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | |
return calendarRange[section].daysInMonth | |
} | |
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { | |
switch kind { | |
case UICollectionView.elementKindSectionHeader: | |
let section = calendarRange[indexPath.section] | |
let date = CalendarManager.getDate(year: section.year, month: section.month) | |
let header = CalendarHeader.dequeue(from: collectionView, at: indexPath, forDate: date) | |
return header | |
default: | |
fatalError("Invalid element type") | |
} | |
} | |
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
let section = calendarRange[indexPath.section] | |
let daysInSection = section.daysInMonth | |
let day = daysInSection - indexPath.item | |
let cell = CalendarCell.dequeue(from: collectionView, at: indexPath, forDay: day) | |
return cell | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment