Skip to content

Commit d2371f6

Browse files
committed
[feature/home_api] MyPage 각 메뉴 클릭 구현 (#93)
1 parent b02cce9 commit d2371f6

File tree

8 files changed

+139
-51
lines changed

8 files changed

+139
-51
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ fun RestaurantTitle(
7575
) {
7676
Row(
7777
modifier = modifier,
78+
verticalAlignment = Alignment.CenterVertically,
7879
) {
7980
Text(
8081
modifier = Modifier.padding(top = 6.dp),
@@ -105,7 +106,9 @@ fun RestaurantLoveCount(
105106
onLoveClick: () -> Unit,
106107
) {
107108
Column(
108-
modifier = Modifier.clickable(
109+
modifier = Modifier
110+
.padding(top = 6.dp)
111+
.clickable(
109112
indication = null,
110113
interactionSource = remember { MutableInteractionSource() }
111114
) { onLoveClick() },

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

+1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ enum class EveryMealRoute(val route: String) {
3939
DETAIL_LIST("detail-list"),
4040
DETAIL_RESTAURANT("detail-restaurant"),
4141
SCHOOL_AUTH("school-auth"),
42+
WITH_DRAW("with-draw")
4243
}

presentation/src/main/java/com/everymeal/presentation/ui/main/MainScreen.kt

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.everymeal.presentation.ui.bottom.navigateBottomNavigationScreen
2020
import com.everymeal.presentation.ui.detail.DetailListScreen
2121
import com.everymeal.presentation.ui.home.HomeScreen
2222
import com.everymeal.presentation.ui.mypage.MyPageScreen
23+
import com.everymeal.presentation.ui.mypage.WithDrawScreen
2324
import com.everymeal.presentation.ui.restaurant.DetailRestaurantScreen
2425
import com.everymeal.presentation.ui.signup.school.SchoolAuthScreen
2526
import com.everymeal.presentation.ui.univfood.UnivFoodScreen
@@ -73,7 +74,11 @@ fun MainScreen(
7374
WhatFoodScreen()
7475
}
7576
composable(route = EveryMealRoute.MY_PAGE.route) {
76-
MyPageScreen()
77+
MyPageScreen(
78+
withDrawClick = {
79+
navController.navigate(EveryMealRoute.WITH_DRAW.route)
80+
}
81+
)
7782
}
7883
composable(route = EveryMealRoute.DETAIL_LIST.route.plus("/{$DETAIL_SCREEN_TYPE}")) {
7984
val detailScreenType = it.arguments?.getString(DETAIL_SCREEN_TYPE) ?: ""
@@ -100,6 +105,9 @@ fun MainScreen(
100105
}
101106
)
102107
}
108+
composable(route = EveryMealRoute.WITH_DRAW.route) {
109+
WithDrawScreen()
110+
}
103111
}
104112
}
105113

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.everymeal.presentation.ui.mypage
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 MyPageContract {
9+
data class MyPageState(
10+
val uiState: LoadState = LoadState.LOADING,
11+
) : ViewState
12+
13+
sealed class MyPageEvent : ViewEvent {
14+
15+
}
16+
17+
sealed class MyPageEffect : ViewSideEffect {
18+
19+
}
20+
}
21+
22+
enum class MyPageSetting(val type : String) {
23+
INQUIRY("문의하기"),
24+
SERVICE_TERMS("서비스 약관"),
25+
OPEN_SOURCE_LICENSE("오픈소스 라이센스"),
26+
VERSION_INFO("버전 정보"),
27+
WITHDRAWAL("탈퇴하기")
28+
}

presentation/src/main/java/com/everymeal/presentation/ui/mypage/MyPageScreen.kt

+39-19
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ import androidx.compose.material3.ExperimentalMaterial3Api
1717
import androidx.compose.material3.Icon
1818
import androidx.compose.material3.Scaffold
1919
import androidx.compose.material3.Text
20-
import androidx.compose.material3.TopAppBar
21-
import androidx.compose.material3.TopAppBarColors
22-
import androidx.compose.material3.TopAppBarDefaults
2320
import androidx.compose.runtime.Composable
2421
import androidx.compose.ui.Alignment
2522
import androidx.compose.ui.Modifier
@@ -30,6 +27,7 @@ import androidx.compose.ui.res.stringResource
3027
import androidx.compose.ui.res.vectorResource
3128
import androidx.compose.ui.tooling.preview.Preview
3229
import androidx.compose.ui.unit.dp
30+
import androidx.hilt.navigation.compose.hiltViewModel
3331
import com.everymeal.presentation.R
3432
import com.everymeal.presentation.ui.theme.EveryMealTypography
3533
import com.everymeal.presentation.ui.theme.Gray100
@@ -40,10 +38,10 @@ import com.everymeal.presentation.ui.theme.Gray800
4038
import com.everymeal.presentation.ui.theme.Gray900
4139

4240

43-
@OptIn(ExperimentalMaterial3Api::class)
4441
@Composable
4542
fun MyPageScreen(
46-
43+
viewModel : MyPageViewModel = hiltViewModel(),
44+
withDrawClick : () -> Unit = {}
4745
) {
4846
Scaffold { innerPadding ->
4947
LazyColumn(
@@ -63,7 +61,9 @@ fun MyPageScreen(
6361
}
6462

6563
item(key = "My Activities") {
66-
MyActivities(Modifier.padding(horizontal = 20.dp))
64+
MyActivities(Modifier.padding(horizontal = 20.dp)) {
65+
66+
}
6767
Spacer(modifier = Modifier.padding(24.dp))
6868
Divider(
6969
color = Gray100,
@@ -73,7 +73,25 @@ fun MyPageScreen(
7373
}
7474

7575
item(key = "My Settings") {
76-
MySettings(Modifier.padding(horizontal = 20.dp))
76+
MySettings(Modifier.padding(horizontal = 20.dp)) {
77+
when(it) {
78+
MyPageSetting.INQUIRY.type -> {
79+
// TODO
80+
}
81+
MyPageSetting.SERVICE_TERMS.type -> {
82+
// TODO
83+
}
84+
MyPageSetting.OPEN_SOURCE_LICENSE.type -> {
85+
// TODO
86+
}
87+
MyPageSetting.VERSION_INFO.type -> {
88+
// TODO
89+
}
90+
MyPageSetting.WITHDRAWAL.type -> {
91+
withDrawClick()
92+
}
93+
}
94+
}
7795
Spacer(modifier = Modifier.padding(24.dp))
7896
}
7997
}
@@ -139,7 +157,8 @@ fun MyInformation(
139157

140158
@Composable
141159
fun MyActivities(
142-
modifier: Modifier = Modifier
160+
modifier: Modifier = Modifier,
161+
onClick: (String) -> Unit
143162
) {
144163
Column (
145164
modifier = modifier
@@ -166,7 +185,8 @@ fun MyActivities(
166185

167186
@Composable
168187
fun MySettings(
169-
modifier: Modifier = Modifier
188+
modifier: Modifier = Modifier,
189+
onClick: (String) -> Unit
170190
) {
171191
Column (
172192
modifier = modifier
@@ -177,25 +197,25 @@ fun MySettings(
177197
color = Gray900
178198
)
179199
MyTabMenu(
180-
menuTitle = "문의하기",
181-
onClick = { }
200+
menuTitle = MyPageSetting.INQUIRY.type,
201+
onClick = { onClick(MyPageSetting.INQUIRY.type) }
182202
)
183203
MyTabMenu(
184-
menuTitle = "서비스 약관",
185-
onClick = { }
204+
menuTitle = MyPageSetting.SERVICE_TERMS.type,
205+
onClick = { onClick(MyPageSetting.SERVICE_TERMS.type) }
186206
)
187207
MyTabMenu(
188-
menuTitle = "오픈소스 라이센스",
189-
onClick = { }
208+
menuTitle = MyPageSetting.OPEN_SOURCE_LICENSE.type,
209+
onClick = { onClick(MyPageSetting.OPEN_SOURCE_LICENSE.type) }
190210
)
191211
MyTabMenu(
192-
menuTitle = "버전 정보",
212+
menuTitle = MyPageSetting.VERSION_INFO.type,
193213
isAppVersion = true,
194-
onClick = { }
214+
onClick = { onClick(MyPageSetting.VERSION_INFO.type) }
195215
)
196216
MyTabMenu(
197-
menuTitle = "탈퇴하기",
198-
onClick = { }
217+
menuTitle = MyPageSetting.WITHDRAWAL.type,
218+
onClick = { onClick(MyPageSetting.WITHDRAWAL.type) }
199219
)
200220
}
201221
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.everymeal.presentation.ui.mypage
2+
3+
import com.everymeal.presentation.base.BaseViewModel
4+
import javax.inject.Inject
5+
6+
class MyPageViewModel @Inject constructor(
7+
8+
): BaseViewModel<MyPageContract.MyPageState, MyPageContract.MyPageEffect, MyPageContract.MyPageEvent>(
9+
MyPageContract.MyPageState()
10+
) {
11+
12+
override fun handleEvents(event: MyPageContract.MyPageEvent) {
13+
14+
}
15+
}
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.everymeal.presentation.ui.mypage
2+
3+
import androidx.compose.runtime.Composable
4+
5+
@Composable
6+
fun WithDrawScreen() {
7+
8+
}

presentation/src/main/java/com/everymeal/presentation/ui/restaurant/DetailRestaurantScreen.kt

+34-30
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ fun DetailRestaurantMainInfo(
344344
.weight(1f)
345345
.padding(vertical = 12.dp),
346346
horizontalArrangement = Arrangement.Center,
347+
verticalAlignment = Alignment.CenterVertically,
347348
) {
348349
Image(
349350
modifier = Modifier.size(24.dp),
@@ -441,7 +442,9 @@ fun DetailRestaurantTabLayout(
441442
restaurantInfo = restaurantInfo,
442443
modifier = Modifier.padding(horizontal = 20.dp)
443444
)
444-
1 -> DetailRestaurantTabImage()
445+
1 -> DetailRestaurantTabImage(
446+
restaurantInfo = restaurantInfo
447+
)
445448
2 -> DetailRestaurantReview()
446449
}
447450
}
@@ -510,36 +513,37 @@ fun DetailRestaurantTabInfo(
510513
}
511514

512515
@Composable
513-
fun DetailRestaurantTabImage() {
514-
// Mock Data
515-
val items = listOf(
516-
R.drawable.food_ex_1,
517-
R.drawable.food_ex_2,
518-
R.drawable.food_ex_3,
519-
R.drawable.food_ex_1,
520-
R.drawable.food_ex_2,
521-
R.drawable.food_ex_3,
522-
R.drawable.food_ex_1,
523-
R.drawable.food_ex_2,
524-
R.drawable.food_ex_3,
525-
)
526-
516+
fun DetailRestaurantTabImage(
517+
restaurantInfo : RestaurantDataEntity
518+
) {
527519
Column {
528-
for (rowItems in items.chunked(3)) {
529-
Row(
530-
modifier = Modifier
531-
.fillMaxWidth()
532-
.padding(bottom = 3.dp),
533-
) {
534-
for (item in rowItems) {
535-
Image(
536-
painter = painterResource(id = item),
537-
contentDescription = null,
538-
modifier = Modifier
539-
.padding(end = if (rowItems.indexOf(item) != 2) 3.dp else 0.dp)
540-
.weight(1f)
541-
.aspectRatio(1f)
542-
)
520+
restaurantInfo.images?.let { images ->
521+
for (rowItems in images.chunked(3)) {
522+
Row(
523+
modifier = Modifier
524+
.fillMaxWidth()
525+
.padding(bottom = 3.dp),
526+
horizontalArrangement = Arrangement.spacedBy(3.dp)
527+
) {
528+
rowItems.forEach { item ->
529+
AsyncImage(
530+
model = item,
531+
contentDescription = null,
532+
modifier = Modifier
533+
.weight(1f)
534+
.aspectRatio(1f),
535+
contentScale = ContentScale.Crop
536+
)
537+
}
538+
if (rowItems.size < 3) {
539+
repeat(3 - rowItems.size) {
540+
Box(
541+
modifier = Modifier
542+
.weight(1f)
543+
.aspectRatio(1f)
544+
)
545+
}
546+
}
543547
}
544548
}
545549
}

0 commit comments

Comments
 (0)