Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deselectAllDates with triggerSelectionDelegate: false and selectDates with triggerSelection false and keepSelection false not working after upgrading to Xcode 9 and iOS 11 #615

Closed
cazares opened this issue Nov 7, 2017 · 15 comments
Assignees

Comments

@cazares
Copy link

cazares commented Nov 7, 2017

  1. I am using v7.1.2 of JTAppleCalendar

  2. Yes, I'm using the latest.

  3. First off, thank you so much for all the work you put into this library! I love it and so do our customers!
    NOTE: this WAS working before. Upon upgrading to Xcode 9/iOS 11, this issue now happens where
    deselectAllDates(triggerSelectionDelegate: false)
    is not working. Also,
    selectDates(from, to, triggerSelectionDelegate: false, keepSelectionIfMultiSelectionAllowed: false)
    doesn't seem to work either. Let me try and explain my implementation a bit to better show you the issue.

almostcompletecal

Upon startup, the last 7 days are selected programmatically. Notice there's two synced textfields at the top showing from and to dates. This is working fine.

almostcompletecal

If I select a date outside the initial range, a new range is made with from and to equal to each other (this is the start of a new range). Notice that the synced textfields are correct, but Nov. 1 through Nov. 7 did not get deselected. This is the first issue.

almostcompletecal

The second issue is that selectDates isn't selecting a range of dates like it used to. Notice in this screenshot that we expect Mon, Oct 09 through Fri, Oct 13 to be the range, Oct 10, 11, and 12 are not selected.

Here is a link to my gist including relevant code:
https://gist.github.com/cazares/d8f8da366e0fe803a15f5bcdb865a9eb

I've been working on this all day and I can't seem to get anywhere. Any help is greatly appreciated!

@patchthecode
Copy link
Owner

hey i think the link to you code gist is not working. Got the link?

@patchthecode
Copy link
Owner

Also, did you implement a shouldSelect or shouldDeselect function?
This now gets called when you do a selection or deselection.
?

@cazares
Copy link
Author

cazares commented Nov 7, 2017

Try now. Also, no I don't implement shouldSelect or shouldDeselect, should I?

@patchthecode
Copy link
Owner

patchthecode commented Nov 7, 2017

@cazares ok i'll look at your code more in detail after work.
You do not have to implement shouldSelect or shouldDeselect. I just asked to further determine the source of your issue.

Since you updated to the latest version. Did you implement the willDisplayItem function?
The one must be implemented according to this -> #553

Let me know if you have done this?

@cazares
Copy link
Author

cazares commented Nov 8, 2017

This one?
func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath)
Yes, but it's an empty implementation.

@cazares
Copy link
Author

cazares commented Nov 8, 2017

Hey I fixed the problem by doing this in willDisplay cell:
cell.isSelected = isInsideDateRange(date)
Thanks for pointing me in the right direction!

@cazares cazares closed this as completed Nov 8, 2017
@cazares cazares reopened this Nov 8, 2017
@patchthecode
Copy link
Owner

@cazares one thing. try to use the cellState.isSelected instead of cell.isSelected

on that same link -> #553 on problem # 2, i explained why.
I am working on an update soon that will allow developers to use the isSelected directly on a cell. But I have not coded it yet. I'll finish it soon.

@cazares
Copy link
Author

cazares commented Nov 8, 2017

For this:
cellState.isSelected = isInsideDateRange(date)
I get "Cannot assign to property: 'isSelected' is a 'let' constant

@cazares
Copy link
Author

cazares commented Nov 8, 2017

Can you give an example how to change isSelected from cellState?

@patchthecode
Copy link
Owner

OK. wait, i thought you were just doing a simple check to see if a cell was selected or not.

I might have been mistaken. What are you doing with the isSelected of a cell? Are you trying to select the cell by setting cell.isSelected = true ?
I am not clear what you are doing.

@cazares
Copy link
Author

cazares commented Nov 8, 2017

Yes I am just looking for different ways to deselect and select a range of cells other than deselectAllDates(triggSelectionDelegate: false) and selecctDates(from, to, triggerSelectionDelegate: false, keepSelectionIfMultiSelectionAllowed: false). These two functions were working before, but now they are not. Seems like keepSelectionIfMultiSelectionAllowed: false is not being respected.

@patchthecode
Copy link
Owner

patchthecode commented Nov 8, 2017

is it possible you can join chat here? https://gitter.im/patchthecode/JTAppleCalendar
typing here is too slow.
But yes,

deselectAllDates(triggSelectionDelegate: false)

and

selectDates(from, to, triggerSelectionDelegate: false, keepSelectionIfMultiSelectionAllowed: false)

Should work. If this does not work, then I need to fix something. Let's not do a work around for something as important as this. I fix issues no matter how small they seem. And this sounds like a huge issue.

  1. Selecting dates work by using any of the selectDate functions
  2. Deselection works by either calling deselectAllDates or (if youre in multiselect mode) by calling a selectDate function again.

keepSelectionIfMultiSelectionAllowed = true means, that if you have a cell selected (under a multiselect calendar) and you try to select it again, it will remain selected.
keepSelectionIfMultiSelectionAllowed = falsethat if you have a cell selected (under a multiselect calendar) and you try to select it again, it will be deselected.

Let me know when is a good time to join the chat.

@cazares
Copy link
Author

cazares commented Nov 8, 2017

Yes I will join shortly.

@cazares
Copy link
Author

cazares commented Nov 8, 2017

I know we have a chat later, but I just wanted to mention that I found out that reverting to any version of JTAppleCalendar between 7.0.0 and 7.0.6 all work. Version 7.1.0 is the first version where my functionality breaks, all the way up to 7.1.3 (all 7.1 versions are broken).

@patchthecode
Copy link
Owner

Closing issue until user responds.
I could not reproduce this in version 7.1+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants