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

SelectedPosition problem when config generateInDates or generateOutDates #1273

Open
SajjadKharrazi opened this issue May 15, 2020 · 19 comments
Assignees

Comments

@SajjadKharrazi
Copy link
Contributor

with these configuration of calendar:

ConfigurationParameters(startDate: startDate, endDate: endDate, generateInDates: .off, generateOutDates: .off)

then cellState.selectedPosition() returns wrong response in start and end of month.
you have an 2tapRangedSelection example, you can edit it and see wrong result.

@SajjadKharrazi
Copy link
Contributor Author

in my app i set this generateOutDates: .tillEndOfRow
and as you can see if month day ends at middle of the week, everything works great:

image

but if a month day ends at end of the week, so it will break. like Jun 2021 and Jul 2021

image

or in April 2022 and May 2022:

image

@SajjadKharrazi
Copy link
Contributor Author

when i set generateOutDates: .off, it will be like this: ( end of the month day is in middle )

image

@patchthecode
Copy link
Owner

this ?

calendarView.rangeSelectionMode = .continuous
calendarView.rangeSelectionMode = .segmented

@SajjadKharrazi
Copy link
Contributor Author

SajjadKharrazi commented May 16, 2020

with .continuous it works correctly

thank you

@SajjadKharrazi
Copy link
Contributor Author

SajjadKharrazi commented May 16, 2020

oops!
with generateOutDates: .tillEndOfRow and calendarView.rangeSelectionMode = .continuous look likes great!

but with generateOutDates: .off and calendarView.rangeSelectionMode = .continuous, last day of month does not have correct SelectedPosition state
( i selected from 22 Jul to 31 Jul )

image

@patchthecode patchthecode self-assigned this May 16, 2020
@patchthecode patchthecode added bug and removed bug labels May 16, 2020
@patchthecode
Copy link
Owner

The behaviour you are seeing is not a bug. It is behaving as intended. It appears that way on your screen because you have hidden the outdates.

The real issue here seems to be this --> I do not have a have to code the library that will satisfy every developer for ranged selection.

There are many conditions that have to be considered.
I will list them later today.

@patchthecode
Copy link
Owner

ok. I see an edge case fix that i can apply.
Let me test it.

@patchthecode
Copy link
Owner

Keep in mind, i know how to fix your issue.
However, if i code it the way you want, then other developers might not like the new behavior. Therefore, let me test an edgecase fix for this case when the final day lands on end of index. Be right back.

@patchthecode
Copy link
Owner

patchthecode commented May 16, 2020

Ok yea, the fix will work. But other developers wont be happy.

Therefore i have determined the ultimate solution for this.
This library needs to create a new set of functions.

calendarView.showIndates()
calendarView.hideIndates()
calendarView.showoutDates()
calendarView.hideOutDates()

Because the problem is that i let the developers determine when to show or hide the indates/outDates on their own.
Because of this, the library does not know when a developer has done this. And because I do not know, I cannot suggest the best visual way the range selection should look.

However, if this library now begins to manage the visibility/invisibility of the inDates/OutDates, Then i will know how to adjust what the ranged left, right, middle should look like.

@SajjadKharrazi
Copy link
Contributor Author

greaaaat!!!
when we can use this?

@patchthecode
Copy link
Owner

patchthecode commented May 16, 2020

I didnt want this library to "hold the developers hand" so much however.....
But it seems that i locked my self into this problem the moment i introduced the selectedPosition feature

@SajjadKharrazi
Copy link
Contributor Author

it's not possible to handle it with generateOutDates parameters?

@SajjadKharrazi
Copy link
Contributor Author

if generateOutDates is .off then handle it like calendarView.hideOutDates()

@patchthecode
Copy link
Owner

patchthecode commented May 16, 2020

How do you suggest?
This is the problem with selecting dates 26 - 31 with outdates/indates hidden.

Screen Shot 2020-05-16 at 10 02 32 AM

If i unhide it, you can see that the library correctly does it as continuous.
The 2nd row of selected dates is** the indates you hid. You can see it is correctly continous.

Screen Shot 2020-05-16 at 10 03 57 AM

@patchthecode
Copy link
Owner

patchthecode commented May 16, 2020

But because it is hidden by the developer (and not the library). The library does not know about it. And therefore cannot make the 31 to be red color.

I can do a fix to fix the issue. But then it will no longer be continuous.
However, If the library manages the visibility of indates/outdates for the developer, then i can fix the range selection under the hood.

@SajjadKharrazi
Copy link
Contributor Author

SajjadKharrazi commented May 16, 2020

but i think developer hide outDate and inDate dates. we always have one 31 which is shown and it's not hidden. so you can decide selectedPosition on visible date.

as you said above if you want to add these functions in library:

calendarView.showIndates()
calendarView.hideIndates()
calendarView.showoutDates()
calendarView.hideOutDates()

i think you can handle it with generateInDates and generateOutDates. like this: ( i think these are equal )

{ calendarView.showIndates() } == { generateInDates: .forFirstMonthOnly, .forAllMonths }
{ calendarView.hideIndates() } == { generateInDates: .off }
{ calendarView.showoutDates() } == { generateOutDates: .tillEndOfRow, .tillEndOfGrid }
{ calendarView.hideoutDates() } == { generateOutDates: .off }

Although maybe I'm wrong and just .off param is equal to related hide or show function

@patchthecode
Copy link
Owner

patchthecode commented May 16, 2020

Ah.
Let me clear it up.
Here indates/outdates are generated and visible.

Screen Shot 2020-05-16 at 10 22 25 AM

Here indates/outdates are generated and hidden/invisible.

Screen Shot 2020-05-16 at 10 23 41 AM

Here indates/outdates are not generated at all. And therefore are not visible.

Screen Shot 2020-05-16 at 10 24 42 AM

So there is difference between generating them and hiding them.

With the solution i plan to implement, I will be handeling the visibility (not the generation).
Based on the visibility, i can fix how the range looks. The decision to generate/not generate will not be handled by the library. It will be handled by the developers.

@imphila
Copy link

imphila commented Jun 16, 2020

how to config like this

@marcuswu0814
Copy link

Hi @patchthecode @SajjadKharrazi , I face the same problem, any workaround for this situation? 🙏

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

4 participants