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 b836e4583..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 @@ -149,7 +149,7 @@ private fun TransferDetailsScreen( ) PasswordBottomSheet( isVisible = { showPasswordBottomSheet }, - transferPassword = getTransfer().password, + transferPassword = { getTransfer().password }, closeBottomSheet = { showPasswordBottomSheet = false }, ) } 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 46143cde6..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() || transferPassword == null) 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?, clo 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?, clo 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 = {}, ) }