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

Does 1 row calendar view sometimes skips days? #12

Closed
soundsmitten opened this issue Apr 30, 2016 · 28 comments
Closed

Does 1 row calendar view sometimes skips days? #12

soundsmitten opened this issue Apr 30, 2016 · 28 comments
Assignees

Comments

@soundsmitten
Copy link

In your example, I change line 40 in ViewController.swift to:

calendarView.numberOfRowsPerMonth = 1 

Most of the days are properly displayed but sometimes there are gaps in days:

screenshot of simulator 4-30-16 2-30-12 pm

I haven't found a pattern in when days are skipped just yet.

My workaround right now is to call

calendarView.changeNumberOfRowsPerMonthTo(1, withFocusDate: NSDate())
calendarView.reloadData()

in viewDidLoad. It gives me an animation when hopping to the date, which isn't ideal, but works for now.

@patchthecode
Copy link
Owner

If you are changing the numberOfRowsPerMonth property, then you must do it like so

calendarView.numberOfRowsPerMonth = 1
calendarView.reloadData()

or so

calendarView.changeNumberOfRowsPerMonthTo(1, withFocusDate: myDate)

@patchthecode
Copy link
Owner

Checking to see when your issue above occurs.

@patchthecode
Copy link
Owner

patchthecode commented Apr 30, 2016

  1. Can you give me the date range you have chosen when you saw that bug above?
  2. Can you tell me if paging is enabled or not?

@soundsmitten
Copy link
Author

  1. Range is -2month to +2month
  2. Paging is disabled.

I'm calling

  calendarView.numberOfRowsPerMonth = 1
calendarView.reloadData()

The numbers start getting lost around March.

@patchthecode
Copy link
Owner

patchthecode commented Apr 30, 2016

75264be2-0ee0-11e6-9b2e-d6d87ff2137b

screen shot 2016-04-30 at 1 13 44 pm

screen shot 2016-04-30 at 1 14 00 pm

I think what you are seeing is the end of a month and the start of another?

[Edit]
End of March - Start of April

@patchthecode
Copy link
Owner

[EDIT]
So what you are seeing above is happening around March- April (i assume)
However, in your provided screen shot, I am seeing the header "February" ?
I think you need to configure you NSCalendar.currentCalendar() to your correct setting so that the month will correctly say "March" in your screen shot.

@patchthecode patchthecode self-assigned this May 2, 2016
@soundsmitten
Copy link
Author

Yeah, thanks it's definitely the boundary dates. For a one row ticker I wouldn't want them, which I've been able to work around. Due to complexity with the single row stuff I'm trying to use, I might fall back to some sort of month view for now to accelerate development.

@patchthecode
Copy link
Owner

OK i see. If there is any upgrade you think this calendar should have, then suggest it and I will see what i can do. Should I leave this issue open for sometime still?

@patchthecode patchthecode changed the title 1 row calendar view sometimes skips days Does 1 row calendar view sometimes skips days? May 2, 2016
@soundsmitten
Copy link
Author

Ideally, when it's a one-row setup, there shouldn't be the boundary dates. Before I changed my mind, I was modeling an app based on Fantastical's week ticker. You can keep this open, as someone might be interested in this.

@patchthecode
Copy link
Owner

patchthecode commented May 3, 2016

I could implement the features so that you can build an app just like fantistical, but i will have to see what the fantastical looks like. Currently it costs about $4 plus on the app store.. and currently, I think it costs too much :(

But if you have time maybe you can send me some animated gif screens so that I can implement the features into this control. (If you got the extra free time of course)

@patchthecode
Copy link
Owner

After thinking about it some more, and after looking at the Fantastical GIF file you provided, I have realized there has to be more that goes in to the update of the calendar.

If you have paging mode off, then the days of the week will have to scroll along with the dates when a user scrolls. Because the dates will not be properly aligned with the days of the week column.

In order to achieve the following:

  1. Fantastical look
  2. The removal of boundary dates with one row of dates

Then the days of the week headers (sun, mon, tue, etc) will have to be scrollable inside of the calendarView itself, just like in the gif you have provided.

2014-04-01 04_38_10 pm

I will think about an upgrade.

@soundsmitten
Copy link
Author

I'm not going to ship it, but as an experiment I'm playing with the Fantastical ticker concept.

I've gotten the cells to display the day of week, which solves the issue (for now) for making them scrollable.

I've found that the trickiest parts of implementing this are:

  1. Detecting what date is on the leftmost side. Right now, I'm having to check for intersection with a rectangle, really dig into CollectionView, do some hackish offsets.
  2. Snapping the ticker to center on a day, i.e. handling the situation when the ticker stops in the middle of two days.

@patchthecode
Copy link
Owner

the function

func calendar(calendar: JTAppleCalendarView, didScrollToDateSegmentStartingWith date: NSDate?, endingWithDate: NSDate?)

tells you the start and end date. But it was developed with pagingEnabled = true
I will make the following update

  1. When paging is not enabled, that function will tell you the date that is on the Leftmost and the date on the Rightmost boundaries of the view.
  2. When in freeflowing mode, cells will snap in place so that they wont be in the middle.

Sounds good?

@patchthecode patchthecode added this to the Enhancements 2.0 milestone May 4, 2016
@soundsmitten
Copy link
Author

Sounds great!

@patchthecode
Copy link
Owner

patchthecode commented May 5, 2016

Ok, i need something answered (so that i dont code unnecessarily for objective # 1)

Is there any reason why you want to know which date is on the left most corner of the screen?
If i know what your intention is, then I will have a better idea on the solution.

@soundsmitten
Copy link
Author

I'll be showing information below the calendar for the date on the leftmost side.

@patchthecode
Copy link
Owner

So heres the thing. Since this control is to be used by all, i have to code to benefit all.
So lets say you have your single row of dates like so:

[29, 30, 31, 1, 2, 3, 4]

What do you want me to return? Let's say i return 29 as the leftmost date and 4 as the right most date.
This might solve your problem.

But the next question is, what would i return for the user who has two rows of dates?

[29, 30, 31, 1, 2, 3, 4]
[ 5, 6, 7, 8, 9, 10, 11]

This was my question. I have to return something that makes sense. I can't just do a solution for you and leave every one else out in the cold. So i need to know what to return for someone with more than one row of dates. Any ideas? (i'm still thinking on it as well)

@soundsmitten
Copy link
Author

Maybe it can return the visible date range: so for in that 2 row example, the NSDates of 29 and 11 would be returned.

@patchthecode
Copy link
Owner

I thought this at first, but then here is where it gets tricky,

// 1. Assume that the first section is currently visible on iPhone

        First Section               Second Section
[29, 30, 31, 1, 2, 3, 4]    [12, 13, 14, 15, 16, 17, 18]
[ 5, 6, 7, 8, 9, 10, 11]     [19, 20, 21, 22, 23, 24, 25]

// 2. Now lets say that the user scrolls one cell. The Visible screen will now look like this

[30, 31, 1, 2, 3, 4, 12]
[6, 7, 8, 9, 10, 11, 19] 

i think that it would be very confusing giving a user 30 and 19 :/
I am still thinking on this. Any ideas/arguments are welcome

@soundsmitten
Copy link
Author

Ah I see... Depending on how it's implemented (I need to look), any way you could pass the whole NSDate as start and end points?

@soundsmitten
Copy link
Author

If this isn't feasible, I'll probably use some sort of class extension on my own.

@soundsmitten
Copy link
Author

I have a solution at this point in my custom code, but it's extremely ugly, fragile, embarrassing, and not robust :D. I think baked into JTCalendar, some NSDate range might be a helpful feature for other folks, we could probably use other people's input.

@patchthecode
Copy link
Owner

patchthecode commented May 5, 2016

And hey, every thing is feasible. Its just that i want it to not be "bloated" code to solve a single problem while not accounting for the others. So from what I gather, the problem is that:

  1. Users want to know the date on the boundaries of the calendar, in order to perform some other logic?

So here's a solution i can implement. I will return an array of dates for the left column. And also an array of dates for the right column.

[29, 30, 31, 1, 2, 3, 4]   will return [29] and [4]


[30, 31, 1, 2, 3, 4, 5]   will return [30,6, 20] and [5,19, 26]
[6, 7, 8, 9, 10, 11, 19] 
[20, 21, 22, 23, 24, 25, 26] 

I can do this update easily. I just hope it isnt bloat code.
Does this sound like a good idea? If it is, i will get to work on objective # 1 right away.

@patchthecode
Copy link
Owner

On second thought. Maybe i'm overthinking it. Having the calendar on free flowing mode with more than 1 row seems weird and complicated when i tried it. I can't imagine any user doing this. Free flowing single rows seems ok though. Working on a solution now.

@soundsmitten
Copy link
Author

Yeah, no one will want that 2-3 rows. 1 row is a special case in terms of the date "skipping" because of boundaries, etc.

The snap to day is working great, by the way!

@patchthecode
Copy link
Owner

patchthecode commented May 6, 2016

Ah thanks. You can control the snapping scrolling by using the calendarView.scrollResistance property. I have updated the sample app to reflect the changes.

Also, Objective # 1 is completed.
Here is the Upgrade.

func cellStatusForDateAtRow(row: Int, column: Int) -> CellState?

By supplying the row and column, user can get information about a visible date cell.

so for instance if your visible cells look like this:

[30, 31, 1, 2, 3, 4, 5] 
[6, 7, 8, 9, 10, 11, 19] 
[20, 21, 22, 23, 24, 25, 26]

if you do cellStatusForDateAtRow(1, column:2), this will return a CellStatus for the date 8th.
CellStatus information includes: isSelected, text, dateBelongsTo, date, and day of the week.

Do a git pull and let me know if it works for you. If there are no bugs, i will officially do an update. Also let me know if there is any thing else needed to make JTAppleCalendar create a calendar like fantastical.
If you have anything else, close this issue and open a new one so we can talk there (cuz this thread is getting long )

@soundsmitten
Copy link
Author

Ok, sorry for the delay, I'll check it out as soon as I get to a Mac!

@patchthecode
Copy link
Owner

Added to version 2.1.2
closing issue.

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