From 0e21cdd51e23932d53958a7581084b64d9463f7a Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Mon, 14 Oct 2024 08:31:10 +0200 Subject: [PATCH 1/2] Turn FileUiItem from interface to data class to make future replacement easier --- .../swisstransfer/ui/components/FileItem.kt | 16 +++---- .../FileUiListPreviewParameterProvider.kt | 42 +++++++++---------- .../ui/screen/main/received/ReceivedScreen.kt | 42 ++++++++++--------- .../ui/screen/main/sent/SentListScreen.kt | 42 ++++++++++--------- .../newtransfer/TransferFilesManager.kt | 8 +--- 5 files changed, 76 insertions(+), 74 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt index f5f6a2c48..7bdb8f32e 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt @@ -35,14 +35,14 @@ import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows -// TODO: Get the interface from the shared kmp code -interface FileUiItem { - val uid: String - val fileName: String - val fileSizeInBytes: Long - val mimeType: String? - val uri: String -} +// TODO: Get the data class from the shared kmp code +data class FileUiItem( + val uid: String, + val fileName: String, + val fileSizeInBytes: Long, + val mimeType: String?, + val uri: String, +) @Composable fun FileItem( diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt index 5a3a453ce..d731a27cd 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt @@ -23,27 +23,27 @@ import com.infomaniak.swisstransfer.ui.components.FileUiItem class FileUiListPreviewParameter : PreviewParameterProvider> { override val values: Sequence> = sequenceOf( listOf( - object : FileUiItem { // Non-image file - override val fileName: String = "How to not get fired.pdf" - override val uid: String = fileName - override val fileSizeInBytes: Long = 10302130 - override val mimeType: String? = null - override val uri: String = "" - }, - object : FileUiItem { // Image file - override val fileName: String = "Opening images tutorial.png" - override val uid: String = fileName - override val fileSizeInBytes: Long = 456782 - override val mimeType: String? = null - override val uri: String = "https://picsum.photos/200/300" - }, - object : FileUiItem { - override val fileName: String = "The 5 step guide to turning it off and on again.docx" - override val uid: String = fileName - override val fileSizeInBytes: Long = 89723143 - override val mimeType: String? = null - override val uri: String = "" - }, + FileUiItem( + fileName = "How to not get fired.pdf", + uid = "How to not get fired.pdf", + fileSizeInBytes = 10302130, + mimeType = null, + uri = "", + ), + FileUiItem( + fileName = "Opening images tutorial.png", + uid = "Opening images tutorial.png", + fileSizeInBytes = 456782, + mimeType = null, + uri = "https://picsum.photos/200/300", + ), + FileUiItem( + fileName = "The 5 step guide to turning it off and on again.docx", + uid = "The 5 step guide to turning it off and on again.docx", + fileSizeInBytes = 89723143, + mimeType = null, + uri = "", + ), ) ) } 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 1a2f21a73..0761fe748 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 @@ -71,25 +71,29 @@ private fun ReceivedScreen( description = R.string.noTransferReceivedDescription, ) } else { - val files = listOf(object : FileUiItem { - override val fileName: String = "The 5-Step Guide to Not Breaking Your Code.txt" - override val uid: String = fileName - override val fileSizeInBytes: Long = 57689032 - override val mimeType: String? = null - override val uri: String = "" - }, object : FileUiItem { - override val fileName: String = "Introduction to Turning It Off and On Again.pptx" - override val uid: String = fileName - override val fileSizeInBytes: Long = 89723143 - override val mimeType: String? = null - override val uri: String = "" - }, object : FileUiItem { - override val fileName: String = "Learning to Copy and Paste: A Complete Guide.docx" - override val uid: String = fileName - override val fileSizeInBytes: Long = 237866728 - override val mimeType: String? = null - override val uri: String = "" - }) + val files = listOf( + FileUiItem( + 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 = "", + ), + FileUiItem( + 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 = "", + ), + FileUiItem( + 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 = "", + ), + ) FileItemList( modifier = Modifier.padding(Margin.Medium), files = files, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt index 2ac1937b4..4b55d2f31 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt @@ -29,25 +29,29 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SentListScreen(transfers: List) { - val transfers = listOf(object : FileUiItem { - override val fileName: String = "The 5-Step Guide to Not Breaking Your Code.txt" - override val uid: String = fileName - override val fileSizeInBytes: Long = 57689032 - override val mimeType: String? = null - override val uri: String = "" - }, object : FileUiItem { - override val fileName: String = "Introduction to Turning It Off and On Again.pptx" - override val uid: String = fileName - override val fileSizeInBytes: Long = 89723143 - override val mimeType: String? = null - override val uri: String = "" - }, object : FileUiItem { - override val fileName: String = "Learning to Copy and Paste: A Complete Guide.docx" - override val uid: String = fileName - override val fileSizeInBytes: Long = 237866728 - override val mimeType: String? = null - override val uri: String = "" - }) + val transfers = listOf( + FileUiItem( + 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 = "", + ), + FileUiItem( + 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 = "", + ), + FileUiItem( + 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 = "", + ), + ) FileItemList( modifier = Modifier.padding(Margin.Medium), files = transfers, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt index bb1c3fb2a..72a463e93 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt @@ -50,13 +50,7 @@ class TransferFilesManager @Inject constructor(@ApplicationContext private val a return cursor?.getFileNameAndSize()?.let { (name, size) -> val uniqueName = FileNameUtils.postfixExistingFileNames(name, alreadyUsedFileNames) - object: FileUiItem { - override val fileName: String = uniqueName - override val uid: String = fileName - override val fileSizeInBytes: Long = size - override val mimeType: String? = null - override val uri: String = uri.toString() - } + FileUiItem(fileName = uniqueName, uid = uniqueName, fileSizeInBytes = size, mimeType = null, uri = uri.toString()) } } From 708e339eb2be3fa83d0d8f22d336e01338c6cce6 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Mon, 14 Oct 2024 09:13:20 +0200 Subject: [PATCH 2/2] Rename FileUiItem into FileUi to match the future data class name --- .../swisstransfer/ui/components/FileItem.kt | 6 +++--- .../swisstransfer/ui/components/FileItemList.kt | 4 ++-- .../swisstransfer/ui/components/FilePreview.kt | 2 +- .../swisstransfer/ui/components/SmallFileItem.kt | 4 ++-- .../FileUiListPreviewParameterProvider.kt | 12 ++++++------ .../ui/screen/main/received/ReceivedScreen.kt | 8 ++++---- .../ui/screen/main/sent/SentListScreen.kt | 8 ++++---- .../ui/screen/newtransfer/NewTransferViewModel.kt | 6 +++--- .../ui/screen/newtransfer/TransferFilesManager.kt | 10 +++++----- .../newtransfer/importfiles/ImportFilesScreen.kt | 4 ++-- .../importfiles/components/ImportedFilesCard.kt | 4 ++-- .../swisstransfer/ui/utils/FileUiItemExt.kt | 6 +++--- 12 files changed, 37 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt index 7bdb8f32e..d30ba4231 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt @@ -36,7 +36,7 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows // TODO: Get the data class from the shared kmp code -data class FileUiItem( +data class FileUi( val uid: String, val fileName: String, val fileSizeInBytes: Long, @@ -46,7 +46,7 @@ data class FileUiItem( @Composable fun FileItem( - file: FileUiItem, + file: FileUi, isRemoveButtonVisible: Boolean, isCheckboxVisible: Boolean, isChecked: () -> Boolean = { false }, @@ -131,7 +131,7 @@ private fun FileItemContent( @PreviewAllWindows @Composable -private fun FileItemPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun FileItemPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { Surface { Column( diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt index 20acf8f84..cb596ec8e 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt @@ -33,7 +33,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun FileItemList( modifier: Modifier = Modifier, - files: List, + files: List, isRemoveButtonVisible: Boolean, isCheckboxVisible: Boolean, isUidChecked: (String) -> Boolean, @@ -61,7 +61,7 @@ fun FileItemList( @PreviewAllWindows @Composable -private fun FileItemListPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun FileItemListPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { FileItemList( files = files, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FilePreview.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FilePreview.kt index 3040a4b0c..e83e17fa7 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FilePreview.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FilePreview.kt @@ -42,7 +42,7 @@ import com.infomaniak.swisstransfer.ui.utils.hasPreview @Composable fun FilePreview( - file: FileUiItem, + file: FileUi, circleColor: Color, circleSize: Dp, ) { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt index 07711333c..869b51912 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SmallFileItem.kt @@ -37,7 +37,7 @@ import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @Composable fun SmallFileItem( modifier: Modifier = Modifier, - file: FileUiItem, + file: FileUi, smallFileTileSize: SmallFileTileSize, onRemove: (() -> Unit)? = null, ) { @@ -67,7 +67,7 @@ enum class SmallFileTileSize(val size: Dp, val shape: Shape) { @Preview(name = "Light") @Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) @Composable -private fun SmallFileItemPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun SmallFileItemPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { Surface(color = SwissTransferTheme.materialColors.surfaceContainerHighest) { Column(Modifier.padding(16.dp)) { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt index d731a27cd..f04da36a5 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/FileUiListPreviewParameterProvider.kt @@ -18,26 +18,26 @@ package com.infomaniak.swisstransfer.ui.previewparameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi -class FileUiListPreviewParameter : PreviewParameterProvider> { - override val values: Sequence> = sequenceOf( +class FileUiListPreviewParameter : PreviewParameterProvider> { + override val values: Sequence> = sequenceOf( listOf( - FileUiItem( + FileUi( fileName = "How to not get fired.pdf", uid = "How to not get fired.pdf", fileSizeInBytes = 10302130, mimeType = null, uri = "", ), - FileUiItem( + FileUi( fileName = "Opening images tutorial.png", uid = "Opening images tutorial.png", fileSizeInBytes = 456782, mimeType = null, uri = "https://picsum.photos/200/300", ), - FileUiItem( + FileUi( fileName = "The 5 step guide to turning it off and on again.docx", uid = "The 5 step guide to turning it off and on again.docx", fileSizeInBytes = 89723143, 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 0761fe748..4e64230ca 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 @@ -29,7 +29,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.EmptyState import com.infomaniak.swisstransfer.ui.components.FileItemList -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.illus.MascotSearching import com.infomaniak.swisstransfer.ui.screen.main.components.BrandTopAppBarScaffold @@ -72,21 +72,21 @@ private fun ReceivedScreen( ) } else { val files = listOf( - FileUiItem( + 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 = "", ), - FileUiItem( + 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 = "", ), - FileUiItem( + FileUi( fileName = "Learning to Copy and Paste: A Complete Guide.docx", uid = "Learning to Copy and Paste: A Complete Guide.docx", fileSizeInBytes = 237866728, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt index 4b55d2f31..c1ff2b6b4 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt @@ -22,7 +22,7 @@ import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.infomaniak.swisstransfer.ui.components.FileItemList -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @@ -30,21 +30,21 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SentListScreen(transfers: List) { val transfers = listOf( - FileUiItem( + 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 = "", ), - FileUiItem( + 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 = "", ), - FileUiItem( + FileUi( fileName = "Learning to Copy and Paste: A Complete Guide.docx", uid = "Learning to Copy and Paste: A Complete Guide.docx", fileSizeInBytes = 237866728, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferViewModel.kt index 01029191c..4696748f6 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferViewModel.kt @@ -20,7 +20,7 @@ package com.infomaniak.swisstransfer.ui.screen.newtransfer import android.net.Uri import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -32,8 +32,8 @@ import javax.inject.Inject @HiltViewModel class NewTransferViewModel @Inject constructor(private val transferFilesManager: TransferFilesManager) : ViewModel() { - private val _files = MutableStateFlow>(emptyList()) - val files: StateFlow> = _files + private val _files = MutableStateFlow>(emptyList()) + val files: StateFlow> = _files private val _failedFileCount = MutableSharedFlow() val failedFileCount: SharedFlow = _failedFileCount diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt index 72a463e93..729af2e5b 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/TransferFilesManager.kt @@ -22,7 +22,7 @@ import android.content.Context import android.database.Cursor import android.net.Uri import android.provider.OpenableColumns -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi import com.infomaniak.swisstransfer.ui.utils.FileNameUtils import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject @@ -30,9 +30,9 @@ import javax.inject.Singleton @Singleton class TransferFilesManager @Inject constructor(@ApplicationContext private val appContext: Context) { - fun getFiles(uris: List, alreadyUsedFileNames: Set): MutableSet { + fun getFiles(uris: List, alreadyUsedFileNames: Set): MutableSet { val currentUsedFileNames = alreadyUsedFileNames.toMutableSet() - val files = mutableSetOf() + val files = mutableSetOf() uris.forEach { uri -> getFile(uri, currentUsedFileNames)?.let { file -> @@ -44,13 +44,13 @@ class TransferFilesManager @Inject constructor(@ApplicationContext private val a return files } - private fun getFile(uri: Uri, alreadyUsedFileNames: Set): FileUiItem? { + private fun getFile(uri: Uri, alreadyUsedFileNames: Set): FileUi? { val contentResolver: ContentResolver = appContext.contentResolver val cursor: Cursor? = contentResolver.query(uri, null, null, null, null) return cursor?.getFileNameAndSize()?.let { (name, size) -> val uniqueName = FileNameUtils.postfixExistingFileNames(name, alreadyUsedFileNames) - FileUiItem(fileName = uniqueName, uid = uniqueName, fileSizeInBytes = size, mimeType = null, uri = uri.toString()) + FileUi(fileName = uniqueName, uid = uniqueName, fileSizeInBytes = size, mimeType = null, uri = uri.toString()) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt index 43648927f..ce5b3d6be 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt @@ -51,7 +51,7 @@ fun ImportFilesScreen( @Composable private fun ImportFilesScreen( - files: () -> List, + files: () -> List, removeFileByUid: (uid: String) -> Unit, addFiles: (List) -> Unit, closeActivity: () -> Unit, @@ -111,7 +111,7 @@ private fun ImportFilesScreen( @PreviewAllWindows @Composable -private fun ImportFilesScreenPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun ImportFilesScreenPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { ImportFilesScreen({ files }, {}, {}, closeActivity = {}) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt index ab45c3041..c5b889114 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/components/ImportedFilesCard.kt @@ -47,7 +47,7 @@ import kotlinx.parcelize.Parcelize @Composable fun ImportedFilesCard( modifier: Modifier = Modifier, - files: () -> List, + files: () -> List, humanReadableSize: () -> String, showUploadSourceChoiceBottomSheet: () -> Unit, removeFileByUid: (uid: String) -> Unit, @@ -140,7 +140,7 @@ private data class TransferLazyRowKey( @Preview(name = "Light") @Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) @Composable -private fun ImportededFilesCardPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { +private fun ImportedFilesCardPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { ImportedFilesCard( modifier = Modifier.padding(Margin.Medium), diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt index e78f6ccb3..82bcd098e 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt @@ -18,8 +18,8 @@ package com.infomaniak.swisstransfer.ui.utils import com.infomaniak.library.filetypes.FileType -import com.infomaniak.swisstransfer.ui.components.FileUiItem +import com.infomaniak.swisstransfer.ui.components.FileUi -val FileUiItem.fileType: FileType get() = mimeType?.let { FileType.guessFromMimeType(it) } ?: FileType.guessFromFileName(fileName) +val FileUi.fileType: FileType get() = mimeType?.let { FileType.guessFromMimeType(it) } ?: FileType.guessFromFileName(fileName) -val FileUiItem.hasPreview: Boolean get() = fileType == FileType.IMAGE +val FileUi.hasPreview: Boolean get() = fileType == FileType.IMAGE