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

[Question] Is it possible to setup a listener for date changes? #61

Open
nd1111 opened this issue Jun 9, 2023 · 3 comments
Open

[Question] Is it possible to setup a listener for date changes? #61

nd1111 opened this issue Jun 9, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@nd1111
Copy link

nd1111 commented Jun 9, 2023

We need to react to the user selecting different days on the calendar, is that possible?

@maxkeppeler
Copy link
Owner

I'm not sure if I understand correctly, but yes it's possible to select multiple dates with the CalendarUseCase where you need to setup a listener to receive the different dates.

@nd1111
Copy link
Author

nd1111 commented Jun 12, 2023

Sorry I should be more specific. We're displaying a sheets calendar view (single day selection) with a different control below. That other control needs to know what date is selected in the calendar view so it can change what it displays. So I need to execute some code when the sheets calendar view selects a new date.
I have this below, but it seems the "onSelectDate" never fires:

    CalendarView(
        useCaseState = rememberUseCaseState(),
        config = CalendarConfig(
            yearSelection = true,
            monthSelection = true,
            boundary = timeBoundary,
            style = CalendarStyle.MONTH,
        ),
        selection = CalendarSelection.Date(
            selectedDate = selectedDay.value
        ) {
            selectedDay.value = it
        }
    )

@maxkeppeler
Copy link
Owner

It only fires through an action, such as the positive button click or via the latest useCaseState invokePositiveAction. It was not intended to invoke the listener whenever it changes. (You can now hide the button view as well.)

I probably can add a change listener to the selection classes, which would be updates just whenever the selection changes, which comes especially handy for the simple use-case views.

@maxkeppeler maxkeppeler self-assigned this Jun 12, 2023
@maxkeppeler maxkeppeler added the enhancement New feature or request label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants