Two ranges next to each other
Is it possible to have two date ranges side by side? My application loads existing ranges, which I made non editable, however if I tap a date in front of the first date or tap a date after the last date of the pre-existing selection it joins it. Is there anyway to prevent this? Here's a mockup of what it should look like ideally.

7.1.6
Yes it is possible.
But this means that you cannot use this library's CellState.selectedPosition() function. Because this will not be the behavior you want.
You will have to come up with the logic for what determines a cell to be a left, middle, right, full, none for yourself.
Can I still use that function for the remaining cells, and just have an exception for this one particular case?
Here is my logic that determines whether its a new range or not:
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
var date1 = date
var date2 = date
date1.changeDays(by: -1)
date2.changeDays(by: 1)
if self.travelingDates.contains(date1) || self.travelingDates.contains(date2) {
self.leftItem(cell: cell as! ShipperChooseDateViewControllerCell, cellState: cellState)
}else{
Here's that leftItem method:
func leftItem(cell: ShipperChooseDateViewControllerCell, cellState: CellState) {
cell.circle.isHidden = false
cell.circle.image = cell.circle.image?.withRenderingMode(.alwaysTemplate)
cell.circle.tintColor = UIColor(named: "greenColor")
cell.selectedView.isHidden = true
cell.label.textColor = .white
}
However when I test this it continues to expand the existing range, it appears handleCellSelection is still called. Is there anyway to prevent this?
Hmm. Maybe i misunderstand something?
The only function i provide with range is cellState.selectedPosition(). All this does is give a description of the cell's position so that the developer can write the code to do the visual range code.
Therefore when you say this,
However when I test this it continues to expand the existing range,it appears handleCellSelection is still called
The library isnt responsible for this section of the code. The handleCellSelection() is written and called by yourself. So if you ask me how to prevent it being called, then the answer would be to just not call it? Unless i misunderstand what you are saying.
Okay I see now. handleCellSelection() is a method I created, following the tutorial to select the cells. The reason it's being called is because the function:
func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {
Is being called which then calls handleCellSelection() which overrides my:
func leftItem(cell: ShipperChooseDateViewControllerCell, cellState: CellState) {
Hopefully this makes more sense.
Ok. I see.
So that means you are now asking "is there a way to make willDisplayCell not be called.
The answer to that would be no. This is called under to hood to update cells.
BTW, the willDisplayCell function and the CellForItemAtDate function should contain the same code as shown in the documentation section.
If you want to handle the cell selection in a different way, You'll have to do that at the handleCellSelection() function. You'll have to know what criteria determines for a cell to be left, right, mid, or full. Not sure if i missed what youre saying.
chat here is faster btw, -: https://gitter.im/patchthecode/JTAppleCalendar
How can I go about determining the cell selection in handleCellSelection? I have the logic which determines if it's a full, left, middle, right. But if I can't use cellState.selectedPosition() I'm not really what else to use.
..if you have the logic which determines if it's a full, left, middle, right correctly based on your criteria, then why do you need cellState.selectedPosition() which also determines full, left, middle, right incorrectly based on a criteria different to what you want?
Fixed, thanks for your help. Closing this issue.
cool. sorry if i misunderstood your questions. glad its resolved.