-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
241 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/FilesSize.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Infomaniak SwissTransfer - Android | ||
* Copyright (C) 2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.infomaniak.swisstransfer.ui.screen.newtransfer | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.pluralStringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.tooling.preview.PreviewParameter | ||
import com.infomaniak.swisstransfer.R | ||
import com.infomaniak.swisstransfer.ui.components.FileUi | ||
import com.infomaniak.swisstransfer.ui.previewparameter.FileUiListPreviewParameter | ||
import com.infomaniak.swisstransfer.ui.theme.Margin | ||
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme | ||
import com.infomaniak.swisstransfer.ui.utils.HumanReadableSizeUtils.formatSpaceLeft | ||
import com.infomaniak.swisstransfer.ui.utils.HumanReadableSizeUtils.getFilesSize | ||
import com.infomaniak.swisstransfer.ui.utils.HumanReadableSizeUtils.getSpaceLeft | ||
|
||
@Composable | ||
fun FilesSize(files: List<FileUi>, withSpaceLeft: Boolean) { | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.wrapContentHeight() | ||
.padding(vertical = Margin.Medium) | ||
) { | ||
val filesCount = files.count() | ||
val filesSize = LocalContext.current.getFilesSize(files) | ||
Text( | ||
pluralStringResource(R.plurals.filesCount, filesCount, filesCount), | ||
modifier = Modifier | ||
.padding(start = Margin.Medium) | ||
.wrapContentWidth(), | ||
color = SwissTransferTheme.colors.secondaryTextColor, | ||
style = SwissTransferTheme.typography.bodySmallRegular, | ||
) | ||
Text( | ||
"•", | ||
modifier = Modifier.padding(horizontal = Margin.Small), | ||
color = SwissTransferTheme.colors.secondaryTextColor, | ||
style = SwissTransferTheme.typography.bodySmallRegular, | ||
) | ||
Text( | ||
filesSize, | ||
color = SwissTransferTheme.colors.secondaryTextColor, | ||
style = SwissTransferTheme.typography.bodySmallRegular, | ||
) | ||
if (withSpaceLeft) { | ||
val context = LocalContext.current | ||
val spaceLeft = formatSpaceLeft { context.getSpaceLeft(files) } | ||
Spacer(modifier = Modifier.weight(1f)) | ||
Text( | ||
modifier = Modifier.padding(horizontal = Margin.Medium), | ||
text = spaceLeft, | ||
color = SwissTransferTheme.colors.secondaryTextColor, | ||
style = SwissTransferTheme.typography.bodySmallRegular, | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun FileSizePreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List<FileUi>) { | ||
SwissTransferTheme { | ||
Surface { | ||
FilesSize(files, withSpaceLeft = true) | ||
} | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
...java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Infomaniak SwissTransfer - Android | ||
* Copyright (C) 2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.PreviewParameter | ||
import com.infomaniak.swisstransfer.R | ||
import com.infomaniak.swisstransfer.ui.components.FileItemList | ||
import com.infomaniak.swisstransfer.ui.components.FileUi | ||
import com.infomaniak.swisstransfer.ui.components.SwissTransferTopAppBar | ||
import com.infomaniak.swisstransfer.ui.components.TopAppBarButton | ||
import com.infomaniak.swisstransfer.ui.previewparameter.FileUiListPreviewParameter | ||
import com.infomaniak.swisstransfer.ui.screen.newtransfer.FilesSize | ||
import com.infomaniak.swisstransfer.ui.theme.Margin | ||
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme | ||
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows | ||
|
||
@Composable | ||
fun FilesDetailsScreen( | ||
withSpaceLeft: Boolean, | ||
title: String? = null, | ||
files: List<FileUi>? = null, | ||
onFileRemoved: (uuid: String) -> Unit, | ||
) { | ||
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 = "", | ||
), | ||
) | ||
Column { | ||
SwissTransferTopAppBar( | ||
title = title, | ||
titleRes = R.string.importFilesScreenTitle, | ||
navigationMenu = TopAppBarButton.backButton {}, | ||
TopAppBarButton.closeButton {}, | ||
) | ||
FilesSize(files, withSpaceLeft) | ||
|
||
FileItemList( | ||
modifier = Modifier.padding(horizontal = Margin.Medium), | ||
files = files, | ||
isRemoveButtonVisible = true, | ||
isCheckboxVisible = false, | ||
isUidChecked = { false }, | ||
setUidCheckStatus = { _, _ -> }, | ||
onRemoveUid = { onFileRemoved(it) }, | ||
) | ||
} | ||
} | ||
|
||
@PreviewAllWindows | ||
@Composable | ||
private fun FilesDetailsScreenPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List<FileUi>) { | ||
SwissTransferTheme { | ||
Surface { | ||
FilesDetailsScreen( | ||
withSpaceLeft = true, | ||
title = "My album", | ||
files = files, | ||
onFileRemoved = {}, | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters