Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
refactor(password): use value and onChangeValue in PasswordFiled
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaBrighi committed May 2, 2023
1 parent 046d716 commit 4582ccd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ import androidx.compose.ui.text.input.VisualTransformation
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PasswordFiled(
password: MutableState<String>,
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
imeAction: ImeAction,
keyboardActions: KeyboardActions
) {
var passwordVisible by remember { mutableStateOf(false) }
OutlinedTextField(
value = password.value,
onValueChange = { password.value = it },
value = value,
onValueChange = onValueChange,
label = { Text("Password") },
singleLine = true,
placeholder = { Text("Password") },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ fun CreateForm(
var email by rememberSaveable { mutableStateOf(emailInsert) }
var name by rememberSaveable { mutableStateOf("") }
var surname by rememberSaveable { mutableStateOf("") }
val password = rememberSaveable { mutableStateOf("") }
val passwordConfirm = rememberSaveable { mutableStateOf("") }
var password by rememberSaveable { mutableStateOf("") }
var passwordConfirm by rememberSaveable { mutableStateOf("") }
OutlinedTextField(
value = email,
onValueChange = { email = it },
Expand Down Expand Up @@ -173,15 +173,17 @@ fun CreateForm(
})
)
PasswordFiled(
password = password,
value = password,
onValueChange = { password = it },
imeAction = ImeAction.Next,
keyboardActions = KeyboardActions(onNext = {
localFocusManager.moveFocus(FocusDirection.Down)
}),
modifier = Modifier.fillMaxWidth(0.8f)
)
PasswordFiled(
password = passwordConfirm,
value = passwordConfirm,
onValueChange = { passwordConfirm = it },
imeAction = ImeAction.Done,
keyboardActions = KeyboardActions(onDone = {
localFocusManager.clearFocus()
Expand All @@ -200,7 +202,7 @@ fun CreateForm(
email = email,
name = name,
surname = surname,
password = password.value
password = password,
)
)
localFocusManager.clearFocus()
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/kotlin/com/intelligentbackpack/app/view/Login.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fun LoginForm(
verticalArrangement = Arrangement.spacedBy(6.dp, Alignment.CenterVertically)
) {
var email by rememberSaveable { mutableStateOf("") }
val password = rememberSaveable { mutableStateOf("") }
var password by rememberSaveable { mutableStateOf("") }
OutlinedTextField(
value = email,
onValueChange = { email = it },
Expand All @@ -144,10 +144,11 @@ fun LoginForm(
})
)
PasswordFiled(
password = password,
value = password,
onValueChange = { password = it },
imeAction = ImeAction.Done,
keyboardActions = KeyboardActions(onDone = {
activateLogin(email, password.value)
activateLogin(email, password)
localFocusManager.clearFocus()
}),
modifier = Modifier.fillMaxWidth(0.8f)
Expand Down Expand Up @@ -178,7 +179,7 @@ fun LoginForm(
}
Button(
onClick = {
activateLogin(email, password.value)
activateLogin(email, password)
localFocusManager.clearFocus()
},
modifier = Modifier
Expand Down

0 comments on commit 4582ccd

Please sign in to comment.