-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
app/src/main/java/org/sopt/official/feature/auth/feature/authmain/AuthMainSideEffect.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.sopt.official.feature.auth.feature.authmain | ||
|
||
sealed class AuthMainSideEffect { | ||
data class ShowToast(val message: String) : AuthMainSideEffect() | ||
} |
43 changes: 43 additions & 0 deletions
43
app/src/main/java/org/sopt/official/feature/auth/feature/authmain/AuthMainViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.sopt.official.feature.auth.feature.authmain | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
import kotlinx.coroutines.flow.SharedFlow | ||
import kotlinx.coroutines.flow.asSharedFlow | ||
import kotlinx.coroutines.launch | ||
import org.sopt.official.domain.auth.model.SignInCode | ||
import org.sopt.official.domain.auth.repository.AuthRepository | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class AuthMainViewModel @Inject constructor( | ||
private val authRepository: AuthRepository, | ||
// private val oAuthInteractor: OAuthInteractor | ||
) : ViewModel() { | ||
|
||
private val _sideEffect = MutableSharedFlow<AuthMainSideEffect>() | ||
val sideEffect: SharedFlow<AuthMainSideEffect> = _sideEffect.asSharedFlow() | ||
|
||
fun signIn(code: String) { | ||
// TODO: 실제 code 넣기 by leeeyubin | ||
viewModelScope.launch { | ||
authRepository.signIn( | ||
SignInCode( | ||
code = "codecodecodecodecode", | ||
authPlatform = GOOGLE | ||
) | ||
).onSuccess { | ||
_sideEffect.emit(AuthMainSideEffect.ShowToast("성공!!")) | ||
}.onFailure { | ||
_sideEffect.emit(AuthMainSideEffect.ShowToast("실패ㅠㅠ!!")) | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private const val GOOGLE = "GOOGLE" | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
data/auth/src/main/java/org/sopt/official/data/auth/mapper/SignInMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.sopt.official.data.auth.mapper | ||
|
||
import org.sopt.official.data.auth.remote.request.SignInRequest | ||
import org.sopt.official.data.auth.remote.response.SignInResponse | ||
import org.sopt.official.domain.auth.model.SignInCode | ||
import org.sopt.official.domain.auth.model.SignInResult | ||
|
||
fun SignInCode.toRequest(): SignInRequest = | ||
SignInRequest( | ||
code = code, | ||
authPlatform = authPlatform | ||
) | ||
|
||
fun SignInResponse.toDomain(): SignInResult = | ||
SignInResult( | ||
accessToken = accessToken, | ||
refreshToken = refreshToken | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
data/auth/src/main/java/org/sopt/official/data/auth/remote/request/SignInRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.sopt.official.data.auth.remote.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SignInRequest ( | ||
@SerialName("code") | ||
val code: String, | ||
@SerialName("authPlatform") | ||
val authPlatform: String | ||
) | ||
|
12 changes: 12 additions & 0 deletions
12
data/auth/src/main/java/org/sopt/official/data/auth/remote/response/SignInResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.sopt.official.data.auth.remote.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SignInResponse( | ||
@SerialName("accessToken") | ||
val accessToken: String, | ||
@SerialName("refreshToken") | ||
val refreshToken: String | ||
) |
6 changes: 6 additions & 0 deletions
6
domain/auth/src/main/java/org/sopt/official/domain/auth/model/SignInCode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.sopt.official.domain.auth.model | ||
|
||
data class SignInCode( | ||
val code: String, | ||
val authPlatform: String | ||
) |
6 changes: 6 additions & 0 deletions
6
domain/auth/src/main/java/org/sopt/official/domain/auth/model/SignInResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.sopt.official.domain.auth.model | ||
|
||
data class SignInResult( | ||
val accessToken: String, | ||
val refreshToken: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters