I have a button in my swiftUI view that allows users to open a datePicker and then use the selected date to start a network fetch.
The date picker is presented using this code:
My plan is to use dateSelected to know when the user taps Done rather than cancelling.
But I'm not sure where I need to check dateSelected.
My first thought was in the body method.
But that doesn't seem to compile, and frankly feels wrong.
I also thought of doing this in ModalDatePicker, but that also feels wrong.
I'm guessing the solution will involve combine and perhaps a publisher, but I don't yet understand how to implement this.
Any assistance would be appreciated.
Thanks,
Mike
The date picker is presented using this code:
Code Block .sheet(isPresented: $showDatePicker) { ModalDatePicker(startDate: self.podcast.earliestDate, endDate: self.podcast.latestDate, currentDate: self.$datePickerDate, isShowing: self.$showDatePicker, doneTapped: self.$dateSelected) }
My plan is to use dateSelected to know when the user taps Done rather than cancelling.
But I'm not sure where I need to check dateSelected.
My first thought was in the body method.
Code Block if dateSelected { dateSelected = false startFetch() }
But that doesn't seem to compile, and frankly feels wrong.
I also thought of doing this in ModalDatePicker, but that also feels wrong.
I'm guessing the solution will involve combine and perhaps a publisher, but I don't yet understand how to implement this.
Any assistance would be appreciated.
Thanks,
Mike