kizitonwose / Calendar

A highly customizable calendar view and compose library for Android and Kotlin Multiplatform.
MIT License
4.67k stars 505 forks source link

Is there a way to figure out position of the element? #495

Closed akrulec closed 1 year ago

akrulec commented 1 year ago

Hi, I'm using view's library, and I would to show continuity of something that is broken by the first and the last element of the week (and in the month view by the first or the last element of the month). For example:

Is that possible? If so, when and where can I set this up? I couldn't find any helper methods that would let me determine the position of the day in the recycler view. Thank you in advance.

Attaching screenshot. Each day individually knows whether to draw the line left of right of it, but the calendar should somehow also help it determine whether it's the last or first element in a row.

Screenshot 2023-09-05 at 16 59 46
kizitonwose commented 1 year ago

This is certainly possible with some work. You can store the month as suggested here, then check the day position in the array when the day is bound. Alternatively, you can figure this out using the date itself but you'll need some more logic to get its position on the calendar grid.