Skip to content

Commit

Permalink
review: Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Nov 13, 2024
1 parent 9428145 commit 0e4cf51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,18 @@ fun TransferItemList(
) {

val selectedTransferUuid = getSelectedTransferUuid()
val titleRes = if (direction == TransferDirection.SENT) R.string.sentFilesTitle else R.string.receivedFilesTitle
val titleRes = when (direction) {
TransferDirection.SENT -> R.string.sentFilesTitle
TransferDirection.RECEIVED -> R.string.receivedFilesTitle
}

LazyColumn(
modifier = modifier,
verticalArrangement = Arrangement.spacedBy(Margin.Medium),
contentPadding = PaddingValues(top = Margin.Mini),
) {

item {
Text(
text = stringResource(titleRes),
style = SwissTransferTheme.typography.h1,
)
}
item { Text(stringResource(titleRes), style = SwissTransferTheme.typography.h1) }

items(
count = transfers.count(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,26 @@ fun TransfersScreenWrapper(direction: TransferDirection) {
private fun ListPane(direction: TransferDirection, navigator: ThreePaneScaffoldNavigator<String>) {
when (direction) {
TransferDirection.SENT -> SentScreen(
navigateToDetails = { transferUuid -> navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, transferUuid) },
getSelectedTransferUuid = { navigator.currentDestination?.content },
navigateToDetails = navigator::navigateToDetails,
getSelectedTransferUuid = navigator::getSelectedTransferUuid,
)
TransferDirection.RECEIVED -> ReceivedScreen(
navigateToDetails = { transferUuid -> navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, transferUuid) },
getSelectedTransferUuid = { navigator.currentDestination?.content },
navigateToDetails = navigator::navigateToDetails,
getSelectedTransferUuid = navigator::getSelectedTransferUuid,
)
}
}

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
private fun ThreePaneScaffoldNavigator<String>.navigateToDetails(transferUuid: String) {
navigateTo(ListDetailPaneScaffoldRole.Detail, transferUuid)
}

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
private fun ThreePaneScaffoldNavigator<String>.getSelectedTransferUuid(): String? {
return currentDestination?.content
}

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
@Composable
private fun DetailPane(navigator: ThreePaneScaffoldNavigator<String>) {
Expand Down

0 comments on commit 0e4cf51

Please sign in to comment.