Skip to content

Commit

Permalink
review: Fix Previews issues in Sent & Received screens
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Nov 13, 2024
1 parent b3342ae commit 7796c62
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<TransferUi>,
areTransfersEmpty: Boolean,
) {
BrandTopAppBarScaffold(
floatingActionButton = { ReceivedEmptyFab { areTransfersEmpty } },
) {
Expand All @@ -69,6 +80,8 @@ private fun Preview() {
ReceivedScreen(
navigateToDetails = {},
getSelectedTransferUuid = { null },
transfers = emptyList(),
areTransfersEmpty = true,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<TransferUi>,
areTransfersEmpty: Boolean,
) {

val windowAdaptiveInfo = currentWindowAdaptiveInfo()

BrandTopAppBarScaffold(
Expand All @@ -63,12 +78,14 @@ fun SentScreen(

@PreviewAllWindows
@Composable
private fun Preview() {
private fun Preview(@PreviewParameter(TransferUiListPreviewParameter::class) transfers: List<TransferUi>) {
SwissTransferTheme {
Surface {
SentScreen(
navigateToDetails = {},
getSelectedTransferUuid = { null },
transfers = transfers,
areTransfersEmpty = false,
)
}
}
Expand Down

0 comments on commit 7796c62

Please sign in to comment.