Skip to content

Commit

Permalink
feat: Use real data when displaying a transfer's Details
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Nov 13, 2024
1 parent b53fbd6 commit 81349bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) }
Expand All @@ -88,7 +86,7 @@ fun TransferDetailsScreen(
) {
Column {

FilesList(transfer, recipients, isMultiselectOn, transferDetailsViewModel)
FilesList(transfer, transferRecipients, isMultiselectOn, transferDetailsViewModel)

BottomBar(
direction = direction,
Expand Down Expand Up @@ -128,12 +126,12 @@ fun TransferDetailsScreen(
@Composable
private fun ColumnScope.FilesList(
transfer: TransferUi,
recipients: List<String>,
transferRecipients: List<String>,
isMultiselectOn: Boolean,
transferDetailsViewModel: TransferDetailsViewModel,
) {

val shouldDisplayRecipients = recipients.isNotEmpty()
val shouldDisplayRecipients = transferRecipients.isNotEmpty()
val shouldDisplayMessage = transfer.message != null

FileItemList(
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Boolean> = mutableStateMapOf()

fun getTransfer(transferUuid: String): TransferUi? = transferManager.getTransferByUUID(transferUuid)

fun getTransferUrl(transferUuid: String): String = sharedApiUrlCreator.shareTransferUrl(transferUuid)
}

0 comments on commit 81349bd

Please sign in to comment.