-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add different selection modes to Calendar (Single, Multi, Range) #66
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this could be made backward compatible by defaulting to single data selection. Then a field or method could change this after constructor returns?
I changed the constructor to default to single mode. It is more backwards compatible, but not completely since the callback requires a slice instead of a single variable. |
Perhaps |
@andydotxyz I readded the OnSelected callback and changed the default constructor to the way it was before. For the Single mode it works the same way and for the Multi and Range mode I called the callback everytime a date is pressed and part of the selected dates. |
that have been selected are now inside the SelectedDates slice of the calendar. A date button is colored using HighImportance if it is selected. And the OnSelect callback has been replaced by the OnChanged callback.
3b26095
to
9bd1fe0
Compare
I'm very sorry this PR got left for a while without re-review. |
This PR adds different modes of selection to the calendar.
This is the same as the current mode. Only one date can be selected at once.
Multiple random dates can be selected at the same time
Select a beginning and end to select all dates in between those dates.
To achieve this change some compatibility breaking changes had to be made:
SelectedDates
field has beend added to the calendar structHere all dates that the user will select are stored no matter what mode has been chosen. This can also be freely manipulated as it is an exported field. When calling
Refresh
the display is updated.OnSelected
has been replaced byOnChanged
OnChanged
has been added as a callback for the new modesThe
OnChanged
callback is now called everytime the user presses a button and the selected dates are changed. WhileOnSelected
is called with the clicked date if the date is part of the selected dates.Since there isn't another way to give buttons custom colors right now. I used the Importance system to signal the user which dates have been selected. And if a button is not selected it uses the previous LowImportance.
This also takes care of #54