From e7e347d2d85c2002d12ece0e820b30cfc17df42f Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Tue, 12 Nov 2024 18:05:23 +0100 Subject: [PATCH 1/4] feat: Use real data for Sent & Received transfers lists --- .../TransfersListWithExpiredBottomSheet.kt | 10 ++++--- .../ui/screen/main/received/ReceivedScreen.kt | 26 +++++-------------- .../ui/screen/main/sent/SentScreen.kt | 25 ++++-------------- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt index f8bf925c8..3d4a85040 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt @@ -26,8 +26,10 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.PreviewParameter +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection -import com.infomaniak.swisstransfer.ui.previewparameter.transfersPreviewData +import com.infomaniak.swisstransfer.ui.previewparameter.TransferUiListPreviewParameter import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @@ -36,6 +38,7 @@ import java.util.Date @Composable fun TransfersListWithExpiredBottomSheet( direction: TransferDirection, + transfers: List, navigateToDetails: (transferUuid: String) -> Unit, getSelectedTransferUuid: () -> String?, ) { @@ -47,7 +50,7 @@ fun TransfersListWithExpiredBottomSheet( TransferItemList( modifier = Modifier.padding(Margin.Medium), direction = direction, - transfers = transfersPreviewData, // TODO: Use real data + transfers = transfers, getSelectedTransferUuid = getSelectedTransferUuid, onClick = { transfer -> when { @@ -81,11 +84,12 @@ fun TransfersListWithExpiredBottomSheet( @PreviewLightAndDark @Composable -private fun Preview() { +private fun Preview(@PreviewParameter(TransferUiListPreviewParameter::class) transfers: List) { SwissTransferTheme { Surface { TransfersListWithExpiredBottomSheet( direction = TransferDirection.RECEIVED, + transfers = transfers, navigateToDetails = {}, getSelectedTransferUuid = { null }, ) 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 668e1de14..b097adfa2 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 @@ -19,7 +19,9 @@ package com.infomaniak.swisstransfer.ui.screen.main.received import androidx.compose.material3.Surface import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf 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.models.TransferDirection @@ -40,34 +42,21 @@ fun ReceivedScreen( getSelectedTransferUuid: () -> String?, transfersViewModel: TransfersViewModel = hiltViewModel(), ) { - val transfers by transfersViewModel.receivedTransfers.collectAsStateWithLifecycle() - val areTransfersEmpty = false // TODO: Use the next line instead when available : - // val areTransfersEmpty by remember { derivedStateOf { transfers?.isEmpty() == true } } - ReceivedScreen( - navigateToDetails = navigateToDetails, - getSelectedTransferUuid = getSelectedTransferUuid, - areTransfersEmpty = { areTransfersEmpty }, - ) -} + val transfers by transfersViewModel.receivedTransfers.collectAsStateWithLifecycle() + val areTransfersEmpty by remember { derivedStateOf { transfers.isEmpty() } } -@Composable -private fun ReceivedScreen( - navigateToDetails: (transferUuid: String) -> Unit, - getSelectedTransferUuid: () -> String?, - areTransfersEmpty: () -> Boolean, -) { BrandTopAppBarScaffold( - floatingActionButton = { ReceivedEmptyFab(areTransfersEmpty) }, + floatingActionButton = { ReceivedEmptyFab { areTransfersEmpty } }, ) { - if (areTransfersEmpty()) { + if (areTransfersEmpty) { EmptyState( icon = AppIllus.MascotSearching, titleRes = R.string.noTransferReceivedTitle, descriptionRes = R.string.noTransferReceivedDescription, ) } else { - TransfersListWithExpiredBottomSheet(TransferDirection.RECEIVED, navigateToDetails, getSelectedTransferUuid) + TransfersListWithExpiredBottomSheet(TransferDirection.RECEIVED, transfers, navigateToDetails, getSelectedTransferUuid) } } } @@ -80,7 +69,6 @@ private fun Preview() { ReceivedScreen( navigateToDetails = {}, getSelectedTransferUuid = { null }, - areTransfersEmpty = { false }, ) } } 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 8a375da46..8c57a6b55 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 @@ -41,36 +41,22 @@ fun SentScreen( getSelectedTransferUuid: () -> String?, transfersViewModel: TransfersViewModel = hiltViewModel(), ) { - val transfers by transfersViewModel.sentTransfers.collectAsStateWithLifecycle() - val areTransfersEmpty by remember { derivedStateOf { transfers?.isEmpty() == true } } - - SentScreen( - navigateToDetails = navigateToDetails, - getSelectedTransferUuid = getSelectedTransferUuid, - areTransfersEmpty = { areTransfersEmpty }, - ) -} - -@Composable -private fun SentScreen( - navigateToDetails: (transferUuid: String) -> Unit, - getSelectedTransferUuid: () -> String?, - areTransfersEmpty: () -> Boolean, -) { + val transfers by transfersViewModel.sentTransfers.collectAsStateWithLifecycle() + val areTransfersEmpty by remember { derivedStateOf { transfers.isEmpty() } } val windowAdaptiveInfo = currentWindowAdaptiveInfo() BrandTopAppBarScaffold( floatingActionButton = { - if (windowAdaptiveInfo.isWindowSmall() && !areTransfersEmpty()) { + if (windowAdaptiveInfo.isWindowSmall() && !areTransfersEmpty) { NewTransferFab(newTransferFabType = NewTransferFabType.BOTTOM_BAR) } }, ) { - if (areTransfersEmpty()) { + if (areTransfersEmpty) { SentEmptyScreen() } else { - TransfersListWithExpiredBottomSheet(TransferDirection.SENT, navigateToDetails, getSelectedTransferUuid) + TransfersListWithExpiredBottomSheet(TransferDirection.SENT, transfers, navigateToDetails, getSelectedTransferUuid) } } } @@ -83,7 +69,6 @@ private fun Preview() { SentScreen( navigateToDetails = {}, getSelectedTransferUuid = { null }, - areTransfersEmpty = { true }, ) } } From fb157c59800abba25bc41253836be328a0199048 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Wed, 13 Nov 2024 12:13:11 +0100 Subject: [PATCH 2/4] 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, ) } } From 327581f7b1cc44e5d31bfb816e0bc057d19f7233 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Wed, 13 Nov 2024 12:44:55 +0100 Subject: [PATCH 3/4] review: Send Transfers into a callback instead of directly sending the initial value --- .../components/transfer/TransferItemList.kt | 12 +++++----- .../TransfersListWithExpiredBottomSheet.kt | 6 ++--- .../ui/screen/main/received/ReceivedScreen.kt | 22 +++++++++++-------- .../ui/screen/main/sent/SentScreen.kt | 20 +++++++++-------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt index 23262535a..7401d5a99 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt @@ -38,8 +38,8 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark fun TransferItemList( modifier: Modifier = Modifier, direction: TransferDirection, - transfers: List, getSelectedTransferUuid: () -> String?, + getTransfers: () -> List, onClick: (TransferUi) -> Unit, ) { @@ -58,11 +58,11 @@ fun TransferItemList( item { Text(stringResource(titleRes), style = SwissTransferTheme.typography.h1) } items( - count = transfers.count(), - key = { transfers[it].uuid }, - contentType = { transfers[it] }, + count = getTransfers().count(), + key = { getTransfers()[it].uuid }, + contentType = { getTransfers()[it] }, itemContent = { - val transfer = transfers[it] + val transfer = getTransfers()[it] TransferItem( transfer = transfer, isSelected = { selectedTransferUuid == transfer.uuid }, @@ -79,9 +79,9 @@ private fun Preview(@PreviewParameter(TransferUiListPreviewParameter::class) tra SwissTransferTheme { Surface { TransferItemList( - transfers = transfers, direction = TransferDirection.SENT, getSelectedTransferUuid = { null }, + getTransfers = { transfers }, onClick = {}, ) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt index 3d4a85040..51114a502 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt @@ -38,9 +38,9 @@ import java.util.Date @Composable fun TransfersListWithExpiredBottomSheet( direction: TransferDirection, - transfers: List, navigateToDetails: (transferUuid: String) -> Unit, getSelectedTransferUuid: () -> String?, + getTransfers: () -> List, ) { var isExpirySheetVisible: Boolean by rememberSaveable { mutableStateOf(false) } @@ -50,8 +50,8 @@ fun TransfersListWithExpiredBottomSheet( TransferItemList( modifier = Modifier.padding(Margin.Medium), direction = direction, - transfers = transfers, getSelectedTransferUuid = getSelectedTransferUuid, + getTransfers = getTransfers, onClick = { transfer -> when { transfer.expiresInDays < 0 -> { @@ -89,9 +89,9 @@ private fun Preview(@PreviewParameter(TransferUiListPreviewParameter::class) tra Surface { TransfersListWithExpiredBottomSheet( direction = TransferDirection.RECEIVED, - transfers = transfers, navigateToDetails = {}, getSelectedTransferUuid = { null }, + getTransfers = { transfers }, ) } } 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 88447e4bd..c4c391c1a 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 @@ -23,7 +23,6 @@ import androidx.compose.runtime.derivedStateOf 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 @@ -44,19 +43,20 @@ fun ReceivedScreen( transfersViewModel: TransfersViewModel = hiltViewModel(), ) { - val transfers by transfersViewModel.receivedTransfers.collectAsStateWithLifecycle() - val areTransfersEmpty by remember { derivedStateOf { transfers.isEmpty() } } + val getTransfers = { transfersViewModel.receivedTransfers.value } - ReceivedScreen(navigateToDetails, getSelectedTransferUuid, transfers, areTransfersEmpty) + ReceivedScreen(navigateToDetails, getSelectedTransferUuid, getTransfers) } @Composable private fun ReceivedScreen( navigateToDetails: (transferUuid: String) -> Unit, getSelectedTransferUuid: () -> String?, - transfers: List, - areTransfersEmpty: Boolean, + getTransfers: () -> List, ) { + + val areTransfersEmpty by remember { derivedStateOf { getTransfers().isEmpty() } } + BrandTopAppBarScaffold( floatingActionButton = { ReceivedEmptyFab { areTransfersEmpty } }, ) { @@ -67,7 +67,12 @@ private fun ReceivedScreen( descriptionRes = R.string.noTransferReceivedDescription, ) } else { - TransfersListWithExpiredBottomSheet(TransferDirection.RECEIVED, transfers, navigateToDetails, getSelectedTransferUuid) + TransfersListWithExpiredBottomSheet( + direction = TransferDirection.RECEIVED, + navigateToDetails = navigateToDetails, + getSelectedTransferUuid = getSelectedTransferUuid, + getTransfers = getTransfers, + ) } } } @@ -80,8 +85,7 @@ private fun Preview() { ReceivedScreen( navigateToDetails = {}, getSelectedTransferUuid = { null }, - transfers = emptyList(), - areTransfersEmpty = true, + getTransfers = { emptyList() }, ) } } 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 1ae6ce2fd..437b61914 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 @@ -25,7 +25,6 @@ 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 @@ -45,20 +44,19 @@ fun SentScreen( transfersViewModel: TransfersViewModel = hiltViewModel(), ) { - val transfers by transfersViewModel.sentTransfers.collectAsStateWithLifecycle() - val areTransfersEmpty by remember { derivedStateOf { transfers.isEmpty() } } + val getTransfers = { transfersViewModel.sentTransfers.value } - SentScreen(navigateToDetails, getSelectedTransferUuid, transfers, areTransfersEmpty) + SentScreen(navigateToDetails, getSelectedTransferUuid, getTransfers) } @Composable private fun SentScreen( navigateToDetails: (transferUuid: String) -> Unit, getSelectedTransferUuid: () -> String?, - transfers: List, - areTransfersEmpty: Boolean, + getTransfers: () -> List, ) { + val areTransfersEmpty by remember { derivedStateOf { getTransfers().isEmpty() } } val windowAdaptiveInfo = currentWindowAdaptiveInfo() BrandTopAppBarScaffold( @@ -71,7 +69,12 @@ private fun SentScreen( if (areTransfersEmpty) { SentEmptyScreen() } else { - TransfersListWithExpiredBottomSheet(TransferDirection.SENT, transfers, navigateToDetails, getSelectedTransferUuid) + TransfersListWithExpiredBottomSheet( + direction = TransferDirection.SENT, + navigateToDetails = navigateToDetails, + getSelectedTransferUuid = getSelectedTransferUuid, + getTransfers = getTransfers, + ) } } } @@ -84,8 +87,7 @@ private fun Preview(@PreviewParameter(TransferUiListPreviewParameter::class) tra SentScreen( navigateToDetails = {}, getSelectedTransferUuid = { null }, - transfers = transfers, - areTransfersEmpty = false, + getTransfers = { transfers }, ) } } From 204ea43f2824f174992f78642467c2ee999d7e06 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Wed, 13 Nov 2024 14:44:04 +0100 Subject: [PATCH 4/4] review: Apply suggestions from code review --- .../ui/screen/main/received/ReceivedScreen.kt | 9 +++++++-- .../ui/screen/main/sent/SentScreen.kt | 9 +++++++-- .../transferdetails/TransferDetailsScreen.kt | 16 ++++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) 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 c4c391c1a..6c82f97b0 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 @@ -23,6 +23,7 @@ import androidx.compose.runtime.derivedStateOf 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 @@ -43,9 +44,13 @@ fun ReceivedScreen( transfersViewModel: TransfersViewModel = hiltViewModel(), ) { - val getTransfers = { transfersViewModel.receivedTransfers.value } + val transfers by transfersViewModel.receivedTransfers.collectAsStateWithLifecycle() - ReceivedScreen(navigateToDetails, getSelectedTransferUuid, getTransfers) + ReceivedScreen( + navigateToDetails = navigateToDetails, + getSelectedTransferUuid = getSelectedTransferUuid, + getTransfers = { transfers }, + ) } @Composable 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 437b61914..404f6b286 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 @@ -25,6 +25,7 @@ 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 @@ -44,9 +45,13 @@ fun SentScreen( transfersViewModel: TransfersViewModel = hiltViewModel(), ) { - val getTransfers = { transfersViewModel.sentTransfers.value } + val transfers by transfersViewModel.sentTransfers.collectAsStateWithLifecycle() - SentScreen(navigateToDetails, getSelectedTransferUuid, getTransfers) + SentScreen( + navigateToDetails = navigateToDetails, + getSelectedTransferUuid = getSelectedTransferUuid, + getTransfers = { transfers }, + ) } @Composable 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 4855c01cd..4cb6693d6 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 @@ -92,8 +92,8 @@ private fun TransferDetailsScreen( val transferPassword = "toto42" // TODO: Use real data var isMultiselectOn: Boolean by rememberSaveable { mutableStateOf(false) } - var showQrCodeSheet: Boolean by rememberSaveable { mutableStateOf(false) } - var showPasswordSheet: Boolean by rememberSaveable { mutableStateOf(false) } + var showQrCodeBottomSheet: Boolean by rememberSaveable { mutableStateOf(false) } + var showPasswordBottomSheet: Boolean by rememberSaveable { mutableStateOf(false) } SmallWindowTopAppBarScaffold( smallWindowTopAppBar = { @@ -115,8 +115,8 @@ private fun TransferDetailsScreen( onClick = { item -> when (item) { BottomBarItem.SHARE -> context.shareText(transferUrl) - BottomBarItem.QR_CODE -> showQrCodeSheet = true - BottomBarItem.PASSWORD -> showPasswordSheet = true + BottomBarItem.QR_CODE -> showQrCodeBottomSheet = true + BottomBarItem.PASSWORD -> showPasswordBottomSheet = true BottomBarItem.DOWNLOAD -> { // TODO: Move the multiselect elsewhere, and implement this feature isMultiselectOn = true @@ -132,14 +132,14 @@ private fun TransferDetailsScreen( } QrCodeBottomSheet( - isVisible = { showQrCodeSheet }, + isVisible = { showQrCodeBottomSheet }, transferUrl = transferUrl, - closeBottomSheet = { showQrCodeSheet = false }, + closeBottomSheet = { showQrCodeBottomSheet = false }, ) PasswordBottomSheet( - isVisible = { showPasswordSheet }, + isVisible = { showPasswordBottomSheet }, transferPassword = transferPassword, - closeBottomSheet = { showPasswordSheet = false }, + closeBottomSheet = { showPasswordBottomSheet = false }, ) } }