WojciechOsak / Calendar

Kotlin Multiplatform Calendar Library
Apache License 2.0
68 stars 3 forks source link

WeekView centering. #2

Closed kalist28 closed 1 month ago

kalist28 commented 1 month ago

When item of a day is smallest, then all items don't centering by max width аnd they are located on the right side.

WeekView(
    modifier = Modifier.fillMaxWidth()
) { state ->
    Column(
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Text(
            text = state.date.daySimpleName(),
        )

        CalendarDay(
            state,
            onChange = { date = it },
        )
    }
}

image

WojciechOsak commented 1 month ago

Hey @kalist28 thanks for report, however this depends on how you define day composable for WeekView. In this case it is just a matter of horizontalAlignment = Alignment.CenterHorizontally set to column inside of WeekView.

kalist28 commented 1 month ago

In this case, I need to calculate the screen width outside WeekView, do it for 7 days and set the result as the width for the day, in this case everything will be fine, but without days will be close to the left side, as in the screenshot and the smaller the size of the day, the more free space. It seems to me that the alignment in this view should be by default and the elements should not be attached to the left side regardless of size.

You can experiment in the sample module and replace Modifier.size(52.dp) with any smaller one and you will see the problem.

I hope we understood each other correctly, maybe you just don’t think it’s a problem:)

WojciechOsak commented 1 month ago

Ohh now I got it what you mean 😁 I just saw your fix here, it is merged and will be shipped with next release, thanks for your contribution!