MINIMAL CHANGES
This commit is contained in:
parent
abe032cdda
commit
1ff34969ba
@ -1,7 +1,7 @@
|
||||
package ru.myitschool.work.core
|
||||
|
||||
object Constants {
|
||||
const val HOST = "http://10.0.0.12:49165"
|
||||
const val HOST = "http://10.0.0.103:49165"
|
||||
const val AUTH_URL = "/auth"
|
||||
const val INFO_URL = "/info"
|
||||
const val BOOKING_URL = "/booking"
|
||||
|
||||
@ -102,5 +102,5 @@ object NetworkDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getUrl(targetUrl: String) = "${Constants.HOST}/api/$targetUrl"
|
||||
private fun getUrl(targetUrl: String) = "${Constants.HOST}/api$targetUrl"
|
||||
}
|
||||
@ -64,23 +64,6 @@ fun AuthScreen(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.difference),
|
||||
contentDescription = stringResource(R.string.icon_alter),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(184.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.size(48.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.auth_title_1),
|
||||
style = MaterialTheme.typography.headlineLarge,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.auth_title_2),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
when (val currentState = state) {
|
||||
is AuthState.Data -> Content(viewModel, currentState)
|
||||
is AuthState.Loading -> {
|
||||
@ -100,6 +83,24 @@ private fun Content(
|
||||
var login by remember { mutableStateOf("") }
|
||||
var password by remember { mutableStateOf("") }
|
||||
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.difference),
|
||||
contentDescription = stringResource(R.string.icon_alter),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(184.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.size(48.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.auth_title_1),
|
||||
style = MaterialTheme.typography.headlineLarge,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.auth_title_2),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.size(48.dp))
|
||||
OutlinedTextField(
|
||||
modifier = Modifier.testTag(TestIds.Auth.CODE_INPUT).fillMaxWidth(),
|
||||
|
||||
@ -42,6 +42,7 @@ class AuthViewModel : ViewModel() {
|
||||
timerSecs -= 1
|
||||
updateStateIfData { oldState ->
|
||||
oldState.copy(
|
||||
isEnabledSend = false,
|
||||
error = "Слишком много попыток входа, попробуйте через $timerSecs секунд"
|
||||
)
|
||||
}
|
||||
@ -61,24 +62,16 @@ class AuthViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
timer.start()
|
||||
updateStateIfData { oldState ->
|
||||
oldState.copy(
|
||||
error = "Слишком много попыток входа, попробуйте через $timerSecs секунд"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
viewModelScope.launch {
|
||||
_uiState.update { AuthState.Loading }
|
||||
checkAndSaveAuthCodeUseCase.invoke(intent.login, intent.password).fold(
|
||||
onSuccess = {
|
||||
_actionFlow.emit(AuthAction.Open(MainScreenDestination))
|
||||
},
|
||||
onFailure = { error ->
|
||||
authTries += 1
|
||||
updateStateIfData { oldState ->
|
||||
oldState.copy(
|
||||
error = error.message
|
||||
)
|
||||
}
|
||||
_uiState.update { AuthState.Data(isEnabledSend = false, error = error.message) }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user