Skip to content

Commit

Permalink
Use callback for files
Browse files Browse the repository at this point in the history
  • Loading branch information
tevincent committed Oct 23, 2024
1 parent 2a730a9 commit 8c58665
Showing 1 changed file with 35 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,51 +36,54 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows

@Composable
fun FilesDetailsScreen(
withSpaceLeft: Boolean,
title: String? = null,
files: List<FileUi>? = null,
onFileRemoved: (uuid: String) -> Unit,
files: () -> List<FileUi>,
withSpaceLeft: Boolean,
onFileRemoved: ((uuid: String) -> Unit)? = null,
) {
val files = listOf(
FileUi(
fileName = "The 5-Step Guide to Not Breaking Your Code.txt",
uid = "The 5-Step Guide to Not Breaking Your Code.txt",
fileSizeInBytes = 57689032,
mimeType = null,
uri = "",
),
FileUi(
fileName = "Introduction to Turning It Off and On Again.pptx",
uid = "Introduction to Turning It Off and On Again.pptx",
fileSizeInBytes = 89723143,
mimeType = null,
uri = "",
),
FileUi(
fileName = "Learning to Copy and Paste: A Complete Guide.docx",
uid = "Learning to Copy and Paste: A Complete Guide.docx",
fileSizeInBytes = 237866728,
mimeType = null,
uri = "",
),
)
val testFiles = {
listOf(
FileUi(
fileName = "The 5-Step Guide to Not Breaking Your Code.txt",
uid = "The 5-Step Guide to Not Breaking Your Code.txt",
fileSizeInBytes = 57689032,
mimeType = null,
uri = "",
),
FileUi(
fileName = "Introduction to Turning It Off and On Again.pptx",
uid = "Introduction to Turning It Off and On Again.pptx",
fileSizeInBytes = 89723143,
mimeType = null,
uri = "",
),
FileUi(
fileName = "Learning to Copy and Paste: A Complete Guide.docx",
uid = "Learning to Copy and Paste: A Complete Guide.docx",
fileSizeInBytes = 237866728,
mimeType = null,
uri = "",
),
)
}
val files = testFiles()
Column {
SwissTransferTopAppBar(
title = title,
titleRes = R.string.importFilesScreenTitle,
navigationMenu = TopAppBarButton.backButton {},
TopAppBarButton.closeButton {},
)
FilesSize(files, withSpaceLeft)

FilesSize(files, withSpaceLeft)
FileItemList(
modifier = Modifier.padding(horizontal = Margin.Medium),
files = files,
isRemoveButtonVisible = true,
isRemoveButtonVisible = onFileRemoved != null,
isCheckboxVisible = false,
isUidChecked = { false },
setUidCheckStatus = { _, _ -> },
onRemoveUid = { onFileRemoved(it) },
onRemoveUid = { onFileRemoved?.invoke(it) },
)
}
}
Expand All @@ -91,10 +94,10 @@ private fun FilesDetailsScreenPreview(@PreviewParameter(FileUiListPreviewParamet
SwissTransferTheme {
Surface {
FilesDetailsScreen(
withSpaceLeft = true,
title = "My album",
files = files,
onFileRemoved = {},
files = { files },
withSpaceLeft = true,
onFileRemoved = { },
)
}
}
Expand Down

0 comments on commit 8c58665

Please sign in to comment.