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

feat: Enable user to see their password #221

Merged
merged 3 commits into from
Dec 2, 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 @@ -100,7 +100,6 @@ private fun TransferDetailsScreen(

val context = LocalContext.current
val transferRecipients: List<String> = 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) }
Expand All @@ -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)
Expand All @@ -149,7 +149,7 @@ private fun TransferDetailsScreen(
)
PasswordBottomSheet(
isVisible = { showPasswordBottomSheet },
transferPassword = transferPassword,
transferPassword = { getTransfer().password },
closeBottomSheet = { showPasswordBottomSheet = false },
)
}
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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,
)
Expand All @@ -93,7 +95,7 @@ private fun Preview() {
Surface {
PasswordBottomSheet(
isVisible = { true },
transferPassword = "toto42",
transferPassword = { "toto42" },
closeBottomSheet = {},
)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
sirambd marked this conversation as resolved.
Show resolved Hide resolved
workmanager = "2.10.0"

[libraries]
Expand Down