diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt index c84929578..f1afae36a 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsScreen.kt @@ -100,7 +100,6 @@ private fun TransferDetailsScreen( val context = LocalContext.current val transferRecipients: List = emptyList() // TODO: Use real data - val transferPassword = "toto42" // TODO: Use real data var isMultiselectOn: Boolean by rememberSaveable { mutableStateOf(false) } var showQrCodeBottomSheet: Boolean by rememberSaveable { mutableStateOf(false) } @@ -123,6 +122,7 @@ private fun TransferDetailsScreen( BottomBar( direction = direction, isMultiselectOn = { isMultiselectOn }, + shouldShowPassword = { getTransfer().password?.isNotEmpty() == true }, onClick = { item -> when (item) { BottomBarItem.SHARE -> context.shareText(transferUrl) @@ -149,7 +149,7 @@ private fun TransferDetailsScreen( ) PasswordBottomSheet( isVisible = { showPasswordBottomSheet }, - transferPassword = transferPassword, + transferPassword = { getTransfer().password }, closeBottomSheet = { showPasswordBottomSheet = false }, ) } @@ -230,7 +230,12 @@ private fun TransferContentHeader() { } @Composable -private fun BottomBar(direction: TransferDirection, isMultiselectOn: () -> Boolean, onClick: (BottomBarItem) -> Unit) { +private fun BottomBar( + direction: TransferDirection, + isMultiselectOn: () -> Boolean, + shouldShowPassword: () -> Boolean, + onClick: (BottomBarItem) -> Unit, +) { Column( modifier = Modifier .height(80.dp) @@ -250,8 +255,10 @@ private fun BottomBar(direction: TransferDirection, isMultiselectOn: () -> Boole Spacer(Modifier.width(Margin.Medium)) BottomBarButton(BottomBarItem.QR_CODE, onClick) - Spacer(Modifier.width(Margin.Medium)) - BottomBarButton(BottomBarItem.PASSWORD, onClick) + if (shouldShowPassword()) { + Spacer(Modifier.width(Margin.Medium)) + BottomBarButton(BottomBarItem.PASSWORD, onClick) + } } TransferDirection.RECEIVED -> { Spacer(Modifier.width(Margin.Medium)) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/PasswordBottomSheet.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/PasswordBottomSheet.kt index ce0f73a9e..e440925e0 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/PasswordBottomSheet.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/PasswordBottomSheet.kt @@ -40,9 +40,11 @@ import com.infomaniak.swisstransfer.ui.utils.copyText import kotlinx.coroutines.launch @Composable -fun PasswordBottomSheet(isVisible: () -> Boolean, transferPassword: String, closeBottomSheet: () -> Unit) { +fun PasswordBottomSheet(isVisible: () -> Boolean, transferPassword: () -> String?, closeBottomSheet: () -> Unit) { - if (!isVisible()) return + val password = transferPassword() + + if (!isVisible() || password == null) return val context = LocalContext.current val scope = rememberCoroutineScope() @@ -57,7 +59,7 @@ fun PasswordBottomSheet(isVisible: () -> Boolean, transferPassword: String, clos imageVector = AppIcons.DocumentOnDocument, onClick = { context.copyText( - text = transferPassword, + text = password, showSnackbar = { scope.launch { snackbarHostState.showSnackbar(it) } }, ) closeBottomSheet() @@ -79,7 +81,7 @@ fun PasswordBottomSheet(isVisible: () -> Boolean, transferPassword: String, clos modifier = Modifier .fillMaxWidth() .padding(horizontal = Margin.Medium), - initialValue = transferPassword, + initialValue = password, isPassword = true, isReadOnly = true, ) @@ -93,7 +95,7 @@ private fun Preview() { Surface { PasswordBottomSheet( isVisible = { true }, - transferPassword = "toto42", + transferPassword = { "toto42" }, closeBottomSheet = {}, ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bb1de516b..40eb48833 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,7 @@ qrose = "1.0.1" recaptcha = "18.6.1" sentry = "4.12.0" serialization = "1.7.3" -swisstransfer = "0.9.0" +swisstransfer = "0.9.2" workmanager = "2.10.0" [libraries]