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

How to focus the month with VerticalYearCalendar on first load? #587

Open
zeroarst opened this issue Sep 16, 2024 · 1 comment
Open

How to focus the month with VerticalYearCalendar on first load? #587

zeroarst opened this issue Sep 16, 2024 · 1 comment

Comments

@zeroarst
Copy link

zeroarst commented Sep 16, 2024

Library information:

  • Version: 2.5.4
  • View or Compose module: VerticalYearCalendar

Question:

When opening up VerticalYearCalendar, it focus on the given year at the top, but I want to make current day and the the current month visible when loaded.

For example, by chaning the Example11Page sample code.

Change

val selections = remember { mutableStateListOf<CalendarDay>() }

to

val selections = remember { mutableStateListOf(CalendarDay(LocalDate.of(2024, 9, 10), DayPosition.MonthDate)) }

Change monthColumn to 2 to ensure that not all months are visible.
Add code above to


with

monthColumns = 2,

Change

isMonthVisible = {
it.yearMonth >= currentMonth
},

to

// isMonthVisible = {
//     it.yearMonth >= currentMonth
// },

Launch the example. We can see that it does not focus on 2024 Sep.
image

Is there any workaround for it?

@kizitonwose
Copy link
Owner

In the view version, there are scrollToMonth and scrollToDay functions in the year calendar, but these unfortunately do not yet exist in the compose library. I am hoping to add them at some point in the future when I have some time.

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

No branches or pull requests

2 participants