Skip to content

Commit

Permalink
#16 착한밥상 & 예비착한 밥상 페이지 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
seoyeonsw committed Nov 7, 2024
1 parent 330d1cc commit 441f0d1
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ import androidx.navigation.compose.rememberNavController
import coil.compose.AsyncImage
import com.hackathon.alddeul_babsang.R
import com.hackathon.alddeul_babsang.core_ui.theme.AlddeulBabsangTheme
import com.hackathon.alddeul_babsang.core_ui.theme.Blue
import com.hackathon.alddeul_babsang.core_ui.theme.Gray300
import com.hackathon.alddeul_babsang.core_ui.theme.Orange700
import com.hackathon.alddeul_babsang.core_ui.theme.Orange800
import com.hackathon.alddeul_babsang.core_ui.theme.Orange900
import com.hackathon.alddeul_babsang.core_ui.theme.Pink
import com.hackathon.alddeul_babsang.core_ui.theme.White
import com.hackathon.alddeul_babsang.core_ui.theme.Yellow
import com.hackathon.alddeul_babsang.core_ui.theme.body2Regular
import com.hackathon.alddeul_babsang.core_ui.theme.body4Regular
import com.hackathon.alddeul_babsang.core_ui.theme.body7Semi
Expand All @@ -57,11 +60,6 @@ fun BabsangRecommendItem(

Column(
modifier = Modifier
.border(
width = 1.dp,
color = Orange700,
shape = RoundedCornerShape(14.dp)
)
.width(170.dp)
.height(192.dp)
.clickable(onClick = {
Expand All @@ -88,6 +86,7 @@ fun BabsangRecommendItem(
.height(17.dp)
.clip(RoundedCornerShape(50.dp))
.background(White),
contentAlignment = Alignment.Center

){
Text(data.address, textAlign = TextAlign.Center, style = body7Semi)
Expand Down Expand Up @@ -151,18 +150,18 @@ fun ReplaceImage(codeName: String, imageUrl: String?) {
}

val backgroundColor = when (codeName) {
"경양식/일식" -> Orange700
"한식" -> Color(0xFAB935)
"중식" -> Color(0xFAB935)
else -> Color(0xFAB935)
"경양식/일식" -> Yellow
"한식" -> Orange700
"중식" -> Pink
else -> Blue
}


Box(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.background(color = Orange700) // 배경색 설정
.background(color = backgroundColor) // 배경색 설정
) {
if (imageUrl.isNullOrEmpty()) {
// imageUrl이 null이나 empty일 경우 대체 이미지 표시
Expand All @@ -175,7 +174,6 @@ fun ReplaceImage(codeName: String, imageUrl: String?) {
.padding(horizontal = 15.dp)
.padding(bottom = 80.dp)
.padding(top = 15.dp)
.background(color = backgroundColor)
)
} else {
// imageUrl이 null이 아니면 AsyncImage로 비동기 이미지 로드
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BabsangRecommendViewModel @Inject constructor() : ViewModel() {
val mockBabsangRecommendList = listOf(
BabsangRecommendEntity(
id = 1,
avatar = null,
avatar = "https://avatars.githubusercontent.com/u/166610834?s=400&u=568eacc2e4696d563a4fd732c148edba2196e4f6&v=4",
name = "송이네 밥상",
codeName = "경양식/일식",
address = "용산구",
Expand All @@ -32,6 +32,20 @@ class BabsangRecommendViewModel @Inject constructor() : ViewModel() {
codeName = "한식",
address = "양천구",
),
BabsangRecommendEntity(
id = 3,
avatar = null,
name = "송이네 한식",
codeName = "중식",
address = "양천구",
),
BabsangRecommendEntity(
id = 1,
avatar = null,
name = "송이네 밥상",
codeName = "경양식/일식",
address = "용산구",
),


)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,169 @@
package com.hackathon.alddeul_babsang.presentation.babsang.screen

import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
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.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.compose.rememberNavController
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.hackathon.alddeul_babsang.R
import com.hackathon.alddeul_babsang.core_ui.theme.AlddeulBabsangTheme
import com.hackathon.alddeul_babsang.core_ui.theme.Gray900
import com.hackathon.alddeul_babsang.core_ui.theme.Orange800
import com.hackathon.alddeul_babsang.core_ui.theme.Orange900
import com.hackathon.alddeul_babsang.core_ui.theme.White
import com.hackathon.alddeul_babsang.core_ui.theme.head4Bold
import com.hackathon.alddeul_babsang.core_ui.theme.head6Bold
import com.hackathon.alddeul_babsang.core_ui.theme.head6Semi
import com.hackathon.alddeul_babsang.core_ui.theme.head7Bold
import com.hackathon.alddeul_babsang.presentation.babsang.navigation.BabsangNavigator
import com.hackathon.alddeul_babsang.presentation.profile.screen.BabsangListViewModel

@Composable
fun BabsangRoute(
navigator: BabsangNavigator
) {
BabsangScreen()
val babsangListViewModel: BabsangListViewModel = hiltViewModel()
val babsangRecommendViewModel: BabsangRecommendViewModel = hiltViewModel()
val systemUiController = rememberSystemUiController()

SideEffect {
systemUiController.setStatusBarColor(
color = White
)
}

BabsangScreen(
navigator = navigator, // navController 대신 navigator 전달
babsangListViewModel = babsangListViewModel,
babsangRecommendViewModel = babsangRecommendViewModel
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun BabsangScreen() {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = "착한 밥상")
}
fun BabsangScreen(
navigator: BabsangNavigator,
babsangListViewModel: BabsangListViewModel,
babsangRecommendViewModel: BabsangRecommendViewModel
) {
val scrollState = rememberScrollState()
val rowScrollState = rememberScrollState()
Scaffold(
topBar = {
CenterAlignedTopAppBar(
modifier = Modifier.background(White),
title = {
Text(
text = stringResource(R.string.tv_babsang_title),
style = head4Bold,
color = Gray900
)
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = White
)
)
}
) { innerPadding ->
Column(
modifier = Modifier
.padding(innerPadding)
.fillMaxSize()
.background(color = White)
.padding(horizontal = 20.dp, vertical = 25.dp)
.verticalScroll(scrollState),

) {
Text(
text = buildAnnotatedString {
withStyle(style = SpanStyle(color = Orange800)) {
append("알뜰 밥상")
}
append("")
withStyle(style = SpanStyle(color = Orange800)) {
append("추천")
}
append("하는 밥상")
},
style = head6Semi
)

Spacer(modifier = Modifier.height(10.dp))
Row(
horizontalArrangement = Arrangement.spacedBy(16.dp),
modifier = Modifier
.horizontalScroll(rowScrollState)
) {
for (item in babsangRecommendViewModel.mockBabsangRecommendList) {
BabsangRecommendItem(
navigator = navigator,
data = item
)
}
}


Spacer(modifier = Modifier.height(30.dp))

Text("착한 밥상 리스트", style = head6Semi)

Spacer(modifier = Modifier.height(15.dp))

Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
for (item in babsangListViewModel.mockLikeList) {
BabsangListItem(
navigator = navigator,
data = item
)
}
}
}}




}

@Preview(showBackground = true)
@Composable
fun BabsangScreenPreview() {
val babsangListViewModel: BabsangListViewModel = hiltViewModel()
val babsangRecommendViewModel: BabsangRecommendViewModel = hiltViewModel()
val navController = rememberNavController()
val navigator = BabsangNavigator(navController)

AlddeulBabsangTheme {
BabsangScreen()
BabsangScreen(
navigator = navigator,
babsangListViewModel = babsangListViewModel,
babsangRecommendViewModel = babsangRecommendViewModel
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ package com.hackathon.alddeul_babsang.presentation.report.screen

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
Expand Down Expand Up @@ -66,44 +69,52 @@ fun ReportScreen(

val scrollState = rememberScrollState()

Column(
modifier = Modifier
.fillMaxSize()
.background(color = White)
.padding(horizontal = 20.dp, vertical = 25.dp)
.verticalScroll(scrollState),

) {
Text("직접 제보받은", style = head7Bold, color = Gray900)
Text("착한 밥상 후보 리스트", style = head6Bold, color = Orange900)
Spacer(modifier = Modifier.height(10.dp))
Text("제보와 후기로 쌓아 보아요", style = head7Bold, color = Gray900)

Spacer(modifier = Modifier.height(30.dp))

Box{
Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
for (item in babsangListViewModel.mockLikeList) {
BabsangItem(
navigator = navigator,
data = item
)
modifier = Modifier
.fillMaxSize()
.background(color = White)
.padding(horizontal = 20.dp, vertical = 25.dp)
.verticalScroll(scrollState),

) {
Text("직접 제보받은", style = head7Bold, color = Gray900)
Text("착한 밥상 후보 리스트", style = head6Bold, color = Orange900)
Spacer(modifier = Modifier.height(10.dp))
Text("제보와 후기로 쌓아 보아요", style = head7Bold, color = Gray900)

Spacer(modifier = Modifier.height(30.dp))

Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
for (item in babsangListViewModel.mockLikeList) {
BabsangItem(
navigator = navigator,
data = item
)
}
}
}








Button(onClick = { onReportWriteClick() }) {
Text(text = "제보하러 가기")
}
Button(
onClick = { onReportWriteClick() },
modifier = Modifier
.width(170.dp)
.height(70.dp)
.offset(y = -20.dp, x=-10.dp)
.align(Alignment.BottomEnd),
colors = ButtonDefaults.buttonColors(
containerColor = Blue, // 버튼 배경색
contentColor = White // 버튼 텍스트 색상
)
) {
Text(text = "제보하러 가기", style= head7Bold) // 텍스트 색상은 흰색으로 설정
}

}

}


Expand Down
Loading

0 comments on commit 441f0d1

Please sign in to comment.