Skip to content

Commit

Permalink
feat(recipeDetail): 레시피 상세 조회 네비게이팅 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongHoonC committed Jun 14, 2024
1 parent d3a02cc commit 40c0f76
Show file tree
Hide file tree
Showing 29 changed files with 481 additions and 366 deletions.
6 changes: 6 additions & 0 deletions Android/.idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import com.sundaegukbap.banchango.Recipe

interface RecipeRepository {
suspend fun getRecipeRecommendation(): Result<List<Recipe>>
suspend fun getRecipeDetail(id: Int): Result<Recipe>
suspend fun getRecipeDetail(id: Long): Result<Recipe>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sundaegukbap.banchango.core.data.di

import com.sundaegukbap.banchango.core.data.repository.DefaultRecipeRepository
import com.sundaegukbap.banchango.core.data.repository.FakeRecipeRepository
import com.sundaegukbap.banchango.core.data.repository.api.RecipeRepository
import dagger.Binds
import dagger.Module
Expand All @@ -12,5 +12,5 @@ import dagger.hilt.components.SingletonComponent
internal abstract class RepositoryModule {

@Binds
abstract fun bindsRecipeRepository(recipeRepository: DefaultRecipeRepository): RecipeRepository
abstract fun bindsRecipeRepository(recipeRepository: FakeRecipeRepository): RecipeRepository
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class DefaultRecipeRepository @Inject constructor(
}
}

override suspend fun getRecipeDetail(id: Int): Result<Recipe> {
override suspend fun getRecipeDetail(id: Long): Result<Recipe> {
return runCatching {
val response = recipeApi.getRecipeDetail(1, id.toLong())
if (response.isSuccessful) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.sundaegukbap.banchango.core.data.repository

import com.sundaegukbap.banchango.Recipe
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,
),

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<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,
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,67 @@ val Typography = Typography(
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
//val Cafe24SsurrroundBold14 = TextStyle(
// fontFamily = FontFamily(Font(R.font.cafe24_ssurrround)),
// fontWeight = FontWeight.Bold,
// fontSize = 14.sp,
// lineHeight = 22.sp,
// letterSpacing = 0.em
//)
//
//val InterBold14 = TextStyle(
// fontFamily = FontFamily(Font(R.font.inter)),
// fontWeight = FontWeight.Bold,
// fontSize = 14.sp,
// lineHeight = 22.sp,
// letterSpacing = 0.em
//)
//
//val MaruBuriBold20 = TextStyle(
// fontFamily = FontFamily(Font(R.font.maruburi)),
// fontWeight = FontWeight.Bold,
// fontSize = 20.sp,
// lineHeight = 22.sp,
// letterSpacing = 0.em
//)
//
//val MaruBuriRegular14 = TextStyle(
// fontFamily = FontFamily(Font(R.font.maruburi)),
// fontWeight = FontWeight.Normal,
// fontSize = 14.sp,
// lineHeight = 22.sp,
// letterSpacing = 0.em
//)
//
//val InterBold16 = TextStyle(
// fontFamily = FontFamily(Font(R.font.inter)),
// fontWeight = FontWeight.Bold,
// fontSize = 16.sp,
// lineHeight = 20.sp,
// letterSpacing = 0.em
//)
//
//val InterRegular12 = TextStyle(
// fontFamily = FontFamily(Font(R.font.inter)),
// fontWeight = FontWeight.Normal,
// fontSize = 12.sp,
// lineHeight = 22.sp,
// letterSpacing = 0.em
//)
//
//val InterSemiBold12 = TextStyle(
// fontFamily = FontFamily(Font(R.font.inter)),
// fontWeight = FontWeight.SemiBold,
// fontSize = 12.sp,
// lineHeight = 22.sp,
// letterSpacing = 0.em
//)
//
//val InterMedium10 = TextStyle(
// fontFamily = FontFamily(Font(R.font.inter)),
// fontWeight = FontWeight.Medium,
// fontSize = 10.sp,
// lineHeight = 22.sp,
// letterSpacing = 0.em
//)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable

sealed interface Route {
@Serializable
data class RecipeDetail(val recipeId: String) : Route
data class RecipeDetail(val recipeId: Long) : Route
}

sealed interface MainTabRoute : Route {
Expand Down
2 changes: 1 addition & 1 deletion Android/feature/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
implementation(project(":core:model"))
implementation(project(":core:designsystem"))
implementation(project(":core:navigation"))
implementation(project(":feature:reciperecommend"))
implementation(project(":feature:recipe"))
implementation(project(":feature:home"))

implementation(libs.androidx.core.ktx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import com.sundaegukbap.banchango.core.designsystem.theme.Orange
import kotlinx.collections.immutable.PersistentList

@Composable
Expand Down Expand Up @@ -100,13 +101,11 @@ private fun RowScope.MainBottomBarItem(
painter = painterResource(tab.iconResId),
contentDescription = tab.contentDescription,
tint = if (selected) {
Neon01
Orange
} else {
MaterialTheme.colorScheme.outline
},
modifier = Modifier.size(34.dp),
)
}
}

val Neon01 = Color(0xFF49F300)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navOptions
import com.sundaegukbap.banchango.feature.home.navigation.navigateHome
import com.sundaegukbap.banchango.feature.reciperecommend.navigation.navigateRecipeRecommend
import com.sundaegukbap.banchango.feature.recipe.navigation.navigateRecipeDetail
import com.sundaegukbap.banchango.feature.recipe.navigation.navigateRecipeRecommend
import com.sundaegukbap.banchango.navigation.MainTabRoute
import com.sundaegukbap.banchango.navigation.Route

Expand Down Expand Up @@ -43,6 +44,10 @@ internal class MainNavigator(
}
}

fun navigateRecipeDetail(recipeId: Long) {
navController.navigateRecipeDetail(recipeId)
}

private fun popBackStack() {
navController.popBackStack()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import com.sundaegukbap.banchango.feature.home.navigation.homeNavGraph
import com.sundaegukbap.banchango.feature.reciperecommend.navigation.recipeRecommendNavGraph
import com.sundaegukbap.banchango.feature.recipe.navigation.recipeNavGraph
import kotlinx.collections.immutable.toPersistentList

@Composable
Expand All @@ -29,7 +29,10 @@ internal fun MainScreen(
startDestination = navigator.startDestination
) {
homeNavGraph(padding = padding)
recipeRecommendNavGraph(padding = padding)
recipeNavGraph(
padding = padding,
onRecipeClick = { navigator.navigateRecipeDetail(it.id) }
)
}
}
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.sundaegukbap.banchango.feature.recipe.navigation

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import androidx.navigation.toRoute
import com.sundaegukbap.banchango.Recipe
import com.sundaegukbap.banchango.feature.recipe.recommend.RecipeRecommendRoute
import com.sundaegukbap.banchango.navigation.MainTabRoute
import com.sundaegukbap.banchango.navigation.Route

fun NavController.navigateRecipeRecommend(navOptions: NavOptions) {
navigate(MainTabRoute.RecipeRecommend, navOptions)
}

fun NavController.navigateRecipeDetail(recipeId: Long) {
navigate(Route.RecipeDetail(recipeId))

}

fun NavGraphBuilder.recipeNavGraph(
padding: PaddingValues,
onRecipeClick: (Recipe) -> Unit
) {
composable<MainTabRoute.RecipeRecommend> {
RecipeRecommendRoute(
padding = padding,
onRecipeClick = onRecipeClick
)
}

composable<Route.RecipeDetail> { navBackStackEntry ->
val recipeId = navBackStackEntry.toRoute<Route.RecipeDetail>().recipeId
Box(modifier = Modifier.fillMaxSize()) {
Text(text = "하이 $recipeId")
}
}
}
Loading

0 comments on commit 40c0f76

Please sign in to comment.