-
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(reciperecommend): 레시피 추천 화면 하단 로딩바 * refactor(data): RecipeRepository 코드 정리 * feat: 화면에 따라 상태 바를 다른 색으로 변경할 수 있다. * refactor: 사용하지 않는 코드 제거 * feat: 레시피 상세 화면 뼈대 작성 * feat(Stars): 별 개수에 따라 별이 그려지는 Composable 구현 * feat(RecipeDifficult): 레시피는 요리 난이도를 가진다 * feat(RecipeDifficult): 레시피 추천 난이도 화면을 그린다 * refactor: Recipe 상세 이동 버튼 분리 * feat: 레시피 상세 TopBar 생성 * feat: 좋아요 표시할 수 있는 레시피 객체 정의 * feat(RecipeRepository): RecipeRepository 에 좋아요를 요청할 수 있다 * feat(RecipeDetailCard): 레시피 상세 정보를 레시피 상세 전체 화면에서에서 분리한다 * feat(statusBarColor): systemBar 변경에서 statusBar 변경으로 바꾼다 * feat(RecipeDetailScreen): LikableRecipe 로 화면을 보여준다. * feat(RecipeDetailScreen): 상단까지 스크롤 하면 색깔이 변경되는 TopBar 를 구현한다 * feat(RecipeDetailScreen): Recipe 이미지에 그림자 그라데이션을 넣는다. * feat(RecipeDetailScreen): 보여주는 화면 크기를 네비게이션 바 전까지로 한다 * chore: gitIgnore 추가
- Loading branch information
1 parent
235e5c6
commit 3b6c362
Showing
30 changed files
with
992 additions
and
178 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 8 additions & 1 deletion
9
...api/src/main/java/com/sundaegukbap/banchango/core/data/repository/api/RecipeRepository.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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package com.sundaegukbap.banchango.core.data.repository.api | ||
|
||
import com.sundaegukbap.banchango.LikableRecipe | ||
import com.sundaegukbap.banchango.Recipe | ||
|
||
interface RecipeRepository { | ||
suspend fun getRecipeRecommendation(): Result<List<Recipe>> | ||
suspend fun getRecipeDetail(id: Long): Result<Recipe> | ||
|
||
suspend fun getRecipeDetail(id: Long): Result<LikableRecipe> | ||
|
||
suspend fun likeRecipe( | ||
id: Long, | ||
isLiked: Boolean, | ||
): Result<Unit> | ||
} |
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
1 change: 1 addition & 0 deletions
1
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
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
56 changes: 32 additions & 24 deletions
56
.../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 |
---|---|---|
@@ -1,39 +1,47 @@ | ||
package com.sundaegukbap.banchango.core.data.repository | ||
|
||
import com.sundaegukbap.banchango.LikableRecipe | ||
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") | ||
internal class DefaultRecipeRepository | ||
@Inject | ||
constructor( | ||
private val recipeApi: RecipeApi, | ||
) : RecipeRepository { | ||
override suspend fun getRecipeRecommendation(): Result<List<Recipe>> = | ||
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") | ||
} | ||
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") | ||
override suspend fun getRecipeDetail(id: Long): Result<LikableRecipe> = | ||
runCatching { | ||
val response = recipeApi.getRecipeDetail(1, id) | ||
if (response.isSuccessful) { | ||
if (response.body() == null) { | ||
throw IllegalStateException("Response body is null") | ||
} | ||
LikableRecipe(response.body()!!.toData(), false) | ||
} else { | ||
throw IllegalStateException("Response is not successful") | ||
} | ||
response.body()!!.toData() | ||
} else { | ||
throw IllegalStateException("Response is not successful") | ||
} | ||
|
||
override suspend fun likeRecipe( | ||
id: Long, | ||
isLiked: Boolean, | ||
): Result<Unit> { | ||
TODO("호감 기능 추가시 구현") | ||
} | ||
} | ||
} |
114 changes: 53 additions & 61 deletions
114
...ata/src/main/java/com/sundaegukbap/banchango/core/data/repository/FakeRecipeRepository.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 |
---|---|---|
@@ -1,72 +1,64 @@ | ||
package com.sundaegukbap.banchango.core.data.repository | ||
|
||
import com.sundaegukbap.banchango.LikableRecipe | ||
import com.sundaegukbap.banchango.Recipe | ||
import com.sundaegukbap.banchango.RecipeDifficulty | ||
import com.sundaegukbap.banchango.core.data.repository.api.RecipeRepository | ||
import javax.inject.Inject | ||
|
||
class FakeRecipeRepository @Inject constructor() : RecipeRepository { | ||
override suspend fun getRecipeRecommendation(): Result<List<Recipe>> { | ||
return Result.success( | ||
listOf( | ||
Recipe( | ||
id = 1, | ||
name = "간장계란볶음밥", | ||
introduction = "아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요. 아이들이 더 좋아할거예요.", | ||
image = "https://recipe1.ezmember.co.kr/cache/recipe/2018/05/26/d0c6701bc673ac5c18183b47212a58571.jpg", | ||
link = "https://www.10000recipe.com/recipe/6889616", | ||
cookingTime = 10, | ||
servings = 2, | ||
difficulty = "Easy", | ||
have = listOf(""), | ||
need = listOf(""), | ||
isBookmarked = false, | ||
), | ||
Recipe( | ||
id = 2, | ||
name = "간장계란볶음밥", | ||
introduction = "아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요. 아이들이 더 좋아할거예요.", | ||
image = "https://recipe1.ezmember.co.kr/cache/recipe/2018/05/26/d0c6701bc673ac5c18183b47212a58571.jpg", | ||
link = "https://www.10000recipe.com/recipe/6889616", | ||
cookingTime = 10, | ||
servings = 2, | ||
difficulty = "Easy", | ||
have = listOf(""), | ||
need = listOf(""), | ||
isBookmarked = false, | ||
), | ||
class FakeRecipeRepository | ||
@Inject | ||
constructor() : RecipeRepository { | ||
override suspend fun getRecipeRecommendation(): Result<List<Recipe>> = | ||
Result.success( | ||
List(3) { | ||
Recipe( | ||
id = (it + 1).toLong(), | ||
name = "간장계란볶음밥", | ||
introduction = "아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요. 아이들이 더 좋아할거예요.", | ||
image = "https://recipe1.ezmember.co.kr/cache/recipe/2018/05/26/d0c6701bc673ac5c18183b47212a58571.jpg", | ||
link = "https://www.10000recipe.com/recipe/6889616", | ||
cookingTime = 10, | ||
servings = 2, | ||
difficulty = RecipeDifficulty.BEGINNER, | ||
have = listOf("계란", "간장"), | ||
need = listOf("식초", "당근", "감자"), | ||
) | ||
}, | ||
) | ||
|
||
Recipe( | ||
id = 3, | ||
name = "간장계란볶음밥", | ||
introduction = "아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요. 아이들이 더 좋아할거예요.", | ||
image = "https://recipe1.ezmember.co.kr/cache/recipe/2018/05/26/d0c6701bc673ac5c18183b47212a58571.jpg", | ||
link = "https://www.10000recipe.com/recipe/6889616", | ||
cookingTime = 10, | ||
servings = 2, | ||
difficulty = "Easy", | ||
have = listOf(""), | ||
need = listOf(""), | ||
isBookmarked = false, | ||
override suspend fun getRecipeDetail(id: Long): Result<LikableRecipe> = | ||
Result.success( | ||
LikableRecipe( | ||
recipe = | ||
Recipe( | ||
id = id, | ||
name = "간장계란볶음밥", | ||
introduction = | ||
"아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요. 아이들이 더 좋아할거예요." + | ||
"아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요. \n " + | ||
"아이들이 더 좋아할거예요. \n" + | ||
"아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요.\n" + | ||
" 아이들이 더 좋아할거예요.\n" + | ||
" 아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요.\n 아이들이 더 좋아할거예요.\n " + | ||
"아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요.\n 아이들이 더 좋아할거예요.\n " + | ||
"아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요.\n 아이들이 더 좋아할거예요.\n" + | ||
" 아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요.\n 아이들이 더 좋아할거예요.\n " + | ||
"아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요.\n 아이들이 더 좋아할거예요.\n", | ||
image = "https://recipe1.ezmember.co.kr/cache/recipe/2018/05/26/d0c6701bc673ac5c18183b47212a58571.jpg", | ||
link = "https://www.10000recipe.com/recipe/6889616", | ||
cookingTime = 10, | ||
servings = 2, | ||
difficulty = RecipeDifficulty.BEGINNER, | ||
have = listOf("계란", "간장"), | ||
need = listOf("식초", "당근", "감자"), | ||
), | ||
isLiked = false, | ||
), | ||
) | ||
) | ||
} | ||
|
||
override suspend fun getRecipeDetail(id: Long): Result<Recipe> { | ||
return Result.success( | ||
Recipe( | ||
id = id, | ||
name = "간장계란볶음밥", | ||
introduction = "아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요. 아이들이 더 좋아할거예요.", | ||
image = "https://recipe1.ezmember.co.kr/cache/recipe/2018/05/26/d0c6701bc673ac5c18183b47212a58571.jpg", | ||
link = "https://www.10000recipe.com/recipe/6889616", | ||
cookingTime = 10, | ||
servings = 2, | ||
difficulty = "Easy", | ||
have = listOf(""), | ||
need = listOf(""), | ||
isBookmarked = false, | ||
) | ||
) | ||
override suspend fun likeRecipe( | ||
id: Long, | ||
isLiked: Boolean, | ||
): Result<Unit> = Result.success(Unit) | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
Android/core/model/src/main/java/com/sundaegukbap/banchango/LikableRecipe.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 com.sundaegukbap.banchango | ||
|
||
data class LikableRecipe( | ||
val recipe: Recipe, | ||
val isLiked: Boolean, | ||
) |
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
9 changes: 9 additions & 0 deletions
9
Android/core/model/src/main/java/com/sundaegukbap/banchango/RecipeDifficulty.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,9 @@ | ||
package com.sundaegukbap.banchango | ||
|
||
enum class RecipeDifficulty(val level: Int, val explain: String) { | ||
ANYONE(1, "아무나"), | ||
BEGINNER(2, "초보"), | ||
INTERMEDIATE(3, "중급"), | ||
ADVANCED(4, "고급"), | ||
GODLIKE(5, "신의 경지"), | ||
} |
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
Oops, something went wrong.