diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmptyState.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmptyState.kt index f43972630..eb9d3b0c3 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmptyState.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmptyState.kt @@ -39,17 +39,17 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @Composable fun EmptyState( - icon: ImageVector, - @StringRes titleRes: Int, - @StringRes descriptionRes: Int, + icon: ImageVector? = null, + @StringRes titleRes: Int? = null, + @StringRes descriptionRes: Int? = null, modifier: Modifier = Modifier, -) = EmptyState(icon, titleRes, stringResource(descriptionRes), modifier) +) = EmptyState(icon, titleRes, descriptionRes?.let { stringResource(it) }, modifier) @Composable fun EmptyState( - icon: ImageVector, - @StringRes titleRes: Int, - description: String, + icon: ImageVector?, + @StringRes titleRes: Int?, + description: String?, modifier: Modifier = Modifier, ) { Box( diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/IllustratedMessageBlock.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/IllustratedMessageBlock.kt index 2c41fb5cd..0e2f3bf4f 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/IllustratedMessageBlock.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/IllustratedMessageBlock.kt @@ -42,34 +42,40 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @Composable fun IllustratedMessageBlock( - icon: ImageVector, - @StringRes title: Int, - description: String, + icon: ImageVector?, + @StringRes title: Int?, + description: String?, modifier: Modifier = Modifier, ) { Column( modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally, ) { - Image(imageVector = icon, contentDescription = null) + icon?.let { + Image(imageVector = it, contentDescription = null) - Spacer(Modifier.height(Margin.Huge)) + Spacer(Modifier.height(Margin.Huge)) + } - Text( - text = stringResource(title), - textAlign = TextAlign.Center, - style = SwissTransferTheme.typography.h1, - ) + title?.let { + Text( + text = stringResource(it), + textAlign = TextAlign.Center, + style = SwissTransferTheme.typography.h1, + ) + } - Spacer(Modifier.height(Margin.Medium)) + description?.let { + Spacer(Modifier.height(Margin.Medium)) - Text( - text = description, - textAlign = TextAlign.Center, - style = SwissTransferTheme.typography.bodyRegular, - color = SwissTransferTheme.colors.secondaryTextColor, - modifier = Modifier.widthIn(max = Dimens.DescriptionWidth), - ) + Text( + text = description, + textAlign = TextAlign.Center, + style = SwissTransferTheme.typography.bodyRegular, + color = SwissTransferTheme.colors.secondaryTextColor, + modifier = Modifier.widthIn(max = Dimens.DescriptionWidth), + ) + } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt index 06932a726..94d960689 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt @@ -30,23 +30,28 @@ import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.EmptyState import com.infomaniak.swisstransfer.ui.components.transfer.TransfersListWithExpiredBottomSheet import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus -import com.infomaniak.swisstransfer.ui.images.illus.MascotSearching +import com.infomaniak.swisstransfer.ui.images.illus.MascotWithMagnifyingGlass import com.infomaniak.swisstransfer.ui.screen.main.components.BrandTopAppBarScaffold import com.infomaniak.swisstransfer.ui.screen.main.received.components.ReceivedEmptyFab import com.infomaniak.swisstransfer.ui.screen.main.transfers.TransfersViewModel +import com.infomaniak.swisstransfer.ui.theme.LocalWindowAdaptiveInfo import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows +import com.infomaniak.swisstransfer.ui.utils.isWindowSmall @Composable fun ReceivedScreen( navigateToDetails: (transferUuid: String) -> Unit, getSelectedTransferUuid: () -> String?, transfersViewModel: TransfersViewModel = hiltViewModel(), + hasTransfer: (Boolean) -> Unit, ) { val transfers by transfersViewModel.receivedTransfers.collectAsStateWithLifecycle() val isLoading by remember { derivedStateOf { transfers == null } } + hasTransfer(transfers?.isNotEmpty() == true) + if (!isLoading) { ReceivedScreen( navigateToDetails = navigateToDetails, @@ -71,8 +76,9 @@ private fun ReceivedScreen( floatingActionButton = { ReceivedEmptyFab { areTransfersEmpty } }, ) { if (areTransfersEmpty) { + val shouldDisplayIcon = LocalWindowAdaptiveInfo.current.isWindowSmall() EmptyState( - icon = AppIllus.MascotSearching, + icon = if (shouldDisplayIcon) AppIllus.MascotWithMagnifyingGlass else null, titleRes = R.string.noTransferReceivedTitle, descriptionRes = R.string.noTransferReceivedDescription, ) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentScreen.kt index 091f9f965..f57134000 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentScreen.kt @@ -45,11 +45,14 @@ fun SentScreen( navigateToDetails: (transferUuid: String) -> Unit, getSelectedTransferUuid: () -> String?, transfersViewModel: TransfersViewModel = hiltViewModel(), + hasTransfer: (Boolean) -> Unit, ) { val transfers by transfersViewModel.sentTransfers.collectAsStateWithLifecycle() val isLoading by remember { derivedStateOf { transfers == null } } + hasTransfer(transfers?.isNotEmpty() == true) + LifecycleEventEffect(Lifecycle.Event.ON_RESUME) { transfersViewModel.fetchPendingTransfers() } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt index b20233f8e..461e8c930 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt @@ -17,18 +17,13 @@ */ package com.infomaniak.swisstransfer.ui.screen.main.settings -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffoldRole import androidx.compose.material3.adaptive.navigation.ThreePaneScaffoldNavigator import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.hilt.navigation.compose.hiltViewModel @@ -38,8 +33,11 @@ import com.infomaniak.multiplatform_swisstransfer.common.models.EmailLanguage import com.infomaniak.multiplatform_swisstransfer.common.models.Theme import com.infomaniak.multiplatform_swisstransfer.common.models.ValidityPeriod import com.infomaniak.swisstransfer.R +import com.infomaniak.swisstransfer.ui.components.EmptyState import com.infomaniak.swisstransfer.ui.components.TwoPaneScaffold import com.infomaniak.swisstransfer.ui.components.safeCurrentContent +import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus +import com.infomaniak.swisstransfer.ui.images.illus.MascotWithMagnifyingGlass import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsOptionScreens.* import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.* @@ -164,8 +162,11 @@ private fun DetailPane( @Composable private fun NoSelectionEmptyState() { - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { - Text("Select a setting item", color = SwissTransferTheme.colors.secondaryTextColor) + Surface { + EmptyState( + icon = AppIllus.MascotWithMagnifyingGlass, + descriptionRes = R.string.noSettingsSelectedDescription + ) } } 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 79a699316..f20a10589 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 @@ -24,13 +24,17 @@ import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffoldRole import androidx.compose.material3.adaptive.navigation.ThreePaneScaffoldNavigator import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.EmptyState import com.infomaniak.swisstransfer.ui.components.TwoPaneScaffold import com.infomaniak.swisstransfer.ui.components.safeCurrentContent import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus -import com.infomaniak.swisstransfer.ui.images.illus.MascotSearching +import com.infomaniak.swisstransfer.ui.images.illus.MascotWithMagnifyingGlass import com.infomaniak.swisstransfer.ui.screen.main.received.ReceivedScreen import com.infomaniak.swisstransfer.ui.screen.main.sent.SentScreen import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.TransferDetailsScreen @@ -42,23 +46,31 @@ import kotlinx.parcelize.Parcelize @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable fun TransfersScreenWrapper(direction: TransferDirection) { + var hasTransfer: Boolean by rememberSaveable { mutableStateOf(false) } + TwoPaneScaffold( - listPane = { ListPane(direction, navigator = this) }, - detailPane = { DetailPane(navigator = this) }, + listPane = { ListPane(direction, navigator = this, hasTransfer = { hasTransfer = it }) }, + detailPane = { DetailPane(navigator = this, hasTransfer) }, ) } @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable -private fun ListPane(direction: TransferDirection, navigator: ThreePaneScaffoldNavigator) { +private fun ListPane( + direction: TransferDirection, + navigator: ThreePaneScaffoldNavigator, + hasTransfer: (Boolean) -> Unit +) { when (direction) { TransferDirection.SENT -> SentScreen( navigateToDetails = { transferUuid -> navigator.navigateToDetails(direction, transferUuid) }, getSelectedTransferUuid = navigator::getSelectedTransferUuid, + hasTransfer = { hasTransfer(it) } ) TransferDirection.RECEIVED -> ReceivedScreen( navigateToDetails = { transferUuid -> navigator.navigateToDetails(direction, transferUuid) }, getSelectedTransferUuid = navigator::getSelectedTransferUuid, + hasTransfer = { hasTransfer(it) } ) } } @@ -78,12 +90,12 @@ private fun ThreePaneScaffoldNavigator.getSelectedTransferUu @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable -private fun DetailPane(navigator: ThreePaneScaffoldNavigator) { +private fun DetailPane(navigator: ThreePaneScaffoldNavigator, hasTransfer: Boolean) { val destinationContent = navigator.safeCurrentContent() if (destinationContent == null) { - NoSelectionEmptyState() + NoSelectionEmptyState(hasTransfer) } else { TransferDetailsScreen( transferUuid = destinationContent.transferUuid, @@ -94,12 +106,18 @@ private fun DetailPane(navigator: ThreePaneScaffoldNavigator } @Composable -private fun NoSelectionEmptyState() { +private fun NoSelectionEmptyState(hasTransfers: Boolean) { + val (titleRes, descriptionRes) = if (hasTransfers) { + R.string.noTransferSelectedTitle to R.string.noTransferSelectedDescription + } else { + null to null + } + Surface { EmptyState( - icon = AppIllus.MascotSearching, - titleRes = R.string.noTransferSelectedTitle, - descriptionRes = R.string.noTransferSelectedDescription, + icon = AppIllus.MascotWithMagnifyingGlass, + titleRes = titleRes, + descriptionRes = descriptionRes ) } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 261d868d7..6c21bf7b7 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -46,6 +46,7 @@ Auf Netzwerk warten… Fügt bis zu 50 GB an Dateien hinzu Keine Datei, keine Übertragung! + Wählt einen Parameter zur Anzeige aus Alle Überweisungen, die du in den letzten 30 Tagen erhältst, werden hier angezeigt. Keine Überweisungen erhalten Wähle eine Übertragung aus oder erstelle eine neue. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 1993bd404..b9e68d41f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -46,6 +46,7 @@ Esperando la red… Añade hasta 50 GB de archivos Si no hay archivo, no hay transferencia. + Selecciona un parámetro para su visualización Aquí aparecerán todas las transferencias recibidas en los últimos 30 días. No se han recibido transferencias Selecciona una transferencia o crea una nueva. diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index b5c2f439f..68ca6c07a 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -47,6 +47,7 @@ En attente de réseau… Ajoute jusqu’à 50 Go de fichiers Pas de fichier, pas de transfert ! + Sélectionne un paramètre pour l’afficher Tous les transferts que tu recevras sur les 30 derniers jours apparaitront ici. Aucun transfert reçu Sélectionne un transfert ou créé-en un nouveau. diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index e8d8cb40c..f748d7def 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -46,6 +46,7 @@ In attesa della rete… Aggiungere fino a 50 GB di file Nessun file, nessun trasferimento! + Seleziona un parametro da visualizzare Qui appariranno tutti i bonifici ricevuti negli ultimi 30 giorni. Nessun trasferimento ricevuto Selezionare un trasferimento o crearne uno nuovo. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 20f580aec..80a196683 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -50,6 +50,7 @@ Waiting for network… Add up to 50 GB of files No file, no transfer! + Selects a parameter to display it All transfers you receive over the last 30 days will appear here. No transfers received Select a transfer or create a new one.