Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
epicadk committed Jun 8, 2021
1 parent bad4889 commit 67353c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ 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.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
Expand All @@ -33,10 +31,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.launch
import org.systers.mentorship.R
import org.systers.mentorship.utils.Constants
Expand Down Expand Up @@ -79,8 +77,7 @@ class LoginActivity : BaseActivity() {
try {
val tokenExpiredVal = intent.extras!!.getInt(Constants.TOKEN_EXPIRED_EXTRA)
if (tokenExpiredVal == 0)
Toast.makeText(this, "Session Token expired, please login again", Toast.LENGTH_LONG)
.show()
loginViewModel.message.value = "Session Token expired, please login again"
} catch (exception: Exception) {
}
}
Expand Down Expand Up @@ -138,9 +135,7 @@ fun LoginContent(

Box {
Column(
Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
Modifier.fillMaxSize(),
verticalArrangement = Arrangement.SpaceAround,
horizontalAlignment = Alignment.CenterHorizontally
) {
Expand Down Expand Up @@ -194,7 +189,7 @@ fun LoginContent(
) {
Text(text = stringResource(R.string.login))
}
Spacer(modifier = Modifier.height(10.dp))
Spacer(modifier = Modifier.height(dimensionResource(id = R.dimen.padding_small)))
Button(
onClick = onSignUpButtonClick,
enabled = !(!isButtonEnabled && username.isNotEmpty() && password.isNotEmpty()),
Expand All @@ -204,7 +199,7 @@ fun LoginContent(
Text(text = stringResource(R.string.sign_up))
}
}
Spacer(modifier = Modifier.height(10.dp))
Spacer(modifier = Modifier.height(dimensionResource(R.dimen.padding_small)))
}
CircularIndeterminateProgressBar(
modifier = Modifier.align(Alignment.Center),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class LoginViewModel : ViewModel() {
private val _successful = MutableLiveData(false)
val successful: LiveData<Boolean> = _successful

private val _message = MutableLiveData<String>()
val message: LiveData<String> = _message
val message = MutableLiveData<String>()

/**
* Will be used to run the login method of the AuthService
Expand All @@ -64,18 +63,18 @@ class LoginViewModel : ViewModel() {
override fun onError(throwable: Throwable) {
when (throwable) {
is IOException -> {
_message.value = MentorshipApplication.getContext()
message.value = MentorshipApplication.getContext()
.getString(R.string.error_please_check_internet)
}
is TimeoutException -> {
_message.value = MentorshipApplication.getContext()
message.value = MentorshipApplication.getContext()
.getString(R.string.error_request_timed_out)
}
is HttpException -> {
_message.value = CommonUtils.getErrorResponse(throwable).message
message.value = CommonUtils.getErrorResponse(throwable).message
}
else -> {
_message.value = MentorshipApplication.getContext()
message.value = MentorshipApplication.getContext()
.getString(R.string.error_something_went_wrong)
Log.e(tag, throwable.localizedMessage)
}
Expand All @@ -101,7 +100,7 @@ class LoginViewModel : ViewModel() {
}

fun onButtonClick() {
_message.value = ""
message.value = ""
login(Login(username.value!!, password.value!!))
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Versions {
const val targetSdkVersion = 30
const val versionCode = 1
const val versionName = "1"
const val gradleBuildTool = "7.1.0-alpha01"
const val gradleBuildTool = "7.1.0-alpha02"
const val kotlinVersion = "1.4.32"
const val designSupportLib = "1.1.0-beta01"
const val swipeRefreshLayout = "1.1.0"
Expand Down

0 comments on commit 67353c7

Please sign in to comment.