Skip to content

Commit 0605a11

Browse files
committedJun 5, 2021
address review comments
1 parent bad4889 commit 0605a11

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed
 

‎app/src/main/java/org/systers/mentorship/view/activities/LoginActivity.kt

+2-7
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import androidx.compose.foundation.layout.Spacer
1313
import androidx.compose.foundation.layout.fillMaxSize
1414
import androidx.compose.foundation.layout.fillMaxWidth
1515
import androidx.compose.foundation.layout.height
16-
import androidx.compose.foundation.rememberScrollState
17-
import androidx.compose.foundation.verticalScroll
1816
import androidx.compose.material.Button
1917
import androidx.compose.material.MaterialTheme
2018
import androidx.compose.material.Scaffold
@@ -79,8 +77,7 @@ class LoginActivity : BaseActivity() {
7977
try {
8078
val tokenExpiredVal = intent.extras!!.getInt(Constants.TOKEN_EXPIRED_EXTRA)
8179
if (tokenExpiredVal == 0)
82-
Toast.makeText(this, "Session Token expired, please login again", Toast.LENGTH_LONG)
83-
.show()
80+
loginViewModel.message.value = "Session Token expired, please login again"
8481
} catch (exception: Exception) {
8582
}
8683
}
@@ -138,9 +135,7 @@ fun LoginContent(
138135

139136
Box {
140137
Column(
141-
Modifier
142-
.fillMaxSize()
143-
.verticalScroll(rememberScrollState()),
138+
Modifier.fillMaxSize(),
144139
verticalArrangement = Arrangement.SpaceAround,
145140
horizontalAlignment = Alignment.CenterHorizontally
146141
) {

‎app/src/main/java/org/systers/mentorship/viewmodels/LoginViewModel.kt

+6-7
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class LoginViewModel : ViewModel() {
4242
private val _successful = MutableLiveData(false)
4343
val successful: LiveData<Boolean> = _successful
4444

45-
private val _message = MutableLiveData<String>()
46-
val message: LiveData<String> = _message
45+
val message = MutableLiveData<String>()
4746

4847
/**
4948
* Will be used to run the login method of the AuthService
@@ -64,18 +63,18 @@ class LoginViewModel : ViewModel() {
6463
override fun onError(throwable: Throwable) {
6564
when (throwable) {
6665
is IOException -> {
67-
_message.value = MentorshipApplication.getContext()
66+
message.value = MentorshipApplication.getContext()
6867
.getString(R.string.error_please_check_internet)
6968
}
7069
is TimeoutException -> {
71-
_message.value = MentorshipApplication.getContext()
70+
message.value = MentorshipApplication.getContext()
7271
.getString(R.string.error_request_timed_out)
7372
}
7473
is HttpException -> {
75-
_message.value = CommonUtils.getErrorResponse(throwable).message
74+
message.value = CommonUtils.getErrorResponse(throwable).message
7675
}
7776
else -> {
78-
_message.value = MentorshipApplication.getContext()
77+
message.value = MentorshipApplication.getContext()
7978
.getString(R.string.error_something_went_wrong)
8079
Log.e(tag, throwable.localizedMessage)
8180
}
@@ -101,7 +100,7 @@ class LoginViewModel : ViewModel() {
101100
}
102101

103102
fun onButtonClick() {
104-
_message.value = ""
103+
message.value = ""
105104
login(Login(username.value!!, password.value!!))
106105
}
107106
}

0 commit comments

Comments
 (0)