From 9b0c038066c5677a9bd6a2287cb4e0ebe983c5bb Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 12 Nov 2024 15:50:29 +0100 Subject: [PATCH] feat: Display sent Transfers details --- .../ui/components/SwissTransferTextField.kt | 6 + .../transferdetails/TransferDetailsScreen.kt | 115 +++++++++++------- .../TransferDetailsViewModel.kt | 8 +- .../components/PasswordBottomSheet.kt | 105 ++++++++++++++++ .../components/QrCodeBottomSheet.kt | 75 ++++++++++++ .../main/transfers/TransfersScreenWrapper.kt | 24 ++-- .../main/transfers/TransfersViewModel.kt | 18 ++- app/src/main/res/values-de/strings.xml | 11 +- app/src/main/res/values-es/strings.xml | 11 +- app/src/main/res/values-fr/strings.xml | 9 ++ app/src/main/res/values-it/strings.xml | 11 +- app/src/main/res/values/strings.xml | 9 ++ 12 files changed, 342 insertions(+), 60 deletions(-) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/PasswordBottomSheet.kt create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/QrCodeBottomSheet.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTextField.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTextField.kt index a38b971046..9dc1e8f3a6 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTextField.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTextField.kt @@ -61,6 +61,7 @@ fun SwissTransferTextField( keyboardType: KeyboardType = KeyboardType.Text, imeAction: ImeAction = ImeAction.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, + isReadOnly: Boolean = false, errorMessage: @Composable () -> String? = { null }, supportingText: String? = null, onValueChange: ((String) -> Unit)? = null, @@ -74,6 +75,9 @@ fun SwissTransferTextField( val textFieldColors = OutlinedTextFieldDefaults.colors( unfocusedLabelColor = SwissTransferTheme.colors.tertiaryTextColor, unfocusedSupportingTextColor = SwissTransferTheme.colors.tertiaryTextColor, + disabledBorderColor = SwissTransferTheme.materialColors.outline, + unfocusedTrailingIconColor = SwissTransferTheme.colors.iconColor, + disabledTrailingIconColor = SwissTransferTheme.colors.iconColor, ) @Composable @@ -89,6 +93,8 @@ fun SwissTransferTextField( OutlinedTextField( modifier = modifier, + readOnly = isReadOnly, + enabled = !isReadOnly, value = text, label = displayLabel?.let { { Text(text = it) } }, minLines = minLineNumber, 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 1453932183..50ddbfec34 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 @@ -30,19 +30,26 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.infomaniak.core2.FORMAT_DATE_FULL import com.infomaniak.core2.format import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi +import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.* import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons import com.infomaniak.swisstransfer.ui.images.icons.ArrowDownBar +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 import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components.TransferInfo import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @@ -53,16 +60,24 @@ import java.util.Date @Composable fun TransferDetailsScreen( transferUuid: String, + direction: TransferDirection, navigateBack: (() -> Unit)?, transferDetailsViewModel: TransferDetailsViewModel = hiltViewModel(), ) { + val context = LocalContext.current val transfer = transfersPreviewData.first() // TODO: Use real data - val transferSenderEmail: String? = "john.smith@ik.me" // TODO - val transferUrl = "https://chk.me/83azQOl" // TODO + 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 transferPassword = "toto42" // TODO: Use real data + + val shouldDisplayRecipients = recipients.isNotEmpty() + val shouldDisplayMessage = transfer.message != null var isMultiselectOn: Boolean by rememberSaveable { mutableStateOf(false) } - val context = LocalContext.current + var isQrCodeVisible: Boolean by rememberSaveable { mutableStateOf(false) } + var isPasswordVisible: Boolean by rememberSaveable { mutableStateOf(false) } SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { @@ -88,17 +103,23 @@ fun TransferDetailsScreen( Column { Spacer(modifier = Modifier.height(Margin.Large)) TransferInfo(transfer) - TransferMessage(transfer, transferSenderEmail) Spacer(modifier = Modifier.height(Margin.Large)) + if (shouldDisplayRecipients) TransferRecipients(recipients) + if (shouldDisplayRecipients && shouldDisplayMessage) Spacer(modifier = Modifier.height(Margin.Mini)) + if (shouldDisplayMessage) TransferMessage(transfer) + if (shouldDisplayRecipients || shouldDisplayMessage) Spacer(modifier = Modifier.height(Margin.Large)) TransferContentHeader() } } BottomBar( + direction = direction, isMultiselectOn = { isMultiselectOn }, onClick = { item -> when (item) { BottomBarItem.SHARE -> context.shareText(transferUrl) + BottomBarItem.QR_CODE -> isQrCodeVisible = true + BottomBarItem.PASSWORD -> isPasswordVisible = true BottomBarItem.DOWNLOAD -> { // TODO: Move the multiselect elsewhere, and implement this feature isMultiselectOn = true @@ -112,51 +133,46 @@ fun TransferDetailsScreen( }, ) } + + QrCodeBottomSheet( + isVisible = { isQrCodeVisible }, + transferUrl = transferUrl, + closeBottomSheet = { isQrCodeVisible = false }, + ) + PasswordBottomSheet( + isVisible = { isPasswordVisible }, + transferPassword = transferPassword, + closeBottomSheet = { isPasswordVisible = false }, + ) } } @Composable -private fun TransferMessage(transfer: TransferUi, transferSenderEmail: String?) { - - if (transferSenderEmail == null && transfer.message == null) return - - Spacer(modifier = Modifier.height(Margin.Large)) +private fun TransferRecipients(recipients: List) { + Text( + text = pluralStringResource(R.plurals.recipientHeader, recipients.count()), + style = SwissTransferTheme.typography.bodySmallRegular, + color = SwissTransferTheme.colors.secondaryTextColor, + ) + Spacer(modifier = Modifier.height(Margin.Mini)) + EmailsFlowRow(recipients) +} +@Composable +private fun TransferMessage(transfer: TransferUi) { Text( text = stringResource(R.string.messageHeader), style = SwissTransferTheme.typography.bodySmallRegular, color = SwissTransferTheme.colors.secondaryTextColor, ) - - SwissTransferCard(modifier = Modifier.padding(top = Margin.Medium)) { - - transferSenderEmail?.let { - Row( - modifier = Modifier.padding(all = Margin.Large), - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - text = stringResource(R.string.fromHeader), - style = SwissTransferTheme.typography.bodySmallRegular, - color = SwissTransferTheme.colors.primaryTextColor, - ) - EmailAddressChip( - text = it, - modifier = Modifier.padding(start = Margin.Mini), - ) - } - } - - if (transferSenderEmail != null && transfer.message != null) HorizontalDivider() - - transfer.message?.let { - Text( - text = it, - modifier = Modifier.padding(all = Margin.Large), - style = SwissTransferTheme.typography.bodySmallRegular, - color = SwissTransferTheme.colors.primaryTextColor, - ) - } + Spacer(modifier = Modifier.height(Margin.Medium)) + SwissTransferCard { + Text( + text = transfer.message!!, + modifier = Modifier.padding(all = Margin.Large), + style = SwissTransferTheme.typography.bodySmallRegular, + color = SwissTransferTheme.colors.primaryTextColor, + ) } } @@ -171,6 +187,7 @@ private fun TransferContentHeader() { @Composable private fun BottomBar( + direction: TransferDirection, isMultiselectOn: () -> Boolean, onClick: (BottomBarItem) -> Unit, ) { @@ -187,8 +204,20 @@ private fun BottomBar( BottomBarButton(BottomBarItem.MULTISELECT_DOWNLOAD, onClick) } else { BottomBarButton(BottomBarItem.SHARE, onClick) - Spacer(modifier = Modifier.width(Margin.Medium)) - BottomBarButton(BottomBarItem.DOWNLOAD, onClick) + + when (direction) { + TransferDirection.SENT -> { + Spacer(modifier = Modifier.width(Margin.Medium)) + BottomBarButton(BottomBarItem.QR_CODE, onClick) + + Spacer(modifier = Modifier.width(Margin.Medium)) + BottomBarButton(BottomBarItem.PASSWORD, onClick) + } + TransferDirection.RECEIVED -> { + Spacer(modifier = Modifier.width(Margin.Medium)) + BottomBarButton(BottomBarItem.DOWNLOAD, onClick) + } + } } } } @@ -215,6 +244,8 @@ private fun RowScope.BottomBarButton(item: BottomBarItem, onClick: (BottomBarIte private enum class BottomBarItem(@StringRes val label: Int, val icon: ImageVector) { SHARE(R.string.buttonShare, AppIcons.Share), + QR_CODE(R.string.transferTypeQrCode, AppIcons.QrCode), + PASSWORD(R.string.settingsOptionPassword, AppIcons.LockedTextField), DOWNLOAD(R.string.buttonDownload, AppIcons.ArrowDownBar), MULTISELECT_DOWNLOAD(R.string.buttonDownloadSelected, AppIcons.ArrowDownBar), } @@ -224,7 +255,7 @@ private enum class BottomBarItem(@StringRes val label: Int, val icon: ImageVecto private fun Preview() { SwissTransferTheme { Surface { - TransferDetailsScreen("", {}) + TransferDetailsScreen("", TransferDirection.SENT, {}) } } } 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 e09cfdd2b6..d2a6f705e6 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 @@ -20,10 +20,16 @@ package com.infomaniak.swisstransfer.ui.screen.main.transferdetails import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.snapshots.SnapshotStateMap import androidx.lifecycle.ViewModel +import com.infomaniak.multiplatform_swisstransfer.SharedApiUrlCreator import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel -class TransferDetailsViewModel @Inject constructor() : ViewModel() { +class TransferDetailsViewModel @Inject constructor( + private val sharedApiUrlCreator: SharedApiUrlCreator, +) : ViewModel() { + val checkedFiles: SnapshotStateMap = mutableStateMapOf() + + fun getTransferUrl(transferUuid: String): String = sharedApiUrlCreator.shareTransferUrl(transferUuid) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/PasswordBottomSheet.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/PasswordBottomSheet.kt new file mode 100644 index 0000000000..401044a5a9 --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/PasswordBottomSheet.kt @@ -0,0 +1,105 @@ +/* + * 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 . + */ +package com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components + +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Surface +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import com.infomaniak.swisstransfer.R +import com.infomaniak.swisstransfer.ui.components.ButtonType +import com.infomaniak.swisstransfer.ui.components.LargeButton +import com.infomaniak.swisstransfer.ui.components.SwissTransferBottomSheet +import com.infomaniak.swisstransfer.ui.components.SwissTransferTextField +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons +import com.infomaniak.swisstransfer.ui.images.icons.DocumentOnDocument +import com.infomaniak.swisstransfer.ui.theme.Margin +import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows +import com.infomaniak.swisstransfer.ui.utils.copyText +import kotlinx.coroutines.launch + +@Composable +fun PasswordBottomSheet( + isVisible: () -> Boolean, + transferPassword: String, + closeBottomSheet: () -> Unit, +) { + + if (!isVisible()) return + + val context = LocalContext.current + val scope = rememberCoroutineScope() + val snackbarHostState = remember { SnackbarHostState() } + + SwissTransferBottomSheet( + onDismissRequest = closeBottomSheet, + topButton = { + LargeButton( + modifier = it, + titleRes = R.string.sharePasswordButton, + imageVector = AppIcons.DocumentOnDocument, + onClick = { + context.copyText( + text = transferPassword, + showSnackbar = { scope.launch { snackbarHostState.showSnackbar(it) } }, + ) + closeBottomSheet() + }, + ) + }, + bottomButton = { + LargeButton( + modifier = it, + titleRes = R.string.contentDescriptionButtonClose, + style = ButtonType.SECONDARY, + onClick = closeBottomSheet, + ) + }, + titleRes = R.string.sharePasswordTitle, + descriptionRes = R.string.sharePasswordDescription, + ) { + SwissTransferTextField( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = Margin.Medium), + initialValue = transferPassword, + isPassword = true, + isReadOnly = true, + ) + } +} + +@PreviewAllWindows +@Composable +private fun Preview() { + SwissTransferTheme { + Surface { + PasswordBottomSheet( + isVisible = { true }, + transferPassword = "toto42", + closeBottomSheet = {}, + ) + } + } +} diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/QrCodeBottomSheet.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/QrCodeBottomSheet.kt new file mode 100644 index 0000000000..8d0aef0973 --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/QrCodeBottomSheet.kt @@ -0,0 +1,75 @@ +/* + * 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 . + */ +package com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.material3.Surface +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.infomaniak.swisstransfer.R +import com.infomaniak.swisstransfer.ui.components.LargeButton +import com.infomaniak.swisstransfer.ui.components.QrCode +import com.infomaniak.swisstransfer.ui.components.SwissTransferBottomSheet +import com.infomaniak.swisstransfer.ui.theme.Margin +import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows + +@Composable +fun QrCodeBottomSheet( + isVisible: () -> Boolean, + transferUrl: String, + closeBottomSheet: () -> Unit, +) { + + if (!isVisible()) return + + SwissTransferBottomSheet( + onDismissRequest = closeBottomSheet, + bottomButton = { + LargeButton( + modifier = it, + titleRes = R.string.contentDescriptionButtonClose, + onClick = closeBottomSheet, + ) + }, + titleRes = R.string.shareQrCodeTitle, + descriptionRes = R.string.shareQrCodeDescription, + ) { + Column { + Spacer(modifier = Modifier.height(Margin.Large)) + QrCode(transferUrl) + Spacer(modifier = Modifier.height(Margin.Large)) + } + } +} + +@PreviewAllWindows +@Composable +private fun Preview() { + SwissTransferTheme { + Surface { + QrCodeBottomSheet( + isVisible = { true }, + transferUrl = "https://chk.me/83azQOl", + closeBottomSheet = {}, + ) + } + } +} diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersScreenWrapper.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersScreenWrapper.kt index 9d7e84ab4b..0990d44fbf 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersScreenWrapper.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersScreenWrapper.kt @@ -41,7 +41,7 @@ import com.infomaniak.swisstransfer.ui.utils.ScreenWrapperUtils @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable fun TransfersScreenWrapper(direction: TransferDirection) { - TwoPaneScaffold( + TwoPaneScaffold>( listPane = { ListPane(direction, navigator = this) }, detailPane = { DetailPane(navigator = this) }, ) @@ -49,40 +49,44 @@ fun TransfersScreenWrapper(direction: TransferDirection) { @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable -private fun ListPane(direction: TransferDirection, navigator: ThreePaneScaffoldNavigator) { +private fun ListPane(direction: TransferDirection, navigator: ThreePaneScaffoldNavigator>) { when (direction) { TransferDirection.SENT -> SentScreen( - navigateToDetails = navigator::navigateToDetails, + navigateToDetails = { transferUuid -> navigator.navigateToDetails(direction, transferUuid) }, getSelectedTransferUuid = navigator::getSelectedTransferUuid, ) TransferDirection.RECEIVED -> ReceivedScreen( - navigateToDetails = navigator::navigateToDetails, + navigateToDetails = { transferUuid -> navigator.navigateToDetails(direction, transferUuid) }, getSelectedTransferUuid = navigator::getSelectedTransferUuid, ) } } @OptIn(ExperimentalMaterial3AdaptiveApi::class) -private fun ThreePaneScaffoldNavigator.navigateToDetails(transferUuid: String) { - navigateTo(ListDetailPaneScaffoldRole.Detail, transferUuid) +private fun ThreePaneScaffoldNavigator>.navigateToDetails( + direction: TransferDirection, + transferUuid: String, +) { + navigateTo(ListDetailPaneScaffoldRole.Detail, direction to transferUuid) } @OptIn(ExperimentalMaterial3AdaptiveApi::class) -private fun ThreePaneScaffoldNavigator.getSelectedTransferUuid(): String? { - return currentDestination?.content +private fun ThreePaneScaffoldNavigator>.getSelectedTransferUuid(): String? { + return currentDestination?.content?.second } @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable -private fun DetailPane(navigator: ThreePaneScaffoldNavigator) { +private fun DetailPane(navigator: ThreePaneScaffoldNavigator>) { - val transferUuid = navigator.safeCurrentContent() + val (direction, transferUuid) = navigator.safeCurrentContent() ?: (TransferDirection.SENT to null) if (transferUuid == null) { NoSelectionEmptyState() } else { TransferDetailsScreen( transferUuid = transferUuid, + direction = direction, navigateBack = ScreenWrapperUtils.getBackNavigation(navigator), ) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersViewModel.kt index 1196b25146..0d8fcfbe08 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersViewModel.kt @@ -21,15 +21,25 @@ import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.snapshots.SnapshotStateMap import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection +import com.infomaniak.multiplatform_swisstransfer.managers.TransferManager import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.stateIn import javax.inject.Inject @HiltViewModel -class TransfersViewModel @Inject constructor() : ViewModel() { - val sentTransfers = flow> { emit(listOf(1)) }.stateIn(viewModelScope, SharingStarted.Eagerly, null) - val receivedTransfers = flow> { emit(listOf(1)) }.stateIn(viewModelScope, SharingStarted.Eagerly, null) +class TransfersViewModel @Inject constructor(transferManager: TransferManager) : ViewModel() { + + val sentTransfers = transferManager.getTransfers(TransferDirection.SENT) + .flowOn(Dispatchers.IO) + .stateIn(viewModelScope, SharingStarted.Eagerly, initialValue = emptyList()) + + val receivedTransfers = transferManager.getTransfers(TransferDirection.RECEIVED) + .flowOn(Dispatchers.IO) + .stateIn(viewModelScope, SharingStarted.Eagerly, initialValue = emptyList()) + val selectedTransferUuids: SnapshotStateMap = mutableStateMapOf() } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index ebf8bb0c14..2ec3a9cf49 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -51,6 +51,10 @@ Keine Überweisungen erhalten Empfangene Dateien Empfangen + + Empfänger: + Adressaten: + Unsere Geschichte beginnt hier Geteilte Dateien Gesendet @@ -95,6 +99,11 @@ %d Tag %d Tage + Kopieren des Passworts + Hier ist das Sesam-öffne-dich zum Herunterladen der Dateien! + Diese Übertragung ist sicher + Lass diesen QR-Code in deiner Umgebung scannen, um deine Übertragung zu teilen: + Schnelles Teilen Link in die Zwischenablage kopiert Es wurde keine Anwendung gefunden, die diese Aktion bearbeitet (Fakultativ) @@ -115,7 +124,7 @@ E-Mail Link In der Nähe - QR-Code + QR Code Übertragen Schicken per Kamera diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 2978d5c7b0..70353a9397 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -51,6 +51,10 @@ No se han recibido transferencias Archivos recibidos Recibido + + Destinatario: + Para: + Nuestra historia comienza aquí Archivos compartidos Enviado a @@ -95,6 +99,11 @@ día %d %d días + Copiar contraseña + Aquí está la clave para descargar los archivos + Esta transferencia es segura + Escanee este código QR a su alrededor para compartir su traslado: + Compartir rápidamente Enlace copiado en el portapapeles No se ha encontrado ninguna aplicación que gestione esta acción (Opcional) @@ -115,7 +124,7 @@ Correo electrónico Enlace Proximidad - Código QR + QR Code Transferencia Enviar por Cámara diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index bcba3ba57c..afe92c444e 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -52,6 +52,10 @@ Aucun transfert reçu Fichiers reçus Reçu + + Destinataire : + Destinataires : + Notre histoire commence ici Fichiers partagés Envoyé @@ -96,6 +100,11 @@ %d jour %d jours + Copier le mot de passe + Voilà le sésame pour télécharger les fichiers ! + Ce transfert est sécurisé + Fais scanner ce QR code autour de toi pour partager ton transfert : + Partage rapide Lien copié dans le presse-papiers Aucune application n’a été trouvée pour gérer cette action (Facultatif) diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 85ef5002c4..4317d12eaf 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -51,6 +51,10 @@ Nessun trasferimento ricevuto File ricevuti Ricevuto + + A: + A: + La nostra storia inizia qui File condivisi Inviato a @@ -95,6 +99,11 @@ %d giorno %d giorni + Copiare la password + Ecco la chiave per scaricare i file! + Questo trasferimento è sicuro + Scansionate questo codice QR intorno a voi per condividere il vostro trasferimento: + Quota rapida Link copiato negli appunti Non è stata trovata alcuna applicazione in grado di gestire questa azione (Opzionale) @@ -115,7 +124,7 @@ Email Link Vicino - Codice QR + QR Code Trasferimento Inviare da Macchina fotografica diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index aefc59e4da..9da62e0a79 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -56,6 +56,10 @@ No transfers received Received files Received + + Recipient: + Recipients: + Our story begins here Shared files Sent @@ -100,6 +104,11 @@ %d day %d days + Copy password + This is the key to downloading the files! + This transfer is secure + Scan this QR code around you to share your transfer: + Quick share Link copied to clipboard No application has been found to handle this action (Optional)