From 3604710fffc8cf1fc527f66dfc2c3725e596fac2 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 5 Oct 2024 11:15:59 -0300 Subject: [PATCH] Fixed some blank spaces and clean comments Some fixed blank spaces and remove comments Delete git file Fixed the password screen --- .../core/designsystem/component/TextField.kt | 115 +++++++++++------- .../editpassword/EditPasswordScreen.kt | 14 +-- .../src/main/res/values/strings.xml | 2 +- 3 files changed, 76 insertions(+), 55 deletions(-) diff --git a/core/designsystem/src/main/kotlin/org/mifospay/core/designsystem/component/TextField.kt b/core/designsystem/src/main/kotlin/org/mifospay/core/designsystem/component/TextField.kt index 143012566..1872bb6cc 100644 --- a/core/designsystem/src/main/kotlin/org/mifospay/core/designsystem/component/TextField.kt +++ b/core/designsystem/src/main/kotlin/org/mifospay/core/designsystem/component/TextField.kt @@ -84,23 +84,21 @@ fun MfOutlinedTextField( }, singleLine = singleLine, trailingIcon = trailingIcon, - keyboardActions = - KeyboardActions { + keyboardActions = KeyboardActions { onKeyboardActions?.invoke() }, keyboardOptions = keyboardOptions, - colors = - OutlinedTextFieldDefaults.colors( + colors = OutlinedTextFieldDefaults.colors( focusedBorderColor = MaterialTheme.colorScheme.onSurface, focusedLabelColor = MaterialTheme.colorScheme.onSurface, ), - textStyle = - LocalDensity.current.run { + textStyle = LocalDensity.current.run { TextStyle(fontSize = 18.sp, color = MaterialTheme.colorScheme.onSurface) }, ) } + @Composable fun MfPasswordTextField( password: String, @@ -111,43 +109,75 @@ fun MfPasswordTextField( onPasswordChange: (String) -> Unit, modifier: Modifier = Modifier, errorMessage: String? = null, - ) { + var isFocused by rememberSaveable { mutableStateOf(false) } - OutlinedTextField( - modifier = modifier, + BasicTextField( value = password, onValueChange = onPasswordChange, - label = { Text( - label, - color = NewUi.primaryColor, - style = MaterialTheme.typography.labelLarge - ) }, - isError = isError, - visualTransformation = - if (isPasswordVisible) { - VisualTransformation.None - } else { - PasswordVisualTransformation() - }, - supportingText = { - errorMessage?.let { Text(text = it) } - }, - trailingIcon = { - IconButton(onClick = onTogglePasswordVisibility) { - Icon( - if (isPasswordVisible) Icons.Filled.Visibility else Icons.Filled.VisibilityOff, - contentDescription = "Show password", - tint = Color.Black, + textStyle = LocalTextStyle.current.copy(color = Color.Black), + modifier = modifier + .fillMaxWidth() + .padding(horizontal = 20.dp) + .padding(top = 10.dp) + .onFocusChanged { focusState -> isFocused = focusState.isFocused } + .semantics(mergeDescendants = true) {}, + enabled = true, + readOnly = false, + visualTransformation = if (isPasswordVisible) VisualTransformation.None else PasswordVisualTransformation(), + keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next), + keyboardActions = KeyboardActions.Default, + singleLine = true, + maxLines = 1, + minLines = 1, + cursorBrush = SolidColor(NewUi.primaryColor), + decorationBox = { innerTextField -> + Column { + Text( + text = label, + color = NewUi.primaryColor, + style = MaterialTheme.typography.labelLarge, + modifier = Modifier.align(alignment = Alignment.Start), + ) + + Spacer(modifier = Modifier.height(5.dp)) + + Box( + modifier = Modifier + .fillMaxWidth() + .background(Color.Transparent), + contentAlignment = Alignment.CenterStart + ) { + innerTextField() + + IconButton( + onClick = onTogglePasswordVisibility, + modifier = Modifier.align(Alignment.CenterEnd)) + { + Icon( + if (isPasswordVisible) Icons.Filled.Visibility else Icons.Filled.VisibilityOff, + contentDescription = "Toggle password visibility", + tint = Color.Black, + ) + } + } + + Spacer(modifier = Modifier.height(5.dp)) + HorizontalDivider( + thickness = 1.dp, + color = if (isFocused) NewUi.secondaryColor else NewUi.onSurface.copy(alpha = 0.05f), ) + + if (isError && errorMessage != null) { + Text( + text = errorMessage, + color = MaterialTheme.colorScheme.error, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(top = 4.dp) + ) + } } }, - colors = OutlinedTextFieldDefaults.colors( - focusedBorderColor = Color.Transparent, // Cor da borda quando focado - unfocusedBorderColor = Color.Transparent, // Cor da borda quando não focado - errorBorderColor = Color.Transparent, // Cor da borda quando em erro - disabledBorderColor = Color.Transparent, // Cor da borda quando desabilitado - ) ) } @@ -170,14 +200,12 @@ fun MifosOutlinedTextField( onValueChange = onValueChange, label = { Text(stringResource(id = label)) }, modifier = modifier, - leadingIcon = - if (icon != null) { + leadingIcon = if (icon != null) { { Image( painter = painterResource(id = icon), contentDescription = null, - colorFilter = - ColorFilter.tint( + colorFilter = ColorFilter.tint( MaterialTheme.colorScheme.onSurface, ), ) @@ -188,13 +216,11 @@ fun MifosOutlinedTextField( trailingIcon = trailingIcon, maxLines = maxLines, singleLine = singleLine, - colors = - OutlinedTextFieldDefaults.colors( + colors = OutlinedTextFieldDefaults.colors( focusedBorderColor = MaterialTheme.colorScheme.onSurface, focusedLabelColor = MaterialTheme.colorScheme.onSurface, ), - textStyle = - LocalDensity.current.run { + textStyle = LocalDensity.current.run { TextStyle(fontSize = 18.sp, color = MaterialTheme.colorScheme.onSurface) }, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next), @@ -319,7 +345,6 @@ fun MfPasswordTextFieldPreview() { modifier = Modifier.background(color = Color.White), - ) { MfPasswordTextField( password = password, diff --git a/feature/editpassword/src/main/kotlin/org/mifospay/feature/editpassword/EditPasswordScreen.kt b/feature/editpassword/src/main/kotlin/org/mifospay/feature/editpassword/EditPasswordScreen.kt index edffb18bc..d971ca1d7 100644 --- a/feature/editpassword/src/main/kotlin/org/mifospay/feature/editpassword/EditPasswordScreen.kt +++ b/feature/editpassword/src/main/kotlin/org/mifospay/feature/editpassword/EditPasswordScreen.kt @@ -12,7 +12,6 @@ package org.mifospay.feature.editpassword import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -48,7 +47,6 @@ import org.mifospay.core.designsystem.theme.MifosBlue import org.mifospay.core.designsystem.theme.MifosTheme import org.mifospay.core.designsystem.theme.NewUi.gradientOne - @Composable internal fun EditPasswordScreen( onBackPress: () -> Unit, @@ -126,7 +124,7 @@ private fun EditPasswordScreen( .fillMaxSize() .padding(paddingValues), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center + verticalArrangement = Arrangement.Center, ) { MfPasswordTextField( password = currentPassword, @@ -141,7 +139,7 @@ private fun EditPasswordScreen( .fillMaxWidth(0.9f) .padding(vertical = 8.dp), - ) + ) MfPasswordTextField( password = newPassword, @@ -189,16 +187,16 @@ private fun EditPasswordScreen( modifier = Modifier .fillMaxWidth() .padding(top = 20.dp, start = 16.dp, end = 16.dp), - horizontalAlignment = Alignment.CenterHorizontally, // Alinha os botões ao centro + horizontalAlignment = Alignment.CenterHorizontally, ) { - Spacer(modifier = Modifier.weight(1f)) + Spacer(Modifier.weight(1f)) MifosButton( modifier = Modifier .fillMaxWidth() .padding(horizontal = 20.dp) .height(54.dp), - color = MifosBlue, // Cor do botão de "Salvar" + color = MifosBlue, onClick = { onSave.invoke(currentPassword, newPassword, confirmNewPassword) }, @@ -207,8 +205,6 @@ private fun EditPasswordScreen( ) Spacer(modifier = Modifier.height(8.dp)) - - MifosButton( modifier = Modifier .fillMaxWidth() diff --git a/feature/editpassword/src/main/res/values/strings.xml b/feature/editpassword/src/main/res/values/strings.xml index f1da3bbdb..e2e34c3ae 100644 --- a/feature/editpassword/src/main/res/values/strings.xml +++ b/feature/editpassword/src/main/res/values/strings.xml @@ -9,7 +9,7 @@ See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md --> - Password changed successfull + Password changed successful Change Password Current Password New Password