|
@@ -1,5 +1,6 @@
|
|
|
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
|
|
@@ -61,11 +62,23 @@ 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.app.Utils
|
|
|
+import com.fastest.pass.helpers.BasePreferenceHelper
|
|
|
+import com.fastest.pass.home.domain.model.PasswordFormData
|
|
|
+import javax.inject.Inject
|
|
|
|
|
|
@Composable
|
|
|
-fun AddPasswordFormScreen() {
|
|
|
+fun AddPasswordFormScreen(
|
|
|
+ onPasswordsFormList: (ArrayList<PasswordFormData>) -> Unit,
|
|
|
+ basePreferenceHelper: BasePreferenceHelper
|
|
|
+) {
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
val focusManager = LocalFocusManager.current
|
|
|
+ var passwords_title by remember { mutableStateOf("") }
|
|
|
+ var passwords_url by remember { mutableStateOf("") }
|
|
|
+ var passwords_username by remember { mutableStateOf("") }
|
|
|
+ var passwords_password by remember { mutableStateOf("") }
|
|
|
+ var passwords_notes by remember { mutableStateOf("") }
|
|
|
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
@@ -75,7 +88,34 @@ fun AddPasswordFormScreen() {
|
|
|
.background(Color.Transparent)
|
|
|
.imePadding()
|
|
|
) {
|
|
|
- SaveButtonAPWFS(buttonText = R.string.save)
|
|
|
+ SaveButtonAPWFS(
|
|
|
+ buttonText = R.string.save,
|
|
|
+ onSaveButtonCLick = {
|
|
|
+ val passwordsFormList = ArrayList<PasswordFormData>()
|
|
|
+ val saltKey = basePreferenceHelper.getCustomSaltKey()
|
|
|
+ val userPassword = basePreferenceHelper.getPassword()
|
|
|
+
|
|
|
+ Log.d("saltKey", "saltKey = $saltKey, password = $userPassword")
|
|
|
+// val passwords_title_enc = Utils.encryptData(
|
|
|
+// passwords_title, userPassword ?: "", saltKey ?: "")
|
|
|
+// passwords_url = Utils.encryptData(
|
|
|
+// passwords_url, userPassword ?: "", saltKey ?: "")
|
|
|
+// passwords_username = Utils.encryptData(
|
|
|
+// passwords_username, userPassword ?: "", saltKey ?: "")
|
|
|
+// passwords_password = Utils.encryptData(
|
|
|
+// passwords_password, userPassword ?: "", saltKey ?: "")
|
|
|
+// passwords_notes = Utils.encryptData(
|
|
|
+// passwords_notes, userPassword ?: "", saltKey ?: "")
|
|
|
+
|
|
|
+ passwordsFormList.add(PasswordFormData("passwords_title", passwords_title))
|
|
|
+ passwordsFormList.add(PasswordFormData("passwords_url", passwords_url))
|
|
|
+ passwordsFormList.add(PasswordFormData("passwords_username", passwords_username))
|
|
|
+ passwordsFormList.add(PasswordFormData("passwords_password", passwords_password))
|
|
|
+ passwordsFormList.add(PasswordFormData("passwords_notes", passwords_notes))
|
|
|
+
|
|
|
+ onPasswordsFormList.invoke(passwordsFormList)
|
|
|
+ }
|
|
|
+ )
|
|
|
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
@@ -86,15 +126,35 @@ fun AddPasswordFormScreen() {
|
|
|
.verticalScroll(rememberScrollState())
|
|
|
) {
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TitleTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ TitleTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ onTitleText = { passwords_title = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- UrlTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ UrlTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ onUrlText = { passwords_url = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- UsernameTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ UsernameTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ onUsernameText = { passwords_username = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- PasswordTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ PasswordTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ onPasswordText = { passwords_password = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NotesTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ NotesTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ onNotesText = { passwords_notes = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(25.dp))
|
|
|
OptionsText()
|
|
|
Spacer(modifier = Modifier.height(25.dp))
|
|
@@ -109,7 +169,8 @@ fun AddPasswordFormScreen() {
|
|
|
@Composable
|
|
|
fun ColumnScope.TitleTextFieldAPS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onTitleText: (String) -> Unit
|
|
|
) {
|
|
|
var titleText by remember { mutableStateOf("") }
|
|
|
|
|
@@ -117,6 +178,7 @@ fun ColumnScope.TitleTextFieldAPS(
|
|
|
value = titleText,
|
|
|
onValueChange = {
|
|
|
titleText = it
|
|
|
+ onTitleText.invoke(titleText)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -178,7 +240,8 @@ fun ColumnScope.TitleTextFieldAPS(
|
|
|
@Composable
|
|
|
fun ColumnScope.UrlTextFieldAPS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onUrlText: (String) -> Unit
|
|
|
) {
|
|
|
var urlText by remember { mutableStateOf("") }
|
|
|
|
|
@@ -186,6 +249,7 @@ fun ColumnScope.UrlTextFieldAPS(
|
|
|
value = urlText,
|
|
|
onValueChange = {
|
|
|
urlText = it
|
|
|
+ onUrlText.invoke(urlText)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -262,7 +326,8 @@ fun ColumnScope.UrlTextFieldAPS(
|
|
|
@Composable
|
|
|
fun ColumnScope.UsernameTextFieldAPS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onUsernameText: (String) -> Unit
|
|
|
) {
|
|
|
var usernameText by remember { mutableStateOf("") }
|
|
|
|
|
@@ -270,6 +335,7 @@ fun ColumnScope.UsernameTextFieldAPS(
|
|
|
value = usernameText,
|
|
|
onValueChange = {
|
|
|
usernameText = it
|
|
|
+ onUsernameText.invoke(usernameText)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -331,7 +397,8 @@ fun ColumnScope.UsernameTextFieldAPS(
|
|
|
@Composable
|
|
|
fun ColumnScope.PasswordTextFieldAPS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onPasswordText: (String) -> Unit
|
|
|
) {
|
|
|
var passwordText by remember { mutableStateOf("") }
|
|
|
var passwordVisible by remember { mutableStateOf(false) }
|
|
@@ -340,6 +407,7 @@ fun ColumnScope.PasswordTextFieldAPS(
|
|
|
value = passwordText,
|
|
|
onValueChange = {
|
|
|
passwordText = it
|
|
|
+ onPasswordText.invoke(passwordText)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -425,7 +493,8 @@ fun ColumnScope.PasswordTextFieldAPS(
|
|
|
@Composable
|
|
|
fun ColumnScope.NotesTextFieldAPS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onNotesText: (String) -> Unit
|
|
|
) {
|
|
|
var notesText by remember { mutableStateOf("") }
|
|
|
|
|
@@ -433,6 +502,7 @@ fun ColumnScope.NotesTextFieldAPS(
|
|
|
value = notesText,
|
|
|
onValueChange = {
|
|
|
notesText = it
|
|
|
+ onNotesText.invoke(notesText)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -580,7 +650,10 @@ fun ColumnScope.SaveButtonAPFS(buttonText: Int) {
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun BoxScope.SaveButtonAPWFS(buttonText: Int) {
|
|
|
+fun BoxScope.SaveButtonAPWFS(
|
|
|
+ buttonText: Int,
|
|
|
+ onSaveButtonCLick: () -> Unit
|
|
|
+ ) {
|
|
|
Button(
|
|
|
modifier = Modifier
|
|
|
.background(colorResource(id = R.color.transparent))
|
|
@@ -588,7 +661,9 @@ fun BoxScope.SaveButtonAPWFS(buttonText: Int) {
|
|
|
.height(60.dp)
|
|
|
.align(Alignment.BottomCenter)
|
|
|
.clickable() { },
|
|
|
- onClick = {},
|
|
|
+ onClick = {
|
|
|
+ onSaveButtonCLick.invoke()
|
|
|
+ },
|
|
|
shape = RoundedCornerShape(15.dp),
|
|
|
// border = BorderStroke(25.dp, colorResource(id = R.color.black)),
|
|
|
colors = ButtonDefaults.buttonColors(
|