Skip to content

Commit

Permalink
[Fix] Team-Sopetit#169 - 이전달로 스크롤 시 매월 1일이 선택되도록 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ahra1221 committed Dec 26, 2024
1 parent a196fd8 commit f8f1706
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ extension AchieveViewController {

func setSelectDateView() {
let today = formatDateToString(selectedDate ?? Date())
achieveView.bindSelectDate(date: extractDayAndWeekday(selectDate: selectedDate ?? Date()).extractedDay, week: extractDayAndWeekday(selectDate: selectedDate ?? Date()).extractedWeekday)
if hasDateKey(for: today) {
let value = findValue(for: today)
let memo = value.memoContent
Expand Down Expand Up @@ -544,9 +545,6 @@ extension AchieveViewController: FSCalendarDelegate, FSCalendarDataSource {
} else {
goTodayButton.isHidden = true
}

achieveView.bindSelectDate(date: extractDayAndWeekday(selectDate: date).extractedDay,
week: extractDayAndWeekday(selectDate: date).extractedWeekday)
selectedDate = date
setSelectDateView()
print(selectDate)
Expand All @@ -567,6 +565,22 @@ extension AchieveViewController: FSCalendarDelegate, FSCalendarDataSource {
func calendarCurrentPageDidChange(_ calendar: FSCalendar) {
fromDidChange = true
updateCalendarHeaderButton()

let currentPageDate = calendar.currentPage
let today = Date()

let calendarComponent = Calendar.current
let currentPageComponents = calendarComponent.dateComponents([.year, .month], from: currentPageDate)
let todayComponents = calendarComponent.dateComponents([.year, .month], from: today)

if currentPageComponents.year != todayComponents.year || currentPageComponents.month != todayComponents.month {
selectedDate = calendarComponent.date(from: currentPageComponents)
goTodayButton.isHidden = false
} else {
selectedDate = Date()
goTodayButton.isHidden = true
}
setSelectDateView()
calendar.reloadData()
}

Expand Down

0 comments on commit f8f1706

Please sign in to comment.