-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: data 모듈 생성 및 의존성 정의 * feat(recipe): 레시피 추천 저장소 & api 구현 * feat(recipeRecommend): 레시피 추천 화면을 그린다 * feat(RecipeUiState): 레시피 추천 아이템을 정의한다 * feat(RecipeRecommend): 레시피 추천 VerticalPager 애니메이션 구현 * feat: Main Screen 을 start destination 으로 변경 * feat(data): 레시피 Response mapper 정의 * feat(designsystem): Color 추가 * feat(reciperecommend): 무한스크롤 추가 * feat(recipeDetail): 레시피 상세 조회 api 사용 * feat(recipeDetail): 레시피 상세 조회 네비게이팅 구현 * feat(RecipeRecommend): 레시피 추천 목록에서 좋아요와 재료 목록을 확인할 수 있다 * feat(core): setting Kotlin Jvm build
- Loading branch information
1 parent
896a692
commit 5f11142
Showing
53 changed files
with
1,082 additions
and
267 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
File renamed without changes.
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,68 @@ | ||
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties | ||
|
||
plugins { | ||
alias(libs.plugins.android.library) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
alias(libs.plugins.hilt) | ||
alias(libs.plugins.org.jetbrains.kotlin.kapt) | ||
alias(libs.plugins.kotlin.serialization) | ||
} | ||
|
||
android { | ||
namespace = "com.sundaegukbap.banchango.core.data" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
minSdk = 28 | ||
buildConfigField("String", "BASE_URL", getSecretKey("base_url")) | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
buildFeatures { | ||
buildConfig = true | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
// modules | ||
implementation(project(":core:model")) | ||
implementation(project(":core:data-api")) | ||
|
||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.appcompat) | ||
implementation(libs.material) | ||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.androidx.junit) | ||
androidTestImplementation(libs.androidx.espresso.core) | ||
|
||
// hilt | ||
implementation(libs.dagger.hilt.android) | ||
kapt(libs.dagger.hilt.compiler) | ||
|
||
// okhttp3 | ||
implementation(libs.okhttp3.okhttp) | ||
implementation(libs.retrofit2.kotlinx.serialization.converter) | ||
implementation(libs.kotlinx.serialization.json) | ||
} | ||
|
||
fun getSecretKey(propertyKey: String): String { | ||
return gradleLocalProperties(rootDir, providers).getProperty(propertyKey) | ||
} |
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest /> | ||
|
19 changes: 19 additions & 0 deletions
19
Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/api/RecipeApi.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,19 @@ | ||
package com.sundaegukbap.banchango.core.data.api | ||
|
||
import com.sundaegukbap.banchango.core.data.api.model.RecipeRecommendResponse | ||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
internal interface RecipeApi { | ||
@GET("api/recipe/recommand/{userId}") | ||
suspend fun getRecipeRecommendation( | ||
@Path("userId") userId: Long | ||
): Response<List<RecipeRecommendResponse>> | ||
|
||
@GET("api/recipe/{userId}/{recipeId}") | ||
suspend fun getRecipeDetail( | ||
@Path("userId") userId: Long, | ||
@Path("recipeId") recipeId: Long | ||
): Response<RecipeRecommendResponse> | ||
} |
8 changes: 8 additions & 0 deletions
8
...a/src/main/java/com/sundaegukbap/banchango/core/data/api/model/RecipeRecommendResponse.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,8 @@ | ||
package com.sundaegukbap.banchango.core.data.api.model | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RecipeRecommendsResponse( | ||
val recipeRecommends: List<RecipeRecommendResponse> | ||
) |
18 changes: 18 additions & 0 deletions
18
...c/main/java/com/sundaegukbap/banchango/core/data/api/model/RecipeRecommendResponseItem.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 com.sundaegukbap.banchango.core.data.api.model | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RecipeRecommendResponse( | ||
val id: Long, | ||
val name: String, | ||
val introduction: String, | ||
val image: String, | ||
val link: String, | ||
val have: List<String>, | ||
val need: List<String>, | ||
val servings: Int, | ||
val cookingTime: Int, | ||
val isBookmarked: Boolean, | ||
val difficulty: String | ||
) |
58 changes: 58 additions & 0 deletions
58
Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/ApiModule.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,58 @@ | ||
package com.sundaegukbap.banchango.core.data.di | ||
|
||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import com.sundaegukbap.banchango.core.data.BuildConfig | ||
import com.sundaegukbap.banchango.core.data.api.RecipeApi | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import retrofit2.Retrofit | ||
import javax.inject.Qualifier | ||
import javax.inject.Singleton | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class BaseUrlQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class DefaultRetrofitQualifier | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal object ApiModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun provideRetrofitConverterFactory(): retrofit2.Converter.Factory { | ||
val json = Json { | ||
ignoreUnknownKeys = true | ||
} | ||
return json.asConverterFactory("application/json".toMediaType()) | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
@DefaultRetrofitQualifier | ||
fun providesDefaultRetrofit( | ||
@BaseUrlQualifier baseUrl: String, | ||
converterFactory: retrofit2.Converter.Factory, | ||
): Retrofit = Retrofit.Builder() | ||
.baseUrl(baseUrl) | ||
.addConverterFactory(converterFactory) | ||
.build() | ||
|
||
@Provides | ||
@Singleton | ||
@BaseUrlQualifier | ||
fun providesBaseUrl(): String = BuildConfig.BASE_URL | ||
|
||
@Provides | ||
@Singleton | ||
fun providesRecipeRecommendApi( | ||
@DefaultRetrofitQualifier retrofit: Retrofit | ||
): RecipeApi = retrofit.create(RecipeApi::class.java) | ||
} |
16 changes: 16 additions & 0 deletions
16
Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/RepositoryModule.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,16 @@ | ||
package com.sundaegukbap.banchango.core.data.di | ||
|
||
import com.sundaegukbap.banchango.core.data.repository.FakeRecipeRepository | ||
import com.sundaegukbap.banchango.core.data.repository.api.RecipeRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
internal abstract class RepositoryModule { | ||
|
||
@Binds | ||
abstract fun bindsRecipeRepository(recipeRepository: FakeRecipeRepository): RecipeRepository | ||
} |
22 changes: 22 additions & 0 deletions
22
Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/mapper/RecipeMapper.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,22 @@ | ||
package com.sundaegukbap.banchango.core.data.mapper | ||
|
||
import com.sundaegukbap.banchango.Recipe | ||
import com.sundaegukbap.banchango.core.data.api.model.RecipeRecommendResponse | ||
|
||
internal fun List<RecipeRecommendResponse>.toData(): List<Recipe> = map { it.toData() } | ||
|
||
internal fun RecipeRecommendResponse.toData(): Recipe { | ||
return Recipe( | ||
id = id, | ||
name = name, | ||
introduction = introduction, | ||
image = image, | ||
link = link, | ||
have = have, | ||
need = need, | ||
servings = servings, | ||
cookingTime = cookingTime, | ||
isBookmarked = isBookmarked, | ||
difficulty = difficulty, | ||
) | ||
} |
39 changes: 39 additions & 0 deletions
39
.../src/main/java/com/sundaegukbap/banchango/core/data/repository/DefaultRecipeRepository.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,39 @@ | ||
package com.sundaegukbap.banchango.core.data.repository | ||
|
||
import com.sundaegukbap.banchango.Recipe | ||
import com.sundaegukbap.banchango.core.data.api.RecipeApi | ||
import com.sundaegukbap.banchango.core.data.mapper.toData | ||
import com.sundaegukbap.banchango.core.data.repository.api.RecipeRepository | ||
import javax.inject.Inject | ||
|
||
internal class DefaultRecipeRepository @Inject constructor( | ||
private val recipeApi: RecipeApi, | ||
) : RecipeRepository { | ||
override suspend fun getRecipeRecommendation(): Result<List<Recipe>> { | ||
return runCatching { | ||
val response = recipeApi.getRecipeRecommendation(1) | ||
if (response.isSuccessful) { | ||
if (response.body() == null) { | ||
throw IllegalStateException("Response body is null") | ||
} | ||
response.body()!!.toData() | ||
} else { | ||
throw IllegalStateException("Response is not successful") | ||
} | ||
} | ||
} | ||
|
||
override suspend fun getRecipeDetail(id: Long): Result<Recipe> { | ||
return runCatching { | ||
val response = recipeApi.getRecipeDetail(1, id.toLong()) | ||
if (response.isSuccessful) { | ||
if (response.body() == null) { | ||
throw IllegalStateException("Response body is null") | ||
} | ||
response.body()!!.toData() | ||
} else { | ||
throw IllegalStateException("Response is not successful") | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.