Skip to content

Commit

Permalink
feat: ✨search view 에서 도시 위치 넘겨주기 구현(#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lia316 committed Jun 2, 2021
1 parent 9329138 commit 93196e5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ class CalendarViewController: UIViewController {
static let headerElementKind = "header-element-kind"

private var calendarViewModel = CalendarViewModel()
private var conditionViewModel = ConditionViewModel()
private var conditionViewModel: ConditionViewModel
private var collectionView: UICollectionView!
private var dataSource: UICollectionViewDiffableDataSource<Date, Day>!
private var containerView: UIView!

init(conditionViewModel: ConditionViewModel) {
self.conditionViewModel = conditionViewModel
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()
configureHierarchy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SearchCityViewController: UIViewController {
private var dataSource: UICollectionViewDiffableDataSource<Int, City>!
private var regionDataSource: UICollectionViewDiffableDataSource<Int, Region>!

private var conditionViewModel = ConditionViewModel()
private var mainUseCase = MainPageUseCase()
private var cancelBag = Set<AnyCancellable>()

Expand Down Expand Up @@ -257,7 +258,9 @@ extension SearchCityViewController: UICollectionViewDelegate {
let nextViewController = DetailDestinationViewController()
self.navigationController?.pushViewController(nextViewController, animated: true)
} else if cell is RegionCell {
let nextViewController = CalendarViewController()
guard let cell = cell as? RegionCell else { return }
conditionViewModel.updateCondition(city: cell.cityId)
let nextViewController = CalendarViewController(conditionViewModel: conditionViewModel)
self.navigationController?.pushViewController(nextViewController, animated: true)
}
}
Expand Down
2 changes: 2 additions & 0 deletions iOS/Airbnb/Airbnb/MainPage/View/RegionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ class RegionCell: UICollectionViewCell {
static let nib = UINib(nibName: RegionCell.reuseIdentifier, bundle: nil)

@IBOutlet weak var regionLabel: UILabel!
private(set) var cityId: Int!

override func awakeFromNib() {
super.awakeFromNib()
}

func fillUI(with region: Region) {
self.cityId = region.id
self.regionLabel.text = region.name
}

Expand Down

0 comments on commit 93196e5

Please sign in to comment.