diff --git a/build-logic/convention/src/main/java/kr/genti/convention/Constants.kt b/build-logic/convention/src/main/java/kr/genti/convention/Constants.kt index a1891e3..350ca45 100644 --- a/build-logic/convention/src/main/java/kr/genti/convention/Constants.kt +++ b/build-logic/convention/src/main/java/kr/genti/convention/Constants.kt @@ -9,7 +9,7 @@ object Constants { const val minSdk = 28 const val targetSdk = 34 - const val versionCode = 20 + const val versionCode = 21 const val versionName = "2.1.0" const val jvmVersion = "17" diff --git a/data/src/main/java/kr/genti/data/dataSource/CreateDataSource.kt b/data/src/main/java/kr/genti/data/dataSource/CreateDataSource.kt index 4a8ee18..f0c0b28 100644 --- a/data/src/main/java/kr/genti/data/dataSource/CreateDataSource.kt +++ b/data/src/main/java/kr/genti/data/dataSource/CreateDataSource.kt @@ -22,7 +22,7 @@ interface CreateDataSource { suspend fun postToVerify(request: KeyRequestDto): BaseResponse - suspend fun getPromptExample(): BaseResponse> + suspend fun getPromptExample(type: String): BaseResponse> suspend fun postToValidatePurchase(request: PurchaseValidRequestDto): BaseResponse } diff --git a/data/src/main/java/kr/genti/data/dataSourceImpl/CreateDataSourceImpl.kt b/data/src/main/java/kr/genti/data/dataSourceImpl/CreateDataSourceImpl.kt index d29961b..3a800fa 100644 --- a/data/src/main/java/kr/genti/data/dataSourceImpl/CreateDataSourceImpl.kt +++ b/data/src/main/java/kr/genti/data/dataSourceImpl/CreateDataSourceImpl.kt @@ -35,8 +35,8 @@ constructor( override suspend fun postToVerify(request: KeyRequestDto): BaseResponse = createService.postToVerify(request) - override suspend fun getPromptExample(): BaseResponse> = - createService.getPromptExample() + override suspend fun getPromptExample(type: String): BaseResponse> = + createService.getPromptExample(type) override suspend fun postToValidatePurchase(request: PurchaseValidRequestDto): BaseResponse = createService.postToValidatePurchase(request) diff --git a/data/src/main/java/kr/genti/data/repositoryImpl/CreateRepositoryImpl.kt b/data/src/main/java/kr/genti/data/repositoryImpl/CreateRepositoryImpl.kt index 4315dae..bcbbb7b 100644 --- a/data/src/main/java/kr/genti/data/repositoryImpl/CreateRepositoryImpl.kt +++ b/data/src/main/java/kr/genti/data/repositoryImpl/CreateRepositoryImpl.kt @@ -51,9 +51,9 @@ constructor( createDataSource.postToVerify(request.toDto()).response } - override suspend fun getPromptExample(): Result> = + override suspend fun getPromptExample(type: String): Result> = runCatching { - createDataSource.getPromptExample().response.map { it.toModel() } + createDataSource.getPromptExample(type).response.map { it.toModel() } } override suspend fun postToValidatePurchase(request: PurchaseValidRequestModel): Result = diff --git a/data/src/main/java/kr/genti/data/service/CreateService.kt b/data/src/main/java/kr/genti/data/service/CreateService.kt index 7ff94fc..997d53f 100644 --- a/data/src/main/java/kr/genti/data/service/CreateService.kt +++ b/data/src/main/java/kr/genti/data/service/CreateService.kt @@ -11,6 +11,7 @@ import kr.genti.data.dto.response.S3PresignedUrlDto import retrofit2.http.Body import retrofit2.http.GET import retrofit2.http.POST +import retrofit2.http.Path interface CreateService { @POST("api/v1/presigned-url") @@ -43,8 +44,10 @@ interface CreateService { @Body request: KeyRequestDto, ): BaseResponse - @GET("api/v1/users/examples/with-picture-square") - suspend fun getPromptExample(): BaseResponse> + @GET("api/v1/users/examples/with-picture-square/{type}") + suspend fun getPromptExample( + @Path("type") type: String + ): BaseResponse> @POST("api/v1/users/in-app-purchases/google/receipt-validation") suspend fun postToValidatePurchase( diff --git a/domain/src/main/kotlin/kr/genti/domain/repository/CreateRepository.kt b/domain/src/main/kotlin/kr/genti/domain/repository/CreateRepository.kt index 8c48933..241790f 100644 --- a/domain/src/main/kotlin/kr/genti/domain/repository/CreateRepository.kt +++ b/domain/src/main/kotlin/kr/genti/domain/repository/CreateRepository.kt @@ -21,7 +21,7 @@ interface CreateRepository { suspend fun postToVerify(request: KeyRequestModel): Result - suspend fun getPromptExample(): Result> + suspend fun getPromptExample(type: String): Result> suspend fun postToValidatePurchase(request: PurchaseValidRequestModel): Result } diff --git a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt index d756915..7299d6c 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/CreateViewModel.kt @@ -73,10 +73,6 @@ constructor( private var firstImageS3KeyList = listOf() private var secondImageS3KeyList = listOf() - init { - // getExamplePrompt() - } - fun modCurrentPercent(amount: Int) { _currentPercent.value += amount } @@ -116,11 +112,16 @@ constructor( _totalGeneratingState.value = UiState.Empty } - private fun getExamplePrompt() { + fun getExamplePrompt() { _getExampleState.value = UiState.Loading + val currentType = when { + !isCreatingParentPic -> TYPE_FREE_ONE + selectedNumber.value == PictureNumber.ONE -> TYPE_PAID_ONE + else -> TYPE_PAID_TWO + } viewModelScope.launch { runCatching { - createRepository.getPromptExample() + createRepository.getPromptExample(currentType) }.onSuccess { _getExampleState.value = UiState.Success(it.getOrThrow()) }.onFailure { @@ -265,5 +266,9 @@ constructor( companion object { const val VALIDATION_FALSE = "VALIDATION_FALSE" const val SERVER_ERROR = "SERVER_ERROR" + + const val TYPE_FREE_ONE = "FREE_ONE" + const val TYPE_PAID_ONE = "PAID_ONE" + const val TYPE_PAID_TWO = "PAID_TWO" } } diff --git a/presentation/src/main/java/kr/genti/presentation/create/DefineFragment.kt b/presentation/src/main/java/kr/genti/presentation/create/DefineFragment.kt index cac132c..8a2816f 100644 --- a/presentation/src/main/java/kr/genti/presentation/create/DefineFragment.kt +++ b/presentation/src/main/java/kr/genti/presentation/create/DefineFragment.kt @@ -49,6 +49,7 @@ class DefineFragment() : BaseFragment(R.layout.fragment_d private fun initView() { binding.vm = viewModel + viewModel.getExamplePrompt() } private fun initCreateBtnListener() { @@ -118,19 +119,17 @@ class DefineFragment() : BaseFragment(R.layout.fragment_d } private fun observeGetExampleState() { - viewModel.getExampleState - .flowWithLifecycle(lifecycle) - .onEach { state -> - when (state) { - is UiState.Success -> { - adapter.submitList(state.data) - binding.dotIndicator.setViewPager(binding.vpCreateRandom) - } - - is UiState.Failure -> toast(stringOf(R.string.error_msg)) - else -> return@onEach + viewModel.getExampleState.flowWithLifecycle(lifecycle).onEach { state -> + when (state) { + is UiState.Success -> { + adapter.submitList(state.data) + binding.dotIndicator.setViewPager(binding.vpCreateRandom) } - }.launchIn(lifecycleScope) + + is UiState.Failure -> toast(stringOf(R.string.error_msg)) + else -> return@onEach + } + }.launchIn(lifecycleScope) } } diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index f023c36..ce8b080 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -154,7 +154,7 @@ 내가 만든 사진 아직 내가 만든 사진이 없어요. 세상에 하나뿐인 나만의 사진을 만들어보세요! - 사진이 저장되었어요\n친구들에게 공유해보세요! + 사진이 저장되었어요 설정 이용 약관