Skip to content

Commit

Permalink
Better write CrossCircleButton
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Oct 18, 2024
1 parent c6f6e50 commit bdc39e3
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit bdc39e3

Please sign in to comment.