Skip to content

Commit

Permalink
[Merge] #81 -> develop
Browse files Browse the repository at this point in the history
[Feat/#81] splash api 연결 및  tendency result api / UI 작업
  • Loading branch information
chattymin authored Jan 12, 2024
2 parents c36e641 + 33f6605 commit 934ab8e
Show file tree
Hide file tree
Showing 49 changed files with 713 additions and 252 deletions.
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.tendencytest.TendencyTestSplashActivity"
android:name="com.going.presentation.tendency.splash.TendencySplashActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.tendencytest.TendencyTestActivity"
android:name="com.going.presentation.tendency.ttest.TendencyTestActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand All @@ -84,7 +84,7 @@
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.tendencytest.result.TendencyTestResultActivity"
android:name="com.going.presentation.tendency.result.TendencyResultActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/com/going/doorip/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import com.going.data.datasource.AuthDataSource
import com.going.data.datasource.DashBoardDataSource
import com.going.data.datasource.EnterTripDataSource
import com.going.data.datasource.MockDataSource
import com.going.data.datasource.ProfileDataSource
import com.going.data.datasource.SettingDataSource
import com.going.data.datasource.TendencyDataSource
import com.going.data.datasource.TodoDataSource
import com.going.data.datasourceImpl.AuthDataSourceImpl
import com.going.data.datasourceImpl.DashBoardDataSourceImpl
import com.going.data.datasourceImpl.EnterTripDataSourceImpl
import com.going.data.datasourceImpl.MockDataSourceImpl
import com.going.data.datasourceImpl.ProfileDataSourceImpl
import com.going.data.datasourceImpl.SettingDataSourceImpl
import com.going.data.datasourceImpl.TendencyDataSourceImpl
import com.going.data.datasourceImpl.TodoDataSourceImpl
Expand Down Expand Up @@ -54,9 +56,13 @@ object DataSourceModule {
fun provideTendencyDataSource(tendencyDataSourceImpl: TendencyDataSourceImpl): TendencyDataSource =
tendencyDataSourceImpl

@Provides
@Singleton
fun provideProfileDataSource(profileDataSourceImpl: ProfileDataSourceImpl): ProfileDataSource =
profileDataSourceImpl

@Provides
@Singleton
fun provideEnterTripDataSource(entertripDataSourceImpl: EnterTripDataSourceImpl): EnterTripDataSource =
entertripDataSourceImpl

}
7 changes: 7 additions & 0 deletions app/src/main/java/com/going/doorip/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.going.data.repositoryImpl.AuthRepositoryImpl
import com.going.data.repositoryImpl.DashBoardRepositoryImpl
import com.going.data.repositoryImpl.EnterTripRepositoryImpl
import com.going.data.repositoryImpl.MockRepositoryImpl
import com.going.data.repositoryImpl.ProfileRepositoryImpl
import com.going.data.repositoryImpl.SettingRepositoryImpl
import com.going.data.repositoryImpl.TendencyRepositoryImpl
import com.going.data.repositoryImpl.TodoRepositoryImpl
Expand All @@ -12,6 +13,7 @@ import com.going.domain.repository.AuthRepository
import com.going.domain.repository.DashBoardRepository
import com.going.domain.repository.EnterTripRepository
import com.going.domain.repository.MockRepository
import com.going.domain.repository.ProfileRepository
import com.going.domain.repository.SettingRepository
import com.going.domain.repository.TendencyRepository
import com.going.domain.repository.TodoRepository
Expand Down Expand Up @@ -65,4 +67,9 @@ object RepositoryModule {
@Singleton
fun provideTendencyRepository(tendencyRepositoryImpl: TendencyRepositoryImpl): TendencyRepository =
tendencyRepositoryImpl

@Provides
@Singleton
fun provideProfileRepository(profileRepositoryImpl: ProfileRepositoryImpl): ProfileRepository =
profileRepositoryImpl
}
6 changes: 6 additions & 0 deletions app/src/main/java/com/going/doorip/di/ServiceModule.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.going.doorip.di

import android.provider.ContactsContract.Profile
import com.going.data.service.AuthService
import com.going.data.service.DashBoardService
import com.going.data.service.EnterTripService
import com.going.data.service.MockService
import com.going.data.service.ProfileService
import com.going.data.service.SettingService
import com.going.data.service.TendencyService
import com.going.data.service.TodoService
Expand Down Expand Up @@ -53,4 +55,8 @@ object ServiceModule {
fun provideTendencyService(retrofit: Retrofit): TendencyService =
retrofit.create(TendencyService::class.java)

@Provides
@Singleton
fun provideProfileService(retrofit: Retrofit): ProfileService =
retrofit.create(ProfileService::class.java)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.going.data.datasource

import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.SignInRequestDto
import com.going.data.dto.request.SignUpRequestDto
import com.going.data.dto.response.AuthResponseDto
Expand All @@ -16,4 +17,6 @@ interface AuthDataSource {
Authorization: String,
data: SignUpRequestDto,
): BaseResponse<AuthResponseDto>

suspend fun getSplash(): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.going.data.datasource

import com.going.data.dto.BaseResponse
import com.going.data.dto.response.UserProfileResponseDto

interface ProfileDataSource {
suspend fun getUserProfile(): BaseResponse<UserProfileResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.going.data.datasourceImpl

import com.going.data.datasource.AuthDataSource
import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.SignInRequestDto
import com.going.data.dto.request.SignUpRequestDto
import com.going.data.dto.response.AuthResponseDto
Expand All @@ -22,4 +23,6 @@ class AuthDataSourceImpl @Inject constructor(
Authorization: String,
data: SignUpRequestDto,
): BaseResponse<AuthResponseDto> = authService.postSignUp(Authorization, data)

override suspend fun getSplash(): NonDataBaseResponse = authService.getSplash()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.going.data.datasourceImpl

import com.going.data.datasource.ProfileDataSource
import com.going.data.dto.BaseResponse
import com.going.data.dto.response.UserProfileResponseDto
import com.going.data.service.ProfileService
import javax.inject.Inject

class ProfileDataSourceImpl @Inject constructor(
private val profileService: ProfileService,
) : ProfileDataSource {
override suspend fun getUserProfile(): BaseResponse<UserProfileResponseDto> =
profileService.getUserProfile()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.going.data.dto.response

import com.going.domain.entity.request.UserProfileRequestModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class UserProfileResponseDto(
@SerialName("name")
val name: String,
@SerialName("intro")
val intro: String,
@SerialName("result")
val result: Int,
) {
fun toProfileModel() = UserProfileRequestModel(name, intro, result)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ class AuthRepositoryImpl @Inject constructor(
signUpRequestModel.toSignUpRequestDto(),
).data.toAuthTokenModel()
}

override suspend fun getSplash(): Result<Unit> = kotlin.runCatching {
authDataSource.getSplash()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.going.data.repositoryImpl

import com.going.data.datasource.AuthDataSource
import com.going.data.datasource.ProfileDataSource
import com.going.domain.entity.request.UserProfileRequestModel
import com.going.domain.repository.AuthRepository
import com.going.domain.repository.ProfileRepository
import javax.inject.Inject

class ProfileRepositoryImpl @Inject constructor(
private val profileDataSource: ProfileDataSource
) : ProfileRepository {
override suspend fun getUserProfile(): Result<UserProfileRequestModel> = runCatching {
profileDataSource.getUserProfile().data.toProfileModel()
}
}
5 changes: 5 additions & 0 deletions data/src/main/java/com/going/data/service/AuthService.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.going.data.service

import com.going.data.dto.BaseResponse
import com.going.data.dto.NonDataBaseResponse
import com.going.data.dto.request.SignInRequestDto
import com.going.data.dto.request.SignUpRequestDto
import com.going.data.dto.response.AuthResponseDto
import com.going.data.dto.response.SignInResponseDto
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST

Expand All @@ -21,4 +23,7 @@ interface AuthService {
@Header("Authorization") Authorization: String,
@Body body: SignUpRequestDto,
): BaseResponse<AuthResponseDto>

@GET("api/users/splash")
suspend fun getSplash(): NonDataBaseResponse
}
10 changes: 10 additions & 0 deletions data/src/main/java/com/going/data/service/ProfileService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.going.data.service

import com.going.data.dto.BaseResponse
import com.going.data.dto.response.UserProfileResponseDto
import retrofit2.http.GET

interface ProfileService {
@GET("api/users/profile")
suspend fun getUserProfile(): BaseResponse<UserProfileResponseDto>
}
5 changes: 5 additions & 0 deletions domain/src/main/kotlin/com/going/domain/entity/AuthState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.going.domain.entity

enum class AuthState {
LOADING, SUCCESS, FAILURE, SIGNUP, SIGNIN, TENDENCY, EMPTY
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.going.domain.entity

data class ProfileMock(
val resultImage: Int,
val profileTitle: String,
val profileSubTitle: String,
val tags: List<String>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.going.domain.entity.request

data class UserProfileRequestModel(
val name: String,
val intro: String,
val result: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ interface AuthRepository {
Authorization: String,
data: SignUpRequestModel,
): Result<AuthTokenModel>

suspend fun getSplash(): Result<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.going.domain.repository

import com.going.domain.entity.request.UserProfileRequestModel

interface ProfileRepository {
suspend fun getUserProfile(): Result<UserProfileRequestModel>
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import android.os.Bundle
import androidx.activity.viewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.going.domain.entity.AuthState
import com.going.presentation.R
import com.going.presentation.dashboard.DashBoardActivity
import com.going.presentation.databinding.ActivitySigninBinding
import com.going.presentation.onboarding.signup.OnboardingProfileSettingActivity
import com.going.presentation.setting.SettingActivity
import com.going.presentation.tendencytest.TendencyTestActivity
import com.going.presentation.tendencytest.TendencyTestSplashActivity
import com.going.presentation.tendency.splash.TendencySplashActivity
import com.going.ui.base.BaseActivity
import com.going.ui.extension.setOnSingleClickListener
import com.going.ui.extension.toast
Expand Down Expand Up @@ -59,18 +59,19 @@ class SignInActivity : BaseActivity<ActivitySigninBinding>(R.layout.activity_sig
private fun observePostChangeTokenState() {
viewModel.postChangeTokenState.flowWithLifecycle(lifecycle).onEach { state ->
when (state) {
SignInState.SUCCESS -> navigateToMainScreen()
SignInState.SIGN_UP -> navigateToOnboardingScreen()
SignInState.TENDENCY -> navigateToTendencyScreen()
SignInState.FAIL -> toast(getString(R.string.server_error))
SignInState.LOADING -> {}
AuthState.LOADING -> return@onEach
AuthState.SUCCESS -> navigateToDashBoardScreen()
AuthState.FAILURE -> toast(getString(R.string.server_error))
AuthState.SIGNUP -> navigateToOnboardingScreen()
AuthState.SIGNIN -> return@onEach
AuthState.TENDENCY -> navigateToTendencyScreen()
AuthState.EMPTY -> return@onEach
}
}.launchIn(lifecycleScope)
}

private fun navigateToMainScreen() {
// 추후 대시보드 연결시 연결 예정
Intent(this, TendencyTestSplashActivity::class.java).apply {
private fun navigateToDashBoardScreen() {
Intent(this, DashBoardActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(this)
}
Expand All @@ -86,7 +87,7 @@ class SignInActivity : BaseActivity<ActivitySigninBinding>(R.layout.activity_sig
}

private fun navigateToTendencyScreen() {
Intent(this, TendencyTestSplashActivity::class.java).apply {
Intent(this, TendencySplashActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(this)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.going.presentation.onboarding.signin
import android.content.Context
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.going.domain.entity.AuthState
import com.going.domain.entity.request.SignInRequestModel
import com.going.domain.repository.AuthRepository
import com.going.domain.repository.TokenRepository
Expand All @@ -22,8 +23,8 @@ class SignInViewModel @Inject constructor(
private val authRepository: AuthRepository,
private val tokenRepository: TokenRepository,
) : ViewModel() {
private val _postChangeTokenState = MutableStateFlow<SignInState>(SignInState.LOADING)
val postChangeTokenState: StateFlow<SignInState> = _postChangeTokenState
private val _postChangeTokenState = MutableStateFlow(AuthState.EMPTY)
val postChangeTokenState: StateFlow<AuthState> = _postChangeTokenState

private val _isAppLoginAvailable = MutableStateFlow(true)
val isAppLoginAvailable: StateFlow<Boolean> = _isAppLoginAvailable
Expand Down Expand Up @@ -68,23 +69,23 @@ class SignInViewModel @Inject constructor(
accessToken: String,
platform: String = KAKAO,
) {
_postChangeTokenState.value = SignInState.LOADING
_postChangeTokenState.value = AuthState.LOADING

viewModelScope.launch {
authRepository.postSignIn(accessToken, SignInRequestModel(platform)).onSuccess {
tokenRepository.setTokens(it.accessToken, it.refreshToken)

if (it.isResult) {
_postChangeTokenState.value = SignInState.SUCCESS
_postChangeTokenState.value = AuthState.SUCCESS
} else {
_postChangeTokenState.value = SignInState.TENDENCY
_postChangeTokenState.value = AuthState.TENDENCY
}
}.onFailure {
val errorCode = toErrorCode(it)

_postChangeTokenState.value = when (errorCode) {
SIGN_UP -> SignInState.SIGN_UP
else -> SignInState.FAIL
SIGN_UP -> AuthState.SIGNUP
else -> AuthState.FAILURE
}
}
}
Expand Down
Loading

0 comments on commit 934ab8e

Please sign in to comment.