0

I want to display a calendar with a set of dates marked (It reflects all the reservations a user has scheduled in a month on my application).

I'm trying to do that without creating a calendar component or importing a library. So, here I'm using the DatePicker component from SwiftUI with this configuration:

DatePicker(
    "",
    selection: $date,
    displayedComponents: [.date])
.datePickerStyle(GraphicalDatePickerStyle())

enter image description here

It's possible to fill this calendar with all the days reserved on my data layer?

What I want is something similar to what the Calendar app does:

enter image description here

chr0x
  • 1,151
  • 3
  • 15
  • 25

1 Answers1

-3

Quite tricky but you can declare binding variable to set date value to your old one.

var body: some View {
    let binding = Binding<Date> {
        self.date
    } set: { newDate in
        self.date = Date() // your old value
    }

    DatePicker(
        "",
        selection:binding,
        displayedComponents: [.date])
    .datePickerStyle(GraphicalDatePickerStyle())

}
erictruong
  • 303
  • 3
  • 14