|
@@ -44,11 +44,18 @@ 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.helpers.BasePreferenceHelper
|
|
|
+import com.fastest.pass.home.data.model.NewItemFormField
|
|
|
|
|
|
@Composable
|
|
|
-fun AddSecureNoteFormScreen() {
|
|
|
+fun AddSecureNoteFormScreen(
|
|
|
+ basePreferenceHelper: BasePreferenceHelper,
|
|
|
+ onSecureNoteFormList: (ArrayList<NewItemFormField>, Boolean) -> Unit
|
|
|
+) {
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
val focusManager = LocalFocusManager.current
|
|
|
+ var notes_title by remember { mutableStateOf("") }
|
|
|
+ var notes_notes by remember { mutableStateOf("") }
|
|
|
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
@@ -60,18 +67,44 @@ fun AddSecureNoteFormScreen() {
|
|
|
.imePadding()
|
|
|
) {
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TitleTextFieldASNFS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ TitleTextFieldASNFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ onText = { notes_title = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NotesTextFieldASNFS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ NotesTextFieldASNFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ onText = { notes_notes = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(25.dp))
|
|
|
- SaveButtonASCFS(buttonText = R.string.save)
|
|
|
+ SaveButtonASCFS(
|
|
|
+ buttonText = R.string.save,
|
|
|
+ onSaveButtonClick = {
|
|
|
+ val secureNotesFormList = ArrayList<NewItemFormField>()
|
|
|
+ val saltKey = basePreferenceHelper.getCustomSaltKey()
|
|
|
+ val secretKey = basePreferenceHelper.getCustomSecretKey()
|
|
|
+
|
|
|
+ val isTitleEmpty = notes_title.isEmpty()
|
|
|
+
|
|
|
+ notes_title = encryptIfNotEmpty(notes_title, secretKey, saltKey)
|
|
|
+ notes_notes = encryptIfNotEmpty(notes_notes, secretKey, saltKey)
|
|
|
+
|
|
|
+ secureNotesFormList.add(NewItemFormField("notes_title", notes_title))
|
|
|
+ secureNotesFormList.add(NewItemFormField("notes_notes", notes_notes))
|
|
|
+
|
|
|
+ onSecureNoteFormList.invoke(secureNotesFormList, isTitleEmpty)
|
|
|
+ }
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
fun ColumnScope.TitleTextFieldASNFS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onText: (String) -> Unit
|
|
|
) {
|
|
|
var titleText by remember { mutableStateOf("") }
|
|
|
|
|
@@ -79,6 +112,7 @@ fun ColumnScope.TitleTextFieldASNFS(
|
|
|
value = titleText,
|
|
|
onValueChange = {
|
|
|
titleText = it
|
|
|
+ onText.invoke(titleText)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -140,7 +174,8 @@ fun ColumnScope.TitleTextFieldASNFS(
|
|
|
@Composable
|
|
|
fun ColumnScope.NotesTextFieldASNFS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onText: (String) -> Unit
|
|
|
) {
|
|
|
var notesText by remember { mutableStateOf("") }
|
|
|
|
|
@@ -148,6 +183,7 @@ fun ColumnScope.NotesTextFieldASNFS(
|
|
|
value = notesText,
|
|
|
onValueChange = {
|
|
|
notesText = it
|
|
|
+ onText.invoke(notesText)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -208,14 +244,19 @@ fun ColumnScope.NotesTextFieldASNFS(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun ColumnScope.SaveButtonASCFS(buttonText: Int) {
|
|
|
+fun ColumnScope.SaveButtonASCFS(
|
|
|
+ buttonText: Int,
|
|
|
+ onSaveButtonClick: () -> Unit
|
|
|
+ ) {
|
|
|
Button(
|
|
|
modifier = Modifier
|
|
|
.background(colorResource(id = R.color.transparent))
|
|
|
.fillMaxWidth()
|
|
|
.height(60.dp)
|
|
|
.clickable() { },
|
|
|
- onClick = {},
|
|
|
+ onClick = {
|
|
|
+ onSaveButtonClick.invoke()
|
|
|
+ },
|
|
|
shape = RoundedCornerShape(15.dp),
|
|
|
// border = BorderStroke(25.dp, colorResource(id = R.color.black)),
|
|
|
colors = ButtonDefaults.buttonColors(
|