From b5d6568fa116b8a79ac83dc1b7d01e889e4c6d23 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 12 Nov 2024 16:50:17 +0100 Subject: [PATCH] refactor: Extract EmailsFlowRow to its own component --- .../ui/components/EmailsFlowRow.kt | 61 +++++++++++++++++++ .../upload/UploadSuccessEmailScreen.kt | 13 +--- 2 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmailsFlowRow.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmailsFlowRow.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmailsFlowRow.kt new file mode 100644 index 000000000..f9da94764 --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmailsFlowRow.kt @@ -0,0 +1,61 @@ +/* + * Infomaniak SwissTransfer - Android + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.infomaniak.swisstransfer.ui.components + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Surface +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.PreviewParameter +import com.infomaniak.swisstransfer.ui.previewparameter.EmailsPreviewParameter +import com.infomaniak.swisstransfer.ui.theme.Margin +import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark + +@OptIn(ExperimentalLayoutApi::class) +@Composable +fun EmailsFlowRow( + emails: List, + modifier: Modifier = Modifier, + horizontalArrangement: Arrangement.Horizontal = Arrangement.Start, +) { + FlowRow( + modifier = modifier, + horizontalArrangement = horizontalArrangement, + ) { + emails.forEach { + EmailAddressChip( + text = it, + modifier = Modifier.padding(horizontal = Margin.Micro), + ) + } + } +} + +@PreviewLightAndDark +@Composable +private fun Preview(@PreviewParameter(EmailsPreviewParameter::class) emails: List) { + SwissTransferTheme { + Surface { + EmailsFlowRow(emails) + } + } +} 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 60675341e..56df0e153 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 @@ -54,7 +54,6 @@ fun UploadSuccessEmailScreen( ) } -@OptIn(ExperimentalLayoutApi::class) @Composable private fun Content(emails: List) { Column( @@ -74,17 +73,11 @@ private fun Content(emails: List) { Spacer(modifier = Modifier.height(Margin.Medium)) - FlowRow( + EmailsFlowRow( + emails = emails, modifier = Modifier.widthIn(max = 800.dp), horizontalArrangement = Arrangement.Center, - ) { - emails.forEach { - EmailAddressChip( - text = it, - modifier = Modifier.padding(horizontal = Margin.Micro), - ) - } - } + ) } }