Skip to content

Commit

Permalink
New UI to change password
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigosouzalopes94 committed Oct 4, 2024
1 parent c5860f6 commit 549732c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,18 @@ fun MfPasswordTextField(
onPasswordChange: (String) -> Unit,
modifier: Modifier = Modifier,
errorMessage: String? = null,

) {

OutlinedTextField(
modifier = modifier,
value = password,
onValueChange = onPasswordChange,
label = { Text(label) },
label = { Text(
label,
color = NewUi.primaryColor,
style = MaterialTheme.typography.labelLarge
) },
isError = isError,
visualTransformation =
if (isPasswordVisible) {
Expand All @@ -132,9 +138,16 @@ fun MfPasswordTextField(
Icon(
if (isPasswordVisible) Icons.Filled.Visibility else Icons.Filled.VisibilityOff,
contentDescription = "Show password",
tint = Color.Black,
)
}
},
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 Down Expand Up @@ -301,8 +314,12 @@ fun MfOutlinedTextFieldPreview() {
fun MfPasswordTextFieldPreview() {
MifosTheme {
val password = " "

Box(

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


) {
MfPasswordTextField(
password = password,
Expand All @@ -313,6 +330,7 @@ fun MfPasswordTextFieldPreview() {
onPasswordChange = { },
modifier = Modifier.fillMaxWidth(),
errorMessage = "Password must be at least 6 characters",

)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
*/
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
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
Expand Down Expand Up @@ -41,7 +44,10 @@ import org.koin.androidx.compose.koinViewModel
import org.mifospay.core.designsystem.component.MfPasswordTextField
import org.mifospay.core.designsystem.component.MifosButton
import org.mifospay.core.designsystem.component.MifosScaffold
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(
Expand Down Expand Up @@ -119,6 +125,8 @@ private fun EditPasswordScreen(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
MfPasswordTextField(
password = currentPassword,
Expand All @@ -130,9 +138,10 @@ private fun EditPasswordScreen(
},
onPasswordChange = { currentPassword = it },
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
.fillMaxWidth(0.9f)
.padding(vertical = 8.dp),

)
MfPasswordTextField(
password = newPassword,

Expand All @@ -142,8 +151,8 @@ private fun EditPasswordScreen(
onTogglePasswordVisibility = { isNewPasswordVisible = !isNewPasswordVisible },
onPasswordChange = { newPassword = it },
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
.fillMaxWidth(0.9f)
.padding(vertical = 8.dp),
errorMessage = if (newPassword.isNotEmpty() && newPassword.length < 6) {
stringResource(
id = R.string.feature_editpassword_password_length_error,
Expand All @@ -162,8 +171,9 @@ private fun EditPasswordScreen(
},
onPasswordChange = { confirmNewPassword = it },
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
.fillMaxWidth(0.9f)
.padding(vertical = 8.dp),

errorMessage = if (newPassword !=
confirmNewPassword && confirmNewPassword.isNotEmpty()
) {
Expand All @@ -175,29 +185,47 @@ private fun EditPasswordScreen(
},
)

Row(
Column(
modifier = Modifier
.fillMaxWidth()
.padding(top = 20.dp, start = 16.dp, end = 16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalAlignment = Alignment.CenterHorizontally, // Alinha os botões ao centro
) {
Spacer(modifier = Modifier.weight(1f))

MifosButton(
onClick = { onCancelChanges.invoke() },
modifier = Modifier
.weight(1f)
.padding(8.dp),
.fillMaxWidth()
.padding(horizontal = 20.dp)
.height(54.dp),
color = MifosBlue, // Cor do botão de "Salvar"
onClick = {
onSave.invoke(currentPassword, newPassword, confirmNewPassword)
},
contentPadding = PaddingValues(16.dp),
content = { Text(text = stringResource(id = R.string.feature_editpassword_cancel)) },
content = { Text(text = stringResource(id = R.string.feature_editpassword_save)) },
)
Spacer(modifier = Modifier.height(8.dp))



MifosButton(
modifier = Modifier
.weight(1f)
.padding(8.dp),
.fillMaxWidth()
.padding(horizontal = 20.dp)
.height(54.dp),
color = gradientOne,

onClick = {
onSave.invoke(currentPassword, newPassword, confirmNewPassword)
onCancelChanges.invoke()
},
contentPadding = PaddingValues(16.dp),
content = { Text(text = stringResource(id = R.string.feature_editpassword_save)) },
content = {
Text(
text = stringResource(id = R.string.feature_editpassword_cancel),
color = MifosBlue,
)
},
)
}
}
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 @@ -18,5 +18,5 @@
<string name="feature_editpassword_password_length_error">Password too short</string>
<string name="feature_editpassword_password_mismatch_error">Password mismatch</string>
<string name="feature_editpassword_cancel">Cancel</string>
<string name="feature_editpassword_save">Save</string>
<string name="feature_editpassword_save">Save Password</string>
</resources>

0 comments on commit 549732c

Please sign in to comment.