Skip to content

Commit d76a0ad

Browse files
authored
Merge pull request #57 from everymeals/feature/more_list
[feature/more_list] 맛집 카테고리 별 상세 화면에 들어갈 바텀다이얼로그 구현
2 parents b8a044a + 1b4051f commit d76a0ad

15 files changed

+586
-32
lines changed

presentation/src/main/java/com/everymeal/presentation/components/EveryMealBottomSheetDialog.kt

+163
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
11
package com.everymeal.presentation.components
22

33
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.clickable
5+
import androidx.compose.foundation.interaction.MutableInteractionSource
6+
import androidx.compose.foundation.layout.Arrangement
47
import androidx.compose.foundation.layout.Column
8+
import androidx.compose.foundation.layout.Row
59
import androidx.compose.foundation.layout.Spacer
610
import androidx.compose.foundation.layout.fillMaxWidth
711
import androidx.compose.foundation.layout.padding
812
import androidx.compose.foundation.layout.size
13+
import androidx.compose.foundation.lazy.LazyRow
14+
import androidx.compose.foundation.shape.RoundedCornerShape
915
import androidx.compose.material3.ExperimentalMaterial3Api
1016
import androidx.compose.material3.ModalBottomSheet
17+
import androidx.compose.material3.Surface
1118
import androidx.compose.material3.Text
1219
import androidx.compose.runtime.Composable
20+
import androidx.compose.runtime.remember
21+
import androidx.compose.ui.Alignment
1322
import androidx.compose.ui.Modifier
1423
import androidx.compose.ui.graphics.Color
24+
import androidx.compose.ui.graphics.vector.ImageVector
1525
import androidx.compose.ui.res.painterResource
1626
import androidx.compose.ui.res.stringResource
27+
import androidx.compose.ui.res.vectorResource
1728
import androidx.compose.ui.text.font.FontWeight
1829
import androidx.compose.ui.unit.dp
1930
import androidx.compose.ui.unit.sp
2031
import com.everymeal.presentation.R
32+
import com.everymeal.presentation.ui.home.CategoryItem
33+
import com.everymeal.presentation.ui.home.HomeCategoryList
2134
import com.everymeal.presentation.ui.theme.Gray600
2235
import com.everymeal.presentation.ui.theme.Gray900
36+
import com.everymeal.presentation.ui.theme.Grey2
37+
import com.everymeal.presentation.ui.theme.Grey7
38+
import com.everymeal.presentation.ui.theme.Typography
2339

2440
@OptIn(ExperimentalMaterial3Api::class)
2541
@Composable
@@ -65,4 +81,151 @@ fun EveryMealMainBottomSheetDialog(
6581
Spacer(modifier = Modifier.padding(10.dp))
6682
}
6783
}
84+
}
85+
86+
@OptIn(ExperimentalMaterial3Api::class)
87+
@Composable
88+
fun EveryMealSortCategoryBottomSheetDialog(
89+
onClick: (String) -> Unit,
90+
onDismiss: () -> Unit
91+
) {
92+
ModalBottomSheet(
93+
onDismissRequest = { onDismiss() },
94+
containerColor = Color.White,
95+
) {
96+
Column(
97+
modifier = Modifier
98+
.fillMaxWidth()
99+
.padding(horizontal = 20.dp)
100+
) {
101+
Text(
102+
modifier = Modifier
103+
.fillMaxWidth()
104+
.clickable { onClick("인기순") }
105+
.padding(vertical = 14.dp),
106+
text = stringResource(R.string.popularity_sort),
107+
fontSize = 17.sp,
108+
color = Gray900,
109+
fontWeight = FontWeight.SemiBold,
110+
)
111+
Spacer(modifier = Modifier.padding(4.dp))
112+
Text(
113+
modifier = Modifier
114+
.fillMaxWidth()
115+
.clickable { onClick("거리순") }
116+
.padding(vertical = 14.dp),
117+
text = stringResource(R.string.distance_sort),
118+
fontSize = 17.sp,
119+
color = Gray900,
120+
fontWeight = FontWeight.SemiBold,
121+
)
122+
Spacer(modifier = Modifier.padding(4.dp))
123+
Text(
124+
modifier = Modifier
125+
.fillMaxWidth()
126+
.clickable { onClick("최신순") }
127+
.padding(vertical = 14.dp),
128+
text = stringResource(R.string.recent_sort),
129+
fontSize = 17.sp,
130+
color = Gray900,
131+
fontWeight = FontWeight.SemiBold,
132+
)
133+
Spacer(modifier = Modifier.padding(10.dp))
134+
}
135+
}
136+
}
137+
138+
@OptIn(ExperimentalMaterial3Api::class)
139+
@Composable
140+
fun EveryMealCategoryRatingBottomSheetDialog(
141+
onClick: () -> Unit,
142+
onDismiss: () -> Unit,
143+
onCategoryClick: (String) -> Unit,
144+
onRatingClick: (Int) -> Unit
145+
) {
146+
ModalBottomSheet(
147+
onDismissRequest = { onDismiss() },
148+
containerColor = Color.White,
149+
) {
150+
Column(
151+
modifier = Modifier
152+
.fillMaxWidth()
153+
.padding(horizontal = 20.dp)
154+
) {
155+
Text(
156+
modifier = Modifier
157+
.fillMaxWidth()
158+
.padding(vertical = 14.dp),
159+
text = stringResource(R.string.meal_category),
160+
fontSize = 17.sp,
161+
color = Gray900,
162+
fontWeight = FontWeight.SemiBold,
163+
)
164+
Spacer(modifier = Modifier.padding(4.dp))
165+
HomeCategoryList(
166+
isBottomSheet = true
167+
) {
168+
onCategoryClick(it)
169+
}
170+
Spacer(modifier = Modifier.padding(4.dp))
171+
Text(
172+
modifier = Modifier
173+
.fillMaxWidth()
174+
.padding(vertical = 14.dp),
175+
text = stringResource(R.string.rating_category),
176+
fontSize = 17.sp,
177+
color = Gray900,
178+
fontWeight = FontWeight.SemiBold,
179+
)
180+
Spacer(modifier = Modifier.padding(4.dp))
181+
LazyRow(content = {
182+
items(5) {
183+
RatingItem(
184+
ratingCount = it + 1,
185+
onRatingClick = onRatingClick
186+
)
187+
Spacer(modifier = Modifier.padding(4.dp))
188+
}
189+
})
190+
Spacer(modifier = Modifier.padding(4.dp))
191+
EveryMealMainButton(
192+
text = stringResource(R.string.meal_rating_category_apply),
193+
onClick = onClick,
194+
)
195+
Spacer(modifier = Modifier.padding(10.dp))
196+
}
197+
}
198+
}
199+
200+
@Composable
201+
fun RatingItem(
202+
ratingCount: Int,
203+
onRatingClick: (Int) -> Unit
204+
) {
205+
Surface(
206+
modifier = Modifier.clickable(
207+
indication = null,
208+
interactionSource = remember { MutableInteractionSource() }
209+
) { onRatingClick(ratingCount) },
210+
color = Grey2,
211+
shape = RoundedCornerShape(100.dp),
212+
) {
213+
Row(
214+
verticalAlignment = Alignment.CenterVertically
215+
) {
216+
Image(
217+
modifier = Modifier
218+
.padding(start = 12.dp)
219+
.size(16.dp),
220+
imageVector = ImageVector.vectorResource(R.drawable.icon_gray_star_mono),
221+
contentDescription = "rating"
222+
)
223+
Text(
224+
text = ratingCount.toString(),
225+
color = Grey7,
226+
style = Typography.bodySmall,
227+
modifier = Modifier.padding(start = 4.dp, end = 12.dp, top = 6.dp, bottom = 6.dp)
228+
)
229+
}
230+
}
68231
}

presentation/src/main/java/com/everymeal/presentation/components/EveryMealRestaurantItem.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ fun RestaurantImage(restaurant: Restaurant) {
254254
@Composable
255255
fun HomeScreenPreview() {
256256
EveryMeal_AndroidTheme {
257-
HomeScreen()
257+
HomeScreen() {
258+
259+
}
258260
}
259261
}

presentation/src/main/java/com/everymeal/presentation/ui/bottom/BottomNavigation.kt

+1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ enum class EveryMealRoute(val route: String) {
3636
UNIV_FOOD("univ-food"),
3737
WHAT_FOOD("what-food"),
3838
MY_PAGE("my-page"),
39+
DETAIL_LIST("detail-list"),
3940
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.everymeal.presentation.ui.detail
2+
3+
import com.everymeal.presentation.base.LoadState
4+
import com.everymeal.presentation.base.ViewEvent
5+
import com.everymeal.presentation.base.ViewSideEffect
6+
import com.everymeal.presentation.base.ViewState
7+
8+
class DetailContract {
9+
data class DetailState(
10+
val uiState: LoadState = LoadState.SUCCESS,
11+
val detailSortCategoryType: DetailSortCategoryType = DetailSortCategoryType.POPULARITY,
12+
val sortBottomSheetState: Boolean = false,
13+
val mealRatingBottomSheetState: Boolean = false,
14+
) : ViewState
15+
16+
sealed class DetailEvent : ViewEvent {
17+
data class OnClickDetailListCategoryType(val detailSortCategoryType: DetailSortCategoryType) : DetailEvent()
18+
data class SortBottomSheetStateChange(val sortBottomSheetState: Boolean) : DetailEvent()
19+
data class MealRatingBottomSheetStateChange(val mealRatingBottomSheetState: Boolean) : DetailEvent()
20+
}
21+
22+
sealed class HomeEffect : ViewSideEffect {
23+
24+
}
25+
}
26+
27+
enum class DetailSortCategoryType {
28+
POPULARITY,
29+
DISTANCE,
30+
RECENT
31+
}
32+
33+
fun String.DetailSortCategoryType(): DetailSortCategoryType {
34+
return when (this) {
35+
"인기순" -> DetailSortCategoryType.POPULARITY
36+
"거리순" -> DetailSortCategoryType.DISTANCE
37+
"최신순" -> DetailSortCategoryType.RECENT
38+
else -> DetailSortCategoryType.POPULARITY
39+
}
40+
}
41+
42+
fun DetailSortCategoryType.title(): String {
43+
return when (this) {
44+
DetailSortCategoryType.POPULARITY -> "인기순"
45+
DetailSortCategoryType.DISTANCE -> "거리순"
46+
DetailSortCategoryType.RECENT -> "최신순"
47+
}
48+
}

0 commit comments

Comments
 (0)