Skip to content

Commit

Permalink
refactor: Use a SuggestionChip for the EmailAddressChip instead of cr…
Browse files Browse the repository at this point in the history
…eating it from scratch
  • Loading branch information
KevinBoulongne committed Oct 21, 2024
1 parent 0c68aa5 commit 31b8f27
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private fun Content() {
description = R.string.uploadSuccessEmailDescription,
)

Spacer(Modifier.height(Margin.Medium))
Spacer(Modifier.height(Margin.Small))

EmailAddressChip("[email protected]") // TODO: Use correct email instead of hard-coded value.
}
Expand Down

0 comments on commit 31b8f27

Please sign in to comment.