Skip to content

Commit 5726563

Browse files
authored
Merge pull request #45 from everymeals/feature/home
[feature/home] 홈 화면 맛집모아보기 까지 Ui 구현
2 parents 40e639c + e84c44e commit 5726563

18 files changed

+805
-10
lines changed

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

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

3+
import androidx.compose.foundation.BorderStroke
34
import androidx.compose.foundation.layout.fillMaxWidth
45
import androidx.compose.foundation.layout.padding
56
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -50,10 +51,49 @@ fun EveryMealMainButton(
5051
}
5152
}
5253

54+
@Composable
55+
fun EveryMealLineButton(
56+
text: String,
57+
enabled: Boolean = true,
58+
onClick: () -> Unit,
59+
) {
60+
Button(
61+
modifier = Modifier
62+
.padding(horizontal = 20.dp)
63+
.fillMaxWidth()
64+
.padding(vertical = 16.dp),
65+
shape = RoundedCornerShape(12.dp),
66+
colors = ButtonDefaults.buttonColors(
67+
containerColor = Color.White,
68+
),
69+
enabled = enabled,
70+
onClick = onClick,
71+
border = BorderStroke(1.dp, Main100),
72+
) {
73+
Text(
74+
text = text,
75+
style = TextStyle(
76+
color = Main100,
77+
fontWeight = FontWeight.Medium,
78+
),
79+
fontSize = 16.sp,
80+
modifier = Modifier.padding(vertical = 8.dp)
81+
)
82+
}
83+
}
84+
5385
@Preview
5486
@Composable
55-
fun PreviewDisableButton() {
87+
fun EveryMealMainButtonPreview() {
5688
EveryMealMainButton(
5789
text = stringResource(R.string.select),
5890
) { }
91+
}
92+
93+
@Preview
94+
@Composable
95+
fun EveryMealLineButtonPreview() {
96+
EveryMealLineButton(
97+
text = stringResource(R.string.select),
98+
) { }
5999
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
package com.everymeal.presentation.components
2+
3+
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.background
5+
import androidx.compose.foundation.layout.Arrangement
6+
import androidx.compose.foundation.layout.Box
7+
import androidx.compose.foundation.layout.Column
8+
import androidx.compose.foundation.layout.Row
9+
import androidx.compose.foundation.layout.Spacer
10+
import androidx.compose.foundation.layout.aspectRatio
11+
import androidx.compose.foundation.layout.fillMaxSize
12+
import androidx.compose.foundation.layout.fillMaxWidth
13+
import androidx.compose.foundation.layout.padding
14+
import androidx.compose.foundation.shape.RoundedCornerShape
15+
import androidx.compose.material3.Text
16+
import androidx.compose.runtime.Composable
17+
import androidx.compose.ui.Alignment
18+
import androidx.compose.ui.Modifier
19+
import androidx.compose.ui.draw.clip
20+
import androidx.compose.ui.graphics.Color
21+
import androidx.compose.ui.graphics.vector.ImageVector
22+
import androidx.compose.ui.res.painterResource
23+
import androidx.compose.ui.res.stringResource
24+
import androidx.compose.ui.res.vectorResource
25+
import androidx.compose.ui.text.font.FontWeight
26+
import androidx.compose.ui.tooling.preview.Preview
27+
import androidx.compose.ui.unit.dp
28+
import androidx.compose.ui.unit.sp
29+
import com.everymeal.presentation.R
30+
import com.everymeal.presentation.ui.home.HomeScreen
31+
import com.everymeal.presentation.ui.home.Restaurant
32+
import com.everymeal.presentation.ui.theme.EveryMeal_AndroidTheme
33+
import com.everymeal.presentation.ui.theme.Gray300
34+
import com.everymeal.presentation.ui.theme.Gray500
35+
import com.everymeal.presentation.ui.theme.Gray600
36+
import com.everymeal.presentation.ui.theme.Gray700
37+
38+
@Composable
39+
fun EveryMealRestaurantItem(
40+
restaurant: Restaurant,
41+
onLoveClick: () -> Unit,
42+
) {
43+
Column(
44+
modifier = Modifier
45+
.fillMaxSize()
46+
.padding(horizontal = 20.dp)
47+
.background(color = Color.White)
48+
) {
49+
RestaurantTitle(restaurant)
50+
Spacer(modifier = Modifier.padding(4.dp))
51+
RestaurantInfo(restaurant)
52+
Spacer(modifier = Modifier.padding(4.dp))
53+
RestaurantImage(restaurant)
54+
}
55+
}
56+
57+
@Composable
58+
fun RestaurantTitle(restaurant: Restaurant) {
59+
Row(
60+
modifier = Modifier.fillMaxWidth(),
61+
verticalAlignment = Alignment.CenterVertically,
62+
) {
63+
Text(
64+
text = restaurant.name,
65+
color = Color.Black,
66+
fontSize = 17.sp,
67+
fontWeight = FontWeight.SemiBold,
68+
)
69+
Text(
70+
modifier = Modifier
71+
.padding(start = 4.dp)
72+
.clip(RoundedCornerShape(4.dp))
73+
.background(color = Gray300)
74+
.padding(vertical = 3.dp, horizontal = 6.dp),
75+
text = restaurant.category,
76+
color = Gray600,
77+
fontSize = 12.sp
78+
)
79+
Spacer(modifier = Modifier.weight(1f))
80+
Image(
81+
modifier = Modifier
82+
.padding(start = 4.dp),
83+
imageVector = ImageVector.vectorResource(R.drawable.icon_heart_mono),
84+
contentDescription = stringResource(R.string.icon_star),
85+
)
86+
}
87+
}
88+
89+
@Composable
90+
fun RestaurantInfo(restaurant: Restaurant) {
91+
Row(
92+
modifier = Modifier.fillMaxWidth(),
93+
verticalAlignment = Alignment.CenterVertically,
94+
) {
95+
Image(
96+
imageVector = ImageVector.vectorResource(R.drawable.icon_star_mono),
97+
contentDescription = stringResource(R.string.icon_star),
98+
)
99+
Text(
100+
modifier = Modifier.padding(start = 2.dp),
101+
text = restaurant.rating.toString(),
102+
color = Gray700,
103+
fontSize = 12.sp,
104+
fontWeight = FontWeight.Medium,
105+
)
106+
Text(
107+
modifier = Modifier.padding(start = 2.dp),
108+
text = "(${restaurant.reviewCount})",
109+
color = Gray700,
110+
fontSize = 12.sp,
111+
fontWeight = FontWeight.Medium,
112+
)
113+
Spacer(modifier = Modifier.weight(1f))
114+
Text(
115+
text = "${restaurant.loveCount}",
116+
color = Gray500,
117+
fontSize = 12.sp,
118+
fontWeight = FontWeight.Medium,
119+
)
120+
}
121+
}
122+
123+
@Composable
124+
fun RestaurantImage(restaurant: Restaurant) {
125+
Row(
126+
modifier = Modifier.fillMaxWidth(),
127+
horizontalArrangement = Arrangement.SpaceBetween
128+
) {
129+
when {
130+
restaurant.image.size == 3 -> {
131+
restaurant.image.forEach { image ->
132+
Image(
133+
modifier = Modifier
134+
.weight(1f)
135+
.aspectRatio(1f)
136+
.clip(RoundedCornerShape(8.dp))
137+
.padding(4.dp),
138+
painter = painterResource(id = image),
139+
contentDescription = null
140+
)
141+
}
142+
}
143+
144+
restaurant.image.size == 2 -> {
145+
restaurant.image.forEach { image ->
146+
Image(
147+
modifier = Modifier
148+
.weight(1f)
149+
.aspectRatio(1f)
150+
.clip(RoundedCornerShape(8.dp))
151+
.padding(4.dp),
152+
painter = painterResource(id = image),
153+
contentDescription = null
154+
)
155+
}
156+
Spacer(modifier = Modifier.weight(1f))
157+
}
158+
159+
restaurant.image.size == 1 -> {
160+
Image(
161+
modifier = Modifier
162+
.weight(1f)
163+
.aspectRatio(1f)
164+
.clip(RoundedCornerShape(8.dp))
165+
.padding(4.dp),
166+
painter = painterResource(id = restaurant.image[0]),
167+
contentDescription = null
168+
)
169+
Spacer(modifier = Modifier.weight(2f))
170+
}
171+
172+
restaurant.image.size > 3 -> {
173+
Image(
174+
modifier = Modifier
175+
.weight(1f)
176+
.aspectRatio(1f)
177+
.clip(RoundedCornerShape(8.dp))
178+
.padding(4.dp),
179+
painter = painterResource(restaurant.image[0]),
180+
contentDescription = null
181+
)
182+
Image(
183+
modifier = Modifier
184+
.weight(1f)
185+
.aspectRatio(1f)
186+
.clip(RoundedCornerShape(8.dp))
187+
.padding(4.dp),
188+
painter = painterResource(restaurant.image[1]),
189+
contentDescription = null
190+
)
191+
Box(
192+
modifier = Modifier
193+
.weight(1f)
194+
.aspectRatio(1f)
195+
.padding(4.dp)
196+
) {
197+
Image(
198+
modifier = Modifier
199+
.aspectRatio(1f)
200+
.fillMaxSize(),
201+
painter = painterResource(id = restaurant.image[2]),
202+
contentDescription = null
203+
)
204+
Box(
205+
modifier = Modifier
206+
.matchParentSize()
207+
.clip(RoundedCornerShape(8.dp))
208+
.background(Color.Black.copy(alpha = 0.5f)),
209+
contentAlignment = Alignment.Center
210+
) {
211+
Text(
212+
text = "+${restaurant.image.size - 2}",
213+
color = Color.White,
214+
fontSize = 14.sp
215+
)
216+
}
217+
}
218+
}
219+
}
220+
}
221+
}
222+
223+
@Preview
224+
@Composable
225+
fun EveryMealRestaurantItemPreview() {
226+
EveryMealRestaurantItem(
227+
Restaurant(
228+
name = "슈니",
229+
category = "한식",
230+
image = listOf(
231+
1,
232+
2,
233+
3,
234+
),
235+
rating = 4.5,
236+
reviewCount = 100,
237+
loveCount = 50,
238+
)
239+
) {
240+
241+
}
242+
}
243+
244+
@Preview
245+
@Composable
246+
fun HomeScreenPreview() {
247+
EveryMeal_AndroidTheme {
248+
HomeScreen()
249+
}
250+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.everymeal.presentation.components
2+
3+
import androidx.compose.runtime.Composable
4+
import com.everymeal.presentation.ui.home.Review
5+
6+
@Composable
7+
fun EveryMealReviewItem(
8+
review: Review,
9+
onDetailRestaurantClick: () -> Unit,
10+
) {
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.everymeal.presentation.ui.home
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 HomeContract {
9+
data class HomeState(
10+
val uiState: LoadState = LoadState.SUCCESS,
11+
) : ViewState
12+
13+
sealed class HomeEvent : ViewEvent {
14+
15+
}
16+
17+
sealed class HomeEffect : ViewSideEffect {
18+
19+
}
20+
}

0 commit comments

Comments
 (0)