Skip to content

Commit

Permalink
Selected Menu UI form
Browse files Browse the repository at this point in the history
  • Loading branch information
SAUL committed Nov 18, 2024
1 parent 4c9d2de commit d0f8658
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 45 deletions.
1 change: 1 addition & 0 deletions src/main/kotlin/core/models/UiModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ enum class PasswordSort(val value: String) {

enum class DefaultMenuItem(val value: String) {
PASSWORDS("Passwords"),
CREDIT_CARD("Credit Cards"),
NOTES("Notes")
}
3 changes: 2 additions & 1 deletion src/main/kotlin/ui/components/FormComponents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ fun UnderLineTextFiled(
field: String,
onFieldChange: (String) -> Unit,
isPassword: Boolean = false,
singleLine: Boolean = true
) {
val interactionSource = remember { MutableInteractionSource() }
var passwordVisible by remember { mutableStateOf(false) }
Expand All @@ -432,7 +433,7 @@ fun UnderLineTextFiled(
textAlign = TextAlign.Start,
fontSize = 12.sp
),
singleLine = true,
singleLine = singleLine,
cursorBrush = SolidColor(Color.White),
visualTransformation = if (!isPassword || passwordVisible) VisualTransformation.None else PasswordVisualTransformation()
) { innerTextField ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fun SecVaultContentScreen(screenModel: SecVaultScreenModel) {
.background(PasswordColors.tertiary)
)
{
PasswordInfo()
PasswordInfo(screenModel)
}

}
Expand Down
141 changes: 141 additions & 0 deletions src/main/kotlin/ui/components/secvault/passwordinfo/CredentialForms.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package ui.components.secvault.passwordinfo

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import ui.components.UnderLineTextFiled

@Composable
fun PasswordCredentialForm() {
var userName by remember { mutableStateOf("") }

Column() {
Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Username",
modifier = Modifier.fillMaxWidth()
)
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Password",
modifier = Modifier.fillMaxWidth(),
isPassword = true
)
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Email",
modifier = Modifier.fillMaxWidth()
)
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Website",
modifier = Modifier.fillMaxWidth()
)
}

}
}

@Composable
fun CreditCardCredentialForm() {
var userName by remember { mutableStateOf("") }

Column() {
Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Bank Name",
modifier = Modifier.fillMaxWidth()
)
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Card Owner",
modifier = Modifier.fillMaxWidth()
)
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Card Number",
modifier = Modifier.fillMaxWidth()
)
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "CVC",
modifier = Modifier.fillMaxWidth()
)
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Pin",
modifier = Modifier.fillMaxWidth()
)
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Expiry Date",
modifier = Modifier.fillMaxWidth()
)
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Notes",
modifier = Modifier.fillMaxWidth(),
singleLine = false
)
}
}
}

@Composable
fun NotesCredentialForm() {
var userName by remember { mutableStateOf("") }

Column() {
Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Notes",
modifier = Modifier.fillMaxWidth(),
singleLine = false
)
}
}
}
52 changes: 14 additions & 38 deletions src/main/kotlin/ui/components/secvault/passwordinfo/PasswordForm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ package ui.components.secvault.passwordinfo

import androidx.compose.foundation.layout.*
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import core.models.DefaultMenuItem
import ui.components.HorizontalSpacer
import ui.components.UnderLineTextFiled
import ui.theme.Font
import viewmodel.SecVaultScreenModel

@Composable
fun PasswordFormTitle() {
Expand Down Expand Up @@ -38,54 +40,28 @@ fun PasswordFormTitle() {
}

@Composable
fun PasswordForm() {
fun PasswordForm(screenModel: SecVaultScreenModel) {
Column(modifier = Modifier.fillMaxWidth().fillMaxHeight()) {

Row(modifier = Modifier.weight(1f)) {
PasswordFormTitle()
}

Row(modifier = Modifier.weight(9f)) {
var userName by remember { mutableStateOf("") }

Column() {
Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Username",
modifier = Modifier.fillMaxWidth()
)
}
val menuItem = screenModel.selectedMenuItem.collectAsState()

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Password",
modifier = Modifier.fillMaxWidth(),
isPassword = true
)
Row(modifier = Modifier.weight(9f)) {
when (menuItem.value) {
DefaultMenuItem.PASSWORDS -> {
PasswordCredentialForm()
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Email",
modifier = Modifier.fillMaxWidth()
)
DefaultMenuItem.CREDIT_CARD -> {
CreditCardCredentialForm()
}

Row(modifier = Modifier.weight(1f)) {
UnderLineTextFiled(
field = userName,
onFieldChange = { userName = it },
label = "Website",
modifier = Modifier.fillMaxWidth()
)
DefaultMenuItem.NOTES -> {
NotesCredentialForm()
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ package ui.components.secvault.passwordinfo

import androidx.compose.foundation.layout.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import core.models.DefaultMenuItem
import viewmodel.SecVaultScreenModel

@Composable
fun PasswordInfo() {
fun PasswordInfo(screenModel: SecVaultScreenModel) {
val menuItem = screenModel.selectedMenuItem.collectAsState()

val credentialFormWeight = if (menuItem.value == DefaultMenuItem.PASSWORDS) 5f else 10f
val miscWeight = if (menuItem.value == DefaultMenuItem.PASSWORDS) 6f else 1f

Column(
modifier = Modifier
.padding(PaddingValues(start = 20.dp, end = 20.dp, top = 20.dp, bottom = 20.dp))
Expand All @@ -25,21 +33,23 @@ fun PasswordInfo() {
}

Row(
modifier = Modifier.weight(5f)
modifier = Modifier.weight(credentialFormWeight)
.fillMaxWidth()
.fillMaxHeight()
)
{
PasswordForm()
PasswordForm(screenModel)
}

Row(
modifier = Modifier.weight(6f)
modifier = Modifier.weight(miscWeight)
.fillMaxWidth()
.fillMaxHeight()
)
{
PasswordMisc()
if (menuItem.value == DefaultMenuItem.PASSWORDS){
PasswordMisc()
}
}
}
}

0 comments on commit d0f8658

Please sign in to comment.