HorizonCalendar icon indicating copy to clipboard operation
HorizonCalendar copied to clipboard

How to add multiple types of ranges (overlapping ranges with different layout)?

Open tzatzosm opened this issue 2 years ago • 2 comments

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.

tzatzosm avatar Mar 04 '22 14:03 tzatzosm

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.

bryankeller avatar Mar 05 '22 01:03 bryankeller

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.

Frame 1

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
    ...
}

tzatzosm avatar Mar 21 '22 22:03 tzatzosm