From 6d7ec882228ba3a84ad255121008c3493e6eea90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Roumy?= Date: Fri, 23 Jun 2023 15:10:12 +0200 Subject: [PATCH] ui: fix padding on click ripple --- .../multidatepicker/MultiDatePicker.kt | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/multiDatePicker/src/main/java/com/playmoweb/multidatepicker/MultiDatePicker.kt b/multiDatePicker/src/main/java/com/playmoweb/multidatepicker/MultiDatePicker.kt index 6e9fd07..73484a4 100644 --- a/multiDatePicker/src/main/java/com/playmoweb/multidatepicker/MultiDatePicker.kt +++ b/multiDatePicker/src/main/java/com/playmoweb/multidatepicker/MultiDatePicker.kt @@ -94,6 +94,7 @@ fun MultiDatePicker( ) }.time } + .padding(xxsmallPadding) ) } @@ -113,9 +114,10 @@ fun MultiDatePicker( Text( text = currDate.value.toMonthYear(), style = MaterialTheme.typography.bodyMedium.copy(color = colors.monthColor), - modifier = Modifier.clickable { - isSelectYear.value = true - } + modifier = Modifier + .clip(RoundedCornerShape(smallRadius)) + .clickable { isSelectYear.value = true } + .padding(xxsmallPadding) ) Row { @@ -145,25 +147,28 @@ fun MultiDatePicker( .height(pickerHeight.value) .fillMaxWidth(), state = yearScrollState, - verticalArrangement = Arrangement.spacedBy(xsmallPadding), horizontalAlignment = Alignment.CenterHorizontally ) { items(allYears) { year -> val isSelected = year == calendar.value.get(Calendar.YEAR) - Text( - year.toString(), - style = if (isSelected) MaterialTheme.typography.headlineMedium.copy(color = colors.monthColor, fontWeight = FontWeight.Black) - else MaterialTheme.typography.titleLarge.copy(color = colors.weekDayColor), + Box( modifier = Modifier - .height(pickerHeight.value / 7 - (if (isSelected) 0.dp else xsmallPadding)) + .height(pickerHeight.value / 7) + .clip(RoundedCornerShape(smallRadius)) .clickable { - currDate.value = calendar.value.apply { - set(Calendar.YEAR, year) - }.time + currDate.value = calendar.value.apply { set(Calendar.YEAR, year) }.time isSelectYear.value = false - } - ) + }, + contentAlignment = Alignment.Center + ) { + Text( + year.toString(), + style = if (isSelected) MaterialTheme.typography.headlineMedium.copy(color = colors.monthColor, fontWeight = FontWeight.Bold) + else MaterialTheme.typography.titleLarge.copy(color = colors.weekDayColor, fontWeight = FontWeight.Light), + modifier = Modifier.padding(horizontal = xsmallPadding) + ) + } } } } else {