|
@@ -1,22 +1,22 @@
|
|
|
+@file:OptIn(ExperimentalComposeUiApi::class)
|
|
|
+
|
|
|
package com.fastest.pass.home.presentation.ui.components
|
|
|
|
|
|
+import android.util.Log
|
|
|
import androidx.compose.foundation.Image
|
|
|
import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.border
|
|
|
import androidx.compose.foundation.clickable
|
|
|
-import androidx.compose.foundation.gestures.detectTapGestures
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
import androidx.compose.foundation.layout.BoxScope
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
import androidx.compose.foundation.layout.ColumnScope
|
|
|
-import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
import androidx.compose.foundation.layout.defaultMinSize
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
-import androidx.compose.foundation.layout.imeNestedScroll
|
|
|
import androidx.compose.foundation.layout.imePadding
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.foundation.layout.size
|
|
@@ -41,12 +41,13 @@ import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
|
import androidx.compose.runtime.setValue
|
|
|
import androidx.compose.ui.Alignment
|
|
|
+import androidx.compose.ui.ExperimentalComposeUiApi
|
|
|
import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.autofill.AutofillType
|
|
|
import androidx.compose.ui.draw.scale
|
|
|
import androidx.compose.ui.focus.FocusManager
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.ColorFilter
|
|
|
-import androidx.compose.ui.input.pointer.pointerInput
|
|
|
import androidx.compose.ui.platform.LocalFocusManager
|
|
|
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
|
|
import androidx.compose.ui.platform.SoftwareKeyboardController
|
|
@@ -61,12 +62,20 @@ import androidx.compose.ui.text.style.TextAlign
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
import com.fastest.pass.R
|
|
|
+import com.fastest.pass.home.domain.model.AddPassword
|
|
|
+import com.fastest.pass.login.presentation.ui.components.autoFill
|
|
|
|
|
|
@Composable
|
|
|
-fun AddPasswordFormScreen() {
|
|
|
+fun AddPasswordFormScreen(onSave: (Any?) -> Unit) {
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
val focusManager = LocalFocusManager.current
|
|
|
|
|
|
+ var titleText by remember { mutableStateOf("") }
|
|
|
+ var urlText by remember { mutableStateOf("") }
|
|
|
+ var usernameText by remember { mutableStateOf("") }
|
|
|
+ var passwordText by remember { mutableStateOf("") }
|
|
|
+ var notesText by remember { mutableStateOf("") }
|
|
|
+
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
.fillMaxSize()
|
|
@@ -75,7 +84,17 @@ fun AddPasswordFormScreen() {
|
|
|
.background(Color.Transparent)
|
|
|
.imePadding()
|
|
|
) {
|
|
|
- SaveButtonAPWFS(buttonText = R.string.save)
|
|
|
+ SaveButtonAPWFS(buttonText = R.string.save) {
|
|
|
+ onSave.invoke(
|
|
|
+ AddPassword(
|
|
|
+ titleText,
|
|
|
+ urlText,
|
|
|
+ usernameText,
|
|
|
+ passwordText,
|
|
|
+ notesText
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
@@ -86,15 +105,49 @@ fun AddPasswordFormScreen() {
|
|
|
.verticalScroll(rememberScrollState())
|
|
|
) {
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TitleTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ TitleTextFieldAPS(
|
|
|
+ titleText,
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager
|
|
|
+ ) {
|
|
|
+ titleText = it
|
|
|
+ }
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- UrlTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ UrlTextFieldAPS(
|
|
|
+ urlText,
|
|
|
+ keyboardController = keyboardController, focusManager = focusManager
|
|
|
+ ) {
|
|
|
+ urlText = it
|
|
|
+ }
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- UsernameTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ UsernameTextFieldAPS(
|
|
|
+ usernameText,
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ onUsernameText = {
|
|
|
+ usernameText = it
|
|
|
+ },
|
|
|
+ onAutofillSelection = {
|
|
|
+ titleText = "testing"
|
|
|
+ urlText = "---testingggg"
|
|
|
+ }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- PasswordTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ PasswordTextFieldAPS(
|
|
|
+ passwordText,
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager
|
|
|
+ ) {
|
|
|
+ passwordText = it
|
|
|
+ }
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NotesTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ NotesTextFieldAPS(
|
|
|
+ notesText,
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager
|
|
|
+ ) {
|
|
|
+ notesText = it
|
|
|
+ }
|
|
|
Spacer(modifier = Modifier.height(25.dp))
|
|
|
OptionsText()
|
|
|
Spacer(modifier = Modifier.height(25.dp))
|
|
@@ -108,18 +161,24 @@ fun AddPasswordFormScreen() {
|
|
|
|
|
|
@Composable
|
|
|
fun ColumnScope.TitleTextFieldAPS(
|
|
|
+ titleText: String,
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onTitleText: (String) -> Unit
|
|
|
) {
|
|
|
- var titleText by remember { mutableStateOf("") }
|
|
|
-
|
|
|
TextField(
|
|
|
value = titleText,
|
|
|
onValueChange = {
|
|
|
- titleText = it
|
|
|
+ onTitleText.invoke(it)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
|
+ .autoFill(
|
|
|
+ autofillTypes = listOf(AutofillType.PersonFirstName),
|
|
|
+ onFill = {
|
|
|
+ onTitleText.invoke(it)
|
|
|
+ }
|
|
|
+ )
|
|
|
.align(Alignment.Start)
|
|
|
.fillMaxWidth()
|
|
|
.defaultMinSize(minHeight = 60.dp)
|
|
@@ -139,7 +198,8 @@ fun ColumnScope.TitleTextFieldAPS(
|
|
|
// )
|
|
|
// },
|
|
|
label = {
|
|
|
- Text(text = stringResource(R.string.title),
|
|
|
+ Text(
|
|
|
+ text = stringResource(R.string.title),
|
|
|
style = MaterialTheme.typography.titleSmall.copy(
|
|
|
color = colorResource(id = R.color.gray_text)
|
|
|
)
|
|
@@ -177,18 +237,25 @@ fun ColumnScope.TitleTextFieldAPS(
|
|
|
|
|
|
@Composable
|
|
|
fun ColumnScope.UrlTextFieldAPS(
|
|
|
+ urlText: String,
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onUrlText: (String) -> Unit
|
|
|
) {
|
|
|
- var urlText by remember { mutableStateOf("") }
|
|
|
-
|
|
|
TextField(
|
|
|
value = urlText,
|
|
|
onValueChange = {
|
|
|
- urlText = it
|
|
|
+ onUrlText.invoke(it)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
|
+ .autoFill(
|
|
|
+ autofillTypes = listOf(AutofillType.PersonLastName),
|
|
|
+ onFill = {
|
|
|
+ onUrlText.invoke(it)
|
|
|
+ Log.d("asdf", "this value was received from autofill: $it")
|
|
|
+ }
|
|
|
+ )
|
|
|
.align(Alignment.Start)
|
|
|
.fillMaxWidth()
|
|
|
.defaultMinSize(minHeight = 60.dp)
|
|
@@ -208,7 +275,8 @@ fun ColumnScope.UrlTextFieldAPS(
|
|
|
// )
|
|
|
// },
|
|
|
label = {
|
|
|
- Text(text = stringResource(R.string.url),
|
|
|
+ Text(
|
|
|
+ text = stringResource(R.string.url),
|
|
|
style = MaterialTheme.typography.titleSmall.copy(
|
|
|
color = colorResource(id = R.color.gray_text)
|
|
|
)
|
|
@@ -225,9 +293,9 @@ fun ColumnScope.UrlTextFieldAPS(
|
|
|
trailingIcon = {
|
|
|
IconButton(
|
|
|
onClick = {
|
|
|
- urlText = ""
|
|
|
+ onUrlText.invoke("")
|
|
|
},
|
|
|
- ) {
|
|
|
+ ) {
|
|
|
if (urlText.isNotEmpty()) {
|
|
|
Image(
|
|
|
painter = painterResource(id = R.drawable.clear_button),
|
|
@@ -261,18 +329,27 @@ fun ColumnScope.UrlTextFieldAPS(
|
|
|
|
|
|
@Composable
|
|
|
fun ColumnScope.UsernameTextFieldAPS(
|
|
|
+ usernameText: String,
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onUsernameText: (String) -> Unit,
|
|
|
+ onAutofillSelection: (String) -> Unit
|
|
|
) {
|
|
|
- var usernameText by remember { mutableStateOf("") }
|
|
|
-
|
|
|
TextField(
|
|
|
value = usernameText,
|
|
|
onValueChange = {
|
|
|
- usernameText = it
|
|
|
+ onUsernameText.invoke(it)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
|
+ .autoFill(
|
|
|
+ autofillTypes = listOf(AutofillType.Username),
|
|
|
+ onFill = {
|
|
|
+ onUsernameText.invoke(it)
|
|
|
+ onAutofillSelection.invoke(it)
|
|
|
+ Log.d("asdf", "this value was received from autofill: $it")
|
|
|
+ }
|
|
|
+ )
|
|
|
.align(Alignment.Start)
|
|
|
.fillMaxWidth()
|
|
|
.defaultMinSize(minHeight = 60.dp)
|
|
@@ -292,7 +369,8 @@ fun ColumnScope.UsernameTextFieldAPS(
|
|
|
// )
|
|
|
// },
|
|
|
label = {
|
|
|
- Text(text = stringResource(R.string.username),
|
|
|
+ Text(
|
|
|
+ text = stringResource(R.string.username),
|
|
|
style = MaterialTheme.typography.titleSmall.copy(
|
|
|
color = colorResource(id = R.color.gray_text)
|
|
|
)
|
|
@@ -330,19 +408,27 @@ fun ColumnScope.UsernameTextFieldAPS(
|
|
|
|
|
|
@Composable
|
|
|
fun ColumnScope.PasswordTextFieldAPS(
|
|
|
+ passwordText: String,
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onPasswordText: (String) -> Unit
|
|
|
) {
|
|
|
- var passwordText by remember { mutableStateOf("") }
|
|
|
var passwordVisible by remember { mutableStateOf(false) }
|
|
|
|
|
|
TextField(
|
|
|
value = passwordText,
|
|
|
onValueChange = {
|
|
|
- passwordText = it
|
|
|
+ onPasswordText.invoke(it)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
|
+ .autoFill(
|
|
|
+ autofillTypes = listOf(AutofillType.Password),
|
|
|
+ onFill = {
|
|
|
+ onPasswordText.invoke(it)
|
|
|
+ Log.d("asdf", "this value was received from autofill: $it")
|
|
|
+ }
|
|
|
+ )
|
|
|
.align(Alignment.Start)
|
|
|
.fillMaxWidth()
|
|
|
.defaultMinSize(minHeight = 60.dp)
|
|
@@ -362,7 +448,8 @@ fun ColumnScope.PasswordTextFieldAPS(
|
|
|
// )
|
|
|
// },
|
|
|
label = {
|
|
|
- Text(text = stringResource(R.string.password),
|
|
|
+ Text(
|
|
|
+ text = stringResource(R.string.password),
|
|
|
style = MaterialTheme.typography.titleSmall.copy(
|
|
|
color = colorResource(id = R.color.gray_text)
|
|
|
)
|
|
@@ -405,8 +492,7 @@ fun ColumnScope.PasswordTextFieldAPS(
|
|
|
contentDescription = description,
|
|
|
modifier = Modifier.size(24.dp)
|
|
|
)
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
Image(
|
|
|
painter = painterResource(id = R.drawable.eye_slash3x),
|
|
|
contentDescription = description,
|
|
@@ -424,18 +510,26 @@ fun ColumnScope.PasswordTextFieldAPS(
|
|
|
|
|
|
@Composable
|
|
|
fun ColumnScope.NotesTextFieldAPS(
|
|
|
+ notesText: String,
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onNoteText: (String) -> Unit
|
|
|
) {
|
|
|
- var notesText by remember { mutableStateOf("") }
|
|
|
|
|
|
TextField(
|
|
|
value = notesText,
|
|
|
onValueChange = {
|
|
|
- notesText = it
|
|
|
+ onNoteText.invoke(it)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
|
+ .autoFill(
|
|
|
+ autofillTypes = listOf(AutofillType.AddressStreet),
|
|
|
+ onFill = {
|
|
|
+ onNoteText.invoke(it)
|
|
|
+ Log.d("asdf", "this value was received from autofill: $it")
|
|
|
+ }
|
|
|
+ )
|
|
|
.align(Alignment.Start)
|
|
|
.fillMaxWidth()
|
|
|
.defaultMinSize(minHeight = 60.dp)
|
|
@@ -445,8 +539,7 @@ fun ColumnScope.NotesTextFieldAPS(
|
|
|
color = colorResource(id = R.color.gray_border_textfield),
|
|
|
shape = RoundedCornerShape(16.dp)
|
|
|
)
|
|
|
- .background(color = colorResource(id = R.color.transparent))
|
|
|
- ,
|
|
|
+ .background(color = colorResource(id = R.color.transparent)),
|
|
|
shape = RoundedCornerShape(16.dp),
|
|
|
// placeholder = {
|
|
|
// Text(
|
|
@@ -456,7 +549,8 @@ fun ColumnScope.NotesTextFieldAPS(
|
|
|
// )
|
|
|
// },
|
|
|
label = {
|
|
|
- Text(text = stringResource(R.string.notes),
|
|
|
+ Text(
|
|
|
+ text = stringResource(R.string.notes),
|
|
|
style = MaterialTheme.typography.titleSmall.copy(
|
|
|
color = colorResource(id = R.color.gray_text)
|
|
|
)
|
|
@@ -558,7 +652,7 @@ fun ColumnScope.SaveButtonAPFS(buttonText: Int) {
|
|
|
.background(colorResource(id = R.color.transparent))
|
|
|
.fillMaxWidth()
|
|
|
.height(60.dp)
|
|
|
- .clickable() { },
|
|
|
+ .clickable { },
|
|
|
onClick = {},
|
|
|
shape = RoundedCornerShape(15.dp),
|
|
|
// border = BorderStroke(25.dp, colorResource(id = R.color.black)),
|
|
@@ -580,15 +674,17 @@ fun ColumnScope.SaveButtonAPFS(buttonText: Int) {
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun BoxScope.SaveButtonAPWFS(buttonText: Int) {
|
|
|
+fun BoxScope.SaveButtonAPWFS(buttonText: Int, onClick: () -> Unit) {
|
|
|
Button(
|
|
|
modifier = Modifier
|
|
|
.background(colorResource(id = R.color.transparent))
|
|
|
.fillMaxWidth()
|
|
|
.height(60.dp)
|
|
|
.align(Alignment.BottomCenter)
|
|
|
- .clickable() { },
|
|
|
- onClick = {},
|
|
|
+ .clickable { },
|
|
|
+ onClick = {
|
|
|
+ onClick.invoke()
|
|
|
+ },
|
|
|
shape = RoundedCornerShape(15.dp),
|
|
|
// border = BorderStroke(25.dp, colorResource(id = R.color.black)),
|
|
|
colors = ButtonDefaults.buttonColors(
|