From fea14d72c8a0274ac115a791aba90749b6904254 Mon Sep 17 00:00:00 2001 From: sanghee Date: Thu, 9 Jun 2022 20:38:01 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20CalendarViewModel,=20WeekdayCollection?= =?UTF-8?q?ViewDataSource=20=EC=B6=94=EA=B0=80=20(ios-h/airbnb#32)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iOS/airbnb.xcodeproj/project.pbxproj | 36 +++++++++++++++++-- .../Calendar/CalendarViewController.swift | 14 ++++---- .../Main/Calendar/Model/CalendarModel.swift | 12 +++++++ .../Main/Calendar/Model/WeekdayModel.swift | 12 +++++++ .../ViewModel/CalendarViewModel.swift | 20 +++++++++++ .../WeekdayCollectionViewDataSource.swift | 28 +++++++++++++++ 6 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 iOS/airbnb/Present/Main/Calendar/Model/CalendarModel.swift create mode 100644 iOS/airbnb/Present/Main/Calendar/Model/WeekdayModel.swift create mode 100644 iOS/airbnb/Present/Main/Calendar/ViewModel/CalendarViewModel.swift create mode 100644 iOS/airbnb/Present/Main/Calendar/WeekdayCollectionViewDataSource.swift diff --git a/iOS/airbnb.xcodeproj/project.pbxproj b/iOS/airbnb.xcodeproj/project.pbxproj index f90cdca73..a02b7a8b4 100644 --- a/iOS/airbnb.xcodeproj/project.pbxproj +++ b/iOS/airbnb.xcodeproj/project.pbxproj @@ -21,6 +21,10 @@ D00B744528519F1100B31424 /* CustomColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00B744428519F1100B31424 /* CustomColor.swift */; }; D00B74472851ABEF00B31424 /* ButtonTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00B74462851ABEF00B31424 /* ButtonTheme.swift */; }; D00B744B2851B95F00B31424 /* MapCoordinate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00B744A2851B95F00B31424 /* MapCoordinate.swift */; }; + D00B744E2851CD8500B31424 /* CalendarViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00B744D2851CD8500B31424 /* CalendarViewModel.swift */; }; + D00B74502851D1D700B31424 /* WeekdayCollectionViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00B744F2851D1D700B31424 /* WeekdayCollectionViewDataSource.swift */; }; + D00B74532851E80600B31424 /* WeekdayModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00B74522851E80600B31424 /* WeekdayModel.swift */; }; + D00B74552851E80D00B31424 /* CalendarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00B74542851E80D00B31424 /* CalendarModel.swift */; }; D01D65EF283C70710067B5E1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D01D65EE283C70710067B5E1 /* AppDelegate.swift */; }; D01D65F1283C70710067B5E1 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D01D65F0283C70710067B5E1 /* SceneDelegate.swift */; }; D01D65F3283C70710067B5E1 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D01D65F2283C70710067B5E1 /* MainViewController.swift */; }; @@ -111,6 +115,10 @@ D00B744428519F1100B31424 /* CustomColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomColor.swift; sourceTree = ""; }; D00B74462851ABEF00B31424 /* ButtonTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonTheme.swift; sourceTree = ""; }; D00B744A2851B95F00B31424 /* MapCoordinate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapCoordinate.swift; sourceTree = ""; }; + D00B744D2851CD8500B31424 /* CalendarViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarViewModel.swift; sourceTree = ""; }; + D00B744F2851D1D700B31424 /* WeekdayCollectionViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeekdayCollectionViewDataSource.swift; sourceTree = ""; }; + D00B74522851E80600B31424 /* WeekdayModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeekdayModel.swift; sourceTree = ""; }; + D00B74542851E80D00B31424 /* CalendarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarModel.swift; sourceTree = ""; }; D01D65EB283C70710067B5E1 /* airbnb.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = airbnb.app; sourceTree = BUILT_PRODUCTS_DIR; }; D01D65EE283C70710067B5E1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; D01D65F0283C70710067B5E1 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -221,10 +229,13 @@ D00B74252850562500B31424 /* Calendar */ = { isa = PBXGroup; children = ( - D00B74282850563900B31424 /* View */, - D00B74262850562B00B31424 /* CalendarViewController.swift */, + D00B74512851D4A700B31424 /* Model */, D00B742D285059C900B31424 /* CalendarCollectionViewDataSource.swift */, D00B743128507E5600B31424 /* CalendarFlowCoordinator.swift */, + D00B74262850562B00B31424 /* CalendarViewController.swift */, + D00B74282850563900B31424 /* View */, + D00B744C2851CCA200B31424 /* ViewModel */, + D00B744F2851D1D700B31424 /* WeekdayCollectionViewDataSource.swift */, ); path = Calendar; sourceTree = ""; @@ -258,6 +269,23 @@ path = Model; sourceTree = ""; }; + D00B744C2851CCA200B31424 /* ViewModel */ = { + isa = PBXGroup; + children = ( + D00B744D2851CD8500B31424 /* CalendarViewModel.swift */, + ); + path = ViewModel; + sourceTree = ""; + }; + D00B74512851D4A700B31424 /* Model */ = { + isa = PBXGroup; + children = ( + D00B74522851E80600B31424 /* WeekdayModel.swift */, + D00B74542851E80D00B31424 /* CalendarModel.swift */, + ); + path = Model; + sourceTree = ""; + }; D01D65E2283C70710067B5E1 = { isa = PBXGroup; children = ( @@ -776,6 +804,7 @@ D089E80E284621960000AE78 /* SearchItem.swift in Sources */, D0D29A2B284FC9ED009D1608 /* ReservationModel.swift in Sources */, D0D299F3284F1DF5009D1608 /* ReservationFlowCoordinator.swift in Sources */, + D00B744E2851CD8500B31424 /* CalendarViewModel.swift in Sources */, D01D6628283CB5550067B5E1 /* WishListViewController.swift in Sources */, D0D299EF284E61C2009D1608 /* SearchResultTableViewDataSource.swift in Sources */, D04C6C41284925CD00A419A5 /* MainViewModel.swift in Sources */, @@ -789,6 +818,7 @@ D0D299ED284E59BA009D1608 /* SearchResultTableViewCell.swift in Sources */, D0D29A29284FC9E3009D1608 /* ReservationCollectionViewCell.swift in Sources */, D089E80328460A4E0000AE78 /* MainSection.swift in Sources */, + D00B74502851D1D700B31424 /* WeekdayCollectionViewDataSource.swift in Sources */, D04C6C4928494B2600A419A5 /* SearchFlowCoordinator.swift in Sources */, D089E80928461EE50000AE78 /* SearchRecommendationViewController.swift in Sources */, D089E7DA2844B4790000AE78 /* MockDataModel.swift in Sources */, @@ -798,9 +828,11 @@ D01D65F1283C70710067B5E1 /* SceneDelegate.swift in Sources */, D00B74272850562B00B31424 /* CalendarViewController.swift in Sources */, D089E7D328446C950000AE78 /* HeroImageCollectionViewCell.swift in Sources */, + D00B74532851E80600B31424 /* WeekdayModel.swift in Sources */, D089E7E2284501810000AE78 /* CommonHeaderView.swift in Sources */, D0D299F1284F1D4D009D1608 /* WishListFlowCoordinator.swift in Sources */, D089E811284622C00000AE78 /* SearchCollectionViewCell.swift in Sources */, + D00B74552851E80D00B31424 /* CalendarModel.swift in Sources */, D00B74432851996100B31424 /* Size.swift in Sources */, D068BD002840700B00EF783E /* TabBarController.swift in Sources */, D01D662A283CB5DB0067B5E1 /* ReservationViewController.swift in Sources */, diff --git a/iOS/airbnb/Present/Main/Calendar/CalendarViewController.swift b/iOS/airbnb/Present/Main/Calendar/CalendarViewController.swift index 62d51b45e..3ceb0af3f 100644 --- a/iOS/airbnb/Present/Main/Calendar/CalendarViewController.swift +++ b/iOS/airbnb/Present/Main/Calendar/CalendarViewController.swift @@ -11,14 +11,7 @@ final class CalendarViewController: UIViewController { var coordinator: CalendarFlow? - private var today = Date() // 오늘의 날짜 - private var dateOfToday = Date() // 날짜를 계산하는 기준 날짜 - private var dateComponents = DateComponents() - private var dateStringOfToday: String? - private var totalDates = [String]() // dates를 담는 배열 - private var weeks = ["일", "월", "화", "수", "목", "금", "토"] - private var daysCountInMonth = 0 // 해당 월이 며칠까지 있는지 - private var weekdayStarting = 0 // 시작일 + private let viewModel: CalendarViewModel = CalendarViewModel() private var weekdayListCollectionView: UICollectionView! = nil private var calendarCollectionView: UICollectionView! = nil @@ -29,5 +22,10 @@ final class CalendarViewController: UIViewController { view.backgroundColor = .white self.navigationItem.title = "숙소 찾기" + + bind() + } + + private func bind() { } } diff --git a/iOS/airbnb/Present/Main/Calendar/Model/CalendarModel.swift b/iOS/airbnb/Present/Main/Calendar/Model/CalendarModel.swift new file mode 100644 index 000000000..6ec811f2b --- /dev/null +++ b/iOS/airbnb/Present/Main/Calendar/Model/CalendarModel.swift @@ -0,0 +1,12 @@ +// +// CalendarModel.swift +// airbnb +// +// Created by 안상희 on 2022/06/09. +// + +import Foundation + +final class CalendarModel { + +} diff --git a/iOS/airbnb/Present/Main/Calendar/Model/WeekdayModel.swift b/iOS/airbnb/Present/Main/Calendar/Model/WeekdayModel.swift new file mode 100644 index 000000000..94685b422 --- /dev/null +++ b/iOS/airbnb/Present/Main/Calendar/Model/WeekdayModel.swift @@ -0,0 +1,12 @@ +// +// WeekdayModel.swift +// airbnb +// +// Created by 안상희 on 2022/06/09. +// + +import Foundation + +final class WeekdayModel { + +} diff --git a/iOS/airbnb/Present/Main/Calendar/ViewModel/CalendarViewModel.swift b/iOS/airbnb/Present/Main/Calendar/ViewModel/CalendarViewModel.swift new file mode 100644 index 000000000..01b5753bc --- /dev/null +++ b/iOS/airbnb/Present/Main/Calendar/ViewModel/CalendarViewModel.swift @@ -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 // 시작일 +} diff --git a/iOS/airbnb/Present/Main/Calendar/WeekdayCollectionViewDataSource.swift b/iOS/airbnb/Present/Main/Calendar/WeekdayCollectionViewDataSource.swift new file mode 100644 index 000000000..fc1302616 --- /dev/null +++ b/iOS/airbnb/Present/Main/Calendar/WeekdayCollectionViewDataSource.swift @@ -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 + } +}