diff --git a/src/main/kotlin/ui/components/FormComponents.kt b/src/main/kotlin/ui/components/FormComponents.kt index 9703ea2..c664882 100644 --- a/src/main/kotlin/ui/components/FormComponents.kt +++ b/src/main/kotlin/ui/components/FormComponents.kt @@ -49,8 +49,8 @@ fun FormTextField( onValueChange = onValueChange, interactionSource = interactionSource, modifier = Modifier - .fillMaxSize() - .padding(start = 14.dp, bottom = 3.dp), + .fillMaxSize() + .padding(start = 14.dp, bottom = 3.dp), textStyle = TextStyle( fontFamily = Font.RussoOne, color = Color.White, @@ -119,8 +119,8 @@ fun FormTextArea( ) { Column( modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 14.dp) + .fillMaxWidth() + .padding(horizontal = 14.dp) ) { if (label.isNotEmpty()) { Text( @@ -137,8 +137,8 @@ fun FormTextArea( onValueChange = onValueChange, interactionSource = interactionSource, modifier = Modifier - .fillMaxWidth() - .padding(bottom = 8.dp), + .fillMaxWidth() + .padding(bottom = 8.dp), textStyle = TextStyle( fontFamily = Font.RussoOne, color = Color.White, @@ -174,8 +174,8 @@ fun FormDropdown( ) { Box( modifier = Modifier - .fillMaxSize() - .clickable { expanded = true } + .fillMaxSize() + .clickable { expanded = true } ) { TextFieldDefaults.DecorationBox( value = selectedItem?.displayText ?: "", @@ -183,8 +183,8 @@ fun FormDropdown( Text( text = selectedItem?.displayText ?: "", modifier = Modifier - .fillMaxWidth() - .padding(start = 14.dp, bottom = 3.dp), + .fillMaxWidth() + .padding(start = 14.dp, bottom = 3.dp), style = TextStyle( fontFamily = Font.RussoOne, color = Color.White, @@ -232,8 +232,8 @@ fun FormDropdown( expanded = expanded, onDismissRequest = { expanded = false }, modifier = Modifier - .background(secondary) - .width(IntrinsicSize.Min) + .background(secondary) + .width(IntrinsicSize.Min) ) { items.forEach { item -> DropdownMenuItem( @@ -250,11 +250,11 @@ fun FormDropdown( expanded = false }, modifier = Modifier - .fillMaxWidth() - .background( - if (item.id == selectedItem?.id) Color.White.copy(alpha = 0.1f) - else Color.Transparent - ) + .fillMaxWidth() + .background( + if (item.id == selectedItem?.id) Color.White.copy(alpha = 0.1f) + else Color.Transparent + ) ) } } @@ -284,8 +284,8 @@ fun PasswordTextField( onValueChange = onValueChange, interactionSource = interactionSource, modifier = Modifier - .fillMaxSize() - .padding(start = 14.dp, bottom = 3.dp), + .fillMaxSize() + .padding(start = 14.dp, bottom = 3.dp), textStyle = TextStyle( fontFamily = Font.RussoOne, color = Color.White, @@ -312,7 +312,7 @@ fun PasswordTextField( checked = passwordVisible, onCheckedChange = { passwordVisible = it }, modifier = Modifier.hoverable(interactionSource) - .pointerHoverIcon(PointerIcon.Hand) + .pointerHoverIcon(PointerIcon.Hand) ) { Icon( @@ -415,6 +415,7 @@ fun UnderLineTextFiled( modifier: Modifier = Modifier, label: String, field: String, + onIconClick: () -> Unit = { }, onFieldChange: (String) -> Unit, isPassword: Boolean = false, singleLine: Boolean = true @@ -468,7 +469,7 @@ fun UnderLineTextFiled( else Icons.Default.Visibility, contentDescription = "", modifier = Modifier.size(width = 15.dp, height = 15.dp) - .pointerHoverIcon(PointerIcon.Default), + .pointerHoverIcon(PointerIcon.Default), tint = Color.Gray ) } @@ -477,14 +478,14 @@ fun UnderLineTextFiled( Column { IconButton( interactionSource = interactionSource, - onClick = {} + onClick = onIconClick ) { Icon( imageVector = Icons.Default.ContentCopy, contentDescription = "", tint = Color.Gray, modifier = Modifier.size(width = 15.dp, height = 15.dp) - .pointerHoverIcon(PointerIcon.Default) + .pointerHoverIcon(PointerIcon.Default) ) } } diff --git a/src/main/kotlin/ui/components/secvault/passwordinfo/CredentialForms.kt b/src/main/kotlin/ui/components/secvault/passwordinfo/CredentialForms.kt index 3200167..35eb3ff 100644 --- a/src/main/kotlin/ui/components/secvault/passwordinfo/CredentialForms.kt +++ b/src/main/kotlin/ui/components/secvault/passwordinfo/CredentialForms.kt @@ -5,13 +5,17 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.* import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.ClipboardManager +import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.text.AnnotatedString import ui.components.UnderLineTextFiled import viewmodel.SecVaultScreenModel @Composable fun PasswordCredentialForm(screenModel: SecVaultScreenModel) { val selectedCredential by screenModel.selectedCredential.collectAsState() - + val clipboardManager: ClipboardManager = LocalClipboardManager.current + var userName by remember(selectedCredential) { mutableStateOf(selectedCredential.password?.username ?: "") } @@ -38,7 +42,8 @@ fun PasswordCredentialForm(screenModel: SecVaultScreenModel) { field = userName, onFieldChange = { userName = it }, label = "Username", - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), + onIconClick = { clipboardManager.setText(AnnotatedString(userName)) } ) } @@ -48,7 +53,8 @@ fun PasswordCredentialForm(screenModel: SecVaultScreenModel) { onFieldChange = { password = it }, label = "Password", modifier = Modifier.fillMaxWidth(), - isPassword = true + isPassword = true, + onIconClick = { clipboardManager.setText(AnnotatedString(password)) } ) } @@ -57,7 +63,8 @@ fun PasswordCredentialForm(screenModel: SecVaultScreenModel) { field = email, onFieldChange = { email = it }, label = "Email", - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), + onIconClick = { clipboardManager.setText(AnnotatedString(email)) } ) } @@ -66,7 +73,8 @@ fun PasswordCredentialForm(screenModel: SecVaultScreenModel) { field = website, onFieldChange = { website = it }, label = "Website", - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), + onIconClick = { clipboardManager.setText(AnnotatedString(website)) } ) } @@ -76,6 +84,7 @@ fun PasswordCredentialForm(screenModel: SecVaultScreenModel) { @Composable fun CreditCardCredentialForm(screenModel: SecVaultScreenModel) { val selectedCredential by screenModel.selectedCredential.collectAsState() + val clipboardManager: ClipboardManager = LocalClipboardManager.current var bankName by remember(selectedCredential) { mutableStateOf(selectedCredential.creditCard?.name ?: "") @@ -119,7 +128,8 @@ fun CreditCardCredentialForm(screenModel: SecVaultScreenModel) { field = bankName, onFieldChange = { bankName = it }, label = "Bank Name", - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), + onIconClick = { clipboardManager.setText(AnnotatedString(bankName)) } ) } @@ -128,7 +138,8 @@ fun CreditCardCredentialForm(screenModel: SecVaultScreenModel) { field = cardOwner, onFieldChange = { cardOwner = it }, label = "Card Owner", - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), + onIconClick = { clipboardManager.setText(AnnotatedString(cardOwner)) } ) } @@ -137,7 +148,8 @@ fun CreditCardCredentialForm(screenModel: SecVaultScreenModel) { field = cardNumber, onFieldChange = { cardNumber = it }, label = "Card Number", - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), + onIconClick = { clipboardManager.setText(AnnotatedString(cardNumber)) } ) } @@ -147,7 +159,8 @@ fun CreditCardCredentialForm(screenModel: SecVaultScreenModel) { onFieldChange = { cvc = it }, label = "CVC", modifier = Modifier.fillMaxWidth(), - isPassword = true + isPassword = true, + onIconClick = { clipboardManager.setText(AnnotatedString(cvc)) } ) } @@ -157,7 +170,8 @@ fun CreditCardCredentialForm(screenModel: SecVaultScreenModel) { onFieldChange = { pin = it }, label = "Pin", modifier = Modifier.fillMaxWidth(), - isPassword = true + isPassword = true, + onIconClick = { clipboardManager.setText(AnnotatedString(pin)) } ) } @@ -166,7 +180,8 @@ fun CreditCardCredentialForm(screenModel: SecVaultScreenModel) { field = expiryDate, onFieldChange = { expiryDate = it }, label = "Expiry Date", - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), + onIconClick = { clipboardManager.setText(AnnotatedString(expiryDate)) } ) } @@ -176,7 +191,8 @@ fun CreditCardCredentialForm(screenModel: SecVaultScreenModel) { onFieldChange = { notes = it }, label = "Notes", modifier = Modifier.fillMaxWidth(), - singleLine = false + singleLine = false, + onIconClick = { clipboardManager.setText(AnnotatedString(notes)) } ) } }