From 9db4fc5a8510958bc55e6063dd58088cf4de428e Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 12 Nov 2024 18:23:35 +0100 Subject: [PATCH] feat: Use real data when displaying a transfer's Details --- .../transferdetails/TransferDetailsScreen.kt | 16 +++++++--------- .../transferdetails/TransferDetailsViewModel.kt | 5 +++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt index 7786507153..5b05d0cb60 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt @@ -46,7 +46,6 @@ import com.infomaniak.swisstransfer.ui.images.icons.LockedTextField import com.infomaniak.swisstransfer.ui.images.icons.QrCode import com.infomaniak.swisstransfer.ui.images.icons.Share import com.infomaniak.swisstransfer.ui.previewparameter.emailsPreviewData -import com.infomaniak.swisstransfer.ui.previewparameter.transfersPreviewData import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components.PasswordBottomSheet import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components.QrCodeBottomSheet @@ -66,10 +65,9 @@ fun TransferDetailsScreen( ) { val context = LocalContext.current - val transfer = transfersPreviewData.first() // TODO: Use real data - val recipients = if (direction == TransferDirection.SENT) emailsPreviewData else emptyList() // TODO: Use real data - val transferUrl = "https://chk.me/83azQOl" // TODO: Use the next line instead when available : - // val transferUrl = transferDetailsViewModel.getTransferUrl(transferUuid) + val transfer = transferDetailsViewModel.getTransfer(transferUuid) ?: return + val transferUrl = transferDetailsViewModel.getTransferUrl(transferUuid) + val transferRecipients = if (direction == TransferDirection.SENT) emailsPreviewData else emptyList() // TODO: Use real data val transferPassword = "toto42" // TODO: Use real data var isMultiselectOn: Boolean by rememberSaveable { mutableStateOf(false) } @@ -88,7 +86,7 @@ fun TransferDetailsScreen( ) { Column { - FilesList(transfer, recipients, isMultiselectOn, transferDetailsViewModel) + FilesList(transfer, transferRecipients, isMultiselectOn, transferDetailsViewModel) BottomBar( direction = direction, @@ -128,12 +126,12 @@ fun TransferDetailsScreen( @Composable private fun ColumnScope.FilesList( transfer: TransferUi, - recipients: List, + transferRecipients: List, isMultiselectOn: Boolean, transferDetailsViewModel: TransferDetailsViewModel, ) { - val shouldDisplayRecipients = recipients.isNotEmpty() + val shouldDisplayRecipients = transferRecipients.isNotEmpty() val shouldDisplayMessage = transfer.message != null FileItemList( @@ -150,7 +148,7 @@ private fun ColumnScope.FilesList( Spacer(modifier = Modifier.height(Margin.Large)) TransferInfo(transfer) Spacer(modifier = Modifier.height(Margin.Large)) - if (shouldDisplayRecipients) TransferRecipients(recipients) + if (shouldDisplayRecipients) TransferRecipients(transferRecipients) if (shouldDisplayRecipients && shouldDisplayMessage) Spacer(modifier = Modifier.height(Margin.Mini)) if (shouldDisplayMessage) TransferMessage(transfer) if (shouldDisplayRecipients || shouldDisplayMessage) Spacer(modifier = Modifier.height(Margin.Large)) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsViewModel.kt index d2a6f705e6..07e87f4bb7 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsViewModel.kt @@ -21,15 +21,20 @@ import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.snapshots.SnapshotStateMap import androidx.lifecycle.ViewModel import com.infomaniak.multiplatform_swisstransfer.SharedApiUrlCreator +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi +import com.infomaniak.multiplatform_swisstransfer.managers.TransferManager import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel class TransferDetailsViewModel @Inject constructor( + private val transferManager: TransferManager, private val sharedApiUrlCreator: SharedApiUrlCreator, ) : ViewModel() { val checkedFiles: SnapshotStateMap = mutableStateMapOf() + fun getTransfer(transferUuid: String): TransferUi? = transferManager.getTransferByUUID(transferUuid) + fun getTransferUrl(transferUuid: String): String = sharedApiUrlCreator.shareTransferUrl(transferUuid) }