Skip to content

Commit

Permalink
Merge pull request #37 from DACOS-SOLUX-Hackathon-Team5/feature/26-pr…
Browse files Browse the repository at this point in the history
…ebabsang-getapi

Feature/26 오류 수정 및 보완
  • Loading branch information
gaeulzzang authored Nov 8, 2024
2 parents b2a53e7 + 95e6d71 commit 79dadad
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ fun BabsangItem(
)
Spacer(modifier = Modifier.width(15.dp))
Text(
text = data.category,
text = when (data.category){
"KOREAN" -> "한식"
"WESTERN_JAPANESE" -> "경양식/일식"
"CHINESE" -> "중식"
else -> "기타외식업"
},
style = body2Regular,
color = Orange800,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ fun LikeItem(
)
Spacer(modifier = Modifier.width(15.dp))
Text(
text = data.category,
text = when (data.category){
"KOREAN" -> "한식"
"WESTERN_JAPANESE" -> "경양식/일식"
"CHINESE" -> "중식"
else -> "기타외식업"
},
style = body2Regular,
color = Orange800,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package com.hackathon.alddeul_babsang.presentation.profile.screen

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
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.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
Expand All @@ -17,6 +20,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
Expand All @@ -34,6 +38,7 @@ import com.hackathon.alddeul_babsang.core_ui.component.LoadingCircleIndicator
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.head6Semi
Expand All @@ -57,13 +62,15 @@ fun LikeRoute(
)
}

when(postLikeState) {
when (postLikeState) {
is UiState.Success -> {
navigator.navigateBack()
}

is UiState.Failure -> {
Timber.e((postLikeState as UiState.Failure).msg)
}

else -> {}
}

Expand Down Expand Up @@ -119,30 +126,54 @@ fun LikeScreen(
.padding(horizontal = 20.dp, vertical = 16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp)
) {
item {
Text(
modifier = Modifier.padding(top = 8.dp, start = 8.dp),
text = buildAnnotatedString {
withStyle(style = SpanStyle(color = Orange800)) {
append(stringResource(R.string.tv_like_history))
}
append(stringResource(R.string.tv_like_connection))
withStyle(style = SpanStyle(color = Orange800)) {
append(stringResource(R.string.tv_like_recommend))
}
append(stringResource(R.string.tv_like_end))
},
style = head6Semi
)
}
when (getLikesState) {
is UiState.Success -> {
items((getLikesState as UiState.Success).data) { item ->
LikeItem(
onClick = { onItemClick(item.restaurantId) },
data = item,
likeViewModel = likeViewModel
)
val data = (getLikesState as UiState.Success).data // getLikesState로 수정
if (data.isEmpty()) {
item {
Box(
modifier = Modifier
.fillMaxSize()
) {
Text(
text = "좋아요를 누른 밥상이 없어요",
style = head6Semi,
color = Orange900,
modifier = Modifier.align(Alignment.Center)
.padding(vertical = 280.dp)
)
}
}
} else {
item {
Text(
modifier = Modifier.padding(top = 8.dp, start = 8.dp),
text = buildAnnotatedString {
withStyle(style = SpanStyle(color = Orange800)) {
append(stringResource(R.string.tv_like_history))
}
append(stringResource(R.string.tv_like_connection))
withStyle(style = SpanStyle(color = Orange800)) {
append(stringResource(R.string.tv_like_recommend))
}
append(stringResource(R.string.tv_like_end))
},
style = head6Semi
)
}

itemsIndexed(data) { index, item ->
LikeItem(
onClick = { onItemClick(item.restaurantId) },
data = item,
likeViewModel = likeViewModel
)

// Spacer는 마지막 아이템을 제외하고 넣어야 하므로 조건 추가
if (index != data.size - 1) {
Spacer(modifier = Modifier.height(16.dp))
}
}
}
}

Expand All @@ -157,9 +188,11 @@ fun LikeScreen(
Text(text = (getLikesState as UiState.Failure).msg)
}
}

else -> {}

}


}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ fun ReportItem(
)
Spacer(modifier = Modifier.width(15.dp))
Text(
text = data.category,
text = when (data.category){
"KOREAN" -> "한식"
"WESTERN_JAPANESE" -> "경양식/일식"
"CHINESE" -> "중식"
else -> "기타외식업"
},
style = body2Regular,
color = Orange800,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ fun ReportScreen(
onReportWriteClick: () -> Unit = {},
reportViewModel: ReportViewModel
) {

val getReportState by reportViewModel.postReportsState.collectAsStateWithLifecycle(UiState.Empty)

Scaffold(
Expand All @@ -80,9 +79,7 @@ fun ReportScreen(
shape = RoundedCornerShape(40.dp),
onClick = { onReportWriteClick() },
contentPadding = PaddingValues(vertical = 20.dp, horizontal = 41.dp),
colors = ButtonDefaults.buttonColors(
containerColor = Blue,
)
colors = ButtonDefaults.buttonColors(containerColor = Blue)
) {
Text(
text = stringResource(R.string.btn_report),
Expand All @@ -94,7 +91,6 @@ fun ReportScreen(
) { innerPadding ->
LazyColumn(
verticalArrangement = Arrangement.spacedBy(16.dp),

modifier = Modifier
.padding(innerPadding)
.fillMaxSize()
Expand All @@ -117,14 +113,15 @@ fun ReportScreen(
Text(
modifier = Modifier.padding(bottom = 14.dp),
text = stringResource(R.string.tv_report_title3),
style = head7Bold, color = Gray900
style = head7Bold,
color = Gray900
)
}

when (getReportState) {
is UiState.Loading -> {
item {
LoadingCircleIndicator()
LoadingCircleIndicator() // 로딩 상태 UI
}
}

Expand Down Expand Up @@ -167,4 +164,4 @@ fun ReportScreen(
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -69,25 +70,29 @@ fun ReportWriteRoute(
navigator: ReportNavigator
) {
val reportViewModel: ReportViewModel = hiltViewModel()
val postReportWriteState by reportViewModel.postReportWriteState.collectAsStateWithLifecycle(
UiState.Empty
)
val postReportWriteState by reportViewModel.postReportWriteState.collectAsStateWithLifecycle(UiState.Empty)

when(postReportWriteState) {
is UiState.Success -> {
navigator.navigateBack()
}
is UiState.Failure -> {
Timber.e((postReportWriteState as UiState.Failure).msg)
// 상태 변화에 따른 네비게이션 처리
LaunchedEffect(postReportWriteState) {
when (postReportWriteState) {
is UiState.Success -> {
// 네비게이션 전에 상태가 완전히 업데이트된 후 진행
navigator.navigateBack()
}
is UiState.Failure -> {
Timber.e((postReportWriteState as UiState.Failure).msg)
}
else -> {}
}
else -> {}
}

ReportWriteScreen(
onBackClick = { navigator.navigateBack() },
reportViewModel = reportViewModel
)
}


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ReportWriteScreen(
Expand Down

0 comments on commit 79dadad

Please sign in to comment.