Skip to content

Commit

Permalink
fix: login
Browse files Browse the repository at this point in the history
  • Loading branch information
therajanmaurya committed Oct 30, 2023
1 parent 6836f10 commit c126fb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class LoginActivity : BaseActivity(), LoginView {
private var googleSignInClient: GoogleSignInClient? = null
private var account: GoogleSignInAccount? = null
private var mMifosSavingProductId = 0

private var usernameContent: String = ""
private var passwordContent: String = ""

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityLoginBinding.inflate(layoutInflater)
Expand All @@ -55,7 +59,9 @@ class LoginActivity : BaseActivity(), LoginView {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
MifosTheme {
LoginScreen({
LoginScreen({ username, password ->
usernameContent = username
passwordContent = password
onLoginClicked()
}, {
onSignupClicked()
Expand Down Expand Up @@ -105,17 +111,13 @@ class LoginActivity : BaseActivity(), LoginView {
}

private fun handleLoginInputChanged() {
val usernameContent = binding.etUsername.text.toString().trim()
val passwordContent = binding.etPassword.text.toString().trim()
mPresenter.handleLoginButtonStatus(usernameContent, passwordContent)
}

fun onLoginClicked() {
hideSoftKeyboard(this)
showProgressDialog(Constants.LOGGING_IN)
mLoginPresenter.loginUser(
binding.etUsername.text.toString().trim(), binding.etPassword.text.toString().trim()
)
mLoginPresenter.loginUser(usernameContent, passwordContent)
}

fun onSignupClicked() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.mifos.mobilewallet.mifospay.theme.styleNormal18sp

@Composable
fun LoginScreen(
login: () -> Unit,
login: (username: String, password: String) -> Unit,
signUp: () -> Unit
) {
var userName by rememberSaveable { mutableStateOf("") }
Expand Down Expand Up @@ -83,7 +83,7 @@ fun LoginScreen(
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Black),
enabled = userName.isNotEmpty() && password.isNotEmpty(),
onClick = {
login.invoke()
login.invoke(userName, password)
}
) {
Text(text = "Login", style = styleMedium16sp.copy(color = Color.White))
Expand Down Expand Up @@ -134,5 +134,5 @@ fun LoginScreen(
@Preview(showSystemUi = true, device = "id:pixel_5")
@Composable
fun LoanScreenPreview() {
LoginScreen({}, {})
LoginScreen({ _, _ -> }, {})
}

0 comments on commit c126fb5

Please sign in to comment.