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

Add different selection modes to Calendar (Single, Multi, Range) #66

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

PucklaJ
Copy link

@PucklaJ PucklaJ commented Jun 22, 2023

This PR adds different modes of selection to the calendar.

  • CalendarSingle
    This is the same as the current mode. Only one date can be selected at once.
  • CalendarMulti
    Multiple random dates can be selected at the same time
  • CalendarRange
    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:

  1. SelectedDates field has beend added to the calendar struct
    Here 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.
  2. OnSelected has been replaced by OnChanged OnChanged has been added as a callback for the new modes
    The OnChanged callback is now called everytime the user presses a button and the selected dates are changed. While OnSelected is called with the clicked date if the date is part of the selected dates.
  3. Selected date buttons are highlighted using the HighImportance
    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

Copy link
Member

@andydotxyz andydotxyz left a 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?

@PucklaJ
Copy link
Author

PucklaJ commented Jul 17, 2023

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.

@andydotxyz
Copy link
Member

Perhaps OnSelected is still valid, as is. And a new callback (OnChanged?) might provide the ability for the slice/range types of callback?

@PucklaJ
Copy link
Author

PucklaJ commented Dec 14, 2023

@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.
@andydotxyz
Copy link
Member

I'm very sorry this PR got left for a while without re-review.
The Calendar has since been promoted to the fyne repo on develop branch - would you be interested in re-creating the work over there. We are working on some time input widgets that provide a single "input field" type approach which might make it easier to see how multi-select calendar fits in?

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

Successfully merging this pull request may close these issues.

2 participants