Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Extract EmailsFlowRow to its own component #173

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import com.infomaniak.swisstransfer.ui.theme.CustomShapes
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
Expand All @@ -38,6 +39,8 @@ fun EmailAddressChip(
label = {
Text(
text = text,
maxLines = 1,
overflow = TextOverflow.MiddleEllipsis,
style = SwissTransferTheme.typography.bodyRegular,
)
},
Expand Down
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>) {
KevinBoulongne marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ val CustomLightColorScheme = CustomColorScheme(
transferTypeQrOnContainer = Color(green_main),
transferTypeProximityContainer = Color(specific3),
transferTypeProximityOnContainer = Color(specific4),
emailAddressChipColor = Color(green_contrast),
emailAddressChipColor = Color(green_secondary),
onEmailAddressChipColor = Color(green_dark),
qrCodeDarkPixels = Color(green_dark),
qrCodeLightPixels = Color(white),
Expand Down
Loading