diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt index c8372578b..0322b5fa2 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt @@ -50,6 +50,8 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.GetSetCallbacks import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows +private val HORIZONTAL_PADDING = Margin.Medium + @Composable fun ImportFilesScreen( importFilesViewModel: ImportFilesViewModel = hiltViewModel(), @@ -152,19 +154,16 @@ private fun ImportFilesScreen( ) }, topButton = { modifier -> - SendButton(filesToImportCount, currentSessionFilesCount, files, modifier, sendTransfer) + SendButton(modifier, filesToImportCount, currentSessionFilesCount, files, sendTransfer) }, content = { Column(modifier = Modifier.verticalScroll(rememberScrollState())) { - FilesToImport(files, removeFileByUid, addFiles, shouldStartByPromptingUserForFiles) + val modifier = Modifier.padding(horizontal = HORIZONTAL_PADDING) + FilesToImport(modifier, files, removeFileByUid, addFiles, shouldStartByPromptingUserForFiles) Spacer(Modifier.height(Margin.Medium)) - ImportTextFields( - modifier = Modifier.padding(horizontal = Margin.Medium), - transferMessage = transferMessage, - selectedTransferType = selectedTransferType.get, - ) - SendByOptions(selectedTransferType) - TransferOptions(transferOptionsCallbacks) + ImportTextFields(modifier, transferMessage, selectedTransferType.get) + SendByOptions(modifier, selectedTransferType) + TransferOptions(modifier, transferOptionsCallbacks) } } ) @@ -172,6 +171,7 @@ private fun ImportFilesScreen( @Composable private fun FilesToImport( + modifier: Modifier, files: () -> List, removeFileByUid: (uid: String) -> Unit, addFiles: (List) -> Unit, @@ -191,31 +191,25 @@ private fun FilesToImport( LaunchedEffect(Unit) { if (shouldShowInitialFilePick) pickFiles() } - ImportFilesTitle(modifier = Modifier.padding(horizontal = Margin.Medium), titleRes = R.string.myFilesTitle) - ImportedFilesCard( - modifier = Modifier.padding(horizontal = Margin.Medium), - files = files, - pickFiles = ::pickFiles, - removeFileByUid = removeFileByUid, - ) + ImportFilesTitle(modifier, R.string.myFilesTitle) + ImportedFilesCard(modifier, files, ::pickFiles, removeFileByUid) } @Composable -private fun ImportTextFields( - modifier: Modifier, +private fun ColumnScope.ImportTextFields( + horizontalPaddingModifier: Modifier, transferMessage: GetSetCallbacks, selectedTransferType: () -> TransferTypeUi, ) { - Column(modifier) { - EmailAddressesTextFields(Modifier.fillMaxWidth(), selectedTransferType) - SwissTransferTextField( - modifier = Modifier.fillMaxWidth(), - label = stringResource(R.string.transferMessagePlaceholder), - isRequired = false, - minLineNumber = 3, - onValueChange = transferMessage.set, - ) - } + val modifier = horizontalPaddingModifier.fillMaxWidth() + EmailAddressesTextFields(modifier, selectedTransferType) + SwissTransferTextField( + modifier = modifier, + label = stringResource(R.string.transferMessagePlaceholder), + isRequired = false, + minLineNumber = 3, + onValueChange = transferMessage.set, + ) } @Composable @@ -242,13 +236,13 @@ private fun ColumnScope.EmailAddressesTextFields(modifier: Modifier, selectedTra } @Composable -private fun SendByOptions(selectedTransferType: GetSetCallbacks) { - ImportFilesTitle(Modifier.padding(horizontal = Margin.Medium), titleRes = R.string.transferTypeTitle) - TransferTypeButtons(selectedTransferType) +private fun SendByOptions(modifier: Modifier, selectedTransferType: GetSetCallbacks) { + ImportFilesTitle(modifier, R.string.transferTypeTitle) + TransferTypeButtons(HORIZONTAL_PADDING, selectedTransferType) } @Composable -private fun TransferOptions(transferOptionsCallbacks: TransferOptionsCallbacks) { +private fun TransferOptions(modifier: Modifier, transferOptionsCallbacks: TransferOptionsCallbacks) { var showTransferOption by rememberSaveable { mutableStateOf(null) } @@ -256,9 +250,9 @@ private fun TransferOptions(transferOptionsCallbacks: TransferOptionsCallbacks) showTransferOption = null } - ImportFilesTitle(Modifier.padding(horizontal = Margin.Medium), titleRes = R.string.advancedSettingsTitle) + ImportFilesTitle(modifier, R.string.advancedSettingsTitle) TransferOptionsTypes( - modifier = Modifier.padding(horizontal = Margin.Medium), + modifier = modifier, transferOptionsStates = transferOptionsCallbacks.transferOptionsStates, onClick = { selectedOptionType -> showTransferOption = selectedOptionType }, ) @@ -311,10 +305,10 @@ private fun ImportFilesTitle(modifier: Modifier = Modifier, @StringRes titleRes: @Composable private fun SendButton( + modifier: Modifier, filesToImportCount: () -> Int, currentSessionFilesCount: () -> Int, importedFiles: () -> List, - modifier: Modifier, navigateToUploadProgress: () -> Unit, ) { val remainingFilesCount = filesToImportCount() diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt index fd2d5d665..6c6b867ca 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/TransferTypeButtons.kt @@ -20,13 +20,15 @@ package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.component import androidx.annotation.PluralsRes import androidx.annotation.StringRes import androidx.compose.foundation.horizontalScroll -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.Dp import com.infomaniak.multiplatform_swisstransfer.common.models.TransferType import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons @@ -40,11 +42,11 @@ import com.infomaniak.swisstransfer.ui.utils.GetSetCallbacks import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable -fun TransferTypeButtons(transferType: GetSetCallbacks) { +fun TransferTypeButtons(horizontalPadding: Dp, transferType: GetSetCallbacks) { Row( modifier = Modifier .horizontalScroll(rememberScrollState()) - .padding(horizontal = Margin.Medium), + .padding(horizontal = horizontalPadding), horizontalArrangement = Arrangement.spacedBy(Margin.Mini), ) { for (transferTypeEntry in TransferTypeUi.entries) { @@ -108,7 +110,10 @@ enum class TransferTypeUi( private fun TransferTypeButtonsPreview() { SwissTransferTheme { Surface { - TransferTypeButtons(GetSetCallbacks(get = { TransferTypeUi.QR_CODE }, set = {})) + TransferTypeButtons( + horizontalPadding = Margin.Medium, + transferType = GetSetCallbacks(get = { TransferTypeUi.QR_CODE }, set = {}), + ) } } }