From bdc39e31fc2ae6401eadb67cd6dfda8a0fba5243 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Fri, 18 Oct 2024 09:35:09 +0200 Subject: [PATCH] Better write CrossCircleButton --- .../swisstransfer/ui/components/CrossCircleButton.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/CrossCircleButton.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/CrossCircleButton.kt index 1f910edef..10a8c525a 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/CrossCircleButton.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/CrossCircleButton.kt @@ -17,6 +17,7 @@ */ package com.infomaniak.swisstransfer.ui.components +import android.content.res.Configuration import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.* @@ -26,6 +27,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.coerceAtLeast import androidx.compose.ui.unit.dp @@ -34,15 +36,13 @@ import com.infomaniak.swisstransfer.ui.images.AppImages import com.infomaniak.swisstransfer.ui.images.icons.CrossThick import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow @Composable @OptIn(ExperimentalMaterial3Api::class) fun BoxScope.CrossCircleButton(onClick: (() -> Unit)?, size: Dp = 48.dp) { - CompositionLocalProvider(LocalRippleConfiguration provides RippleConfiguration(color = Color.White)) { - val buttonPadding = ((size - 24.dp) / 2f).coerceAtLeast(0.dp) + val buttonPadding = ((size - 24.dp) / 2f).coerceAtLeast(0.dp) + CompositionLocalProvider(LocalRippleConfiguration provides RippleConfiguration(color = Color.White)) { Button( modifier = Modifier .size(size) @@ -64,8 +64,8 @@ fun BoxScope.CrossCircleButton(onClick: (() -> Unit)?, size: Dp = 48.dp) { } -@PreviewSmallWindow -@PreviewLargeWindow +@Preview(name = "Light") +@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) @Composable private fun CrossCircleButtonPreview() { SwissTransferTheme {