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

Selecting a date should also select its FollowingMonthWithinBoundary or PreviousMonthWithinBoundary counterpart and vice versa #18

Closed
N1c0L4z3R opened this issue May 17, 2016 · 12 comments
Assignees

Comments

@N1c0L4z3R
Copy link
Contributor

N1c0L4z3R commented May 17, 2016

Hello,

I'm trying to do a range selection. Everything works fine except when I try to select multiple dates.
Dates from the previous or next month, displayed in the current month view are not being selected when I call calendarView.selectDates([dates]).
Also, selecting (by tapping) a date from FollowingMonthWithinBoundary or PreviousMonthWithinBoundary won't select the date on the month it belongs.

On the screenshots I selected April 1st as start date and May 10 as end date and I'm selecting all the dates between with calendarView.selectDates method.
img_1701
img_1702

Is there any solution/workaround to achieve this please?

@patchthecode patchthecode self-assigned this May 18, 2016
@patchthecode patchthecode added this to the Questions milestone May 18, 2016
@patchthecode
Copy link
Owner

Looking into this to see if i understand your problem. one sec.

@patchthecode
Copy link
Owner

Ok, i get what you're saying.

Selecting a date should also select its FollowingMonthWithinBoundary or PreviousMonthWithinBoundary counterpart?

@N1c0L4z3R
Copy link
Contributor Author

Yes that's exactly what I want to do with calendarView.selectDates()
Is it possible please?

@patchthecode
Copy link
Owner

patchthecode commented May 18, 2016

It will be possible after i put in the next update. Should be in by this Saturday worst case or by end of day today best case.
I had forgot to include that code actually. In making the calendar I cant think of every scenario unless you guys point it out.

One last request: How did you make the other dateCells to have the date only for one date and Month plus date for another cell?
screen shot 2016-05-18 at 8 19 26 am
screen shot 2016-05-18 at 8 19 17 am

Did you have all the configuration for the cell in a single xib file?
The reason I am asking you this is because I am currently working on an upgrade that should allow you to register multiple cells, which would reduce the clutter of a developer cramming trying to cram multiple configurations into an xib. So letting me know how you did it would be very beneficial to this project. Thanks.

@patchthecode patchthecode changed the title When calling selectDates function, dates from following/previous month within boundaries are not selected Selecting a date should also select its FollowingMonthWithinBoundary or PreviousMonthWithinBoundary counterpart and vice versa May 18, 2016
@N1c0L4z3R
Copy link
Contributor Author

Thank you very much for updating the library!

For the month displayed on the cell, I did it in the setupCellBeforeDisplay of the CellView.
The xib is the same, only the label is being displayed on 2 lines instead of 1.

        let cal: NSCalendar = NSCalendar.currentCalendar()
        let comp: NSDateComponents = cal.components([.Day], fromDate: cellState.date)

        if comp.day == 1 {
            let monthFormatter = NSDateFormatter()
            monthFormatter.dateFormat = "MMM"

            let attributedString = NSMutableAttributedString()
            attributedString.appendString(monthFormatter.stringFromDate(cellState.date), color: UIColor.darkGrayColor(), font: .buttonTextBoldFont())
            attributedString.appendString("\n\(cellState.text)", color: UIColor.darkGrayColor(), font: .termsOfUseFont())
            dayLabel.attributedText = attributedString
        }

Hope it helps a bit ;)

@patchthecode
Copy link
Owner

patchthecode commented May 18, 2016

Thanks. I'll continue with the fix i mentioned above, and the update coming for this Saturday or end of day today (best case scenario)

@patchthecode
Copy link
Owner

updated to version 3.0.0
Let me know if its still an issue. Or we can close this one.

@N1c0L4z3R
Copy link
Contributor Author

Hello!
Thank you for the update I'm going to check and I'll let you know!

@patchthecode
Copy link
Owner

patchthecode commented May 24, 2016

updated to version 3.0.1 to fix a small visual bug i missed.
Closing this issue. Reopen it if you are still experiencing problems.

@N1c0L4z3R
Copy link
Contributor Author

Hi again.
Thank you so much!! It's working great!

I only have one issue now, you commented "init(frame: CGRect)" and the only initializer left is "init?(coder aDecoder: NSCoder)".
This is good if you are working only with XIB or storyboards, but since in my team we are doing everything in code, this optional initializer is driving me crazy and require me to unwrap the variable everywhere in my code.
Could you add a simple init or uncomment the init(frame: CGRect) line 389 please? :)

Also do you want me to open a new issue for this?
I think it could be a nice improvement to make the lib 100% independent from xib.
Thank you for your time and your great lib!

@patchthecode
Copy link
Owner

Ok. Open a new issue for this. I will look into it in the mean time.

@patchthecode
Copy link
Owner

Oh that init! haha. I commented it out to look into something. I forgot to uncomment it.
Uncomment it from your end. I will do a patch release after i work out a visual bug i'm working on.

In the mean time, just open a new issue for this. thanks!

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