hi-manshu / Kalendar

Kalendar is a powerful and customizable calendar library for Android applications. It provides a flexible and intuitive way to display and interact with calendars in your app. With Kalendar, you can easily render calendar views, handle date selection, pagination, and range selection, and customize the layout to match your app's design.
https://www.himanshoe.com
Apache License 2.0
818 stars 66 forks source link

Incorrect Month Progression. #157

Open Onwa1kenobi opened 1 year ago

Onwa1kenobi commented 1 year ago

image

I think I may be doing something wrong, because for some reason, when I am using the Endlos version of the calendar, I only get the remaining months of the current year, for all years. As you can see from the screenshot, after December, the next year begins from August.

Also, if the week does not have dates in the current month, there looks to be some kind of a padding/margin issue I haven't been able to fix. Any pointers would be appreciated.

AndroidJunior9 commented 1 year ago

I am working on this issue. I think the problem is with the KalendarPagingSource Class. In this class we filter the kalendar items.

Screenshot (1)

I think the kalendaritems are not filtered correctly. I am not sure though. I think it should be changed from: val kalendarItems = kalendarRepository.generateDates(page) .filter { date -> date.year >= today.year && date.month.value >= today.monthNumber } to val kalendarItems = kalendarRepository.generateDates(page) .filter { date -> date.year >= today.year && date.month.value >= today.monthNumber }

What happens is that when we filter dates in the first example, we say that the year should be greater than or equal to the current year which is 2023. It means that only dates whose year is greater than or equal to 2023 are allowed. Thats fine but the problem here is that the months are also filtered according to the today's month. Thats why we say see august month after December as any dates before the month of august are not in the kalendaritems.

In the next example we solve this issue.

I have created a pull request too for this issue: Fixed InCorrect Month Progression Bug

ParkJongJoon7128 commented 1 year ago

how did u make a dot on Day?

AndroidJunior9 commented 1 year ago

Just Use the KalendarEvents function inside the Kalendar

ParkJongJoon7128 commented 1 year ago

can u show how to use it like for instance?

AndroidJunior9 commented 1 year ago

Sure, Here is an example how you can add events to your calendar

Kalendar(          currentDay = currentDay,          kalendarType = kalendarType,          modifier = modifier,          daySelectionMode = daySelectionMode,          showLabel = showLabel,          kalendarHeaderTextKonfig = kalendarHeaderTextKonfig,          kalendarColors = kalendarColors,          kalendarDayKonfig = kalendarDayKonfig,          onDayClick = onDayClick,          dayContent = dayContent,          headerContent = headerContent,          events = KalendarEvents(                  listOf(KalendarEvent(                         date = //date                          eventName  = "event"//add your event name                  )          ),          onRangeSelected = onRangeSelected,          onErrorRangeSelected = onErrorRangeSelected      ) }

ParkJongJoon7128 commented 1 year ago

I dont know how to set dot in day each....

Could u share me ur code..? I want to refer to it