From 78df8f3bc4d507165a79bd08d5128187598400f4 Mon Sep 17 00:00:00 2001 From: anastasizzz Date: Sun, 21 Jul 2024 23:59:25 +0300 Subject: [PATCH] #3 fix vm --- .../java/by/eapp/musicroom/navigation/NavHost.kt | 6 ++---- .../musicroom/screens/AuthorizationViewModel.kt | 14 +++----------- .../musicroom/screens/login/LoginScreenAction.kt | 11 ----------- .../musicroom/screens/login/LoginScreenState.kt | 10 ---------- 4 files changed, 5 insertions(+), 36 deletions(-) delete mode 100644 android/app/src/main/java/by/eapp/musicroom/screens/login/LoginScreenAction.kt delete mode 100644 android/app/src/main/java/by/eapp/musicroom/screens/login/LoginScreenState.kt diff --git a/android/app/src/main/java/by/eapp/musicroom/navigation/NavHost.kt b/android/app/src/main/java/by/eapp/musicroom/navigation/NavHost.kt index bdfed61..d000f49 100644 --- a/android/app/src/main/java/by/eapp/musicroom/navigation/NavHost.kt +++ b/android/app/src/main/java/by/eapp/musicroom/navigation/NavHost.kt @@ -2,17 +2,14 @@ package by.eapp.musicroom.navigation import RegistrationScreen -import androidx.compose.animation.AnimatedContentScope - import androidx.compose.animation.AnimatedContentTransitionScope -import androidx.compose.animation.core.FastOutLinearInEasing import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.tween import androidx.compose.runtime.Composable import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable -import by.eapp.musicroom.screens.login.LoginScreen +import by.eapp.musicroom.screens.view.login.LoginScreen @Composable fun NavHostController( @@ -50,6 +47,7 @@ fun NavHostController( }, ) { + //val viewModel = hilAuthorizationViewModel() добавить хилт вм LoginScreen(navController = navController) } composable(route = Screens.MainScreen.route) { diff --git a/android/app/src/main/java/by/eapp/musicroom/screens/AuthorizationViewModel.kt b/android/app/src/main/java/by/eapp/musicroom/screens/AuthorizationViewModel.kt index 0e31f41..04f6d0f 100644 --- a/android/app/src/main/java/by/eapp/musicroom/screens/AuthorizationViewModel.kt +++ b/android/app/src/main/java/by/eapp/musicroom/screens/AuthorizationViewModel.kt @@ -37,7 +37,7 @@ class AuthorizationViewModel @Inject constructor( } - fun submitCode(submitData: SubmitData) { + private fun submitCode(submitData: SubmitData) { _stateUi.value = LoginScreenState.Loading viewModelScope.launch { val token = auth.submitCode(submitData) @@ -64,8 +64,7 @@ class AuthorizationViewModel @Inject constructor( when (action) { is LoginScreenAction.LoginUser -> loginUser(action.loginData) is LoginScreenAction.RegisterUser -> registerUser(action.registrationData) - is LoginScreenAction.Success -> _stateUi.value = LoginScreenState.Success - is LoginScreenAction.Error -> _stateUi.value = LoginScreenState.Error(action.error) + is LoginScreenAction.SubmitCode -> submitCode(action.submitData) } } @@ -75,17 +74,10 @@ class AuthorizationViewModel @Inject constructor( } -sealed interface RegistrationScreenAction { - data object Loading : RegistrationScreenAction - data object Success : RegistrationScreenAction - data class Error(val error: Throwable?) : RegistrationScreenAction -} - sealed interface LoginScreenAction { data class LoginUser(val loginData: LoginData) : LoginScreenAction data class RegisterUser(val registrationData: RegistrationData) : LoginScreenAction - data object Success : LoginScreenAction - data class Error(val error: Throwable?) : LoginScreenAction + data class SubmitCode(val submitData: SubmitData) : LoginScreenAction } sealed interface LoginScreenState { diff --git a/android/app/src/main/java/by/eapp/musicroom/screens/login/LoginScreenAction.kt b/android/app/src/main/java/by/eapp/musicroom/screens/login/LoginScreenAction.kt deleted file mode 100644 index d261b22..0000000 --- a/android/app/src/main/java/by/eapp/musicroom/screens/login/LoginScreenAction.kt +++ /dev/null @@ -1,11 +0,0 @@ -package by.eapp.musicroom.screens.login - -interface LoginScreenAction { - data object StartAuth : LoginScreenAction -// data class ResponseSsoSettings(val startSSOSettingsData: StartSSOSettingsData) : -// LoginScreenAction - - //data class CompleteAuth(val authResult: AuthResult) : LoginScreenAction - data object Success : LoginScreenAction - data class Error(val error: Throwable?) : LoginScreenAction -} \ No newline at end of file diff --git a/android/app/src/main/java/by/eapp/musicroom/screens/login/LoginScreenState.kt b/android/app/src/main/java/by/eapp/musicroom/screens/login/LoginScreenState.kt deleted file mode 100644 index 874e34c..0000000 --- a/android/app/src/main/java/by/eapp/musicroom/screens/login/LoginScreenState.kt +++ /dev/null @@ -1,10 +0,0 @@ -package by.eapp.musicroom.screens.login - -sealed interface LoginScreenState { - data object Init : LoginScreenState - data object Loading : LoginScreenState - - // data class AuthWithSdkSso(val startSSOSettingsData: StartSSOSettingsData) : LoginScreenState - data class Error(val error: Throwable?) : LoginScreenState - data object Success : LoginScreenState -} \ No newline at end of file