fix: animation incoherent in PasswordTextField

This commit is contained in:
2023-11-19 06:05:03 +08:00
parent 98f062bf8c
commit 85032e8be0

View File

@@ -285,7 +285,6 @@ fun PasswordTextField(
textStyle: TextStyle = TextField.textStyle textStyle: TextStyle = TextField.textStyle
) { ) {
var passwordVisible by remember { mutableStateOf(defaultPasswordVisible) } var passwordVisible by remember { mutableStateOf(defaultPasswordVisible) }
if (value.text.isEmpty()) passwordVisible = defaultPasswordVisible
TextField( TextField(
value = value, value = value,
onValueChange = onValueChange, onValueChange = onValueChange,
@@ -313,6 +312,7 @@ fun PasswordTextField(
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
val animatedSize by animateDpAsState(if (value.text.isNotEmpty()) DefaultDecorIconSize else 0.dp) val animatedSize by animateDpAsState(if (value.text.isNotEmpty()) DefaultDecorIconSize else 0.dp)
if (value.text.isEmpty() && animatedSize == 0.dp) passwordVisible = defaultPasswordVisible
IconToggleButton( IconToggleButton(
modifier = Modifier.size(animatedSize).pointerHoverState(TextFieldPoinerState.NORMAL), modifier = Modifier.size(animatedSize).pointerHoverState(TextFieldPoinerState.NORMAL),
style = IconButton.style.copy(padding = DefaultDecorIconPadding), style = IconButton.style.copy(padding = DefaultDecorIconPadding),