ComposeCalendar icon indicating copy to clipboard operation
ComposeCalendar copied to clipboard

Inconsistent padding/height

Open CmdrSharp opened this issue 2 years ago • 6 comments

Hi! Thanks for a great composable :)

I've found that the padding seems a tad inconsistent. Below are three screenshots. The text at the bottom is positioned the same across all three, but note how the calendar has padding on some months, and none on others. From my testing, it seems that some months in each year (different for different years) get padded.

See the screenshots, where you can notice this clearly on the month April.

The following months have padding added in 2022

  • April
  • September
  • December

In 2023 the following months have padding:

  • June
  • September

And in 2024, the following:

  • August
  • November

..And so on. I find no good reason for this behaviour when looking through the source.

Here's an example to reproduce:

import androidx.compose.foundation.layout.Column
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.navigation.NavController
import io.github.boguszpawlowski.composecalendar.SelectableCalendar
import io.github.boguszpawlowski.composecalendar.rememberSelectableCalendarState
import java.time.DayOfWeek

@Composable
fun SplashScreen(navController: NavController) {
    val state = rememberSelectableCalendarState()

    Column {
        SelectableCalendar(
            calendarState = state,
            showAdjacentMonths = true,
            firstDayOfWeek = DayOfWeek.MONDAY,
        )

        Text(text = "Test")
    }
}

image image image

CmdrSharp avatar Apr 20 '22 17:04 CmdrSharp

Some further debugging: This only occurs with horizontalSwipeEnabled set to true.

CmdrSharp avatar Apr 20 '22 17:04 CmdrSharp

Hi @CmdrSharp Thank you for submitting the issue. Unfortunately, the bug is caused by Horizontal Pager, which calculates its height eagerly, thus setting it to a height of a month with 5 rows. So right now I don't think its fixable from my side, but I will check if its an expected behaviour of the pager over the weekend.

boguszpawlowski avatar Apr 20 '22 18:04 boguszpawlowski

I understand. A possible workaround is mentioned here: https://github.com/google/accompanist/issues/1050

CmdrSharp avatar Apr 20 '22 18:04 CmdrSharp

Another interesting note @boguszpawlowski: Note how June and April have the same amount of row, yet one has padding, and one does not.

CmdrSharp avatar Apr 21 '22 09:04 CmdrSharp

@CmdrSharp Thanks for the workaround! I will see if it's fixing the problem in this case.

boguszpawlowski avatar May 01 '22 18:05 boguszpawlowski

@CmdrSharp Sorry for a late reply, I was able to try the workaround, but the results were pretty laggy and inconsistent. So, until a better workaround comes, or this will be fixed from the Accompanist side, I will leave mark this issue as blocked.

boguszpawlowski avatar May 16 '22 23:05 boguszpawlowski