Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove file choice bottom sheet #204

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons
import com.infomaniak.swisstransfer.ui.images.icons.Camera
import com.infomaniak.swisstransfer.ui.images.icons.Add
import com.infomaniak.swisstransfer.ui.theme.Dimens
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark

private val BOTTOM_SHEET_ITEM_HEIGHT = 56.dp

// Unused for now, but this is still the official component with the appropriate style of a bottom sheet item so this needs to be
// used if we ever create a new bottom sheet
@Composable
fun BottomSheetItem(imageVector: ImageVector, @StringRes titleRes: Int, onClick: () -> Unit) {
SharpRippleButton(
Expand Down Expand Up @@ -73,7 +75,7 @@ fun BottomSheetItem(imageVector: ImageVector, @StringRes titleRes: Int, onClick:
private fun ChoiceItemPreview() {
SwissTransferTheme {
Surface {
BottomSheetItem(AppIcons.Camera, R.string.transferUploadSourceChoiceCamera) {}
BottomSheetItem(AppIcons.Add, R.string.appName) {}
}
}
}

This file was deleted.

This file was deleted.

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() }
LunarX marked this conversation as resolved.
Show resolved Hide resolved

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
Loading
Loading