Skip to content

Commit

Permalink
[feat] #117 로그인 시 단체 정보 확인 후 해당되는 뷰로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
Doreminwoo committed Jan 12, 2024
1 parent 6e1e4a4 commit cba1c3a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ package org.sopt.pingle.presentation.ui.auth

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.activity.viewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.pingle.R
import org.sopt.pingle.data.service.KakaoAuthService
import org.sopt.pingle.databinding.ActivityAuthBinding
import org.sopt.pingle.presentation.ui.main.MainActivity
import org.sopt.pingle.presentation.ui.onboarding.OnBoardingActivity
import org.sopt.pingle.util.base.BindingActivity
import org.sopt.pingle.util.view.UiState
import timber.log.Timber
import javax.inject.Inject

@AndroidEntryPoint
class AuthActivity : BindingActivity<ActivityAuthBinding>(R.layout.activity_auth) {
Expand Down Expand Up @@ -51,8 +53,14 @@ class AuthActivity : BindingActivity<ActivityAuthBinding>(R.layout.activity_auth
}

private fun navigateToOnBoarding() {
Intent(this, OnBoardingActivity::class.java).apply {
startActivity(this)
if (viewModel.isLocalGroupId()) {
Intent(this, MainActivity::class.java).apply {
startActivity(this)
}
} else {
Intent(this, OnBoardingActivity::class.java).apply {
startActivity(this)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package org.sopt.pingle.presentation.ui.auth
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import org.sopt.pingle.data.datasource.local.PingleLocalDataSource
import org.sopt.pingle.data.model.remote.request.RequestAuthDto
import org.sopt.pingle.domain.repository.AuthRepository
import org.sopt.pingle.util.view.UiState
import javax.inject.Inject

@HiltViewModel
class AuthViewModel @Inject constructor(
Expand Down Expand Up @@ -42,6 +42,8 @@ class AuthViewModel @Inject constructor(
localStorage.userName = userName
}

fun isLocalGroupId(): Boolean = localStorage.groupId == -1

companion object {
const val LOGIN_PLATFORM = "KAKAO"
const val HEADER_BEARER = "Bearer "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class SplashActivity : BindingActivity<ActivitySplashBinding>(R.layout.activity_
val storage = PingleLocalDataSourceImpl(this)

val nextActivity =
if (storage.isLogin) MainActivity::class.java else AuthActivity::class.java
if (storage.isLogin) {
MainActivity::class.java
} else if (storage.groupId != -1) MainActivity::class.java else AuthActivity::class.java

startActivity(Intent(this, nextActivity))
finish()
Expand Down

0 comments on commit cba1c3a

Please sign in to comment.