Skip to content

Commit

Permalink
#86 refactor : Merge Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
plashdof committed Nov 21, 2023
1 parent 85e0bfa commit d8b28d8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
17 changes: 17 additions & 0 deletions Aos/.idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Aos/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
android:name=".app.App"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:usesCleartextTraffic="true"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/Theme.Nibobnebob"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding>(R.layout.fragment_login

override fun onSuccess() {
val token = NaverIdLoginSDK.getAccessToken().toString()
viewModel.naverLogin(token)
viewModel.loginNaver(token)
}
}
NaverIdLoginSDK.authenticate(requireContext(), oAuthLoginCallback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.avengers.nibobnebob.app.DataStoreManager
import com.avengers.nibobnebob.data.model.ApiState
import com.avengers.nibobnebob.data.repository.LoginRepository
import com.avengers.nibobnebob.data.repository.IntroRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -25,7 +25,7 @@ sealed class LoginEvent {

@HiltViewModel
class LoginViewModel @Inject constructor(
private val loginRepository: LoginRepository,
private val introRepository: IntroRepository,
private val dataStoreManager: DataStoreManager
) : ViewModel() {
private val TAG = "LoginViewModelDebug"
Expand Down Expand Up @@ -65,16 +65,20 @@ class LoginViewModel @Inject constructor(
autoLogin.value = newState
}

fun postCommonLogin(){
fun loginCommon(){
//TODO : 일반로그인
}

fun naverLogin(token : String){
fun loginNaver(token : String){
viewModelScope.launch {
dataStoreManager.putAccessToken(token)
loginRepository.loginNaver().onEach {
introRepository.loginNaver().onEach {
when(it){
is ApiState.Success -> {
dataStoreManager.putAutoLogin(true)
dataStoreManager.putAccessToken(it.data.accessToken.toString())
dataStoreManager.putRefreshToken(it.data.refreshToken.toString())

_events.emit(LoginEvent.NavigateToMain)
}
is ApiState.Error -> {
Expand All @@ -94,4 +98,5 @@ class LoginViewModel @Inject constructor(
}.launchIn(viewModelScope)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.avengers.nibobnebob.presentation.ui.splash
import androidx.lifecycle.viewModelScope
import com.avengers.nibobnebob.app.DataStoreManager
import com.avengers.nibobnebob.app.NetworkManager
import com.avengers.nibobnebob.data.repository.LoginRepository
import com.avengers.nibobnebob.presentation.base.BaseActivityViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
Expand Down
2 changes: 1 addition & 1 deletion Aos/app/src/main/res/layout/fragment_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="bold"
android:onClick="@{() -> vm.postCommonLogin()}"
android:onClick="@{() -> vm.loginCommon()}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_password" />
Expand Down

0 comments on commit d8b28d8

Please sign in to comment.