From 1c18ec97f63f9a8bc5bdf47ac8cfcb889a383b6c Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Wed, 13 Nov 2024 12:13:11 +0100 Subject: [PATCH] review: Fix Previews issues in Sent & Received screens --- .../ui/screen/main/received/ReceivedScreen.kt | 13 +++++++++++++ .../ui/screen/main/sent/SentScreen.kt | 19 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) 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 b097adfa2..88447e4bd 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 @@ -24,6 +24,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +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.EmptyState @@ -46,6 +47,16 @@ fun ReceivedScreen( val transfers by transfersViewModel.receivedTransfers.collectAsStateWithLifecycle() val areTransfersEmpty by remember { derivedStateOf { transfers.isEmpty() } } + ReceivedScreen(navigateToDetails, getSelectedTransferUuid, transfers, areTransfersEmpty) +} + +@Composable +private fun ReceivedScreen( + navigateToDetails: (transferUuid: String) -> Unit, + getSelectedTransferUuid: () -> String?, + transfers: List, + areTransfersEmpty: Boolean, +) { BrandTopAppBarScaffold( floatingActionButton = { ReceivedEmptyFab { areTransfersEmpty } }, ) { @@ -69,6 +80,8 @@ private fun Preview() { ReceivedScreen( navigateToDetails = {}, getSelectedTransferUuid = { null }, + transfers = emptyList(), + areTransfersEmpty = true, ) } } 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 8c57a6b55..1ae6ce2fd 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 @@ -23,12 +23,15 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.remember +import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection import com.infomaniak.swisstransfer.ui.components.NewTransferFab import com.infomaniak.swisstransfer.ui.components.NewTransferFabType import com.infomaniak.swisstransfer.ui.components.transfer.TransfersListWithExpiredBottomSheet +import com.infomaniak.swisstransfer.ui.previewparameter.TransferUiListPreviewParameter import com.infomaniak.swisstransfer.ui.screen.main.components.BrandTopAppBarScaffold import com.infomaniak.swisstransfer.ui.screen.main.transfers.TransfersViewModel import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @@ -44,6 +47,18 @@ fun SentScreen( val transfers by transfersViewModel.sentTransfers.collectAsStateWithLifecycle() val areTransfersEmpty by remember { derivedStateOf { transfers.isEmpty() } } + + SentScreen(navigateToDetails, getSelectedTransferUuid, transfers, areTransfersEmpty) +} + +@Composable +private fun SentScreen( + navigateToDetails: (transferUuid: String) -> Unit, + getSelectedTransferUuid: () -> String?, + transfers: List, + areTransfersEmpty: Boolean, +) { + val windowAdaptiveInfo = currentWindowAdaptiveInfo() BrandTopAppBarScaffold( @@ -63,12 +78,14 @@ fun SentScreen( @PreviewAllWindows @Composable -private fun Preview() { +private fun Preview(@PreviewParameter(TransferUiListPreviewParameter::class) transfers: List) { SwissTransferTheme { Surface { SentScreen( navigateToDetails = {}, getSelectedTransferUuid = { null }, + transfers = transfers, + areTransfersEmpty = false, ) } }