I’ve applied Airbnb horizontal calender in SwiftUI app, however with swap to point out subsequent and former month I additionally wish to present subsequent and former button which ought to be in sync with swipe additionally, however I cannot discover any manner for that in Airbnb horizontal calender
CalendarViewRepresentable(
visibleDateRange: Date()...Calendar.present.date(byAdding: .12 months, worth: 10, to: Date())!,
monthsLayout: .horizontal,
dataDependency: nil
)
.monthHeaders { month in
let monthName: String
change month.month {
case 1: monthName = "January"
case 2: monthName = "February"
case 3: monthName = "March"
case 4: monthName = "April"
case 5: monthName = "Might"
case 6: monthName = "June"
case 7: monthName = "July"
case 8: monthName = "August"
case 9: monthName = "September"
case 10: monthName = "October"
case 11: monthName = "November"
case 12: monthName = "December"
default: monthName = "Unknown"
}
return AnyView(
HStack(spacing: 0) {
Textual content("(monthName) (month.12 months.description)")
.fontWithLineHeight(font: UIFont(identify: HHFonts.Lato_Regular.rawValue, measurement: 20), lineHeight: 32)
.foregroundColor(HHColor.primarydarkblue)
Spacer()
}
)
}
.days { day in
let calendar = Calendar.present
guard let date = calendar.date(from: day.parts) else {
return AnyView(EmptyView())
}
let isToday = calendar.isDateInToday(date) // Verify if the date is immediately
let isSelected = weddingDate == date // Verify if the date is chosen
return AnyView(
ZStack {
if isSelected {
Circle()
.fill(HHColor.primarydarkblue)
.body(width: 44, peak: 44)
}
else if isToday {
Circle()
.fill(HHColor.greyscalelightgrey1)
.body(width: 44, peak: 44)
}
Textual content("(day.day)")
.fontWithLineHeight(font: UIFont(identify: isToday ? HHFonts.Lato_Bold.rawValue : HHFonts.Lato_Regular.rawValue, measurement: 20), lineHeight: isToday ? 29 : 24)
.foregroundColor(isSelected ? HHColor.greyscalewhite : HHColor.primarydarkblue)
.onTapGesture {
weddingDate = date // Replace the chosen date when tapped
viewModel.weddingDate = HHUtility.formattedDateString(from: weddingDate ?? Date.now)
print("Chosen Date: (viewModel.weddingDate)")
}
}
)
}