HorizonCalendar
HorizonCalendar copied to clipboard
How to add multiple types of ranges (overlapping ranges with different layout)?
In my app's case we have to add some overlapping ranges but I couldn't find a way to do so.
I think there should be a way to have multiple types of ranges (even overlapping ones).
I have already done a very plain implementation that works for me but I would like to start a discussion here before openning a PR so that I gather more requirements on how this should be done.
Hi @tzatzosm , can you provide screenshots / an example of what you mean? With the current API, you should be able to specify multiple overlapping ranges, like 2022-01-19 - 2022-01-25
and 2022-01-15 - 2022-01-21
(an overlap of 2 days). You could then provide a day range item for each of those ranges.
Hello @bryankeller,
Sorry for the delay and sorry for my poor design skills.
I understand that the API allows you to have multiple, even overlapping ranges.
Due to the fact that that dayRangeItemProvider
's input is a Set<ClosedRange<Date>>
if 2 from different types are equal then it would take additional computation inside the provider function.
My suggestion would be to be able to add multiple dayRangeItemProviders
, one for each range type we got with its own Set of date ranges. These would render (zIndex) in the order added.
.dayRangeItemProvider(for: ownerBookedRanges) { dayRangeLayoutContext in
...
}
.dayRangeItemProvider(for: specialDayRanges) { dayRangeLayoutContext in
...
}
.dayRangeItemProvider(for: dateRanges) { dayRangeLayoutContext in
...
}