Skip to content

Commit

Permalink
#1645 fixed the error in the EditPasswordScreen.kt regarding the Mif…
Browse files Browse the repository at this point in the history
…osScaffold.kt Composable (#1647)

Issues Fix
 Fixes #1646

 Description
 The EditPasswordScreen.kt had some errors related to the composable MifosScaffold.k where the scaffold content was not being passed as one of the arguments required by the Composable. The error was fixed along with teh help of @PratyushSingh07.
  • Loading branch information
Sarthak9504 authored Jun 5, 2024
1 parent 89768a0 commit 16c3ee8
Showing 1 changed file with 70 additions and 69 deletions.
139 changes: 70 additions & 69 deletions mifospay/src/main/java/org/mifospay/password/ui/EditPasswordScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,84 +103,85 @@ fun EditPasswordScreen(
snackbarHost = {
SnackbarHost(hostState = snackbarHostState)
},
backPress = onBackPress
) { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
) {
MfPasswordTextField(
backPress = onBackPress,
scaffoldContent = {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
password = currentPassword,
label = stringResource(R.string.current_password),
isError = false,
isPasswordVisible = isConfirmPasswordVisible,
onTogglePasswordVisibility = {
isConfirmPasswordVisible = !isConfirmPasswordVisible
},
onPasswordChange = { currentPassword = it },
)
MfPasswordTextField(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
password = newPassword,
label = stringResource(id = R.string.new_password),
isError = newPassword.isNotEmpty() && newPassword.length < 6,
errorMessage = if (newPassword.isNotEmpty() && newPassword.length < 6) stringResource(
id = R.string.password_length_error
) else null,
isPasswordVisible = isNewPasswordVisible,
onTogglePasswordVisibility = { isNewPasswordVisible = !isNewPasswordVisible },
onPasswordChange = { newPassword = it }
)
MfPasswordTextField(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
password = confirmNewPassword,
label = stringResource(id = R.string.confirm_new_password),
isError = newPassword != confirmNewPassword && confirmNewPassword.isNotEmpty(),
errorMessage = if (newPassword != confirmNewPassword && confirmNewPassword.isNotEmpty()) stringResource(
id = R.string.password_mismatch_error
) else null,
isPasswordVisible = isConfirmNewPasswordVisible,
onTogglePasswordVisibility = {
isConfirmNewPasswordVisible = !isConfirmNewPasswordVisible
},
onPasswordChange = { confirmNewPassword = it }
)

Row(
modifier = Modifier
.fillMaxWidth()
.padding(top = 20.dp, start = 16.dp, end = 16.dp),
verticalAlignment = Alignment.CenterVertically
.fillMaxSize()
.padding(it)
) {
MifosButton(
onClick = { onCancelChanges.invoke() },
MfPasswordTextField(
modifier = Modifier
.weight(1f)
.padding(8.dp),
contentPadding = PaddingValues(16.dp),
content = { Text(text = stringResource(id = R.string.cancel)) }
.fillMaxWidth()
.padding(horizontal = 16.dp),
password = currentPassword,
label = stringResource(R.string.current_password),
isError = false,
isPasswordVisible = isConfirmPasswordVisible,
onTogglePasswordVisibility = {
isConfirmPasswordVisible = !isConfirmPasswordVisible
},
onPasswordChange = { currentPassword = it },
)
MifosButton(
MfPasswordTextField(
modifier = Modifier
.weight(1f)
.padding(8.dp),
onClick = {
onSave.invoke(currentPassword, newPassword, confirmNewPassword)
.fillMaxWidth()
.padding(horizontal = 16.dp),
password = newPassword,
label = stringResource(id = R.string.new_password),
isError = newPassword.isNotEmpty() && newPassword.length < 6,
errorMessage = if (newPassword.isNotEmpty() && newPassword.length < 6) stringResource(
id = R.string.password_length_error
) else null,
isPasswordVisible = isNewPasswordVisible,
onTogglePasswordVisibility = { isNewPasswordVisible = !isNewPasswordVisible },
onPasswordChange = { newPassword = it }
)
MfPasswordTextField(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
password = confirmNewPassword,
label = stringResource(id = R.string.confirm_new_password),
isError = newPassword != confirmNewPassword && confirmNewPassword.isNotEmpty(),
errorMessage = if (newPassword != confirmNewPassword && confirmNewPassword.isNotEmpty()) stringResource(
id = R.string.password_mismatch_error
) else null,
isPasswordVisible = isConfirmNewPasswordVisible,
onTogglePasswordVisibility = {
isConfirmNewPasswordVisible = !isConfirmNewPasswordVisible
},
contentPadding = PaddingValues(16.dp),
content = { Text(text = stringResource(id = R.string.save)) }
onPasswordChange = { confirmNewPassword = it }
)

Row(
modifier = Modifier
.fillMaxWidth()
.padding(top = 20.dp, start = 16.dp, end = 16.dp),
verticalAlignment = Alignment.CenterVertically
) {
MifosButton(
onClick = { onCancelChanges.invoke() },
modifier = Modifier
.weight(1f)
.padding(8.dp),
contentPadding = PaddingValues(16.dp),
content = { Text(text = stringResource(id = R.string.cancel)) }
)
MifosButton(
modifier = Modifier
.weight(1f)
.padding(8.dp),
onClick = {
onSave.invoke(currentPassword, newPassword, confirmNewPassword)
},
contentPadding = PaddingValues(16.dp),
content = { Text(text = stringResource(id = R.string.save)) }
)
}
}
}
}
)
}

class EditPasswordUiStateProvider : PreviewParameterProvider<EditPasswordUiState> {
Expand Down

0 comments on commit 16c3ee8

Please sign in to comment.