-
Notifications
You must be signed in to change notification settings - Fork 0
[feature/#43] root 및 메인 네비게이션, 네비게이션 UI구현 #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
84cd648
858f529
9fc2f94
6a8b863
2e49569
1fa7360
fe5025c
044611c
0ac173f
e0ab41e
79dd31c
9f50908
d004f5e
1b81b92
a874723
44efa64
db68676
020bf5e
72c514a
15a80c1
25480ac
bf2979e
aab7fba
6ad95bd
e6da2b6
f08db34
ee6c5bd
d6d8885
7948742
87f561a
412d523
4820d8d
c4c6b9b
2636171
eac4c12
a66ccd7
765da06
16fb2a7
1ea7d77
0597bb7
ea7ec3c
3f6db65
08b4897
0e22ed9
9e5f56a
243621c
6740d0b
b4aa253
0295297
ffec8ec
1cc091b
fd97cfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.gildongmu.dduru.presentation.feature.login.util | ||
|
|
||
| sealed interface LoginSideEffect { | ||
| data class LoginSuccess(val isNewUser: Boolean) : LoginSideEffect | ||
| data class ShowError(val message: String) : LoginSideEffect | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.gildongmu.dduru.presentation.feature.login.util | ||
|
|
||
| data class LoginUiState( | ||
| val isLoading: Boolean = false | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| package com.gildongmu.dduru.presentation.feature.login.viewmodel | ||
|
|
||
| import android.content.Context | ||
| import android.util.Log | ||
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.gildongmu.dduru.data.remote.datasource.KakaoAuthDataSource | ||
| import com.gildongmu.dduru.domain.usecase.LoginGoogleUseCase | ||
| import com.gildongmu.dduru.domain.usecase.LoginKakaoUseCase | ||
| import com.gildongmu.dduru.presentation.feature.login.util.LoginSideEffect | ||
| import com.gildongmu.dduru.presentation.feature.login.util.LoginUiState | ||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||
| import javax.inject.Inject | ||
| import kotlinx.coroutines.flow.MutableSharedFlow | ||
| import kotlinx.coroutines.flow.MutableStateFlow | ||
| import kotlinx.coroutines.flow.SharedFlow | ||
| import kotlinx.coroutines.flow.StateFlow | ||
| import kotlinx.coroutines.flow.asSharedFlow | ||
| import kotlinx.coroutines.flow.asStateFlow | ||
| import kotlinx.coroutines.launch | ||
|
|
||
| @HiltViewModel | ||
| class LoginViewModel @Inject constructor( | ||
| private val loginGoogleUseCase: LoginGoogleUseCase, | ||
| private val loginKakaoUseCase: LoginKakaoUseCase, | ||
| private val kakaoAuthDataSource: KakaoAuthDataSource | ||
| ) : ViewModel() { | ||
|
|
||
| private val _uiState = MutableStateFlow(LoginUiState()) | ||
| val uiState: StateFlow<LoginUiState> = _uiState.asStateFlow() | ||
|
|
||
| private val _sideEffect = MutableSharedFlow<LoginSideEffect>() | ||
| val sideEffect: SharedFlow<LoginSideEffect> = _sideEffect.asSharedFlow() | ||
|
|
||
| fun startGoogleLogin(context: Context) { | ||
| viewModelScope.launch { | ||
| updateLoading(true) | ||
| try { | ||
| val result = loginGoogleUseCase(context) | ||
|
|
||
| result.onSuccess { isNewUser -> | ||
| _sideEffect.emit(LoginSideEffect.LoginSuccess(isNewUser)) | ||
| }.onFailure { e -> | ||
| Log.e("LoginViewModel", "Google Login failed: ${e.message}", e) | ||
| _sideEffect.emit(LoginSideEffect.ShowError("구글 로그인에 실패했습니다. 다시 시도해주세요.")) | ||
| } | ||
| } finally { | ||
| updateLoading(false) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fun startKakaoLogin() { | ||
| viewModelScope.launch { | ||
| updateLoading(true) | ||
| try { | ||
| val idToken = kakaoAuthDataSource.getIdToken() | ||
| if (idToken.isNullOrBlank()) { | ||
| _sideEffect.emit(LoginSideEffect.ShowError("카카오 로그인에 실패했습니다. 다시 시도해주세요.")) | ||
| return@launch | ||
| } | ||
|
|
||
| loginKakao(idToken) | ||
| } finally { | ||
| updateLoading(false) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fun loginWithKakao(idToken: String) { | ||
| viewModelScope.launch { | ||
| updateLoading(true) | ||
| try { | ||
| loginKakao(idToken) | ||
| } finally { | ||
| updateLoading(false) | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+70
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: loginWithKakao 함수의 사용처 검색
# Expect: 호출처가 있거나 향후 사용 예정임을 확인
rg -n "loginWithKakao" --type-add 'kotlin:*.kt' --type kotlinRepository: ddu-ru/ddu-ru-android Length of output: 2137 🏁 Script executed: # Search for LoginViewModel references and usage
rg -n "LoginViewModel" --type-add 'kotlin:*.kt' --type kotlin -A 3 -B 1 | head -100
# Also search for any call patterns that might invoke loginWithKakao
rg -n "\.loginWithKakao\(" --type-add 'kotlin:*.kt' --type kotlinRepository: ddu-ru/ddu-ru-android Length of output: 3935 🏁 Script executed: # View LoginScreen.kt to see actual method calls
cat -n app/src/main/java/com/gildongmu/dduru/presentation/feature/login/screen/LoginScreen.kt | grep -A 10 -B 10 -i "kakao\|loginWithKakao\|startKakaoLogin"Repository: ddu-ru/ddu-ru-android Length of output: 2593
UI 레이어에서 실제 사용되는 카카오 로그인 진입점은 🤖 Prompt for AI Agents |
||
|
|
||
| private suspend fun loginKakao(idToken: String) { | ||
| val result = loginKakaoUseCase(idToken) | ||
|
|
||
| result.onSuccess { isNewUser -> | ||
| _sideEffect.emit(LoginSideEffect.LoginSuccess(isNewUser)) | ||
| }.onFailure { e -> | ||
| Log.e("LoginViewModel", "Kakao Login failed: ${e.message}", e) | ||
| _sideEffect.emit(LoginSideEffect.ShowError("카카오 로그인에 실패했습니다. 다시 시도해주세요.")) | ||
| } | ||
| } | ||
|
|
||
| private fun updateLoading(isLoading: Boolean) { | ||
| _uiState.value = _uiState.value.copy(isLoading = isLoading) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 LoginUiState만든것처럼 SideEffect도 새로운 파일에 만들어주세용 ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정했습니다