From 9467d05af5cb9e0a0e0657731ffe6a552098af0a Mon Sep 17 00:00:00 2001 From: vrexpert Date: Sat, 15 Jun 2024 16:18:32 +0900 Subject: [PATCH 01/19] =?UTF-8?q?feat(reciperecommend):=20=EB=A0=88?= =?UTF-8?q?=EC=8B=9C=ED=94=BC=20=EC=B6=94=EC=B2=9C=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=ED=95=98=EB=8B=A8=20=EB=A1=9C=EB=94=A9=EB=B0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Android/.idea/deploymentTargetSelector.xml | 8 +++ .../recommend/RecipeRecommendViewModel.kt | 16 ++---- .../recommend/RecipesRecommendScreen.kt | 56 ++++++++++++------- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/Android/.idea/deploymentTargetSelector.xml b/Android/.idea/deploymentTargetSelector.xml index c4abe25..16e0a13 100644 --- a/Android/.idea/deploymentTargetSelector.xml +++ b/Android/.idea/deploymentTargetSelector.xml @@ -4,6 +4,14 @@ - - diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipeRecommendViewModel.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipeRecommendViewModel.kt index a546129..9a31afd 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipeRecommendViewModel.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipeRecommendViewModel.kt @@ -26,7 +26,6 @@ class RecipeRecommendViewModel @Inject constructor( val remainRecipes = (_uiState.value as? RecipeRecommendUiState.Success)?.recipes ?: listOf() viewModelScope.launch { - delay(5000) recipeRepository.getRecipeRecommendation() .onSuccess { recipes -> _uiState.value = RecipeRecommendUiState.Success( @@ -51,11 +50,8 @@ class RecipeRecommendViewModel @Inject constructor( } private fun List.toUiState(): List { - return mapIndexed { index, recipe -> - RecipeRecommendItemUiState( - recipe = recipe.copy(name = recipe.name + index.toString()), - isLiked = false, - ) + return map { recipe -> + RecipeRecommendItemUiState(recipe = recipe, isLiked = false) } } } From ee8adfc40c108c4aaa95c47d63560c2abf426d86 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Sun, 16 Jun 2024 14:15:48 +0900 Subject: [PATCH 05/19] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=ED=99=94=EB=A9=B4=20=EB=BC=88=EB=8C=80=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe/detail/RecipeDetailScreen.kt | 225 ++++++++++++++++++ .../recipe/detail/RecipeDetailUiState.kt | 9 + .../recipe/detail/RecipeDetailViewModel.kt | 31 +++ 3 files changed, 265 insertions(+) create mode 100644 Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt create mode 100644 Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailUiState.kt create mode 100644 Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailViewModel.kt diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt new file mode 100644 index 0000000..eeae9e5 --- /dev/null +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt @@ -0,0 +1,225 @@ +package com.sundaegukbap.banchango.feature.recipe.detail + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.BottomSheetScaffold +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.SheetValue +import androidx.compose.material3.Text +import androidx.compose.material3.rememberBottomSheetScaffoldState +import androidx.compose.material3.rememberStandardBottomSheetState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.sundaegukbap.banchango.Recipe +import com.sundaegukbap.banchango.core.designsystem.component.NetworkImage + +@Composable +fun RecipeDetailRoute( + recipeId: Long, + modifier: Modifier = Modifier, + onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit, + viewModel: RecipeDetailViewModel = hiltViewModel(), +) { + val uiState by viewModel.uiState.collectAsStateWithLifecycle() + + LaunchedEffect(Unit) { + viewModel.getRecipeDetail(recipeId) + } + + RecipeDetailContent( + uiState = uiState, + modifier = modifier, + onChangeSystemBarsColor = onChangeSystemBarsColor, + ) +} + +@Composable +fun RecipeDetailContent( + uiState: RecipeDetailUiState, + onShowErrorSnackBar: (throwable: Throwable?) -> Unit = {}, + onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit, + modifier: Modifier = Modifier, +) { + when (uiState) { + is RecipeDetailUiState.Loading -> { + RecipeDetailLoading() + } + + is RecipeDetailUiState.Success -> { + onChangeSystemBarsColor(Color.Transparent, false) + RecipeDetailScreen(recipe = uiState.recipe, modifier = modifier) + } + + is RecipeDetailUiState.Error -> { + onShowErrorSnackBar(uiState.throwable) + } + } +} + +@Composable +fun RecipeDetailLoading() { + Box( + modifier = Modifier.fillMaxSize(), + contentAlignment = Alignment.Center + ) { + CircularProgressIndicator() + } +} + + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun RecipeDetailScreen( + recipe: Recipe, + modifier: Modifier = Modifier +) { + val scaffoldState = rememberBottomSheetScaffoldState( + rememberStandardBottomSheetState(initialValue = SheetValue.PartiallyExpanded) + ) + + val screenHeight = LocalConfiguration.current.screenHeightDp.dp + + Box( + modifier = modifier.fillMaxSize() + ) { + NetworkImage( + url = recipe.image, + modifier = Modifier + .fillMaxWidth() + .height(screenHeight * 0.5f) + .align(Alignment.TopCenter), + ) + BottomSheetScaffold( + scaffoldState = scaffoldState, + sheetContent = { + RecipeDetailInfo( + recipe = recipe, + modifier = Modifier + ) + }, + modifier = Modifier.background(Color.White), + sheetPeekHeight = screenHeight * 0.7f, + ) {} + } +} + +@Composable +fun RecipeDetailInfo( + recipe: Recipe, + modifier: Modifier = Modifier +) { + Box( + modifier = modifier.fillMaxSize() + ) { + + Column( + Modifier.padding(horizontal = 16.dp) + ) { + + Text( + text = recipe.name, + fontSize = 20.sp, + fontWeight = FontWeight.Bold + ) + + Text( + text = recipe.introduction, + fontSize = 12.sp, + modifier = Modifier.padding(top = 12.dp) + ) + + Text( + text = "식재료", + fontSize = 12.sp, + fontWeight = FontWeight.Bold, + modifier = Modifier.padding(top = 24.dp) + ) + + LazyRow( + modifier = Modifier.padding(top = 16.dp), + horizontalArrangement = Arrangement.spacedBy(24.dp), + ) { + items(recipe.have) { + Box( + modifier = Modifier.background(color = Color.Gray, shape = CircleShape) + ) { + Text(modifier = Modifier.padding(16.dp), text = it) + } + } + } + + LazyRow( + modifier = Modifier.padding(top = 16.dp), + horizontalArrangement = Arrangement.spacedBy(24.dp), + ) { + items(recipe.need) { + Box(modifier = Modifier.background(color = Color.Gray, shape = CircleShape)) { + Text(modifier = Modifier.padding(16.dp), text = it) + } + } + } + + } + } +} + +@Preview(showBackground = true) +@Composable +fun RecipeDetailInfoPreview() { + RecipeDetailInfo( + recipe = 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, + ), + ) +} + +@Preview(showBackground = true) +@Composable +fun RecipeDetailScreenPreview() { + RecipeDetailScreen( + recipe = 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, + ), + ) +} diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailUiState.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailUiState.kt new file mode 100644 index 0000000..2407997 --- /dev/null +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailUiState.kt @@ -0,0 +1,9 @@ +package com.sundaegukbap.banchango.feature.recipe.detail + +import com.sundaegukbap.banchango.Recipe + +sealed interface RecipeDetailUiState { + data object Loading : RecipeDetailUiState + data class Success(val recipe: Recipe) : RecipeDetailUiState + data class Error(val throwable: Throwable) : RecipeDetailUiState +} diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailViewModel.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailViewModel.kt new file mode 100644 index 0000000..848e9f8 --- /dev/null +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailViewModel.kt @@ -0,0 +1,31 @@ +package com.sundaegukbap.banchango.feature.recipe.detail + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.sundaegukbap.banchango.core.data.repository.api.RecipeRepository +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class RecipeDetailViewModel @Inject constructor( + private val recipeRepository: RecipeRepository +) : ViewModel() { + private val _uiState: MutableStateFlow = + MutableStateFlow(RecipeDetailUiState.Loading) + val uiState: StateFlow = _uiState.asStateFlow() + + fun getRecipeDetail(recipeId: Long) { + viewModelScope.launch { + recipeRepository.getRecipeDetail(recipeId) + .onSuccess { recipe -> + _uiState.value = RecipeDetailUiState.Success(recipe) + }.onFailure { throwable -> + _uiState.value = RecipeDetailUiState.Error(throwable) + } + } + } +} From 0bef42243bac83094fd324be4333fda6fe142180 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Sun, 16 Jun 2024 20:05:08 +0900 Subject: [PATCH 06/19] =?UTF-8?q?feat(Stars):=20=EB=B3=84=20=EA=B0=9C?= =?UTF-8?q?=EC=88=98=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EB=B3=84=EC=9D=B4=20?= =?UTF-8?q?=EA=B7=B8=EB=A0=A4=EC=A7=80=EB=8A=94=20Composable=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/recipe/difficulty/Stars.kt | 57 +++++++++++++++++++ .../src/main/res/drawable/ic_star_filled.xml | 5 ++ .../src/main/res/drawable/ic_star_outline.xml | 12 ++++ 3 files changed, 74 insertions(+) create mode 100644 Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/difficulty/Stars.kt create mode 100644 Android/feature/recipe/src/main/res/drawable/ic_star_filled.xml create mode 100644 Android/feature/recipe/src/main/res/drawable/ic_star_outline.xml diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/difficulty/Stars.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/difficulty/Stars.kt new file mode 100644 index 0000000..c4bccd5 --- /dev/null +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/difficulty/Stars.kt @@ -0,0 +1,57 @@ +package com.sundaegukbap.banchango.feature.recipe.difficulty + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.sundaegukbap.banchango.core.designsystem.theme.BanchangoTheme +import com.sundaegukbap.banchango.feature.reciperecommend.R + +@Composable +fun Stars( + modifier: Modifier = Modifier, + starSize: Int, + filledCount: Int, +) { + Row(modifier = modifier) { + repeat(filledCount) { + Star(modifier = Modifier.size(starSize.dp), isFilled = true) + } + repeat(5 - filledCount) { + Star(modifier = Modifier.size(starSize.dp), isFilled = false) + } + } +} + +@Composable +fun Star(modifier: Modifier, isFilled: Boolean) { + Image( + modifier = modifier, + painter = painterResource(id = if (isFilled) R.drawable.ic_star_filled else R.drawable.ic_star_outline), + contentDescription = null, + ) +} + +@Preview(showBackground = true) +@Composable +fun StarPreview() { + BanchangoTheme { + Row { + Star(modifier = Modifier.size(40.dp), isFilled = true) + Star(modifier = Modifier.size(40.dp), isFilled = false) + } + } +} + +@Preview(showBackground = true) +@Composable +fun DifficultyStarPreview() { + BanchangoTheme { + Stars(modifier = Modifier.wrapContentSize(), starSize = 24, filledCount = 3) + } +} diff --git a/Android/feature/recipe/src/main/res/drawable/ic_star_filled.xml b/Android/feature/recipe/src/main/res/drawable/ic_star_filled.xml new file mode 100644 index 0000000..1bcb71e --- /dev/null +++ b/Android/feature/recipe/src/main/res/drawable/ic_star_filled.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Android/feature/recipe/src/main/res/drawable/ic_star_outline.xml b/Android/feature/recipe/src/main/res/drawable/ic_star_outline.xml new file mode 100644 index 0000000..d81354e --- /dev/null +++ b/Android/feature/recipe/src/main/res/drawable/ic_star_outline.xml @@ -0,0 +1,12 @@ + + + From 90345c608ce1be48559a855a972696fc562af3df Mon Sep 17 00:00:00 2001 From: vrexpert Date: Sun, 16 Jun 2024 20:06:02 +0900 Subject: [PATCH 07/19] =?UTF-8?q?feat(RecipeDifficult):=20=EB=A0=88?= =?UTF-8?q?=EC=8B=9C=ED=94=BC=EB=8A=94=20=EC=9A=94=EB=A6=AC=20=EB=82=9C?= =?UTF-8?q?=EC=9D=B4=EB=8F=84=EB=A5=BC=20=EA=B0=80=EC=A7=84=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/sundaegukbap/banchango/Recipe.kt | 5 ++--- .../java/com/sundaegukbap/banchango/RecipeDifficulty.kt | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 Android/core/model/src/main/java/com/sundaegukbap/banchango/RecipeDifficulty.kt diff --git a/Android/core/model/src/main/java/com/sundaegukbap/banchango/Recipe.kt b/Android/core/model/src/main/java/com/sundaegukbap/banchango/Recipe.kt index 4ff188b..c6a7c43 100644 --- a/Android/core/model/src/main/java/com/sundaegukbap/banchango/Recipe.kt +++ b/Android/core/model/src/main/java/com/sundaegukbap/banchango/Recipe.kt @@ -8,8 +8,7 @@ data class Recipe( val link: String, val cookingTime: Int, val servings: Int, - val difficulty: String, - val isBookmarked: Boolean, + val difficulty: RecipeDifficulty, val have: List, - val need: List + val need: List, ) diff --git a/Android/core/model/src/main/java/com/sundaegukbap/banchango/RecipeDifficulty.kt b/Android/core/model/src/main/java/com/sundaegukbap/banchango/RecipeDifficulty.kt new file mode 100644 index 0000000..af00a06 --- /dev/null +++ b/Android/core/model/src/main/java/com/sundaegukbap/banchango/RecipeDifficulty.kt @@ -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, "신의 경지"), +} From 617585d5a16801c370401e73f1dd4546afed71e5 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Tue, 25 Jun 2024 22:34:30 +0900 Subject: [PATCH 08/19] =?UTF-8?q?feat(RecipeDifficult):=20=EB=A0=88?= =?UTF-8?q?=EC=8B=9C=ED=94=BC=20=EC=B6=94=EC=B2=9C=20=EB=82=9C=EC=9D=B4?= =?UTF-8?q?=EB=8F=84=20=ED=99=94=EB=A9=B4=EC=9D=84=20=EA=B7=B8=EB=A6=B0?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/model/RecipeRecommendResponseItem.kt | 1 - .../core/data/di/RepositoryModule.kt | 3 +- .../core/data/mapper/RecipeMapper.kt | 10 +- .../data/repository/FakeRecipeRepository.kt | 7 +- .../core/designsystem/theme/Color.kt | 2 +- .../feature/recipe/detail/RecipeDetailInfo.kt | 126 ++++++++++++++++++ .../recipe/detail/RecipeDetailScreen.kt | 111 +++++++++++---- .../feature/recipe/recommend/RecipeItem.kt | 6 +- .../recommend/RecipesRecommendScreen.kt | 12 +- 9 files changed, 231 insertions(+), 47 deletions(-) create mode 100644 Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailInfo.kt diff --git a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/api/model/RecipeRecommendResponseItem.kt b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/api/model/RecipeRecommendResponseItem.kt index 7189032..b0d0e17 100644 --- a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/api/model/RecipeRecommendResponseItem.kt +++ b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/api/model/RecipeRecommendResponseItem.kt @@ -13,6 +13,5 @@ data class RecipeRecommendResponse( val need: List, val servings: Int, val cookingTime: Int, - val isBookmarked: Boolean, val difficulty: String ) diff --git a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/RepositoryModule.kt b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/RepositoryModule.kt index 323553a..7013ecb 100644 --- a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/RepositoryModule.kt +++ b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/RepositoryModule.kt @@ -1,5 +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 @@ -12,5 +13,5 @@ import dagger.hilt.components.SingletonComponent internal abstract class RepositoryModule { @Binds - abstract fun bindsRecipeRepository(recipeRepository: FakeRecipeRepository): RecipeRepository + abstract fun bindsRecipeRepository(recipeRepository: DefaultRecipeRepository): RecipeRepository } diff --git a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/mapper/RecipeMapper.kt b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/mapper/RecipeMapper.kt index 54be7dd..582323a 100644 --- a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/mapper/RecipeMapper.kt +++ b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/mapper/RecipeMapper.kt @@ -1,11 +1,20 @@ package com.sundaegukbap.banchango.core.data.mapper import com.sundaegukbap.banchango.Recipe +import com.sundaegukbap.banchango.RecipeDifficulty import com.sundaegukbap.banchango.core.data.api.model.RecipeRecommendResponse internal fun List.toData(): List = map { it.toData() } internal fun RecipeRecommendResponse.toData(): Recipe { + val difficulty = when (difficulty) { + "아무나" -> RecipeDifficulty.ANYONE + "초보" -> RecipeDifficulty.BEGINNER + "중급" -> RecipeDifficulty.INTERMEDIATE + "고급" -> RecipeDifficulty.ADVANCED + "신의경지" -> RecipeDifficulty.GODLIKE + else -> RecipeDifficulty.ANYONE + } return Recipe( id = id, name = name, @@ -16,7 +25,6 @@ internal fun RecipeRecommendResponse.toData(): Recipe { need = need, servings = servings, cookingTime = cookingTime, - isBookmarked = isBookmarked, difficulty = difficulty, ) } diff --git a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/FakeRecipeRepository.kt b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/FakeRecipeRepository.kt index a81f2e0..925f93d 100644 --- a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/FakeRecipeRepository.kt +++ b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/FakeRecipeRepository.kt @@ -1,6 +1,7 @@ package com.sundaegukbap.banchango.core.data.repository import com.sundaegukbap.banchango.Recipe +import com.sundaegukbap.banchango.RecipeDifficulty import com.sundaegukbap.banchango.core.data.repository.api.RecipeRepository import javax.inject.Inject @@ -16,10 +17,9 @@ class FakeRecipeRepository @Inject constructor() : RecipeRepository { link = "https://www.10000recipe.com/recipe/6889616", cookingTime = 10, servings = 2, - difficulty = "Easy", + difficulty = RecipeDifficulty.BEGINNER, have = listOf("계란", "간장"), need = listOf("식초", "당근", "감자"), - isBookmarked = false, ) } ) @@ -35,10 +35,9 @@ class FakeRecipeRepository @Inject constructor() : RecipeRepository { link = "https://www.10000recipe.com/recipe/6889616", cookingTime = 10, servings = 2, - difficulty = "Easy", + difficulty = RecipeDifficulty.BEGINNER, have = listOf("계란", "간장"), need = listOf("식초", "당근", "감자"), - isBookmarked = false, ) ) } diff --git a/Android/core/designsystem/src/main/java/com/sundaegukbap/banchango/core/designsystem/theme/Color.kt b/Android/core/designsystem/src/main/java/com/sundaegukbap/banchango/core/designsystem/theme/Color.kt index 4eb5ca2..d3bac00 100644 --- a/Android/core/designsystem/src/main/java/com/sundaegukbap/banchango/core/designsystem/theme/Color.kt +++ b/Android/core/designsystem/src/main/java/com/sundaegukbap/banchango/core/designsystem/theme/Color.kt @@ -11,7 +11,7 @@ val PurpleGrey40 = Color(0xFF625b71) val Pink40 = Color(0xFF7D5260) val Orange = Color(0xFFFF7A00) -val LightBeige = Color(0xFFF5EB) +val LightOrange = Color(0xFFFFC085) val White = Color(0xFFFFFFFF) val Black = Color(0xFF000000) diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailInfo.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailInfo.kt new file mode 100644 index 0000000..6a441af --- /dev/null +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailInfo.kt @@ -0,0 +1,126 @@ +package com.sundaegukbap.banchango.feature.recipe.detail + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.material3.Text +import androidx.compose.material3.VerticalDivider +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.FontWeight.Companion.Bold +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.sundaegukbap.banchango.RecipeDifficulty +import com.sundaegukbap.banchango.core.designsystem.theme.BanchangoTheme +import com.sundaegukbap.banchango.core.designsystem.theme.LightOrange +import com.sundaegukbap.banchango.core.designsystem.theme.Orange +import com.sundaegukbap.banchango.feature.recipe.difficulty.Stars + +@Composable +fun RecipeDetailInfo( + difficulty: RecipeDifficulty, + serving: Int, + cookingTime: Int, + paddingHorizontal: Int, + modifier: Modifier = Modifier +) { + Row(modifier = modifier.fillMaxWidth()) { + RecipeDetailDifficulty( + modifier = Modifier + .wrapContentSize() + .align(Alignment.CenterVertically) + .padding(horizontal = paddingHorizontal.dp), + difficulty = difficulty + ) + + RecipeLine(alignment = Alignment.CenterVertically) + + DetailText( + modifier = Modifier.align(Alignment.CenterVertically), + text = "${serving}인분", + paddingHorizontal = paddingHorizontal + ) + + RecipeLine(alignment = Alignment.CenterVertically) + + DetailText( + modifier = Modifier.align(Alignment.CenterVertically), + text = "${cookingTime}m", + paddingHorizontal = paddingHorizontal + ) + } +} + +@Composable +private fun RecipeDetailDifficulty( + modifier: Modifier = Modifier, + difficulty: RecipeDifficulty +) { + Column(modifier = modifier) { + Stars( + modifier = Modifier.wrapContentSize(), + starSize = 14, + filledCount = difficulty.level + ) + Text( + modifier = Modifier + .wrapContentSize() + .align(Alignment.CenterHorizontally), + text = difficulty.explain, + fontSize = 12.sp, + fontWeight = Bold, + color = Orange, + ) + } +} + +@Composable +private fun RowScope.RecipeLine(alignment: Alignment.Vertical) { + VerticalDivider( + modifier = Modifier + .height(52.dp) + .align(alignment), + color = LightOrange, + thickness = 2.dp + ) +} + +@Composable +private fun RowScope.DetailText( + modifier: Modifier = Modifier, + paddingHorizontal: Int, + text: String +) { + Text( + modifier = modifier + .wrapContentSize() + .padding(horizontal = paddingHorizontal.dp) + .align(Alignment.CenterVertically), + text = text, + fontSize = 12.sp, + fontWeight = Bold, + color = Orange, + textAlign = TextAlign.Center + ) +} + +@Preview(showBackground = true) +@Composable +fun RecipeDetailInfoPreview() { + BanchangoTheme { + RecipeDetailInfo( + difficulty = RecipeDifficulty.ADVANCED, + serving = 2, + cookingTime = 30, + 20, + ) + } +} + diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt index eeae9e5..d2ae07a 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt @@ -1,6 +1,9 @@ package com.sundaegukbap.banchango.feature.recipe.detail +import android.content.Intent +import android.net.Uri import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -12,8 +15,11 @@ import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.BottomSheetScaffold +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonColors import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.SheetValue import androidx.compose.material3.Text import androidx.compose.material3.rememberBottomSheetScaffoldState @@ -25,14 +31,19 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.core.content.ContextCompat.startActivity import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.sundaegukbap.banchango.Recipe +import com.sundaegukbap.banchango.RecipeDifficulty import com.sundaegukbap.banchango.core.designsystem.component.NetworkImage +import com.sundaegukbap.banchango.core.designsystem.theme.LightOrange +import com.sundaegukbap.banchango.core.designsystem.theme.Orange @Composable fun RecipeDetailRoute( @@ -49,8 +60,8 @@ fun RecipeDetailRoute( RecipeDetailContent( uiState = uiState, - modifier = modifier, onChangeSystemBarsColor = onChangeSystemBarsColor, + modifier = modifier, ) } @@ -78,7 +89,7 @@ fun RecipeDetailContent( } @Composable -fun RecipeDetailLoading() { +private fun RecipeDetailLoading() { Box( modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center @@ -90,7 +101,7 @@ fun RecipeDetailLoading() { @OptIn(ExperimentalMaterial3Api::class) @Composable -fun RecipeDetailScreen( +private fun RecipeDetailScreen( recipe: Recipe, modifier: Modifier = Modifier ) { @@ -113,31 +124,59 @@ fun RecipeDetailScreen( BottomSheetScaffold( scaffoldState = scaffoldState, sheetContent = { - RecipeDetailInfo( + RecipeDetailCard( recipe = recipe, modifier = Modifier ) }, - modifier = Modifier.background(Color.White), + sheetContainerColor = Color.White, sheetPeekHeight = screenHeight * 0.7f, ) {} + val context = LocalContext.current + Button( + modifier = Modifier + .align(Alignment.BottomCenter) + .padding(bottom = 60.dp), + colors = ButtonColors( + containerColor = Orange, + contentColor = Color.White, + disabledContainerColor = LightOrange, + disabledContentColor = Color.White + ), + onClick = { + context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(recipe.link))) + }, + ) { + Text(text = "레시피 이동하기") + } } } @Composable -fun RecipeDetailInfo( +private fun RecipeDetailCard( recipe: Recipe, modifier: Modifier = Modifier ) { Box( - modifier = modifier.fillMaxSize() + modifier = modifier + .fillMaxSize() ) { Column( Modifier.padding(horizontal = 16.dp) ) { + RecipeDetailInfo( + difficulty = recipe.difficulty, + serving = recipe.servings, + cookingTime = recipe.cookingTime, + modifier = Modifier + .fillMaxWidth() + .align(Alignment.CenterHorizontally), + paddingHorizontal = 32, + ) Text( + modifier = Modifier.padding(top = 20.dp), text = recipe.name, fontSize = 20.sp, fontWeight = FontWeight.Bold @@ -149,45 +188,61 @@ fun RecipeDetailInfo( modifier = Modifier.padding(top = 12.dp) ) - Text( - text = "식재료", - fontSize = 12.sp, - fontWeight = FontWeight.Bold, - modifier = Modifier.padding(top = 24.dp) - ) + Box( + modifier = Modifier + .fillMaxWidth() + .padding(top = 20.dp) + ) { + Text( + text = "식재료", + fontSize = 12.sp, + fontWeight = FontWeight.Bold, + ) + Text( + text = "${recipe.have.size}/${recipe.have.size + recipe.need.size}", + color = Color.White, + fontSize = 12.sp, + fontWeight = FontWeight.Bold, + modifier = Modifier + .background(color = Orange, shape = CircleShape) + .padding(horizontal = 8.dp) + .align(Alignment.CenterEnd) + ) + } + + HorizontalDivider(modifier = Modifier.padding(top = 12.dp), color = Orange) LazyRow( modifier = Modifier.padding(top = 16.dp), - horizontalArrangement = Arrangement.spacedBy(24.dp), + horizontalArrangement = Arrangement.spacedBy(12.dp), ) { items(recipe.have) { Box( - modifier = Modifier.background(color = Color.Gray, shape = CircleShape) + modifier = Modifier + .border(1.dp, color = Orange, shape = CircleShape) + .background(color = Color.White, shape = CircleShape) ) { Text(modifier = Modifier.padding(16.dp), text = it) } } - } - - LazyRow( - modifier = Modifier.padding(top = 16.dp), - horizontalArrangement = Arrangement.spacedBy(24.dp), - ) { items(recipe.need) { - Box(modifier = Modifier.background(color = Color.Gray, shape = CircleShape)) { + Box( + modifier = Modifier + .border(1.dp, color = Orange, shape = CircleShape) + .background(color = LightOrange, shape = CircleShape) + ) { Text(modifier = Modifier.padding(16.dp), text = it) } } } - } } } @Preview(showBackground = true) @Composable -fun RecipeDetailInfoPreview() { - RecipeDetailInfo( +fun RecipeDetailCardPreview() { + RecipeDetailCard( recipe = Recipe( id = 1, name = "간장계란볶음밥", @@ -196,10 +251,9 @@ fun RecipeDetailInfoPreview() { link = "https://www.10000recipe.com/recipe/6889616", cookingTime = 10, servings = 2, - difficulty = "Easy", + difficulty = RecipeDifficulty.BEGINNER, have = listOf("계란", "간장"), need = listOf("식초", "당근", "감자"), - isBookmarked = false, ), ) } @@ -216,10 +270,9 @@ fun RecipeDetailScreenPreview() { link = "https://www.10000recipe.com/recipe/6889616", cookingTime = 10, servings = 2, - difficulty = "Easy", + difficulty = RecipeDifficulty.BEGINNER, have = listOf("계란", "간장"), need = listOf("식초", "당근", "감자"), - isBookmarked = false, ), ) } diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipeItem.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipeItem.kt index d727a25..607081c 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipeItem.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipeItem.kt @@ -28,6 +28,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.compose.ui.util.lerp import com.sundaegukbap.banchango.Recipe +import com.sundaegukbap.banchango.RecipeDifficulty import com.sundaegukbap.banchango.core.designsystem.component.NetworkImage import com.sundaegukbap.banchango.core.designsystem.theme.BanchangoTheme import com.sundaegukbap.banchango.feature.reciperecommend.R @@ -120,7 +121,7 @@ private fun RecipeInfo( alpha = 0.8f ) .fillMaxWidth() - .padding(top = 40.dp, bottom = 40.dp), + .padding(vertical = 40.dp, horizontal = 16.dp), ) } } @@ -169,10 +170,9 @@ fun RecipeItemPreview() { link = "https://www.10000recipe.com/recipe/6889616", cookingTime = 10, servings = 2, - difficulty = "Easy", + difficulty = RecipeDifficulty.BEGINNER, have = listOf(""), need = listOf(""), - isBookmarked = false, ), isLiked = true, ), diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipesRecommendScreen.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipesRecommendScreen.kt index 78a57bd..0c4ea4c 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipesRecommendScreen.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipesRecommendScreen.kt @@ -18,6 +18,7 @@ import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.sundaegukbap.banchango.Recipe +import com.sundaegukbap.banchango.RecipeDifficulty import com.sundaegukbap.banchango.core.designsystem.theme.BanchangoTheme import kotlin.math.absoluteValue @@ -30,7 +31,7 @@ fun RecipeRecommendRoute( ) { val uiState by viewModel.uiState.collectAsStateWithLifecycle() - LaunchedEffect(uiState) { + LaunchedEffect(Unit) { if (uiState is RecipeRecommendUiState.Loading) viewModel.getRecipeRecommendation() } @@ -142,10 +143,9 @@ fun RecipePagePreview() { link = "https://www.10000recipe.com/recipe/6889616", cookingTime = 10, servings = 2, - difficulty = "Easy", + difficulty = RecipeDifficulty.BEGINNER, have = listOf(""), need = listOf(""), - isBookmarked = false, ), isLiked = false ), @@ -158,10 +158,9 @@ fun RecipePagePreview() { link = "https://www.10000recipe.com/recipe/6889616", cookingTime = 10, servings = 2, - difficulty = "Easy", + difficulty = RecipeDifficulty.BEGINNER, have = listOf(""), need = listOf(""), - isBookmarked = false, ), isLiked = false ), @@ -174,10 +173,9 @@ fun RecipePagePreview() { link = "https://www.10000recipe.com/recipe/6889616", cookingTime = 10, servings = 2, - difficulty = "Easy", + difficulty = RecipeDifficulty.BEGINNER, have = listOf(""), need = listOf(""), - isBookmarked = false, ), isLiked = false ), From 8b1d84bbf225b31b9c247032c736a2838f6b8d91 Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 15:56:14 +0900 Subject: [PATCH 09/19] =?UTF-8?q?refactor:=20Recipe=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=20=EC=9D=B4=EB=8F=99=20=EB=B2=84=ED=8A=BC=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/recipe/detail/BtnMoveToRecipe.kt | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/BtnMoveToRecipe.kt diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/BtnMoveToRecipe.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/BtnMoveToRecipe.kt new file mode 100644 index 0000000..e548b0b --- /dev/null +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/BtnMoveToRecipe.kt @@ -0,0 +1,45 @@ +package com.sundaegukbap.banchango.feature.recipe.detail + +import android.content.Intent +import android.net.Uri +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonColors +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.tooling.preview.Preview +import com.sundaegukbap.banchango.core.designsystem.theme.LightOrange +import com.sundaegukbap.banchango.core.designsystem.theme.Orange + +@Composable +fun BtnMoveToRecipe( + recipeLink: String, + modifier: Modifier = Modifier, +) { + val context = LocalContext.current + Button( + modifier = modifier, + colors = + ButtonColors( + containerColor = Orange, + contentColor = Color.White, + disabledContainerColor = LightOrange, + disabledContentColor = Color.White, + ), + onClick = { + context.startActivity( + Intent(Intent.ACTION_VIEW, Uri.parse(recipeLink)), + ) + }, + ) { + Text(text = "레시피 이동하기") + } +} + +@Composable +@Preview +fun PreviewBtnMoveToRecipe() { + BtnMoveToRecipe(recipeLink = "https://www.google.com") +} From 1c9d4dc8030496ca242f039b8572ea32973a95b4 Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 15:56:47 +0900 Subject: [PATCH 10/19] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20TopBar=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/recipe/detail/RecipeTopbar.kt | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeTopbar.kt diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeTopbar.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeTopbar.kt new file mode 100644 index 0000000..0cebdef --- /dev/null +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeTopbar.kt @@ -0,0 +1,67 @@ +package com.sundaegukbap.banchango.feature.recipe.detail + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.res.vectorResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.sundaegukbap.banchango.feature.reciperecommend.R + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun RecipeTobBar( + backgroundColor: Color, + navigationIconColor: Color, + actionIconColor: Color, + onBackClick: () -> Unit, + onLikeClick: () -> Unit, +) { + TopAppBar( + modifier = Modifier.background(Color.Transparent), + title = {}, + navigationIcon = { + IconButton(onClick = onBackClick) { + Icon(Icons.AutoMirrored.Default.ArrowBack, contentDescription = "Back") + } + }, + actions = { + IconButton(onClick = onLikeClick, modifier = Modifier) { + Icon( + ImageVector.vectorResource(R.drawable.ic_heart_filled), + contentDescription = "Like", + modifier = Modifier.size(20.dp), + ) + } + }, + colors = + TopAppBarDefaults.topAppBarColors( + containerColor = backgroundColor, + scrolledContainerColor = backgroundColor, + navigationIconContentColor = navigationIconColor, + actionIconContentColor = actionIconColor, + ), + ) +} + +@Preview(showBackground = false) +@Composable +fun PreviewRecipeTopBar() { + RecipeTobBar( + backgroundColor = Color.White, + onBackClick = {}, + onLikeClick = {}, + navigationIconColor = Color.Black, + actionIconColor = Color.Black, + ) +} From f2807213f3620b2739dbe530e47b2e336f28b565 Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 15:57:25 +0900 Subject: [PATCH 11/19] =?UTF-8?q?feat:=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EB=A0=88=EC=8B=9C=ED=94=BC=20=EA=B0=9D=EC=B2=B4=20=EC=A0=95?= =?UTF-8?q?=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sundaegukbap/banchango/LikableRecipe.kt | 6 ++++++ .../feature/recipe/detail/RecipeDetailUiState.kt | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 Android/core/model/src/main/java/com/sundaegukbap/banchango/LikableRecipe.kt diff --git a/Android/core/model/src/main/java/com/sundaegukbap/banchango/LikableRecipe.kt b/Android/core/model/src/main/java/com/sundaegukbap/banchango/LikableRecipe.kt new file mode 100644 index 0000000..da3a214 --- /dev/null +++ b/Android/core/model/src/main/java/com/sundaegukbap/banchango/LikableRecipe.kt @@ -0,0 +1,6 @@ +package com.sundaegukbap.banchango + +data class LikableRecipe( + val recipe: Recipe, + val isLiked: Boolean, +) diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailUiState.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailUiState.kt index 2407997..5585a80 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailUiState.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailUiState.kt @@ -1,9 +1,15 @@ package com.sundaegukbap.banchango.feature.recipe.detail -import com.sundaegukbap.banchango.Recipe +import com.sundaegukbap.banchango.LikableRecipe sealed interface RecipeDetailUiState { data object Loading : RecipeDetailUiState - data class Success(val recipe: Recipe) : RecipeDetailUiState - data class Error(val throwable: Throwable) : RecipeDetailUiState + + data class Success( + val likableRecipe: LikableRecipe, + ) : RecipeDetailUiState + + data class Error( + val throwable: Throwable, + ) : RecipeDetailUiState } From 1afbd7cd0d9ec2d3c93df6c3ec5e91ef806b8cd8 Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 15:58:44 +0900 Subject: [PATCH 12/19] =?UTF-8?q?feat(RecipeRepository):=20RecipeRepositor?= =?UTF-8?q?y=20=EC=97=90=20=EC=A2=8B=EC=95=84=EC=9A=94=EB=A5=BC=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/api/RecipeRepository.kt | 9 +- .../core/data/di/RepositoryModule.kt | 2 +- .../repository/DefaultRecipeRepository.kt | 56 +++++++----- .../data/repository/FakeRecipeRepository.kt | 88 ++++++++++++------- .../recipe/detail/RecipeDetailViewModel.kt | 46 ++++++---- 5 files changed, 126 insertions(+), 75 deletions(-) diff --git a/Android/core/data-api/src/main/java/com/sundaegukbap/banchango/core/data/repository/api/RecipeRepository.kt b/Android/core/data-api/src/main/java/com/sundaegukbap/banchango/core/data/repository/api/RecipeRepository.kt index 84340ad..b42e230 100644 --- a/Android/core/data-api/src/main/java/com/sundaegukbap/banchango/core/data/repository/api/RecipeRepository.kt +++ b/Android/core/data-api/src/main/java/com/sundaegukbap/banchango/core/data/repository/api/RecipeRepository.kt @@ -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> - suspend fun getRecipeDetail(id: Long): Result + + suspend fun getRecipeDetail(id: Long): Result + + suspend fun likeRecipe( + id: Long, + isLiked: Boolean, + ): Result } diff --git a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/RepositoryModule.kt b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/RepositoryModule.kt index 7013ecb..358075f 100644 --- a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/RepositoryModule.kt +++ b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/di/RepositoryModule.kt @@ -13,5 +13,5 @@ import dagger.hilt.components.SingletonComponent internal abstract class RepositoryModule { @Binds - abstract fun bindsRecipeRepository(recipeRepository: DefaultRecipeRepository): RecipeRepository + abstract fun bindsRecipeRepository(recipeRepository: FakeRecipeRepository): RecipeRepository } diff --git a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/DefaultRecipeRepository.kt b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/DefaultRecipeRepository.kt index 5cfc3e0..8a734e4 100644 --- a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/DefaultRecipeRepository.kt +++ b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/DefaultRecipeRepository.kt @@ -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> { - 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> = + 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 { - return runCatching { - val response = recipeApi.getRecipeDetail(1, id) - if (response.isSuccessful) { - if (response.body() == null) { - throw IllegalStateException("Response body is null") + override suspend fun getRecipeDetail(id: Long): Result = + 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 { + TODO("호감 기능 추가시 구현") } } -} diff --git a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/FakeRecipeRepository.kt b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/FakeRecipeRepository.kt index 925f93d..22e81e5 100644 --- a/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/FakeRecipeRepository.kt +++ b/Android/core/data/src/main/java/com/sundaegukbap/banchango/core/data/repository/FakeRecipeRepository.kt @@ -1,44 +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> { - return 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("식초", "당근", "감자"), - ) - } - ) - } +class FakeRecipeRepository + @Inject + constructor() : RecipeRepository { + override suspend fun getRecipeRecommendation(): Result> = + 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("식초", "당근", "감자"), + ) + }, + ) - override suspend fun getRecipeDetail(id: Long): Result { - 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 = RecipeDifficulty.BEGINNER, - have = listOf("계란", "간장"), - need = listOf("식초", "당근", "감자"), + override suspend fun getRecipeDetail(id: Long): Result = + 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 likeRecipe( + id: Long, + isLiked: Boolean, + ): Result = Result.success(Unit) } -} diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailViewModel.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailViewModel.kt index 848e9f8..031412e 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailViewModel.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailViewModel.kt @@ -11,21 +11,37 @@ import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel -class RecipeDetailViewModel @Inject constructor( - private val recipeRepository: RecipeRepository -) : ViewModel() { - private val _uiState: MutableStateFlow = - MutableStateFlow(RecipeDetailUiState.Loading) - val uiState: StateFlow = _uiState.asStateFlow() +class RecipeDetailViewModel + @Inject + constructor( + private val recipeRepository: RecipeRepository, + ) : ViewModel() { + private val _uiState: MutableStateFlow = + MutableStateFlow(RecipeDetailUiState.Loading) + val uiState: StateFlow = _uiState.asStateFlow() - fun getRecipeDetail(recipeId: Long) { - viewModelScope.launch { - recipeRepository.getRecipeDetail(recipeId) - .onSuccess { recipe -> - _uiState.value = RecipeDetailUiState.Success(recipe) - }.onFailure { throwable -> - _uiState.value = RecipeDetailUiState.Error(throwable) - } + fun getRecipeDetail(recipeId: Long) { + viewModelScope.launch { + recipeRepository + .getRecipeDetail(recipeId) + .onSuccess { likableRecipe -> + _uiState.value = + RecipeDetailUiState.Success(likableRecipe) + }.onFailure { throwable -> + _uiState.value = RecipeDetailUiState.Error(throwable) + } + } + } + + fun likeRecipe( + recipeId: Long, + isLiked: Boolean, + ) { + val successUiState = uiState.value as? RecipeDetailUiState.Success ?: return + viewModelScope.launch { + recipeRepository.likeRecipe(recipeId, isLiked) + _uiState.value = + RecipeDetailUiState.Success(successUiState.likableRecipe.copy(isLiked = isLiked)) + } } } -} From 8f57822819b2d37acc5595325189a0a5f8b36f56 Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 16:00:18 +0900 Subject: [PATCH 13/19] =?UTF-8?q?feat(RecipeDetailCard):=20=EB=A0=88?= =?UTF-8?q?=EC=8B=9C=ED=94=BC=20=EC=83=81=EC=84=B8=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=EB=A5=BC=20=EB=A0=88=EC=8B=9C=ED=94=BC=20=EC=83=81=EC=84=B8=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=ED=99=94=EB=A9=B4=EC=97=90=EC=84=9C?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EB=B6=84=EB=A6=AC=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/recipe/detail/RecipeDetailCard.kt | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailCard.kt diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailCard.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailCard.kt new file mode 100644 index 0000000..5c7c8b5 --- /dev/null +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailCard.kt @@ -0,0 +1,168 @@ +package com.sundaegukbap.banchango.feature.recipe.detail + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.sundaegukbap.banchango.Recipe +import com.sundaegukbap.banchango.RecipeDifficulty +import com.sundaegukbap.banchango.core.designsystem.theme.LightOrange +import com.sundaegukbap.banchango.core.designsystem.theme.Orange + +@Composable +fun RecipeDetailCard( + recipe: Recipe, + modifier: Modifier = Modifier, +) { + LazyColumn( + modifier = modifier, + ) { + item { + RecipeDetailInfo( + difficulty = recipe.difficulty, + serving = recipe.servings, + cookingTime = recipe.cookingTime, + modifier = + Modifier + .fillMaxWidth() + .padding(horizontal = 12.dp), + paddingHorizontal = 32, + ) + } + item { + Text( + modifier = Modifier.padding(top = 20.dp, start = 12.dp, end = 12.dp), + text = recipe.name, + fontSize = 20.sp, + fontWeight = FontWeight.Bold, + ) + } + + item { + Text( + text = recipe.introduction, + fontSize = 12.sp, + modifier = Modifier.padding(top = 12.dp, start = 12.dp, end = 12.dp), + ) + } + + item { + Ingredients(title = "핵심 재료", have = recipe.have, need = recipe.need) + } + item { + Ingredients("식자재", recipe.have, recipe.need) + } + } +} + +@Composable +private fun Ingredients( + title: String, + have: List, + need: List, +) { + Box( + modifier = + Modifier + .fillMaxWidth() + .padding(top = 20.dp, start = 12.dp, end = 12.dp), + ) { + Text( + text = title, + fontSize = 12.sp, + fontWeight = FontWeight.Bold, + ) + Text( + text = "${have.size}/${have.size + need.size}", + color = Color.White, + fontSize = 12.sp, + fontWeight = FontWeight.Bold, + modifier = + Modifier + .background(color = Orange, shape = CircleShape) + .padding(horizontal = 8.dp) + .align(Alignment.CenterEnd), + ) + } + + HorizontalDivider( + modifier = Modifier.padding(top = 12.dp, start = 12.dp, end = 12.dp), + color = Orange, + ) + + LazyRow( + modifier = Modifier.padding(top = 16.dp), + horizontalArrangement = Arrangement.spacedBy(12.dp), + ) { + val ingredients = + have.map { ItemIngredient(it, true) } + need.map { ItemIngredient(it, false) } + itemsIndexed(ingredients) { index, it -> + if (index == 0) { + IngredientCard(it, modifier = Modifier.padding(start = 12.dp)) + } else { + IngredientCard(it) + } + } + } +} + +@Composable +private fun IngredientCard( + itemIngredient: ItemIngredient, + modifier: Modifier = Modifier, +) { + Box( + modifier = + modifier + .border(1.dp, color = Orange, shape = CircleShape) + .background( + color = if (itemIngredient.has) Color.White else LightOrange, + shape = CircleShape, + ), + ) { + Text(modifier = Modifier.padding(16.dp), text = itemIngredient.name) + } +} + +data class ItemIngredient( + val name: String, + val has: Boolean, +) + +@Preview(showBackground = true) +@Composable +fun RecipeDetailCardPreview() { + RecipeDetailCard( + recipe = + Recipe( + id = 1, + name = "간장계란볶음밥", + introduction = + "아주 간단하면서 맛있는 계란간장볶음밥으로 한끼식사 만들어보세요. \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("식초", "당근", "감자", "깨소금", "밥"), + ), + ) +} From af134e6ae086b5e44b27269134828b6555b2eb83 Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 17:23:51 +0900 Subject: [PATCH 14/19] =?UTF-8?q?feat(statusBarColor):=20systemBar=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=97=90=EC=84=9C=20statusBar=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EB=B0=94=EA=BE=BC=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sundaegukbap/banchango/feature/home/HomeScreen.kt | 2 +- .../feature/home/navigation/HomeNavigator.kt | 4 ++-- .../banchango/feature/main/MainActivity.kt | 11 ++++------- .../sundaegukbap/banchango/feature/main/MainScreen.kt | 6 +++--- .../feature/recipe/navigation/RecipeNavigation.kt | 6 +++--- .../recipe/recommend/RecipesRecommendScreen.kt | 4 ++-- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Android/feature/home/src/main/java/com/sundaegukbap/banchango/feature/home/HomeScreen.kt b/Android/feature/home/src/main/java/com/sundaegukbap/banchango/feature/home/HomeScreen.kt index 2df1678..0e4b374 100644 --- a/Android/feature/home/src/main/java/com/sundaegukbap/banchango/feature/home/HomeScreen.kt +++ b/Android/feature/home/src/main/java/com/sundaegukbap/banchango/feature/home/HomeScreen.kt @@ -7,6 +7,6 @@ import androidx.compose.ui.graphics.Color @Composable fun HomeScreen( padding: PaddingValues, - onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit, + onChangeStatusBarColor: (color: Color, darkIcons: Boolean) -> Unit, ) { } diff --git a/Android/feature/home/src/main/java/com/sundaegukbap/banchango/feature/home/navigation/HomeNavigator.kt b/Android/feature/home/src/main/java/com/sundaegukbap/banchango/feature/home/navigation/HomeNavigator.kt index 0b162b4..9b3f838 100644 --- a/Android/feature/home/src/main/java/com/sundaegukbap/banchango/feature/home/navigation/HomeNavigator.kt +++ b/Android/feature/home/src/main/java/com/sundaegukbap/banchango/feature/home/navigation/HomeNavigator.kt @@ -15,9 +15,9 @@ fun NavController.navigateHome(navOptions: NavOptions) { fun NavGraphBuilder.homeNavGraph( padding: PaddingValues, - onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit, + onChangeStatusBarColor: (color: Color, darkIcons: Boolean) -> Unit, ) { composable { - HomeScreen(padding, onChangeSystemBarsColor) + HomeScreen(padding, onChangeStatusBarColor) } } diff --git a/Android/feature/main/src/main/java/com/sundaegukbap/banchango/feature/main/MainActivity.kt b/Android/feature/main/src/main/java/com/sundaegukbap/banchango/feature/main/MainActivity.kt index 2c89a85..bb7c901 100644 --- a/Android/feature/main/src/main/java/com/sundaegukbap/banchango/feature/main/MainActivity.kt +++ b/Android/feature/main/src/main/java/com/sundaegukbap/banchango/feature/main/MainActivity.kt @@ -10,28 +10,25 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController import com.sundaegukbap.banchango.core.designsystem.theme.BanchangoTheme import dagger.hilt.android.AndroidEntryPoint - @AndroidEntryPoint class MainActivity : ComponentActivity() { - private lateinit var systemUiController: SystemUiController override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) enableEdgeToEdge() + super.onCreate(savedInstanceState) setContent { BanchangoTheme { val navController = rememberMainNavigator() - systemUiController = rememberSystemUiController() systemUiController.setNavigationBarColor(color = Color(0xFFFFFFFF)) MainScreen( navigator = navController, onChangeDarkTheme = {}, - onChangeSystemBarsColor = { color, darkIcons -> - systemUiController.setSystemBarsColor(color = color, darkIcons = darkIcons) - } + onChangeStatusBarColor = { color, darkIcons -> + systemUiController.setStatusBarColor(color = color, darkIcons = darkIcons,) + }, ) } } diff --git a/Android/feature/main/src/main/java/com/sundaegukbap/banchango/feature/main/MainScreen.kt b/Android/feature/main/src/main/java/com/sundaegukbap/banchango/feature/main/MainScreen.kt index f5804c3..ca4bee1 100644 --- a/Android/feature/main/src/main/java/com/sundaegukbap/banchango/feature/main/MainScreen.kt +++ b/Android/feature/main/src/main/java/com/sundaegukbap/banchango/feature/main/MainScreen.kt @@ -17,7 +17,7 @@ import kotlinx.collections.immutable.toPersistentList internal fun MainScreen( navigator: MainNavigator = rememberMainNavigator(), onChangeDarkTheme: (Boolean) -> Unit, - onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit + onChangeStatusBarColor: (color: Color, darkIcons: Boolean) -> Unit ) { Scaffold( content = { padding -> @@ -32,12 +32,12 @@ internal fun MainScreen( ) { homeNavGraph( padding = padding, - onChangeSystemBarsColor = onChangeSystemBarsColor + onChangeStatusBarColor = onChangeStatusBarColor ) recipeNavGraph( padding = padding, onRecipeClick = { navigator.navigateRecipeDetail(it.id) }, - onChangeSystemBarsColor = onChangeSystemBarsColor + onChangeStatusBarColor = onChangeStatusBarColor ) } } diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/navigation/RecipeNavigation.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/navigation/RecipeNavigation.kt index 4818f5a..aac8219 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/navigation/RecipeNavigation.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/navigation/RecipeNavigation.kt @@ -25,18 +25,18 @@ fun NavController.navigateRecipeDetail(recipeId: Long) { fun NavGraphBuilder.recipeNavGraph( padding: PaddingValues, onRecipeClick: (Recipe) -> Unit, - onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit + onChangeStatusBarColor: (color: Color, darkIcons: Boolean) -> Unit ) { composable { RecipeRecommendRoute( padding = padding, onRecipeClick = onRecipeClick, - onChangeSystemBarsColor = onChangeSystemBarsColor + onChangeStatusBarColor = onChangeStatusBarColor ) } composable { navBackStackEntry -> val recipeId = navBackStackEntry.toRoute().recipeId - RecipeDetailRoute(recipeId = recipeId, onChangeSystemBarsColor = onChangeSystemBarsColor) + RecipeDetailRoute(recipeId = recipeId, onChangeSystemBarsColor = onChangeStatusBarColor) } } diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipesRecommendScreen.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipesRecommendScreen.kt index 0c4ea4c..df1b2d3 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipesRecommendScreen.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/recommend/RecipesRecommendScreen.kt @@ -27,7 +27,7 @@ fun RecipeRecommendRoute( padding: PaddingValues, viewModel: RecipeRecommendViewModel = hiltViewModel(), onRecipeClick: (Recipe) -> Unit, - onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit, + onChangeStatusBarColor: (color: Color, darkIcons: Boolean) -> Unit, ) { val uiState by viewModel.uiState.collectAsStateWithLifecycle() @@ -42,7 +42,7 @@ fun RecipeRecommendRoute( onLikeClick = { viewModel.likeRecipe(it) }, onLastPageVisible = { viewModel.getRecipeRecommendation() }, onRecipeClick = onRecipeClick, - onChangeSystemBarsColor = onChangeSystemBarsColor + onChangeSystemBarsColor = onChangeStatusBarColor ) } From 3b102eac9a7ed2fcf4edcc6543a430aa9840831b Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 17:28:26 +0900 Subject: [PATCH 15/19] =?UTF-8?q?feat(RecipeDetailScreen):=20LikableRecipe?= =?UTF-8?q?=20=EB=A1=9C=20=ED=99=94=EB=A9=B4=EC=9D=84=20=EB=B3=B4=EC=97=AC?= =?UTF-8?q?=EC=A4=80=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe/detail/RecipeDetailScreen.kt | 63 ++++++++++++------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt index d2ae07a..63e95e2 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt @@ -39,6 +39,7 @@ import androidx.compose.ui.unit.sp import androidx.core.content.ContextCompat.startActivity import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.sundaegukbap.banchango.LikableRecipe import com.sundaegukbap.banchango.Recipe import com.sundaegukbap.banchango.RecipeDifficulty import com.sundaegukbap.banchango.core.designsystem.component.NetworkImage @@ -62,15 +63,18 @@ fun RecipeDetailRoute( uiState = uiState, onChangeSystemBarsColor = onChangeSystemBarsColor, modifier = modifier, - ) + ) { likableRecipe -> + viewModel.likeRecipe(likableRecipe.recipe.id, !likableRecipe.isLiked) + } } @Composable fun RecipeDetailContent( + modifier: Modifier = Modifier, uiState: RecipeDetailUiState, onShowErrorSnackBar: (throwable: Throwable?) -> Unit = {}, onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit, - modifier: Modifier = Modifier, + onLikeCLick: (likableRecipe: LikableRecipe) -> Unit, ) { when (uiState) { is RecipeDetailUiState.Loading -> { @@ -79,7 +83,12 @@ fun RecipeDetailContent( is RecipeDetailUiState.Success -> { onChangeSystemBarsColor(Color.Transparent, false) - RecipeDetailScreen(recipe = uiState.recipe, modifier = modifier) + RecipeDetailScreen( + likableRecipe = uiState.likableRecipe, + modifier = modifier, + onLikeCLick = { onLikeCLick(uiState.likableRecipe) }, + onChangeSystemBarsColor = onChangeSystemBarsColor, + ) } is RecipeDetailUiState.Error -> { @@ -102,8 +111,10 @@ private fun RecipeDetailLoading() { @OptIn(ExperimentalMaterial3Api::class) @Composable private fun RecipeDetailScreen( - recipe: Recipe, - modifier: Modifier = Modifier + likableRecipe: LikableRecipe, + modifier: Modifier = Modifier, + onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit, + onLikeCLick: () -> Unit, ) { val scaffoldState = rememberBottomSheetScaffoldState( rememberStandardBottomSheetState(initialValue = SheetValue.PartiallyExpanded) @@ -114,9 +125,10 @@ private fun RecipeDetailScreen( Box( modifier = modifier.fillMaxSize() ) { - NetworkImage( - url = recipe.image, - modifier = Modifier + RecipeImage( + imageUrl = likableRecipe.recipe.image, + modifier = + Modifier .fillMaxWidth() .height(screenHeight * 0.5f) .align(Alignment.TopCenter), @@ -125,8 +137,8 @@ private fun RecipeDetailScreen( scaffoldState = scaffoldState, sheetContent = { RecipeDetailCard( - recipe = recipe, - modifier = Modifier + likableRecipe.recipe, + Modifier.height(screenHeight * 0.98f), ) }, sheetContainerColor = Color.White, @@ -262,17 +274,24 @@ fun RecipeDetailCardPreview() { @Composable fun RecipeDetailScreenPreview() { RecipeDetailScreen( - recipe = 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 = RecipeDifficulty.BEGINNER, - have = listOf("계란", "간장"), - need = listOf("식초", "당근", "감자"), - ), + likableRecipe = + LikableRecipe( + recipe = + 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 = RecipeDifficulty.BEGINNER, + have = listOf("계란", "간장"), + need = listOf("식초", "당근", "감자"), + ), + isLiked = false, + ), + onLikeCLick = {}, + onChangeSystemBarsColor = { color, darkIcons -> }, ) } From b73516633d3b65b1a8fb17d25cee0d0b8edb9129 Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 17:29:53 +0900 Subject: [PATCH 16/19] =?UTF-8?q?feat(RecipeDetailScreen):=20=EC=83=81?= =?UTF-8?q?=EB=8B=A8=EA=B9=8C=EC=A7=80=20=EC=8A=A4=ED=81=AC=EB=A1=A4=20?= =?UTF-8?q?=ED=95=98=EB=A9=B4=20=EC=83=89=EA=B9=94=EC=9D=B4=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=EB=90=98=EB=8A=94=20TopBar=20=EB=A5=BC=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe/detail/RecipeDetailScreen.kt | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt index 63e95e2..b80b4ad 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt @@ -116,11 +116,31 @@ private fun RecipeDetailScreen( onChangeSystemBarsColor: (color: Color, darkIcons: Boolean) -> Unit, onLikeCLick: () -> Unit, ) { - val scaffoldState = rememberBottomSheetScaffoldState( - rememberStandardBottomSheetState(initialValue = SheetValue.PartiallyExpanded) - ) + val scaffoldState = + rememberBottomSheetScaffoldState( + rememberStandardBottomSheetState(initialValue = SheetValue.PartiallyExpanded), + ) val screenHeight = LocalConfiguration.current.screenHeightDp.dp + val onBackPressedDispatcher = LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher + + var topBarIconColor by remember { mutableStateOf(Color.White) } // 초기 아이콘 색상 설정 + var topBarBackgroundColor by remember { mutableStateOf(Color.Transparent) } + + LaunchedEffect(scaffoldState.bottomSheetState) { + snapshotFlow { scaffoldState.bottomSheetState.requireOffset() } + .collect { offsetValue -> + if (offsetValue.dp >= (screenHeight * 0.4f)) { + topBarBackgroundColor = Color.Transparent + topBarIconColor = Color.White + onChangeSystemBarsColor(Color.Transparent, false) + } else { + topBarBackgroundColor = Color.White + topBarIconColor = Color.Gray + onChangeSystemBarsColor(Color.White, true) + } + } + } Box( modifier = modifier.fillMaxSize() @@ -144,9 +164,19 @@ private fun RecipeDetailScreen( sheetContainerColor = Color.White, sheetPeekHeight = screenHeight * 0.7f, ) {} - val context = LocalContext.current - Button( - modifier = Modifier + + RecipeTobBar( + backgroundColor = topBarBackgroundColor, + navigationIconColor = topBarIconColor, + actionIconColor = topBarIconColor, + onBackClick = { onBackPressedDispatcher?.onBackPressed() }, + onLikeClick = onLikeCLick, + ) + + BtnMoveToRecipe( + likableRecipe.recipe.link, + modifier = + Modifier .align(Alignment.BottomCenter) .padding(bottom = 60.dp), colors = ButtonColors( From 84c918252c7b97ca444bfee85df79e43644be8dc Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 17:30:59 +0900 Subject: [PATCH 17/19] =?UTF-8?q?feat(RecipeDetailScreen):=20Recipe=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=EC=97=90=20=EA=B7=B8=EB=A6=BC?= =?UTF-8?q?=EC=9E=90=20=EA=B7=B8=EB=9D=BC=EB=8D=B0=EC=9D=B4=EC=85=98?= =?UTF-8?q?=EC=9D=84=20=EB=84=A3=EB=8A=94=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe/detail/RecipeDetailScreen.kt | 166 ++++-------------- 1 file changed, 34 insertions(+), 132 deletions(-) diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt index b80b4ad..9e76363 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt @@ -1,50 +1,41 @@ package com.sundaegukbap.banchango.feature.recipe.detail -import android.content.Intent -import android.net.Uri +import androidx.activity.compose.LocalOnBackPressedDispatcherOwner import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.material3.BottomSheetScaffold -import androidx.compose.material3.Button -import androidx.compose.material3.ButtonColors import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.SheetValue -import androidx.compose.material3.Text import androidx.compose.material3.rememberBottomSheetScaffoldState import androidx.compose.material3.rememberStandardBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalConfiguration -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import androidx.core.content.ContextCompat.startActivity import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.sundaegukbap.banchango.LikableRecipe import com.sundaegukbap.banchango.Recipe import com.sundaegukbap.banchango.RecipeDifficulty import com.sundaegukbap.banchango.core.designsystem.component.NetworkImage -import com.sundaegukbap.banchango.core.designsystem.theme.LightOrange -import com.sundaegukbap.banchango.core.designsystem.theme.Orange @Composable fun RecipeDetailRoute( @@ -107,7 +98,6 @@ private fun RecipeDetailLoading() { } } - @OptIn(ExperimentalMaterial3Api::class) @Composable private fun RecipeDetailScreen( @@ -179,127 +169,39 @@ private fun RecipeDetailScreen( Modifier .align(Alignment.BottomCenter) .padding(bottom = 60.dp), - colors = ButtonColors( - containerColor = Orange, - contentColor = Color.White, - disabledContainerColor = LightOrange, - disabledContentColor = Color.White - ), - onClick = { - context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(recipe.link))) - }, - ) { - Text(text = "레시피 이동하기") - } + ) } } @Composable -private fun RecipeDetailCard( - recipe: Recipe, - modifier: Modifier = Modifier +private fun RecipeImage( + imageUrl: String, + modifier: Modifier, ) { - Box( - modifier = modifier - .fillMaxSize() - ) { - - Column( - Modifier.padding(horizontal = 16.dp) - ) { - RecipeDetailInfo( - difficulty = recipe.difficulty, - serving = recipe.servings, - cookingTime = recipe.cookingTime, - modifier = Modifier - .fillMaxWidth() - .align(Alignment.CenterHorizontally), - paddingHorizontal = 32, - ) - - Text( - modifier = Modifier.padding(top = 20.dp), - text = recipe.name, - fontSize = 20.sp, - fontWeight = FontWeight.Bold - ) - - Text( - text = recipe.introduction, - fontSize = 12.sp, - modifier = Modifier.padding(top = 12.dp) - ) - - - Box( - modifier = Modifier - .fillMaxWidth() - .padding(top = 20.dp) - ) { - Text( - text = "식재료", - fontSize = 12.sp, - fontWeight = FontWeight.Bold, - ) - Text( - text = "${recipe.have.size}/${recipe.have.size + recipe.need.size}", - color = Color.White, - fontSize = 12.sp, - fontWeight = FontWeight.Bold, - modifier = Modifier - .background(color = Orange, shape = CircleShape) - .padding(horizontal = 8.dp) - .align(Alignment.CenterEnd) - ) - } - - HorizontalDivider(modifier = Modifier.padding(top = 12.dp), color = Orange) - LazyRow( - modifier = Modifier.padding(top = 16.dp), - horizontalArrangement = Arrangement.spacedBy(12.dp), - ) { - items(recipe.have) { - Box( - modifier = Modifier - .border(1.dp, color = Orange, shape = CircleShape) - .background(color = Color.White, shape = CircleShape) - ) { - Text(modifier = Modifier.padding(16.dp), text = it) - } - } - items(recipe.need) { - Box( - modifier = Modifier - .border(1.dp, color = Orange, shape = CircleShape) - .background(color = LightOrange, shape = CircleShape) - ) { - Text(modifier = Modifier.padding(16.dp), text = it) - } - } - } - } + Box(modifier = modifier) { + NetworkImage( + url = imageUrl, + modifier = Modifier.fillMaxSize(), + ) + Box( + Modifier + .fillMaxSize() + .background( + brush = + Brush.verticalGradient( + colors = + listOf( + Color.Black.copy(alpha = 0.3f), + Color.Transparent, + ), + startY = 0f, + endY = Float.POSITIVE_INFINITY, + ), + ), + ) } } -@Preview(showBackground = true) -@Composable -fun RecipeDetailCardPreview() { - RecipeDetailCard( - recipe = 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 = RecipeDifficulty.BEGINNER, - have = listOf("계란", "간장"), - need = listOf("식초", "당근", "감자"), - ), - ) -} - @Preview(showBackground = true) @Composable fun RecipeDetailScreenPreview() { From d310ba8f5d153d0f6f557e3a13ce17a319335623 Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 17:31:36 +0900 Subject: [PATCH 18/19] =?UTF-8?q?feat(RecipeDetailScreen):=20=EB=B3=B4?= =?UTF-8?q?=EC=97=AC=EC=A3=BC=EB=8A=94=20=ED=99=94=EB=A9=B4=20=ED=81=AC?= =?UTF-8?q?=EA=B8=B0=EB=A5=BC=20=EB=84=A4=EB=B9=84=EA=B2=8C=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=EB=B0=94=20=EC=A0=84=EA=B9=8C=EC=A7=80=EB=A1=9C=20?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../banchango/feature/recipe/detail/RecipeDetailScreen.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt index 9e76363..b226b83 100644 --- a/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt +++ b/Android/feature/recipe/src/main/java/com/sundaegukbap/banchango/feature/recipe/detail/RecipeDetailScreen.kt @@ -133,7 +133,10 @@ private fun RecipeDetailScreen( } Box( - modifier = modifier.fillMaxSize() + modifier = + modifier + .windowInsetsPadding(WindowInsets.navigationBars) + .fillMaxSize(), ) { RecipeImage( imageUrl = likableRecipe.recipe.image, From decc4122b77d32cdf1383b69995659896f7b4f90 Mon Sep 17 00:00:00 2001 From: SeongHoonC Date: Sun, 21 Jul 2024 17:33:26 +0900 Subject: [PATCH 19/19] =?UTF-8?q?chore:=20gitIgnore=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Android/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/Android/.gitignore b/Android/.gitignore index aa724b7..226d61c 100644 --- a/Android/.gitignore +++ b/Android/.gitignore @@ -7,6 +7,7 @@ /.idea/workspace.xml /.idea/navEditor.xml /.idea/assetWizardSettings.xml +/.idea/deploymentTargetSelector.xml .DS_Store /build /captures