diff --git a/app/src/main/java/com/going/doorip/di/DataSourceModule.kt b/app/src/main/java/com/going/doorip/di/DataSourceModule.kt index b4905e72..d7a51379 100644 --- a/app/src/main/java/com/going/doorip/di/DataSourceModule.kt +++ b/app/src/main/java/com/going/doorip/di/DataSourceModule.kt @@ -3,10 +3,12 @@ package com.going.doorip.di import com.going.data.datasource.AuthDataSource import com.going.data.datasource.MockDataSource 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.MockDataSourceImpl import com.going.data.datasourceImpl.SettingDataSourceImpl +import com.going.data.datasourceImpl.TendencyDataSourceImpl import com.going.data.datasourceImpl.TodoDataSourceImpl import dagger.Module import dagger.Provides @@ -38,4 +40,8 @@ object DataSourceModule { fun provideTodoDataSource(todoDataSourceImpl: TodoDataSourceImpl): TodoDataSource = todoDataSourceImpl + @Provides + @Singleton + fun provideTendencyDataSource(tendencyDataSourceImpl: TendencyDataSourceImpl): TendencyDataSource = + tendencyDataSourceImpl } diff --git a/app/src/main/java/com/going/doorip/di/RepositoryModule.kt b/app/src/main/java/com/going/doorip/di/RepositoryModule.kt index 08aae754..2c8af37c 100644 --- a/app/src/main/java/com/going/doorip/di/RepositoryModule.kt +++ b/app/src/main/java/com/going/doorip/di/RepositoryModule.kt @@ -3,11 +3,13 @@ package com.going.doorip.di import com.going.data.repositoryImpl.AuthRepositoryImpl import com.going.data.repositoryImpl.MockRepositoryImpl import com.going.data.repositoryImpl.SettingRepositoryImpl +import com.going.data.repositoryImpl.TendencyRepositoryImpl import com.going.data.repositoryImpl.TodoRepositoryImpl import com.going.data.repositoryImpl.TokenRepositoryImpl import com.going.domain.repository.AuthRepository import com.going.domain.repository.MockRepository import com.going.domain.repository.SettingRepository +import com.going.domain.repository.TendencyRepository import com.going.domain.repository.TodoRepository import com.going.domain.repository.TokenRepository import dagger.Module @@ -45,4 +47,8 @@ object RepositoryModule { fun provideTodoRepository(todoRepositoryImpl: TodoRepositoryImpl): TodoRepository = todoRepositoryImpl + @Provides + @Singleton + fun provideTendencyRepository(tendencyRepositoryImpl: TendencyRepositoryImpl): TendencyRepository = + tendencyRepositoryImpl } diff --git a/app/src/main/java/com/going/doorip/di/ServiceModule.kt b/app/src/main/java/com/going/doorip/di/ServiceModule.kt index 4e74947d..1242cff4 100644 --- a/app/src/main/java/com/going/doorip/di/ServiceModule.kt +++ b/app/src/main/java/com/going/doorip/di/ServiceModule.kt @@ -3,6 +3,7 @@ package com.going.doorip.di import com.going.data.service.AuthService import com.going.data.service.MockService import com.going.data.service.SettingService +import com.going.data.service.TendencyService import com.going.data.service.TodoService import dagger.Module import dagger.Provides @@ -35,4 +36,8 @@ object ServiceModule { fun provideTodoService(retrofit: Retrofit): TodoService = retrofit.create(TodoService::class.java) + @Provides + @Singleton + fun provideTendencyService(retrofit: Retrofit): TendencyService = + retrofit.create(TendencyService::class.java) } diff --git a/core-ui/src/main/java/com/going/ui/extension/EnumUiState.kt b/core-ui/src/main/java/com/going/ui/extension/EnumUiState.kt index d9700d4c..c39fed1c 100644 --- a/core-ui/src/main/java/com/going/ui/extension/EnumUiState.kt +++ b/core-ui/src/main/java/com/going/ui/extension/EnumUiState.kt @@ -1,5 +1,5 @@ package com.going.ui.extension enum class EnumUiState { - LOADING, SUCCESS, FAILURE + SUCCESS, FAILURE, LOADING, EMPTY } diff --git a/data/src/main/java/com/going/data/datasource/SettingDataSource.kt b/data/src/main/java/com/going/data/datasource/SettingDataSource.kt index 3a14bbe4..da5ec881 100644 --- a/data/src/main/java/com/going/data/datasource/SettingDataSource.kt +++ b/data/src/main/java/com/going/data/datasource/SettingDataSource.kt @@ -1,10 +1,9 @@ package com.going.data.datasource import com.going.data.dto.NonDataBaseResponse -import com.going.data.dto.response.SignOutResponseDto interface SettingDataSource { - suspend fun patchSignOut(): SignOutResponseDto + suspend fun patchSignOut(): NonDataBaseResponse - suspend fun deleteWithDraw(): NonDataBaseResponse + suspend fun deleteWithDraw(): NonDataBaseResponse } diff --git a/data/src/main/java/com/going/data/datasource/TendencyDataSource.kt b/data/src/main/java/com/going/data/datasource/TendencyDataSource.kt new file mode 100644 index 00000000..320da64e --- /dev/null +++ b/data/src/main/java/com/going/data/datasource/TendencyDataSource.kt @@ -0,0 +1,8 @@ +package com.going.data.datasource + +import com.going.data.dto.NonDataBaseResponse +import com.going.data.dto.request.TendencyTestRequestDto + +interface TendencyDataSource { + suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse +} diff --git a/data/src/main/java/com/going/data/datasourceImpl/SettingDataSourceImpl.kt b/data/src/main/java/com/going/data/datasourceImpl/SettingDataSourceImpl.kt index d5f0beb0..af959b78 100644 --- a/data/src/main/java/com/going/data/datasourceImpl/SettingDataSourceImpl.kt +++ b/data/src/main/java/com/going/data/datasourceImpl/SettingDataSourceImpl.kt @@ -2,13 +2,12 @@ package com.going.data.datasourceImpl import com.going.data.datasource.SettingDataSource import com.going.data.dto.NonDataBaseResponse -import com.going.data.dto.response.SignOutResponseDto import com.going.data.service.SettingService import javax.inject.Inject class SettingDataSourceImpl @Inject constructor( private val settingService: SettingService, ) : SettingDataSource { - override suspend fun patchSignOut(): SignOutResponseDto = settingService.patchSignOut() - override suspend fun deleteWithDraw(): NonDataBaseResponse = settingService.deleteWithDraw() + override suspend fun patchSignOut(): NonDataBaseResponse = settingService.patchSignOut() + override suspend fun deleteWithDraw(): NonDataBaseResponse = settingService.deleteWithDraw() } diff --git a/data/src/main/java/com/going/data/datasourceImpl/TendencyDataSourceImpl.kt b/data/src/main/java/com/going/data/datasourceImpl/TendencyDataSourceImpl.kt new file mode 100644 index 00000000..125e883f --- /dev/null +++ b/data/src/main/java/com/going/data/datasourceImpl/TendencyDataSourceImpl.kt @@ -0,0 +1,14 @@ +package com.going.data.datasourceImpl + +import com.going.data.datasource.TendencyDataSource +import com.going.data.dto.NonDataBaseResponse +import com.going.data.dto.request.TendencyTestRequestDto +import com.going.data.service.TendencyService +import javax.inject.Inject + +class TendencyDataSourceImpl @Inject constructor( + private val tendencyService: TendencyService, +) : TendencyDataSource { + override suspend fun patchTendencyTest(result: TendencyTestRequestDto): NonDataBaseResponse = + tendencyService.patchTendencyTest(result) +} diff --git a/data/src/main/java/com/going/data/dto/NonDataBaseResponse.kt b/data/src/main/java/com/going/data/dto/NonDataBaseResponse.kt index 3138cd55..24f56e49 100644 --- a/data/src/main/java/com/going/data/dto/NonDataBaseResponse.kt +++ b/data/src/main/java/com/going/data/dto/NonDataBaseResponse.kt @@ -4,7 +4,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class NonDataBaseResponse( +data class NonDataBaseResponse( @SerialName("status") val status: Int, @SerialName("code") diff --git a/data/src/main/java/com/going/data/dto/request/SignInRequestDto.kt b/data/src/main/java/com/going/data/dto/request/SignInRequestDto.kt index 7a5f50c2..108d13e3 100644 --- a/data/src/main/java/com/going/data/dto/request/SignInRequestDto.kt +++ b/data/src/main/java/com/going/data/dto/request/SignInRequestDto.kt @@ -1,6 +1,6 @@ package com.going.data.dto.request -import com.going.domain.entity.request.RequestSignInModel +import com.going.domain.entity.request.SignInRequestModel import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -10,5 +10,5 @@ data class SignInRequestDto( val platform: String, ) -fun RequestSignInModel.toSignInRequestDto(): SignInRequestDto = +fun SignInRequestModel.toSignInRequestDto(): SignInRequestDto = SignInRequestDto(platform) diff --git a/data/src/main/java/com/going/data/dto/request/SignUpRequestDto.kt b/data/src/main/java/com/going/data/dto/request/SignUpRequestDto.kt index c5f8b525..67c3afb2 100644 --- a/data/src/main/java/com/going/data/dto/request/SignUpRequestDto.kt +++ b/data/src/main/java/com/going/data/dto/request/SignUpRequestDto.kt @@ -1,6 +1,6 @@ package com.going.data.dto.request -import com.going.domain.entity.request.RequestSignUpModel +import com.going.domain.entity.request.SignUpRequestModel import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -14,5 +14,5 @@ data class SignUpRequestDto( val platform: String, ) -fun RequestSignUpModel.toSignUpRequestDto(): SignUpRequestDto = +fun SignUpRequestModel.toSignUpRequestDto(): SignUpRequestDto = SignUpRequestDto(name, intro, platform) diff --git a/data/src/main/java/com/going/data/dto/request/TendencyRequestDto.kt b/data/src/main/java/com/going/data/dto/request/TendencyRequestDto.kt new file mode 100644 index 00000000..a0c54f19 --- /dev/null +++ b/data/src/main/java/com/going/data/dto/request/TendencyRequestDto.kt @@ -0,0 +1,13 @@ +package com.going.data.dto.request + +import com.going.domain.entity.request.TendencyRequestModel +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class TendencyTestRequestDto( + @SerialName("result") + val result: List, +) + +fun TendencyRequestModel.toTendencyTestRequestDto() = TendencyTestRequestDto(result) diff --git a/data/src/main/java/com/going/data/dto/response/SignOutResponseDto.kt b/data/src/main/java/com/going/data/dto/response/SignOutResponseDto.kt deleted file mode 100644 index 6a03f5e2..00000000 --- a/data/src/main/java/com/going/data/dto/response/SignOutResponseDto.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.going.data.dto.response - -import com.going.domain.entity.response.SignOutModel -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class SignOutResponseDto( - @SerialName("status") - val status: Int, - @SerialName("message") - val message: String, -) { - fun toSignOutModel() = - SignOutModel(status, message) -} diff --git a/data/src/main/java/com/going/data/repositoryImpl/AuthRepositoryImpl.kt b/data/src/main/java/com/going/data/repositoryImpl/AuthRepositoryImpl.kt index c0cf36f6..d2f6e9eb 100644 --- a/data/src/main/java/com/going/data/repositoryImpl/AuthRepositoryImpl.kt +++ b/data/src/main/java/com/going/data/repositoryImpl/AuthRepositoryImpl.kt @@ -3,8 +3,8 @@ package com.going.data.repositoryImpl import com.going.data.datasource.AuthDataSource import com.going.data.dto.request.toSignInRequestDto import com.going.data.dto.request.toSignUpRequestDto -import com.going.domain.entity.request.RequestSignInModel -import com.going.domain.entity.request.RequestSignUpModel +import com.going.domain.entity.request.SignInRequestModel +import com.going.domain.entity.request.SignUpRequestModel import com.going.domain.entity.response.AuthTokenModel import com.going.domain.entity.response.SignInModel import com.going.domain.repository.AuthRepository @@ -15,7 +15,7 @@ class AuthRepositoryImpl @Inject constructor( ) : AuthRepository { override suspend fun postSignIn( Authorization: String, - requestSignIpModel: RequestSignInModel, + requestSignIpModel: SignInRequestModel, ): Result = runCatching { authDataSource.postSignIn( @@ -26,12 +26,12 @@ class AuthRepositoryImpl @Inject constructor( override suspend fun postSignUp( Authorization: String, - requestSignUpModel: RequestSignUpModel, + signUpRequestModel: SignUpRequestModel, ): Result = runCatching { authDataSource.postSignUp( Authorization, - requestSignUpModel.toSignUpRequestDto(), + signUpRequestModel.toSignUpRequestDto(), ).data.toAuthTokenModel() } } diff --git a/data/src/main/java/com/going/data/repositoryImpl/SettingRepositoryImpl.kt b/data/src/main/java/com/going/data/repositoryImpl/SettingRepositoryImpl.kt index ecc36a7b..501963d1 100644 --- a/data/src/main/java/com/going/data/repositoryImpl/SettingRepositoryImpl.kt +++ b/data/src/main/java/com/going/data/repositoryImpl/SettingRepositoryImpl.kt @@ -1,15 +1,14 @@ package com.going.data.repositoryImpl import com.going.data.datasource.SettingDataSource -import com.going.domain.entity.response.SignOutModel import com.going.domain.repository.SettingRepository import javax.inject.Inject class SettingRepositoryImpl @Inject constructor( private val settingDataSource: SettingDataSource, ) : SettingRepository { - override suspend fun patchSignOut(): Result = runCatching { - settingDataSource.patchSignOut().toSignOutModel() + override suspend fun patchSignOut(): Result = runCatching { + settingDataSource.patchSignOut() } override suspend fun deleteWithDraw(): Result = runCatching { diff --git a/data/src/main/java/com/going/data/repositoryImpl/TendencyRepositoryImpl.kt b/data/src/main/java/com/going/data/repositoryImpl/TendencyRepositoryImpl.kt new file mode 100644 index 00000000..e48b3e32 --- /dev/null +++ b/data/src/main/java/com/going/data/repositoryImpl/TendencyRepositoryImpl.kt @@ -0,0 +1,16 @@ +package com.going.data.repositoryImpl + +import com.going.data.datasource.TendencyDataSource +import com.going.data.dto.request.toTendencyTestRequestDto +import com.going.domain.entity.request.TendencyRequestModel +import com.going.domain.repository.TendencyRepository +import javax.inject.Inject + +class TendencyRepositoryImpl @Inject constructor( + private val tendencyDataSource: TendencyDataSource, +) : TendencyRepository { + override suspend fun patchTendencyTest(result: TendencyRequestModel): Result = + runCatching { + tendencyDataSource.patchTendencyTest(result.toTendencyTestRequestDto()) + } +} diff --git a/data/src/main/java/com/going/data/service/SettingService.kt b/data/src/main/java/com/going/data/service/SettingService.kt index 27f7953d..43ef8bd2 100644 --- a/data/src/main/java/com/going/data/service/SettingService.kt +++ b/data/src/main/java/com/going/data/service/SettingService.kt @@ -1,14 +1,13 @@ package com.going.data.service import com.going.data.dto.NonDataBaseResponse -import com.going.data.dto.response.SignOutResponseDto import retrofit2.http.DELETE import retrofit2.http.PATCH interface SettingService { @PATCH("api/users/signout") - suspend fun patchSignOut(): SignOutResponseDto + suspend fun patchSignOut(): NonDataBaseResponse @DELETE("api/users/withdraw") - suspend fun deleteWithDraw(): NonDataBaseResponse + suspend fun deleteWithDraw(): NonDataBaseResponse } diff --git a/data/src/main/java/com/going/data/service/TendencyService.kt b/data/src/main/java/com/going/data/service/TendencyService.kt new file mode 100644 index 00000000..5ed0eb84 --- /dev/null +++ b/data/src/main/java/com/going/data/service/TendencyService.kt @@ -0,0 +1,13 @@ +package com.going.data.service + +import com.going.data.dto.NonDataBaseResponse +import com.going.data.dto.request.TendencyTestRequestDto +import retrofit2.http.Body +import retrofit2.http.PATCH + +interface TendencyService { + @PATCH("api/users/test") + suspend fun patchTendencyTest( + @Body result: TendencyTestRequestDto, + ): NonDataBaseResponse +} diff --git a/domain/src/main/kotlin/com/going/domain/entity/request/RequestSignInModel.kt b/domain/src/main/kotlin/com/going/domain/entity/request/SignInRequestModel.kt similarity index 68% rename from domain/src/main/kotlin/com/going/domain/entity/request/RequestSignInModel.kt rename to domain/src/main/kotlin/com/going/domain/entity/request/SignInRequestModel.kt index fc88c6ea..d2e69653 100644 --- a/domain/src/main/kotlin/com/going/domain/entity/request/RequestSignInModel.kt +++ b/domain/src/main/kotlin/com/going/domain/entity/request/SignInRequestModel.kt @@ -1,5 +1,5 @@ package com.going.domain.entity.request -data class RequestSignInModel( +data class SignInRequestModel( val platform: String ) diff --git a/domain/src/main/kotlin/com/going/domain/entity/request/RequestSignUpModel.kt b/domain/src/main/kotlin/com/going/domain/entity/request/SignUpRequestModel.kt similarity index 78% rename from domain/src/main/kotlin/com/going/domain/entity/request/RequestSignUpModel.kt rename to domain/src/main/kotlin/com/going/domain/entity/request/SignUpRequestModel.kt index 17be5dc3..7edf4ed6 100644 --- a/domain/src/main/kotlin/com/going/domain/entity/request/RequestSignUpModel.kt +++ b/domain/src/main/kotlin/com/going/domain/entity/request/SignUpRequestModel.kt @@ -1,6 +1,6 @@ package com.going.domain.entity.request -data class RequestSignUpModel( +data class SignUpRequestModel( val name: String, val intro: String, val platform: String, diff --git a/domain/src/main/kotlin/com/going/domain/entity/request/TendencyRequestModel.kt b/domain/src/main/kotlin/com/going/domain/entity/request/TendencyRequestModel.kt new file mode 100644 index 00000000..23255d7f --- /dev/null +++ b/domain/src/main/kotlin/com/going/domain/entity/request/TendencyRequestModel.kt @@ -0,0 +1,5 @@ +package com.going.domain.entity.request + +data class TendencyRequestModel( + val result: List +) diff --git a/domain/src/main/kotlin/com/going/domain/entity/response/OngoingListModel.kt b/domain/src/main/kotlin/com/going/domain/entity/response/OngoingListModel.kt index 64fd1b83..e132f47d 100644 --- a/domain/src/main/kotlin/com/going/domain/entity/response/OngoingListModel.kt +++ b/domain/src/main/kotlin/com/going/domain/entity/response/OngoingListModel.kt @@ -5,4 +5,4 @@ data class OngoingListModel( val startDate: String, val endDate: String, val day: Int -) \ No newline at end of file +) diff --git a/domain/src/main/kotlin/com/going/domain/entity/response/SignOutModel.kt b/domain/src/main/kotlin/com/going/domain/entity/response/SignOutModel.kt deleted file mode 100644 index 991849e2..00000000 --- a/domain/src/main/kotlin/com/going/domain/entity/response/SignOutModel.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.going.domain.entity.response - -data class SignOutModel( - val status: Int, - val message: String, -) diff --git a/domain/src/main/kotlin/com/going/domain/repository/AuthRepository.kt b/domain/src/main/kotlin/com/going/domain/repository/AuthRepository.kt index 4caa0966..c51d1d4c 100644 --- a/domain/src/main/kotlin/com/going/domain/repository/AuthRepository.kt +++ b/domain/src/main/kotlin/com/going/domain/repository/AuthRepository.kt @@ -1,18 +1,18 @@ package com.going.domain.repository -import com.going.domain.entity.request.RequestSignInModel -import com.going.domain.entity.request.RequestSignUpModel +import com.going.domain.entity.request.SignInRequestModel +import com.going.domain.entity.request.SignUpRequestModel import com.going.domain.entity.response.AuthTokenModel import com.going.domain.entity.response.SignInModel interface AuthRepository { suspend fun postSignIn( Authorization: String, - data: RequestSignInModel, + data: SignInRequestModel, ): Result suspend fun postSignUp( Authorization: String, - data: RequestSignUpModel, + data: SignUpRequestModel, ): Result } diff --git a/domain/src/main/kotlin/com/going/domain/repository/SettingRepository.kt b/domain/src/main/kotlin/com/going/domain/repository/SettingRepository.kt index 6220d7e9..8a8e6e2f 100644 --- a/domain/src/main/kotlin/com/going/domain/repository/SettingRepository.kt +++ b/domain/src/main/kotlin/com/going/domain/repository/SettingRepository.kt @@ -1,9 +1,7 @@ package com.going.domain.repository -import com.going.domain.entity.response.SignOutModel - interface SettingRepository { - suspend fun patchSignOut(): Result + suspend fun patchSignOut(): Result suspend fun deleteWithDraw(): Result } diff --git a/domain/src/main/kotlin/com/going/domain/repository/TendencyRepository.kt b/domain/src/main/kotlin/com/going/domain/repository/TendencyRepository.kt new file mode 100644 index 00000000..41b1ec5e --- /dev/null +++ b/domain/src/main/kotlin/com/going/domain/repository/TendencyRepository.kt @@ -0,0 +1,7 @@ +package com.going.domain.repository + +import com.going.domain.entity.request.TendencyRequestModel + +interface TendencyRepository { + suspend fun patchTendencyTest(result: TendencyRequestModel): Result +} diff --git a/presentation/src/main/java/com/going/presentation/onboarding/signin/SignInActivity.kt b/presentation/src/main/java/com/going/presentation/onboarding/signin/SignInActivity.kt index 48b75689..0219d53f 100644 --- a/presentation/src/main/java/com/going/presentation/onboarding/signin/SignInActivity.kt +++ b/presentation/src/main/java/com/going/presentation/onboarding/signin/SignInActivity.kt @@ -70,7 +70,7 @@ class SignInActivity : BaseActivity(R.layout.activity_sig private fun navigateToMainScreen() { // 추후 대시보드 연결시 연결 예정 - Intent(this, SettingActivity::class.java).apply { + Intent(this, TendencyTestSplashActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) startActivity(this) } diff --git a/presentation/src/main/java/com/going/presentation/onboarding/signin/SignInViewModel.kt b/presentation/src/main/java/com/going/presentation/onboarding/signin/SignInViewModel.kt index 88a20b99..f5d101e0 100644 --- a/presentation/src/main/java/com/going/presentation/onboarding/signin/SignInViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/onboarding/signin/SignInViewModel.kt @@ -3,7 +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.request.RequestSignInModel +import com.going.domain.entity.request.SignInRequestModel import com.going.domain.repository.AuthRepository import com.going.domain.repository.TokenRepository import com.going.presentation.util.toErrorCode @@ -71,7 +71,7 @@ class SignInViewModel @Inject constructor( _postChangeTokenState.value = SignInState.LOADING viewModelScope.launch { - authRepository.postSignIn(accessToken, RequestSignInModel(platform)).onSuccess { + authRepository.postSignIn(accessToken, SignInRequestModel(platform)).onSuccess { tokenRepository.setTokens(it.accessToken, it.refreshToken) if (it.isResult) { diff --git a/presentation/src/main/java/com/going/presentation/onboarding/signup/OnboardingProfileSettingViewModel.kt b/presentation/src/main/java/com/going/presentation/onboarding/signup/OnboardingProfileSettingViewModel.kt index 37fb9b51..66e8d154 100644 --- a/presentation/src/main/java/com/going/presentation/onboarding/signup/OnboardingProfileSettingViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/onboarding/signup/OnboardingProfileSettingViewModel.kt @@ -4,7 +4,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.going.domain.entity.NameState -import com.going.domain.entity.request.RequestSignUpModel +import com.going.domain.entity.request.SignUpRequestModel import com.going.domain.repository.AuthRepository import com.kakao.sdk.auth.AuthApiClient import com.kakao.sdk.auth.TokenManagerProvider @@ -84,7 +84,7 @@ class OnboardingProfileSettingViewModel @Inject constructor( viewModelScope.launch { authRepository.postSignUp( kakaoAccessToken, - RequestSignUpModel(name.value, info.value, KAKAO), + SignUpRequestModel(name.value, info.value, KAKAO), ).onSuccess { _isSignUpState.value = SignUpState.SUCCESS }.onFailure { diff --git a/presentation/src/main/java/com/going/presentation/onboarding/splash/SplashActivity.kt b/presentation/src/main/java/com/going/presentation/onboarding/splash/SplashActivity.kt index 0f77897d..54b5a48f 100644 --- a/presentation/src/main/java/com/going/presentation/onboarding/splash/SplashActivity.kt +++ b/presentation/src/main/java/com/going/presentation/onboarding/splash/SplashActivity.kt @@ -32,6 +32,8 @@ class SplashActivity : BaseActivity(R.layout.activity_spl private fun initSplash() { Handler(Looper.getMainLooper()).postDelayed({ + viewModel.clear() + if (viewModel.getHasAccessToken()) { navigateToMainScreen() } else { diff --git a/presentation/src/main/java/com/going/presentation/onboarding/splash/SplashViewModel.kt b/presentation/src/main/java/com/going/presentation/onboarding/splash/SplashViewModel.kt index 4858299c..911a4e10 100644 --- a/presentation/src/main/java/com/going/presentation/onboarding/splash/SplashViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/onboarding/splash/SplashViewModel.kt @@ -10,4 +10,5 @@ class SplashViewModel @Inject constructor( private val tokenRepository: TokenRepository, ) : ViewModel() { fun getHasAccessToken(): Boolean = tokenRepository.getAccessToken().isNotBlank() + fun clear() = tokenRepository.clearTokens() } diff --git a/presentation/src/main/java/com/going/presentation/setting/SettingLogoutDialogFragment.kt b/presentation/src/main/java/com/going/presentation/setting/SettingLogoutDialogFragment.kt index fc6fb3ec..0d67c32c 100644 --- a/presentation/src/main/java/com/going/presentation/setting/SettingLogoutDialogFragment.kt +++ b/presentation/src/main/java/com/going/presentation/setting/SettingLogoutDialogFragment.kt @@ -51,9 +51,10 @@ class SettingLogoutDialogFragment() : private fun observeUserSignOutState() { viewModel.userSignOutState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { + EnumUiState.LOADING -> {} EnumUiState.SUCCESS -> restartApp(requireContext()) EnumUiState.FAILURE -> toast(getString(R.string.server_error)) - EnumUiState.LOADING -> {} + EnumUiState.EMPTY -> {} } }.launchIn(lifecycleScope) } diff --git a/presentation/src/main/java/com/going/presentation/setting/SettingQuitDialogFragment.kt b/presentation/src/main/java/com/going/presentation/setting/SettingQuitDialogFragment.kt index b37b4c40..fa5a2243 100644 --- a/presentation/src/main/java/com/going/presentation/setting/SettingQuitDialogFragment.kt +++ b/presentation/src/main/java/com/going/presentation/setting/SettingQuitDialogFragment.kt @@ -57,9 +57,10 @@ class SettingQuitDialogFragment : private fun observeUserWithDrawState() { viewModel.userWithDrawState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { + EnumUiState.LOADING -> {} EnumUiState.SUCCESS -> restartApp(requireContext()) EnumUiState.FAILURE -> toast(getString(R.string.server_error)) - EnumUiState.LOADING -> {} + EnumUiState.EMPTY -> {} } }.launchIn(lifecycleScope) } diff --git a/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestActivity.kt b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestActivity.kt index 46175d74..1cbaf2f1 100644 --- a/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestActivity.kt +++ b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestActivity.kt @@ -2,6 +2,7 @@ package com.going.presentation.tendencytest import android.animation.Animator import android.animation.ObjectAnimator +import android.content.Intent import android.os.Bundle import android.view.animation.DecelerateInterpolator import android.widget.ProgressBar @@ -10,19 +11,24 @@ import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import com.going.presentation.R import com.going.presentation.databinding.ActivityTendencyTestBinding +import com.going.presentation.tendencytest.result.TendencyTestResultActivity import com.going.ui.base.BaseActivity +import com.going.ui.extension.EnumUiState import com.going.ui.extension.setOnSingleClickListener +import com.going.ui.extension.toast +import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +@AndroidEntryPoint class TendencyTestActivity : BaseActivity(R.layout.activity_tendency_test) { + private val viewModel by viewModels() + private lateinit var fadeInList: List private lateinit var fadeOutList: List - private val viewModel by viewModels() - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -31,6 +37,7 @@ class TendencyTestActivity : initFadeListener() initNextBtnClickListener() observeButtonSelected() + observeIsSubmitTendencyState() } private fun initBindingViewModel() { @@ -74,7 +81,7 @@ class TendencyTestActivity : object : Animator.AnimatorListener { override fun onAnimationStart(animation: Animator) { viewModel.clearAllChecked() - setProgressAnimate(binding.pbTendencyTest, viewModel.step.value + 1) + setProgressAnimate(binding.pbTendencyTest, viewModel.step.value) fadeOutList.map { it.start() } @@ -110,16 +117,12 @@ class TendencyTestActivity : private fun initNextBtnClickListener() { binding.btnTendencyNext.setOnSingleClickListener { when (viewModel.step.value) { - 9 -> moveTendencyTestResultActivity() + 9 -> viewModel.submitTendencyTest() else -> fadeOutList[0].start() } } } - private fun moveTendencyTestResultActivity() { - // 페이지 이동 기능 추가 예정 - } - private fun observeButtonSelected() { viewModel.isFirstChecked.flowWithLifecycle(lifecycle).onEach { binding.tvFirstAnswer.setTextAppearance(setFont(it)) @@ -144,6 +147,25 @@ class TendencyTestActivity : R.style.TextAppearance_Doorip_Body3_Medi } + private fun observeIsSubmitTendencyState() { + viewModel.isSubmitTendencyState.flowWithLifecycle(lifecycle).onEach { state -> + when (state) { + EnumUiState.LOADING -> {} + EnumUiState.SUCCESS -> navigateToTendencyTestResultScreen() + EnumUiState.FAILURE -> toast(getString(R.string.server_error)) + EnumUiState.EMPTY -> {} + } + }.launchIn(lifecycleScope) + } + + private fun navigateToTendencyTestResultScreen() { + Intent(this, TendencyTestResultActivity::class.java).apply { + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) + startActivity(this) + } + finish() + } + companion object { const val DURATION = 500L diff --git a/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestViewModel.kt b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestViewModel.kt index a69f66ab..1ae5eac1 100644 --- a/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestViewModel.kt @@ -2,10 +2,21 @@ package com.going.presentation.tendencytest import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope import com.going.domain.entity.TendencyTestMock +import com.going.domain.entity.request.TendencyRequestModel +import com.going.domain.repository.TendencyRepository +import com.going.ui.extension.EnumUiState +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.launch +import javax.inject.Inject -class TendencyTestViewModel : ViewModel() { +@HiltViewModel +class TendencyTestViewModel @Inject constructor( + private val tendencyRepository: TendencyRepository, +) : ViewModel() { val step = MutableStateFlow(1) val isChecked = MutableLiveData(false) val isFirstChecked = MutableStateFlow(false) @@ -13,71 +24,74 @@ class TendencyTestViewModel : ViewModel() { val isThirdChecked = MutableStateFlow(false) val isFourthChecked = MutableStateFlow(false) - val tendencyResultList: MutableList = MutableList(9) { 0 } + private val tendencyResultList: MutableList = MutableList(9) { 0 } + + private val _isSubmitTendencyState = MutableStateFlow(EnumUiState.EMPTY) + val isSubmitTendencyState: StateFlow = _isSubmitTendencyState val mockList: List = listOf( TendencyTestMock( - "1번 문항", - "1-1", - "1-2", - "1-3", - "1-4", + "어떤 여행지에 가시겠어요?", + "사람들이 많이 방문한 대중적인 곳", + "교통이 발달하고 치안이 좋아 안전한 곳", + "여기서만 경험할 수 있는 활동이 있는 곳", + "아무도 가보지 않은, 숨겨진 명소가 있는 곳", ), TendencyTestMock( - "2번 문항", - "2-1", - "2-2", - "2-3", - "2-4", + "여행을 가게 되면 먼저 할 일은?", + "예약 가능한 비행기 표와 숙소 알아보기", + "다른 사람이 다녀온 여행 후기 찾아보기", + "가고 싶은 맛집, 명소 찾아보기", + "여기에서만 할 수 있는 액티비티 찾아보기", ), TendencyTestMock( - "3번 문항", - "3-1", - "3-2", - "3-3", - "3-4", + "갑자기 특이한 메뉴를 추천받으면?", + "도전하기보다는 원래 정했던 메뉴를 주문한다", + "구글맵에 후기를 검색한다", + "한국에는 없잖아! 바로 주문한다", + "오히려 좋아. 더 추천해달라고 한다", ), TendencyTestMock( - "4번 문항", - "4-1", - "4-2", - "4-3", - "4-4", + "친구의 지인이 동행하자고 한다면?", + "새 친구랑 친해질 수 있는 기회! 너무 좋다", + "잘 맞으면 너무 좋을 것 같은데? 어떤 사람일까?", + "불편하지만 우선 고민해보겠다고 말한다", + "\"우리끼리 여행하는 게 좋아\" 라고 거절한다", ), TendencyTestMock( - "5번 문항", - "5-1", - "5-2", - "5-3", - "5-4", + "친구가 하루만 혼자 놀겠다 하면?", + "하고 싶은 걸 물어보고 일정을 바꾼다", + "보내주지만 속으로는 불만이 있을까 걱정한다", + "하고 싶은 게 있나 보다' 생각하며 보내준다", + "그럼 오늘은 각자 시간을 보내자고 제안한다", ), TendencyTestMock( - "6번 문항", - "6-1", - "6-2", - "6-3", - "6-4", + "여행 마지막 날 숙소에서 나는?", + "친구들과 함께 야식을 먹으며 이야기 나누기", + "아쉬우니까 같이 파티 타임 가질까?", + "다음 날의 일정을 위해 빠르게 잠에 들기", + "각자 핸드폰을 보며 개인 시간 보내기", ), TendencyTestMock( - "7번 문항", - "7-1", - "7-2", - "7-3", - "7-4", + "우연히 예쁜 소품샵을 발견했다면?", + "들어가면 일정에 차질이 생기는지 확인하기", + "가볼 만한 곳인지 검색해 보기", + "운명이라고 생각하며 사진부터 찍는다", + "일단 들어가서 이것저것 구경한다", ), TendencyTestMock( - "8번 문항", - "8-1", - "8-2", - "8-3", - "8-4", + "여행 계획을 세우는 방법은?", + "시간별 일정을 세우고 정해진 대로 움직이기", + "큰 계획만 세우고 상황 따라 일정 조정하기", + "가고 싶은 곳만 정하고 그때그때 선택하기", + "상황에 맞춰 무엇을 할지 즉흥으로 고민하기", ), TendencyTestMock( - "9번 문항", - "9-1", - "9-2", - "9-3", - "9-4", + "가려고 한 식당이 문을 닫았다면?", + "이미 영업시간을 체크해서 그런 일은 없다", + "다른 날에라도 갈 수 있게 일정을 조정한다", + "옆에 있는 다른 식당에 들어가 본다", + "이것도 추억이지 근처 가까운 식당으로 간다", ), ) @@ -91,10 +105,10 @@ class TendencyTestViewModel : ViewModel() { tendencyResultList[step.value - 1] = id when (id) { - 1 -> isFirstChecked.value = true - 2 -> isSecondChecked.value = true - 3 -> isThirdChecked.value = true - 4 -> isFourthChecked.value = true + 0 -> isFirstChecked.value = true + 1 -> isSecondChecked.value = true + 2 -> isThirdChecked.value = true + 3 -> isFourthChecked.value = true } } @@ -106,6 +120,18 @@ class TendencyTestViewModel : ViewModel() { isFourthChecked.value = false } + fun submitTendencyTest() { + viewModelScope.launch { + _isSubmitTendencyState.value = EnumUiState.LOADING + tendencyRepository.patchTendencyTest(TendencyRequestModel(tendencyResultList)) + .onSuccess { + _isSubmitTendencyState.value = EnumUiState.SUCCESS + }.onFailure { + _isSubmitTendencyState.value = EnumUiState.FAILURE + } + } + } + companion object { const val MAX_STEP = 9 } diff --git a/presentation/src/main/res/drawable/img_tendency_splash.png b/presentation/src/main/res/drawable/img_tendency_splash.png new file mode 100644 index 00000000..d6743b43 Binary files /dev/null and b/presentation/src/main/res/drawable/img_tendency_splash.png differ diff --git a/presentation/src/main/res/drawable/img_tendency_test.png b/presentation/src/main/res/drawable/img_tendency_test.png new file mode 100644 index 00000000..1fc7a759 Binary files /dev/null and b/presentation/src/main/res/drawable/img_tendency_test.png differ diff --git a/presentation/src/main/res/drawable/sel_full_button.xml b/presentation/src/main/res/drawable/sel_full_button.xml new file mode 100644 index 00000000..ddd1156f --- /dev/null +++ b/presentation/src/main/res/drawable/sel_full_button.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/presentation/src/main/res/layout/activity_tendency_test.xml b/presentation/src/main/res/layout/activity_tendency_test.xml index 46973157..074f8e59 100644 --- a/presentation/src/main/res/layout/activity_tendency_test.xml +++ b/presentation/src/main/res/layout/activity_tendency_test.xml @@ -87,7 +87,7 @@ android:layout_height="wrap_content" android:background="@color/transparent" android:clickable="true" - android:onClick="@{() -> viewModel.setCheckedValue(1)}" + android:onClick="@{() -> viewModel.setCheckedValue(0)}" android:text="@{viewModel.mockList.get(viewModel.step - 1).component2()}" android:textAppearance="@style/TextAppearance.Doorip.Body3.Medi" /> @@ -115,7 +115,7 @@ android:layout_height="wrap_content" android:background="@color/transparent" android:clickable="true" - android:onClick="@{() -> viewModel.setCheckedValue(2)}" + android:onClick="@{() -> viewModel.setCheckedValue(1)}" android:text="@{viewModel.mockList.get(viewModel.step - 1).component3()}" android:textAppearance="@style/TextAppearance.Doorip.Body3.Medi" /> @@ -143,7 +143,7 @@ android:layout_height="wrap_content" android:background="@color/transparent" android:clickable="true" - android:onClick="@{() -> viewModel.setCheckedValue(3)}" + android:onClick="@{() -> viewModel.setCheckedValue(2)}" android:text="@{viewModel.mockList.get(viewModel.step - 1).component4()}" android:textAppearance="@style/TextAppearance.Doorip.Body3.Medi" /> @@ -171,22 +171,29 @@ android:layout_height="wrap_content" android:background="@color/transparent" android:clickable="true" - android:onClick="@{() -> viewModel.setCheckedValue(4)}" + android:onClick="@{() -> viewModel.setCheckedValue(3)}" android:text="@{viewModel.mockList.get(viewModel.step - 1).component5()}" android:textAppearance="@style/TextAppearance.Doorip.Body3.Medi" /> + + + + - - - + + + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/tv_tendency_splash_title" /> @color/gray_700 false false - 1.0 + 1.2 - \ No newline at end of file + diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 9ab1c5ff..33ee8bb1 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -29,8 +29,9 @@ 유형 검사하러 가기 - 9개의 질문으로\n여행 성향을 분석해보세요 - 시작하기 + 여행을 할 때 우리는 어떤 모습일까? + 9개의 질문으로\n나를 대신 할 여행 캐릭터를 찾아보세요 + 테스트 시작하기 나의 여행 성향은?