Skip to content

Commit

Permalink
Merge pull request #57 from everymeals/feature/more_list
Browse files Browse the repository at this point in the history
[feature/more_list] 맛집 카테고리 별 상세 화면에 들어갈 바텀다이얼로그 구현
  • Loading branch information
SsongSik authored Sep 21, 2023
2 parents b8a044a + 1b4051f commit d76a0ad
Show file tree
Hide file tree
Showing 15 changed files with 586 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
package com.everymeal.presentation.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.everymeal.presentation.R
import com.everymeal.presentation.ui.home.CategoryItem
import com.everymeal.presentation.ui.home.HomeCategoryList
import com.everymeal.presentation.ui.theme.Gray600
import com.everymeal.presentation.ui.theme.Gray900
import com.everymeal.presentation.ui.theme.Grey2
import com.everymeal.presentation.ui.theme.Grey7
import com.everymeal.presentation.ui.theme.Typography

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -65,4 +81,151 @@ fun EveryMealMainBottomSheetDialog(
Spacer(modifier = Modifier.padding(10.dp))
}
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EveryMealSortCategoryBottomSheetDialog(
onClick: (String) -> Unit,
onDismiss: () -> Unit
) {
ModalBottomSheet(
onDismissRequest = { onDismiss() },
containerColor = Color.White,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
) {
Text(
modifier = Modifier
.fillMaxWidth()
.clickable { onClick("인기순") }
.padding(vertical = 14.dp),
text = stringResource(R.string.popularity_sort),
fontSize = 17.sp,
color = Gray900,
fontWeight = FontWeight.SemiBold,
)
Spacer(modifier = Modifier.padding(4.dp))
Text(
modifier = Modifier
.fillMaxWidth()
.clickable { onClick("거리순") }
.padding(vertical = 14.dp),
text = stringResource(R.string.distance_sort),
fontSize = 17.sp,
color = Gray900,
fontWeight = FontWeight.SemiBold,
)
Spacer(modifier = Modifier.padding(4.dp))
Text(
modifier = Modifier
.fillMaxWidth()
.clickable { onClick("최신순") }
.padding(vertical = 14.dp),
text = stringResource(R.string.recent_sort),
fontSize = 17.sp,
color = Gray900,
fontWeight = FontWeight.SemiBold,
)
Spacer(modifier = Modifier.padding(10.dp))
}
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EveryMealCategoryRatingBottomSheetDialog(
onClick: () -> Unit,
onDismiss: () -> Unit,
onCategoryClick: (String) -> Unit,
onRatingClick: (Int) -> Unit
) {
ModalBottomSheet(
onDismissRequest = { onDismiss() },
containerColor = Color.White,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
) {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 14.dp),
text = stringResource(R.string.meal_category),
fontSize = 17.sp,
color = Gray900,
fontWeight = FontWeight.SemiBold,
)
Spacer(modifier = Modifier.padding(4.dp))
HomeCategoryList(
isBottomSheet = true
) {
onCategoryClick(it)
}
Spacer(modifier = Modifier.padding(4.dp))
Text(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 14.dp),
text = stringResource(R.string.rating_category),
fontSize = 17.sp,
color = Gray900,
fontWeight = FontWeight.SemiBold,
)
Spacer(modifier = Modifier.padding(4.dp))
LazyRow(content = {
items(5) {
RatingItem(
ratingCount = it + 1,
onRatingClick = onRatingClick
)
Spacer(modifier = Modifier.padding(4.dp))
}
})
Spacer(modifier = Modifier.padding(4.dp))
EveryMealMainButton(
text = stringResource(R.string.meal_rating_category_apply),
onClick = onClick,
)
Spacer(modifier = Modifier.padding(10.dp))
}
}
}

@Composable
fun RatingItem(
ratingCount: Int,
onRatingClick: (Int) -> Unit
) {
Surface(
modifier = Modifier.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }
) { onRatingClick(ratingCount) },
color = Grey2,
shape = RoundedCornerShape(100.dp),
) {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Image(
modifier = Modifier
.padding(start = 12.dp)
.size(16.dp),
imageVector = ImageVector.vectorResource(R.drawable.icon_gray_star_mono),
contentDescription = "rating"
)
Text(
text = ratingCount.toString(),
color = Grey7,
style = Typography.bodySmall,
modifier = Modifier.padding(start = 4.dp, end = 12.dp, top = 6.dp, bottom = 6.dp)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ fun RestaurantImage(restaurant: Restaurant) {
@Composable
fun HomeScreenPreview() {
EveryMeal_AndroidTheme {
HomeScreen()
HomeScreen() {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ enum class EveryMealRoute(val route: String) {
UNIV_FOOD("univ-food"),
WHAT_FOOD("what-food"),
MY_PAGE("my-page"),
DETAIL_LIST("detail-list"),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.everymeal.presentation.ui.detail

import com.everymeal.presentation.base.LoadState
import com.everymeal.presentation.base.ViewEvent
import com.everymeal.presentation.base.ViewSideEffect
import com.everymeal.presentation.base.ViewState

class DetailContract {
data class DetailState(
val uiState: LoadState = LoadState.SUCCESS,
val detailSortCategoryType: DetailSortCategoryType = DetailSortCategoryType.POPULARITY,
val sortBottomSheetState: Boolean = false,
val mealRatingBottomSheetState: Boolean = false,
) : ViewState

sealed class DetailEvent : ViewEvent {
data class OnClickDetailListCategoryType(val detailSortCategoryType: DetailSortCategoryType) : DetailEvent()
data class SortBottomSheetStateChange(val sortBottomSheetState: Boolean) : DetailEvent()
data class MealRatingBottomSheetStateChange(val mealRatingBottomSheetState: Boolean) : DetailEvent()
}

sealed class HomeEffect : ViewSideEffect {

}
}

enum class DetailSortCategoryType {
POPULARITY,
DISTANCE,
RECENT
}

fun String.DetailSortCategoryType(): DetailSortCategoryType {
return when (this) {
"인기순" -> DetailSortCategoryType.POPULARITY
"거리순" -> DetailSortCategoryType.DISTANCE
"최신순" -> DetailSortCategoryType.RECENT
else -> DetailSortCategoryType.POPULARITY
}
}

fun DetailSortCategoryType.title(): String {
return when (this) {
DetailSortCategoryType.POPULARITY -> "인기순"
DetailSortCategoryType.DISTANCE -> "거리순"
DetailSortCategoryType.RECENT -> "최신순"
}
}
Loading

0 comments on commit d76a0ad

Please sign in to comment.