From 31b8f27096e21b4dfef027ca04df48605dffb2a3 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Mon, 21 Oct 2024 18:06:38 +0200 Subject: [PATCH] refactor: Use a SuggestionChip for the EmailAddressChip instead of creating it from scratch --- .../ui/components/EmailAddressChip.kt | 42 +++++++++++-------- .../upload/UploadSuccessEmailScreen.kt | 2 +- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmailAddressChip.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmailAddressChip.kt index 492224fc5..36055110d 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmailAddressChip.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmailAddressChip.kt @@ -18,32 +18,40 @@ package com.infomaniak.swisstransfer.ui.components import android.content.res.Configuration -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.padding +import androidx.compose.material3.ChipColors +import androidx.compose.material3.SuggestionChip import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.theme.CustomShapes -import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @Composable fun EmailAddressChip(text: String) { - Box( - modifier = Modifier - .clip(CustomShapes.ROUNDED) - .background(SwissTransferTheme.colors.emailAddressChipColor) - .padding(horizontal = Margin.Small), - ) { - Text( - color = SwissTransferTheme.colors.onEmailAddressChipColor, - text = text, - ) - } + SuggestionChip( + onClick = { }, + label = { + Text( + text = text, + style = SwissTransferTheme.typography.bodyRegular, + ) + }, + enabled = false, + shape = CustomShapes.ROUNDED, + colors = ChipColors( + containerColor = Color.Unspecified, + disabledContainerColor = SwissTransferTheme.colors.emailAddressChipColor, + labelColor = Color.Unspecified, + disabledLabelColor = SwissTransferTheme.colors.onEmailAddressChipColor, + leadingIconContentColor = Color.Unspecified, + disabledLeadingIconContentColor = Color.Unspecified, + trailingIconContentColor = Color.Unspecified, + disabledTrailingIconContentColor = Color.Unspecified, + ), + border = null, + ) } @Preview(name = "Light mode") diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessEmailScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessEmailScreen.kt index e3d187945..a59961956 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessEmailScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessEmailScreen.kt @@ -63,7 +63,7 @@ private fun Content() { description = R.string.uploadSuccessEmailDescription, ) - Spacer(Modifier.height(Margin.Medium)) + Spacer(Modifier.height(Margin.Small)) EmailAddressChip("test.test@ik.me") // TODO: Use correct email instead of hard-coded value. }