Skip to content

Commit

Permalink
Rename FileUi fields to match the KMP model's ones before replacing
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Oct 30, 2024
1 parent 4cf2751 commit dfe103b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows
data class FileUi(
val uid: String,
val fileName: String,
val fileSizeInBytes: Long,
val fileSize: Long,
val mimeType: String?,
val uri: String,
val localPath: String,
)

@Composable
Expand All @@ -60,7 +60,7 @@ fun FileItem(
isRemoveButtonVisible = isRemoveButtonVisible,
onRemove = onRemove,
title = file.fileName,
description = Formatter.formatShortFileSize(LocalContext.current, file.fileSizeInBytes),
description = Formatter.formatShortFileSize(LocalContext.current, file.fileSize),
content = {
FilePreview(
file = file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fun FilePreview(
var displayPreview by rememberSaveable { mutableStateOf(file.hasPreview) }

if (displayPreview) {
FileThumbnail(file.uri, onError = { displayPreview = false })
FileThumbnail(file.localPath, onError = { displayPreview = false })
} else {
FileIcon(file.fileType, circleColor, circleSize)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ class FileUiListPreviewParameter : PreviewParameterProvider<List<FileUi>> {
FileUi(
fileName = "How to not get fired.pdf",
uid = "How to not get fired.pdf",
fileSizeInBytes = 10302130,
fileSize = 10302130,
mimeType = null,
uri = "",
localPath = "",
),
FileUi(
fileName = "Opening images tutorial.png",
uid = "Opening images tutorial.png",
fileSizeInBytes = 456782,
fileSize = 456782,
mimeType = null,
uri = "https://picsum.photos/200/300",
localPath = "https://picsum.photos/200/300",
),
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,
fileSize = 89723143,
mimeType = null,
uri = "",
localPath = "",
),
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ private fun ReceivedScreen(
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,
fileSize = 57689032,
mimeType = null,
uri = "",
localPath = "",
),
FileUi(
fileName = "Introduction to Turning It Off and On Again.pptx",
uid = "Introduction to Turning It Off and On Again.pptx",
fileSizeInBytes = 89723143,
fileSize = 89723143,
mimeType = null,
uri = "",
localPath = "",
),
FileUi(
fileName = "Learning to Copy and Paste: A Complete Guide.docx",
uid = "Learning to Copy and Paste: A Complete Guide.docx",
fileSizeInBytes = 237866728,
fileSize = 237866728,
mimeType = null,
uri = "",
localPath = "",
),
)
FileItemList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ fun SentListScreen(transfers: List<Any>) {
FileUi(
fileName = "The 5-Step Guide to Not Breaking Your Code.txt",
uid = "The 5-Step Guide to Not Breaking Your Code.txt",
fileSizeInBytes = 57_689_032L,
fileSize = 57_689_032L,
mimeType = null,
uri = "",
localPath = "",
),
FileUi(
fileName = "Introduction to Turning It Off and On Again.pptx",
uid = "Introduction to Turning It Off and On Again.pptx",
fileSizeInBytes = 89_723_143L,
fileSize = 89_723_143L,
mimeType = null,
uri = "",
localPath = "",
),
FileUi(
fileName = "Learning to Copy and Paste: A Complete Guide.docx",
uid = "Learning to Copy and Paste: A Complete Guide.docx",
fileSizeInBytes = 237_866_728L,
fileSize = 237_866_728L,
mimeType = null,
uri = "",
localPath = "",
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FilesMutableStateFlow {
val index = files.indexOfFirst { it.uid == uid }.takeIf { it != -1 } ?: return null
val fileToRemove = files.removeAt(index)

runCatching { File(fileToRemove.uri).delete() }
runCatching { File(fileToRemove.localPath).delete() }

this.files.value = files

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class ImportationFilesManager @Inject constructor(
FileUi(
uid = fileToImport.fileName,
fileName = fileToImport.fileName,
fileSizeInBytes = fileToImport.fileSizeInBytes,
fileSize = fileToImport.fileSizeInBytes,
mimeType = null,
uri = copiedFile.toUri().toString(),
localPath = copiedFile.toUri().toString(),
)
)
}
Expand All @@ -131,9 +131,9 @@ class ImportationFilesManager @Inject constructor(
FileUi(
uid = localFile.name,
fileName = localFile.name,
fileSizeInBytes = fileSizeInBytes,
fileSize = fileSizeInBytes,
mimeType = null,
uri = localFile.toUri().toString(),
localPath = localFile.toUri().toString(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private fun ImportFilesScreen(

val importedFiles = files()
val humanReadableSize = remember(importedFiles) {
val usedSpace = importedFiles.sumOf { it.fileSizeInBytes }
val usedSpace = importedFiles.sumOf { it.fileSize }
val spaceLeft = (TOTAL_FILE_SIZE - usedSpace).coerceAtLeast(0)
getHumanReadableSize(context, spaceLeft)
}
Expand Down

0 comments on commit dfe103b

Please sign in to comment.