Skip to content

Commit

Permalink
Password Form Field validation
Browse files Browse the repository at this point in the history
  • Loading branch information
SAUL committed Oct 23, 2024
1 parent 4105b5e commit 6a8b25e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/main/kotlin/ui/components/forms/PasswordForm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import ui.validators.PasswordFormFieldName
fun PasswordForm(
formValidator: FormValidator,
isFormValid: Boolean,
onSaveClick: () -> Unit
onSaveClick: () -> Unit,
onCancelClick: () -> Unit
) {

val userName = formValidator.getField(PasswordFormFieldName.USERNAME)
Expand Down Expand Up @@ -226,7 +227,7 @@ fun PasswordForm(
horizontalArrangement = Arrangement.spacedBy(30.dp, Alignment.CenterHorizontally)
) {
Button(
onClick = {},
onClick = onSaveClick,
modifier = Modifier.width(175.dp),
enabled = isFormValid,
colors = ButtonColors(
Expand All @@ -247,7 +248,7 @@ fun PasswordForm(
)
}
Button(
onClick = onSaveClick,
onClick = onCancelClick,
modifier = Modifier.width(175.dp),
colors = ButtonColors(
containerColor = primary,
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/ui/screens/PasswordFormScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.LocalNavigator
import ui.components.forms.PasswordForm
import ui.validators.passwordFormValidator

Expand All @@ -13,13 +14,14 @@ class PasswordFormScreen : Screen {
override fun Content() {

val formValidator = remember { passwordFormValidator() }

val navigator = LocalNavigator.current
val isFormValid by formValidator.isValid

PasswordForm(
formValidator,
isFormValid,
onSaveClick = {}
onSaveClick = {},
onCancelClick = { navigator?.pop() }
)
}

Expand Down

0 comments on commit 6a8b25e

Please sign in to comment.