I'm using IGCalendarView in day view only in an app. I have implemented drag-and-drop in iOS 11 and have extended IGCalendarView to make it a drop target. I implemented a binary search algorithm using the calendar to determine what 30-minute time bucket something was dropped into on the day view (see the Swift code fragment below). This code obviously assumes (which I noticed by observation), that each row in the day view appears to be 40 pixels. It would be great if you could expose this as a method on IGCalendarView that uses the exact metrics to calculate and return the time that is represented by a point. It would be nice if you could offer a customizable overload that would allow me to specify the number of time buckets, either per hour or for the complete day. For example, I could use 4 to indicate that I want 15-minute time buckets per hour, or 96 to specify that the entire day should be divided into 15 minute time buckets. The return value could be a CGFloat that returns 9.0 for 9am, 9.25 for 9:15am, 9.5 for 9:30am, etc.
For drag-and-drop in iOS 11+, it would also be great if there was a method that could be called with a specific time to determine if something appears on the calendar at that time or not. The use case for this is during a drag operation if I want to limit the drop to only time buckets that are free, during the drag my UIDropInteractionDelegate.dropInteraction(_sessionDidUpdate:) method could call IGCalendarView with either the location from the UIDropSession or the time returned by the method requested above that either returns the list of IGCalendarAppointments that may be scheduled at that time, or a true/false to indicate if anything if scheduled at that point.
Thank you for your consideration.
func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) {
let point = session.location(in: calendarView)
var start = 0
var end = 48 // There are 48 30-minute time buckets in a day
var time = 0
while start <= end {
time = (start + end) / 2
let location = calendarView.resolvePositionOfTime(inDayView: CGFloat(time) * 0.5)
if location <= point.y && (location + 40.0) > point.y {
break
}
if location < point.y {
start = time + 1
} else {
end = time - 1
}
// CGFloat(time) * 0.5 == the time bucket (13 = 1pm, 13.5 = 1:30pm, etc.)
}