Skip to content

Commit

Permalink
Fixed some blank spaces and clean comments
Browse files Browse the repository at this point in the history
Some fixed blank spaces and remove comments

Delete git file

Fixed the password screen
  • Loading branch information
rodrigosouzalopes94 committed Oct 9, 2024
1 parent 549732c commit 3604710
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)
)
}

Expand All @@ -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,
),
)
Expand All @@ -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),
Expand Down Expand Up @@ -319,7 +345,6 @@ fun MfPasswordTextFieldPreview() {

modifier = Modifier.background(color = Color.White),


) {
MfPasswordTextField(
password = password,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -126,7 +124,7 @@ private fun EditPasswordScreen(
.fillMaxSize()
.padding(paddingValues),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
verticalArrangement = Arrangement.Center,
) {
MfPasswordTextField(
password = currentPassword,
Expand All @@ -141,7 +139,7 @@ private fun EditPasswordScreen(
.fillMaxWidth(0.9f)
.padding(vertical = 8.dp),

)
)
MfPasswordTextField(
password = newPassword,

Expand Down Expand Up @@ -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)
},
Expand All @@ -207,8 +205,6 @@ private fun EditPasswordScreen(
)
Spacer(modifier = Modifier.height(8.dp))



MifosButton(
modifier = Modifier
.fillMaxWidth()
Expand Down
2 changes: 1 addition & 1 deletion feature/editpassword/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
-->
<resources>
<string name="feature_editpassword_password_changed_successfully">Password changed successfull</string>
<string name="feature_editpassword_password_changed_successfully">Password changed successful</string>
<string name="feature_editpassword_change_password">Change Password</string>
<string name="feature_editpassword_current_password">Current Password</string>
<string name="feature_editpassword_new_password">New Password</string>
Expand Down

0 comments on commit 3604710

Please sign in to comment.