main #6

Closed
student-d-sherstnev wants to merge 19 commits from Minipigi-org/NTO-2026-Android-TeamTask-Template:main into main
4 changed files with 23 additions and 29 deletions
Showing only changes of commit 1ff34969ba - Show all commits

View File

@ -1,7 +1,7 @@
package ru.myitschool.work.core package ru.myitschool.work.core
object Constants { 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 AUTH_URL = "/auth"
const val INFO_URL = "/info" const val INFO_URL = "/info"
const val BOOKING_URL = "/booking" const val BOOKING_URL = "/booking"

View File

@ -102,5 +102,5 @@ object NetworkDataSource {
} }
} }
private fun getUrl(targetUrl: String) = "${Constants.HOST}/api/$targetUrl" private fun getUrl(targetUrl: String) = "${Constants.HOST}/api$targetUrl"
} }

View File

@ -64,23 +64,6 @@ fun AuthScreen(
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center 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) { when (val currentState = state) {
is AuthState.Data -> Content(viewModel, currentState) is AuthState.Data -> Content(viewModel, currentState)
is AuthState.Loading -> { is AuthState.Loading -> {
@ -100,6 +83,24 @@ private fun Content(
var login by remember { mutableStateOf("") } var login by remember { mutableStateOf("") }
var password 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)) Spacer(modifier = Modifier.size(48.dp))
OutlinedTextField( OutlinedTextField(
modifier = Modifier.testTag(TestIds.Auth.CODE_INPUT).fillMaxWidth(), modifier = Modifier.testTag(TestIds.Auth.CODE_INPUT).fillMaxWidth(),

View File

@ -42,6 +42,7 @@ class AuthViewModel : ViewModel() {
timerSecs -= 1 timerSecs -= 1
updateStateIfData { oldState -> updateStateIfData { oldState ->
oldState.copy( oldState.copy(
isEnabledSend = false,
error = "Слишком много попыток входа, попробуйте через $timerSecs секунд" error = "Слишком много попыток входа, попробуйте через $timerSecs секунд"
) )
} }
@ -61,24 +62,16 @@ class AuthViewModel : ViewModel() {
} }
} }
timer.start() timer.start()
updateStateIfData { oldState ->
oldState.copy(
error = "Слишком много попыток входа, попробуйте через $timerSecs секунд"
)
}
} else { } else {
viewModelScope.launch { viewModelScope.launch {
_uiState.update { AuthState.Loading }
checkAndSaveAuthCodeUseCase.invoke(intent.login, intent.password).fold( checkAndSaveAuthCodeUseCase.invoke(intent.login, intent.password).fold(
onSuccess = { onSuccess = {
_actionFlow.emit(AuthAction.Open(MainScreenDestination)) _actionFlow.emit(AuthAction.Open(MainScreenDestination))
}, },
onFailure = { error -> onFailure = { error ->
authTries += 1 authTries += 1
updateStateIfData { oldState -> _uiState.update { AuthState.Data(isEnabledSend = false, error = error.message) }
oldState.copy(
error = error.message
)
}
} }
) )
} }