From 83bbff1765e0025e70158409456242711f5fb582 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Wed, 23 Oct 2024 07:44:57 +0200 Subject: [PATCH] feat: Use a FlowRow to display a list of emails instead of a single one in UploadSuccessEmail screen --- .../ui/components/EmailAddressChip.kt | 9 +++- .../upload/UploadSuccessEmailScreen.kt | 41 +++++++++++++++---- .../newtransfer/upload/UploadSuccessScreen.kt | 2 +- 3 files changed, 42 insertions(+), 10 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 6bdb39ef3..59751fce3 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 @@ -23,12 +23,16 @@ import androidx.compose.material3.SuggestionChipDefaults import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @Composable -fun EmailAddressChip(text: String) { +fun EmailAddressChip( + text: String, + modifier: Modifier = Modifier, +) { SuggestionChip( onClick = { }, label = { @@ -37,6 +41,7 @@ fun EmailAddressChip(text: String) { style = SwissTransferTheme.typography.bodyRegular, ) }, + modifier = modifier, enabled = false, shape = CustomShapes.ROUNDED, colors = SuggestionChipDefaults.suggestionChipColors( @@ -53,7 +58,7 @@ fun EmailAddressChip(text: String) { private fun EmailAddressChipPreview() { SwissTransferTheme { Surface { - EmailAddressChip("test.test@ik.me") + EmailAddressChip(text = "test.test@ik.me") } } } 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 a36ec08c6..2ced48689 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 @@ -32,8 +32,26 @@ import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows +// TODO: Use correct emails instead of hard-coded values @Composable -fun UploadSuccessEmailScreen(email: String) { +fun UploadSuccessEmailScreen( + emails: List = listOf( + "email@example.com", + "firstname.lastname@example.com", + "email@subdomain.example.com", + "firstname+lastname@example.com", + "email@123.123.123.123", + "email@[123.123.123.123]", + "\"email\"@example.com", + "1234567890@example.com", + "email@example-one.com", + "_______@example.com", + "email@example.name", + "email@example.museum", + "email@example.co.jp", + "firstname-lastname@example.com", + ), +) { BottomStickyButtonScaffold( topBar = { BrandTopAppBar() }, bottomButton = { @@ -43,12 +61,13 @@ fun UploadSuccessEmailScreen(email: String) { onClick = { /* TODO */ }, ) }, - content = { Content(email) }, + content = { Content(emails) }, ) } +@OptIn(ExperimentalLayoutApi::class) @Composable -private fun Content(email: String) { +private fun Content(emails: List) { Column( modifier = Modifier .fillMaxSize() @@ -64,9 +83,17 @@ private fun Content(email: String) { modifier = Modifier.padding(horizontal = Margin.Medium), ) - Spacer(Modifier.height(Margin.Small)) - - EmailAddressChip(text = email) + FlowRow( + modifier = Modifier.padding(Margin.Medium), + horizontalArrangement = Arrangement.Center, + ) { + emails.forEach { + EmailAddressChip( + text = it, + modifier = Modifier.padding(horizontal = Margin.XSmall) + ) + } + } } } @@ -75,7 +102,7 @@ private fun Content(email: String) { private fun UploadSuccessEmailScreenPreview() { SwissTransferTheme { Surface { - UploadSuccessEmailScreen("test.test@ik.me") + UploadSuccessEmailScreen() } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt index 081116c13..e5e68de77 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/upload/UploadSuccessScreen.kt @@ -26,7 +26,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun UploadSuccessScreen(transferType: TransferType) { if (transferType == TransferType.MAIL) { - UploadSuccessEmailScreen(email = "test.test@ik.me") // TODO: Use correct email instead of hard-coded value + UploadSuccessEmailScreen() } else { UploadSuccessQrScreen(transferType) }