forked from codesquad-members-2022/airbnb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: CalendarViewModel, WeekdayCollectionViewDataSource 추가 (#32)
- Loading branch information
1 parent
39a2f07
commit fea14d7
Showing
6 changed files
with
112 additions
and
10 deletions.
There are no files selected for viewing
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
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
12 changes: 12 additions & 0 deletions
12
iOS/airbnb/Present/Main/Calendar/Model/CalendarModel.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// CalendarModel.swift | ||
// airbnb | ||
// | ||
// Created by 안상희 on 2022/06/09. | ||
// | ||
|
||
import Foundation | ||
|
||
final class CalendarModel { | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// WeekdayModel.swift | ||
// airbnb | ||
// | ||
// Created by 안상희 on 2022/06/09. | ||
// | ||
|
||
import Foundation | ||
|
||
final class WeekdayModel { | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
iOS/airbnb/Present/Main/Calendar/ViewModel/CalendarViewModel.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// CalendarViewModel.swift | ||
// airbnb | ||
// | ||
// Created by 안상희 on 2022/06/09. | ||
// | ||
|
||
import Foundation | ||
|
||
final class CalendarViewModel { | ||
static let weeks = ["일", "월", "화", "수", "목", "금", "토"] | ||
|
||
let today = Date() // 오늘의 날짜 | ||
let dateOfToday = Date() // 날짜를 계산하는 기준 날짜 | ||
let dateComponents = DateComponents() | ||
let dateStringOfToday: String? = nil | ||
let totalDates = [String]() // dates를 담는 배열 | ||
let daysCountInMonth = 0 // 해당 월이 며칠까지 있는지 | ||
let weekdayStarting = 0 // 시작일 | ||
} |
28 changes: 28 additions & 0 deletions
28
iOS/airbnb/Present/Main/Calendar/WeekdayCollectionViewDataSource.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// WeekdayCollectionViewDataSource.swift | ||
// airbnb | ||
// | ||
// Created by 안상희 on 2022/06/09. | ||
// | ||
|
||
import UIKit | ||
|
||
final class WeekdayCollectionViewDataSource: NSObject, UICollectionViewDataSource { | ||
|
||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
return 7 | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, | ||
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
guard let cell = collectionView | ||
.dequeueReusableCell(withReuseIdentifier: String(describing: CalendarCollectionViewCell.self), | ||
for: indexPath) as? CalendarCollectionViewCell else { | ||
return UICollectionViewCell() | ||
} | ||
|
||
let dayString = CalendarViewModel.weeks[indexPath.item] | ||
cell.textLabel.text = dayString | ||
return cell | ||
} | ||
} |