Skip to content

Commit

Permalink
Merge: pull request (#189)
Browse files Browse the repository at this point in the history
feat: add home date Button today text (#188)
  • Loading branch information
hyesuuou authored Jun 21, 2023
2 parents b7bd680 + 0a6d4c8 commit e2220d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ final class MyWorkitHeaderView: UICollectionReusableView {

public func setDate(startDate: Date, endDate: Date) {
print(startDate, endDate)
dateButton.setDate(fromDate: startDate, toDate: endDate)
dateButton.setDate(fromDate: startDate, toDate: endDate, isHome: true)
}

private func setBackgroundColor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public final class WKDateButton: UIView {
/// - Parameters:
/// - fromDate: 시작날짜 (날짜 선택 전일 경우 nil)
/// - toDate: 끝나는 날짜 (단일 날짜의 경우 nil)
public func setDate(fromDate: Date?, toDate: Date?) {
/// - isHome: 홈인경우 오늘이면 "오늘"로 나와야 해서 true값으로 준다. (optional)
public func setDate(fromDate: Date?, toDate: Date?, isHome: Bool = false) {
self.fromDate = fromDate
self.toDate = toDate
if fromDate == nil && toDate == nil {
Expand All @@ -127,14 +128,21 @@ public final class WKDateButton: UIView {
} else if toDate == nil, let fromDate = fromDate {
/// 날짜 단일인 경우
self.dateLabel.text = "\(fromDate.toString(type: .dot))"
if isHome, fromDate == Date() {
self.dateLabel.text = "오늘"
}
} else if let fromDate = fromDate?.toString(type: .dot),
let toDate = toDate?.toString(type: .dot) {
if fromDate == toDate {
self.dateLabel.text = "\(fromDate)"
if isHome, fromDate == Date().toString(type: .dot) {
self.dateLabel.text = "오늘"
}
} else {
self.dateLabel.text = "\(fromDate) - \(toDate)"
}
}

dateLabel.sizeToFit()
}
}
Expand Down

0 comments on commit e2220d4

Please sign in to comment.