Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New UI to change password #1781

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,

) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove blank lines

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

OutlinedTextField(
modifier = modifier,
value = password,
onValueChange = onPasswordChange,
label = { Text(label) },
label = { Text(
label,
color = NewUi.primaryColor,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you format these lines of code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already change

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And remove these comments too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

)
)
}

Expand Down Expand Up @@ -301,8 +314,12 @@ fun MfOutlinedTextFieldPreview() {
fun MfPasswordTextFieldPreview() {
MifosTheme {
val password = " "

Box(

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these extra blank lines..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


) {
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),

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the blank lines

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

)
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))


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove here too


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>