Skip to content

Commit

Permalink
Remove file choice bottom sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX authored and KevinBoulongne committed Nov 21, 2024
1 parent 7f9c73c commit 3ee5f2d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fun ImportFilesScreen(
addFiles = importFilesViewModel::importFiles,
closeActivity = closeActivity,
sendTransfer = importFilesViewModel::sendTransfer,
initialShowUploadSourceChoiceBottomSheet = true,
shouldStartByPromptingUserForFiles = true,
)
}

Expand Down Expand Up @@ -144,11 +144,11 @@ private fun ImportFilesScreen(
removeFileByUid: (uid: String) -> Unit,
addFiles: (List<Uri>) -> Unit,
closeActivity: () -> Unit,
initialShowUploadSourceChoiceBottomSheet: Boolean,
shouldStartByPromptingUserForFiles: Boolean,
sendTransfer: () -> Unit,
) {
val context = LocalContext.current
var showUploadSourceChoiceBottomSheet by rememberSaveable { mutableStateOf(initialShowUploadSourceChoiceBottomSheet) }
var shouldShowInitialFilePick by rememberSaveable { mutableStateOf(shouldStartByPromptingUserForFiles) }
var showTransferOption by rememberSaveable { mutableStateOf<TransferOptionType?>(null) }

val importedFiles = files()
Expand All @@ -164,10 +164,17 @@ private fun ImportFilesScreen(
addFiles(uris)
}

fun pickFiles() {
shouldShowInitialFilePick = false
filePickerLauncher.launch(arrayOf("*/*"))
}

fun closeTransferOption() {
showTransferOption = null
}

LaunchedEffect(Unit) { if (shouldShowInitialFilePick) pickFiles() }

BottomStickyButtonScaffold(
topBar = {
SwissTransferTopAppBar(
Expand All @@ -190,7 +197,7 @@ private fun ImportFilesScreen(
modifier = Modifier.padding(vertical = Margin.Medium),
files = files,
humanReadableSize = { humanReadableSize },
showUploadSourceChoiceBottomSheet = { showUploadSourceChoiceBottomSheet = true },
pickFiles = ::pickFiles,
removeFileByUid = removeFileByUid,
)
ImportTextFields(transferMessage, selectedTransferType.get)
Expand All @@ -204,12 +211,6 @@ private fun ImportFilesScreen(
}

TransferOptions({ showTransferOption }, transferOptionsCallbacks, ::closeTransferOption)

UploadSourceChoiceBottomSheet(
isVisible = { showUploadSourceChoiceBottomSheet },
onFilePickerClicked = { filePickerLauncher.launch(arrayOf("*/*")) },
closeBottomSheet = { showUploadSourceChoiceBottomSheet = false },
)
}
)
}
Expand Down Expand Up @@ -384,7 +385,7 @@ private fun Preview(@PreviewParameter(FileUiListPreviewParameter::class) files:
removeFileByUid = {},
addFiles = {},
closeActivity = {},
initialShowUploadSourceChoiceBottomSheet = false,
shouldStartByPromptingUserForFiles = false,
sendTransfer = {},
)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fun ImportedFilesCard(
modifier: Modifier = Modifier,
files: () -> List<FileUi>,
humanReadableSize: () -> String,
showUploadSourceChoiceBottomSheet: () -> Unit,
pickFiles: () -> Unit,
removeFileByUid: (uid: String) -> Unit,
) {
SwissTransferCard(modifier) {
Expand Down Expand Up @@ -76,7 +76,7 @@ fun ImportedFilesCard(
horizontalArrangement = Arrangement.spacedBy(Margin.Medium),
) {
item(key = TransferLazyRowKey(TransferLazyRowKey.Type.ADD_BUTTON)) {
AddNewFileButton(Modifier.animateItem()) { showUploadSourceChoiceBottomSheet() }
AddNewFileButton(Modifier.animateItem()) { pickFiles() }
}

items(
Expand Down Expand Up @@ -131,7 +131,7 @@ private fun ImportedFilesCardPreview(@PreviewParameter(FileUiListPreviewParamete
modifier = Modifier.padding(Margin.Medium),
files = { files },
humanReadableSize = { "20 GB" },
showUploadSourceChoiceBottomSheet = {},
pickFiles = {},
removeFileByUid = {},
)
}
Expand Down

0 comments on commit 3ee5f2d

Please sign in to comment.