|
@@ -1,5 +1,6 @@
|
|
|
package com.fastest.pass.home.presentation.ui.components
|
|
|
|
|
|
+import android.util.Log
|
|
|
import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.border
|
|
|
import androidx.compose.foundation.clickable
|
|
@@ -46,11 +47,28 @@ 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.data.model.NewItemFormField
|
|
|
|
|
|
@Composable
|
|
|
-fun AddBankAccountFormScreen() {
|
|
|
+fun AddBankAccountFormScreen(
|
|
|
+ basePreferenceHelper: BasePreferenceHelper,
|
|
|
+ onBankAccountFormList: (ArrayList<NewItemFormField>, Boolean) -> Unit
|
|
|
+ ) {
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
val focusManager = LocalFocusManager.current
|
|
|
+ var bank_accounts_title by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_bank_name by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_account_type by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_routing_number by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_account_number by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_swift_code by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_iban_number by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_pin by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_branch_address by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_branch_phone by remember { mutableStateOf("") }
|
|
|
+ var bank_accounts_notes by remember { mutableStateOf("") }
|
|
|
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
@@ -60,7 +78,42 @@ fun AddBankAccountFormScreen() {
|
|
|
.background(Color.Transparent)
|
|
|
.imePadding()
|
|
|
) {
|
|
|
- SaveButtonABAFS(buttonText = R.string.save)
|
|
|
+ SaveButtonABAFS(
|
|
|
+ buttonText = R.string.save,
|
|
|
+ onSaveButtonCLick = {
|
|
|
+ val bankAccountFormList = ArrayList<NewItemFormField>()
|
|
|
+ val saltKey = basePreferenceHelper.getCustomSaltKey()
|
|
|
+ val secretKey = basePreferenceHelper.getCustomSecretKey()
|
|
|
+
|
|
|
+ val isTitleEmpty = bank_accounts_title.isEmpty()
|
|
|
+
|
|
|
+ bank_accounts_title = encryptIfNotEmpty(bank_accounts_title, secretKey, saltKey)
|
|
|
+ bank_accounts_bank_name = encryptIfNotEmpty(bank_accounts_bank_name, secretKey, saltKey)
|
|
|
+ bank_accounts_account_type = encryptIfNotEmpty(bank_accounts_account_type, secretKey, saltKey)
|
|
|
+ bank_accounts_routing_number = encryptIfNotEmpty(bank_accounts_routing_number, secretKey, saltKey)
|
|
|
+ bank_accounts_account_number = encryptIfNotEmpty(bank_accounts_account_number, secretKey, saltKey)
|
|
|
+ bank_accounts_swift_code = encryptIfNotEmpty(bank_accounts_swift_code, secretKey, saltKey)
|
|
|
+ bank_accounts_iban_number = encryptIfNotEmpty(bank_accounts_iban_number, secretKey, saltKey)
|
|
|
+ bank_accounts_pin = encryptIfNotEmpty(bank_accounts_pin, secretKey, saltKey)
|
|
|
+ bank_accounts_branch_address = encryptIfNotEmpty(bank_accounts_branch_address, secretKey, saltKey)
|
|
|
+ bank_accounts_branch_phone = encryptIfNotEmpty(bank_accounts_branch_phone, secretKey, saltKey)
|
|
|
+ bank_accounts_notes = encryptIfNotEmpty(bank_accounts_notes, secretKey, saltKey)
|
|
|
+
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_title", bank_accounts_title))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_bank_name", bank_accounts_bank_name))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_account_type", bank_accounts_account_type))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_routing_number", bank_accounts_routing_number))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_account_number", bank_accounts_account_number))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_swift_code", bank_accounts_swift_code))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_iban_number", bank_accounts_iban_number))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_pin", bank_accounts_pin))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_branch_address", bank_accounts_branch_address))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_branch_phone", bank_accounts_branch_phone))
|
|
|
+ bankAccountFormList.add(NewItemFormField("bank-accounts_notes", bank_accounts_notes))
|
|
|
+
|
|
|
+ onBankAccountFormList.invoke(bankAccountFormList, isTitleEmpty)
|
|
|
+ }
|
|
|
+ )
|
|
|
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
@@ -71,27 +124,86 @@ fun AddBankAccountFormScreen() {
|
|
|
.verticalScroll(rememberScrollState())
|
|
|
) {
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldABAFS(keyboardController = keyboardController, focusManager = focusManager, R.string.title)
|
|
|
+ NameTextFieldABAFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ R.string.title,
|
|
|
+ onText = { bank_accounts_title = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldABAFS(keyboardController = keyboardController, focusManager = focusManager, R.string.bank_name)
|
|
|
+ NameTextFieldABAFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ R.string.bank_name,
|
|
|
+ onText = { bank_accounts_bank_name = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldABAFS(keyboardController = keyboardController, focusManager = focusManager, R.string.account_type)
|
|
|
+ NameTextFieldABAFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ R.string.account_type,
|
|
|
+ onText = { bank_accounts_account_type = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NumberTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager, R.string.routing_number, "123456789")
|
|
|
+ NumberTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ R.string.routing_number,
|
|
|
+ "123456789",
|
|
|
+ onText = { bank_accounts_routing_number = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TextNumberTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager, R.string.account_number, "12345678912")
|
|
|
+ TextNumberTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ R.string.account_number,
|
|
|
+ "12345678912",
|
|
|
+ onText = { bank_accounts_account_number = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TextNumberTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager, R.string.swift_code, "1234567890")
|
|
|
+ TextNumberTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ R.string.swift_code,
|
|
|
+ "1234567890",
|
|
|
+ onText = { bank_accounts_swift_code = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TextNumberTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager, R.string.iban_number, "12 12 123456 12345678")
|
|
|
+ TextNumberTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ R.string.iban_number,
|
|
|
+ "12 12 123456 12345678",
|
|
|
+ onText = { bank_accounts_iban_number = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- TextNumberTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager, R.string.pin, "1234")
|
|
|
+ TextNumberTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ R.string.pin,
|
|
|
+ "1234",
|
|
|
+ onText = { bank_accounts_pin = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldABAFS(keyboardController = keyboardController, focusManager = focusManager, R.string.branch_address)
|
|
|
+ NameTextFieldABAFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ R.string.branch_address,
|
|
|
+ onText = { bank_accounts_branch_address = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- PhoneNumberTextFieldAPS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.branch_phone)
|
|
|
+ PhoneNumberTextFieldAPS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.branch_phone,
|
|
|
+ onText = { bank_accounts_branch_phone = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NotesTextFieldABAFS(keyboardController = keyboardController, focusManager = focusManager)
|
|
|
+ NotesTextFieldABAFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ onText = { bank_accounts_notes = it }
|
|
|
+ )
|
|
|
// Spacer(modifier = Modifier.height(25.dp))
|
|
|
// SaveButtonABAFS(buttonText = R.string.save)
|
|
|
}
|
|
@@ -102,7 +214,8 @@ fun AddBankAccountFormScreen() {
|
|
|
fun ColumnScope.NameTextFieldABAFS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
focusManager: FocusManager,
|
|
|
- labelText: Int
|
|
|
+ labelText: Int,
|
|
|
+ onText: (String) -> Unit
|
|
|
) {
|
|
|
var text by remember { mutableStateOf("") }
|
|
|
|
|
@@ -110,6 +223,7 @@ fun ColumnScope.NameTextFieldABAFS(
|
|
|
value = text,
|
|
|
onValueChange = {
|
|
|
text = it
|
|
|
+ onText.invoke(text)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -173,7 +287,8 @@ fun ColumnScope.NumberTextFieldAPS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
focusManager: FocusManager,
|
|
|
labelText: Int,
|
|
|
- placeholder: String
|
|
|
+ placeholder: String,
|
|
|
+ onText: (String) -> Unit
|
|
|
) {
|
|
|
var text by remember { mutableStateOf("") }
|
|
|
|
|
@@ -181,6 +296,7 @@ fun ColumnScope.NumberTextFieldAPS(
|
|
|
value = text,
|
|
|
onValueChange = {
|
|
|
text = it
|
|
|
+ onText.invoke(text)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -245,7 +361,8 @@ fun ColumnScope.TextNumberTextFieldAPS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
focusManager: FocusManager,
|
|
|
labelText: Int,
|
|
|
- placeholder: String
|
|
|
+ placeholder: String,
|
|
|
+ onText: (String) -> Unit
|
|
|
) {
|
|
|
var text by remember { mutableStateOf("") }
|
|
|
|
|
@@ -253,6 +370,7 @@ fun ColumnScope.TextNumberTextFieldAPS(
|
|
|
value = text,
|
|
|
onValueChange = {
|
|
|
text = it
|
|
|
+ onText.invoke(text)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -316,7 +434,8 @@ fun ColumnScope.TextNumberTextFieldAPS(
|
|
|
fun ColumnScope.PhoneNumberTextFieldAPS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
focusManager: FocusManager,
|
|
|
- labelText: Int
|
|
|
+ labelText: Int,
|
|
|
+ onText: (String) -> Unit
|
|
|
) {
|
|
|
var text by remember { mutableStateOf("") }
|
|
|
|
|
@@ -324,6 +443,7 @@ fun ColumnScope.PhoneNumberTextFieldAPS(
|
|
|
value = text,
|
|
|
onValueChange = {
|
|
|
text = it
|
|
|
+ onText.invoke(text)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -384,15 +504,20 @@ fun ColumnScope.PhoneNumberTextFieldAPS(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun BoxScope.SaveButtonABAFS(buttonText: Int) {
|
|
|
+fun BoxScope.SaveButtonABAFS(
|
|
|
+ buttonText: Int,
|
|
|
+ onSaveButtonCLick: () -> Unit
|
|
|
+ ) {
|
|
|
Button(
|
|
|
modifier = Modifier
|
|
|
.background(colorResource(id = R.color.transparent))
|
|
|
.fillMaxWidth()
|
|
|
.height(60.dp)
|
|
|
.align(Alignment.BottomCenter)
|
|
|
- .clickable() { },
|
|
|
- onClick = {},
|
|
|
+ .clickable() {},
|
|
|
+ onClick = {
|
|
|
+ onSaveButtonCLick.invoke()
|
|
|
+ },
|
|
|
shape = RoundedCornerShape(15.dp),
|
|
|
// border = BorderStroke(25.dp, colorResource(id = R.color.black)),
|
|
|
colors = ButtonDefaults.buttonColors(
|
|
@@ -415,7 +540,8 @@ fun BoxScope.SaveButtonABAFS(buttonText: Int) {
|
|
|
@Composable
|
|
|
fun ColumnScope.NotesTextFieldABAFS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onText: (String) -> Unit
|
|
|
) {
|
|
|
var notesText by remember { mutableStateOf("") }
|
|
|
|
|
@@ -423,6 +549,7 @@ fun ColumnScope.NotesTextFieldABAFS(
|
|
|
value = notesText,
|
|
|
onValueChange = {
|
|
|
notesText = it
|
|
|
+ onText.invoke(notesText)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -480,4 +607,4 @@ fun ColumnScope.NotesTextFieldABAFS(
|
|
|
}
|
|
|
),
|
|
|
)
|
|
|
-}
|
|
|
+}
|