Skip to content

Commit

Permalink
[feature/get_restaurant] 별점 칩 활성화 구현 (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
SsongSik committed Jan 6, 2024
1 parent 8e63930 commit 570ae28
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class DetailContract {
data class OnClickRestaurantCategoryType(val restaurantCategoryType: RestaurantCategoryType) : DetailEvent()
data class OnClickRating(val rating: Int) : DetailEvent()
object OnDeleteClickRestaurantCategoryType : DetailEvent()
object OnDeleteClickRating : DetailEvent()
}

sealed class DetailEffect : ViewSideEffect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.ui.res.vectorResource
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.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
Expand Down Expand Up @@ -138,15 +139,13 @@ fun DetailListScreen(
) {
DetailScreenChip(
title = detailListViewState.detailSortCategoryType.title(),
isCategory = true,
onChipClicked = {
detailListViewModel.setEvent(DetailContract.DetailEvent.SortBottomSheetStateChange(true))
}
)
Spacer(modifier = Modifier.padding(4.dp))
DetailScreenChip(
title = "필터",
isCategory = true,
onChipClicked = {
detailListViewModel.setEvent(DetailContract.DetailEvent.MealRatingBottomSheetStateChange(true))
},
Expand All @@ -163,6 +162,18 @@ fun DetailListScreen(
detailListViewState = detailListViewState
)
}
if(detailListViewState.rating != 0) {
Spacer(modifier = Modifier.padding(4.dp))
DetailScreenChip(
title = "${detailListViewState.rating}",
isCategory = false,
isRating = true,
onChipClicked = {
detailListViewModel.setEvent(DetailContract.DetailEvent.OnDeleteClickRating)
},
detailListViewState = detailListViewState
)
}
// DetailScreenChip(
// title = "TEST신고버튼",
// isCategory = true,
Expand Down Expand Up @@ -190,7 +201,8 @@ fun DetailListScreen(
@Composable
fun DetailScreenChip(
title: String,
isCategory: Boolean,
isCategory: Boolean = true,
isRating: Boolean = false,
onChipClicked: () -> Unit,
detailListViewState: DetailContract.DetailState? = null
) {
Expand All @@ -213,16 +225,26 @@ fun DetailScreenChip(
Row(
verticalAlignment = Alignment.CenterVertically
) {
if(isRating) {
Image(
modifier = Modifier
.padding(start = 12.dp, top = 8.dp, bottom = 8.dp)
.size(16.dp),
imageVector = ImageVector.vectorResource(id = R.drawable.icon_gray_star_mono),
contentDescription = "gray_star",
colorFilter = ColorFilter.tint(Main100)
)
}
Text(
text = title,
color = when {
detailListViewState == null -> Grey7
isRatingOrCategory -> Main100
else -> Grey7
},
style = Typography.bodySmall,
modifier = Modifier.padding(start = 12.dp, end = 4.dp, top = 6.dp, bottom = 6.dp),
fontWeight = FontWeight.Bold
fontSize = 14.sp,
modifier = Modifier.padding(start = if(!isRating) 12.dp else 4.dp, end = 4.dp, top = 6.dp, bottom = 6.dp),
fontWeight = FontWeight.SemiBold
)
if(isCategory) {
Image(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class DetailListViewModel @Inject constructor(
)
getRestaurantList()
}
is DetailEvent.OnDeleteClickRating -> {
reflectUpdateState(
rating = 0
)
getRestaurantList()
}
}
}

Expand Down

0 comments on commit 570ae28

Please sign in to comment.