Skip to content

Commit

Permalink
[iOS] feat: SearchFilter - guests 업데이트 기능 구현
Browse files Browse the repository at this point in the history
issue: #131
  • Loading branch information
corykim0829 committed Jun 5, 2020
1 parent d58d692 commit 18921f3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,12 @@ extension StayListViewController: GuestsFilterSearchDelegate {
func searchStayList(guests: (adults: Int?, children: Int?, infants: Int?)) {
searchFilterQuery.updateFilters(
guest: SearchFilterQuery.Guest(
adults: guests.adults,
children: guests.children,
infants: guests.infants))
if searchFilterQuery.filteredGuests() != (1, 0, 0) {
searchFilterView.updateGuestsFiltered(with: true)
fetchStayList()
} else {
searchFilterView.updateGuestsFiltered(with: false)
}
adults: guests.adults ?? 0,
children: guests.children ?? 0,
infants: guests.infants ?? 0))
let filteredGuests = searchFilterQuery.filteredGuests()
searchFilterView.updateGuestsFiltered(with: true, guests: filteredGuests)
fetchStayList()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ final class FilterButton: UIButton {
return CGSize(width: size.width + (sidePadding * 2), height: size.height)
}

func update(with filtered: Bool) {
func update(with filtered: Bool, guests: (adults: Int, children: Int, infants: Int)? = nil) {
guard let guests = guests else { return }
if filtered {
var guestsText = "Guests \(guests.adults + guests.children)"
if guests.infants != 0 {
guestsText = "\(guestsText) ・ infants \(guests.infants)"
}
setTitle(guestsText, for: .normal)
}
backgroundColor = filtered ? .darkGray : .white
setTitleColor(filtered ? .white : .darkGray, for: .normal)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class SearchFilterView: UIView, ViewFromXib {
delegate?.didTapGuestsFilter()
}

func updateGuestsFiltered(with filtered: Bool) {
guestsFilterButton.update(with: filtered)
func updateGuestsFiltered(with filtered: Bool, guests: (Int, Int, Int)? = nil) {
guestsFilterButton.update(with: filtered, guests: guests)
}
}

0 comments on commit 18921f3

Please sign in to comment.