Skip to content

Commit

Permalink
refactor: Extract EmailsFlowRow to its own component
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Nov 12, 2024
1 parent 05ad0f0 commit 3ba75ea
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<String>,
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<String>) {
SwissTransferTheme {
Surface {
EmailsFlowRow(emails)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ fun UploadSuccessEmailScreen(
)
}

@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun Content(emails: List<String>) {
Column(
Expand All @@ -74,17 +73,11 @@ private fun Content(emails: List<String>) {

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),
)
}
}
)
}
}

Expand Down

0 comments on commit 3ba75ea

Please sign in to comment.