diff --git a/app/src/main/java/com/hackathon/alddeul_babsang/domain/entity/ProfileLikeListEntity.kt b/app/src/main/java/com/hackathon/alddeul_babsang/domain/entity/ProfileLikeListEntity.kt new file mode 100644 index 0000000..56ad75e --- /dev/null +++ b/app/src/main/java/com/hackathon/alddeul_babsang/domain/entity/ProfileLikeListEntity.kt @@ -0,0 +1,11 @@ +package com.hackathon.alddeul_babsang.domain.entity + +data class ProfileLikeListEntity( + val id: Long, + val avatar: String? = null, + val name: String, + val codeName: String, + val address: String, + val phone: String, + val favorite: Boolean=false, +) \ No newline at end of file diff --git a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/navigation/ProfileNavGraph.kt b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/navigation/ProfileNavGraph.kt index 92ee9c7..ea99be0 100644 --- a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/navigation/ProfileNavGraph.kt +++ b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/navigation/ProfileNavGraph.kt @@ -4,8 +4,7 @@ import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable import com.hackathon.alddeul_babsang.presentation.profile.screen.ProfileLikeListRoute import com.hackathon.alddeul_babsang.presentation.profile.screen.ProfileRoute -import com.hackathon.alddeul_babsang.presentation.report.navigation.ReportNavigator -import com.hackathon.alddeul_babsang.presentation.report.screen.ReportWriteRoute + fun NavGraphBuilder.profileNavGraph( navigator: ProfileNavigator @@ -13,12 +12,7 @@ fun NavGraphBuilder.profileNavGraph( composable(route = "profile") { ProfileRoute(navigator = navigator) } -} - -fun NavGraphBuilder.profileLikeListNavGraph( - navigator: ProfileNavigator -) { composable(route = "profileLikeList") { ProfileLikeListRoute(navigator = navigator) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/navigation/ProfileNavigator.kt b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/navigation/ProfileNavigator.kt index b5e2bb2..8953845 100644 --- a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/navigation/ProfileNavigator.kt +++ b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/navigation/ProfileNavigator.kt @@ -6,10 +6,6 @@ class ProfileNavigator( val navController: NavController ) { - fun profileLikeList() { - navController.navigate("profileLikeList") - } - fun navigateBack() { navController.popBackStack() } diff --git a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/LikeItem.kt b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/LikeItem.kt index 1f11653..dcde40d 100644 --- a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/LikeItem.kt +++ b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/LikeItem.kt @@ -3,7 +3,7 @@ package com.hackathon.alddeul_babsang.presentation.profile.screen import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement.Bottom +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -12,49 +12,47 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ColorFilter -import androidx.compose.ui.graphics.graphicsLayer -import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.vectorResource -import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.hilt.navigation.compose.hiltViewModel 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.Font_B04 -import com.hackathon.alddeul_babsang.core_ui.theme.Gray200 import com.hackathon.alddeul_babsang.core_ui.theme.Gray300 -import com.hackathon.alddeul_babsang.core_ui.theme.Gray600 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.body2Regular -import com.hackathon.alddeul_babsang.core_ui.theme.body3Semi import com.hackathon.alddeul_babsang.core_ui.theme.body4Regular import com.hackathon.alddeul_babsang.core_ui.theme.head4Bold -import com.hackathon.alddeul_babsang.domain.entity.BabsangDetailEntity -import com.hackathon.alddeul_babsang.domain.entity.ReviewEntity -import com.hackathon.alddeul_babsang.presentation.detail.screen.DetailViewModel -import kotlin.math.round +import com.hackathon.alddeul_babsang.domain.entity.ProfileLikeListEntity @Composable fun LikeItem( - data: BabsangDetailEntity + data: ProfileLikeListEntity ) { + var isFavorite by remember { mutableStateOf(data.favorite ?: false) } + + // 클릭할 때마다 favorite 값 토글 + val heartIconId = if (isFavorite) { + R.drawable.ic_heart_red + } else { + R.drawable.ic_heart_white + } + + Column( modifier = Modifier .width(350.dp) @@ -71,16 +69,19 @@ fun LikeItem( .height(140.dp) .clip(RoundedCornerShape(topStart = 14.dp, topEnd = 14.dp)) ) { - // AsyncImage 로드를 위한 함수 호출 + // AsyncImage 로드 LoadImageWithPlaceholder(data.codeName, data.avatar) - // 아이콘을 이미지 위에 오버레이 Image( - painter = painterResource(id = R.drawable.ic_heart_white), + painter = painterResource(heartIconId), contentDescription = null, modifier = Modifier .padding(end = 10.dp, top = 10.dp) .align(Alignment.TopEnd) // Box 내에서 오른쪽 끝으로 배치 + .clickable { + // 클릭 시 좋아요 상태를 토글 + isFavorite = !isFavorite + } ) } @@ -128,18 +129,15 @@ fun LikeItem( @Composable fun LoadImageWithPlaceholder(codeName: String, imageUrl: String?) { - var imageId =R.drawable.ic_korean_food - if (codeName =="경양식/일식"){ - imageId=R.drawable.ic_japanese_food - } - else if (codeName =="한식"){ - imageId=R.drawable.ic_korean_food - } - else if (codeName =="중식"){ - imageId=R.drawable.ic_chinese_food - } - else { - imageId=R.drawable.ic_etc_food + var imageId = R.drawable.ic_korean_food + if (codeName == "경양식/일식") { + imageId = R.drawable.ic_japanese_food + } else if (codeName == "한식") { + imageId = R.drawable.ic_korean_food + } else if (codeName == "중식") { + imageId = R.drawable.ic_chinese_food + } else { + imageId = R.drawable.ic_etc_food } @@ -147,36 +145,47 @@ fun LoadImageWithPlaceholder(codeName: String, imageUrl: String?) { modifier = Modifier .fillMaxWidth() .fillMaxHeight() - .background(color= Orange700) // 배경색 설정 + .background(color = Orange700) // 배경색 설정 ) { - AsyncImage( - model = imageUrl, - contentDescription = null, - placeholder = painterResource(id = imageId), // codeName에 따라 다른 placeholder 제공 - modifier = Modifier - .fillMaxWidth() - .fillMaxHeight() - .padding(vertical = 15.dp) - ) + if (imageUrl.isNullOrEmpty()) { + // imageUrl이 null이나 empty일 경우 대체 이미지 표시 + Image( + painter = painterResource(id = imageId), // 대체 이미지 + contentDescription = null, + modifier = Modifier + .fillMaxWidth() + .fillMaxHeight() + .padding(vertical = 15.dp) + ) + } else { + // imageUrl이 null이 아니면 AsyncImage로 비동기 이미지 로드 + AsyncImage( + model = imageUrl, + contentDescription = null, + placeholder = painterResource(id = imageId), // codeName에 따라 다른 placeholder 제공 + contentScale = ContentScale.Crop, + modifier = Modifier + .fillMaxWidth() + .fillMaxHeight() + .padding(vertical = 15.dp) + ) + } } } @Preview(showBackground = true) @Composable fun ReviewItemPreview() { - val LikeListViewModel: LikeListViewModel = hiltViewModel() AlddeulBabsangTheme { LikeItem( - data = BabsangDetailEntity( + data = ProfileLikeListEntity( id = 1, - avatar = "", + avatar = null, name = "송이네 밥상", codeName = "경양식/일식", address = "서울특별시 용산구 청파동 11", phone = "02-210-0220", - rating = 4.3, - menu = "김치찌개: 8000, 된장찌개 9000", - review = LikeListViewModel.mockReviews + favorite = true ) ) } diff --git a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/LikeListViewModel.kt b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/LikeListViewModel.kt index ea0d590..5ad549e 100644 --- a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/LikeListViewModel.kt +++ b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/LikeListViewModel.kt @@ -2,87 +2,60 @@ package com.hackathon.alddeul_babsang.presentation.profile.screen import androidx.lifecycle.ViewModel -import com.hackathon.alddeul_babsang.domain.entity.BabsangDetailEntity -import com.hackathon.alddeul_babsang.domain.entity.MenuEntity -import com.hackathon.alddeul_babsang.domain.entity.ReviewEntity +import com.hackathon.alddeul_babsang.domain.entity.ProfileLikeListEntity import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel class LikeListViewModel @Inject constructor() : ViewModel() { - val mockMenuList = listOf( - MenuEntity("김치찌개", 8000), - MenuEntity("된장찌개", 9000), - ) - - val mockReviews = listOf( - ReviewEntity( - id = 1, - avatar = "https://avatars.githubusercontent.com/u/12345678?v=4", - nickname = "김개발", - createdAt = "24.03.12", - star = 4.56, - content = "맛있어요!" - ), - ReviewEntity( - id = 2, - avatar = "https://avatars.githubusercontent.com/u/12345678?v=4", - nickname = "김디자인", - createdAt = "24.03.12", - star = 3.28, - content = "그저 그랬어요 블라블라블라!" - ), - ReviewEntity( - id = 3, - avatar = "https://avatars.githubusercontent.com/u/12345678?v=4", - nickname = "김마케팅", - createdAt = "24.03.12", - star = 2.49, - content = "위생이 별로에요!" - ), - ) val mockLikeList = listOf( - BabsangDetailEntity( - id = 1, + ProfileLikeListEntity( + id=1, + avatar = null, name = "송이네 밥상", + codeName = "기타외식업", + address = "서울특별시 용산구 청파동 81", + phone = "02-210-0120", + favorite = true + ), + ProfileLikeListEntity( + id=2, + avatar = null, + name = "송이네 일식", codeName = "경양식/일식", - address = "서울특별시 용산구 청파동 1211", - phone = "02-295-0220", - rating = 4.3, - menu = "김치찌개: 8000, 된장찌개 9000", - review = mockReviews + address = "서울특별시 용산구 청파동 11", + phone = "02-210-0220", + favorite = true ), - BabsangDetailEntity( - id = 2, - name = "송이네 밥상2", + ProfileLikeListEntity( + id=3, + avatar = null, + name = "송이네 한식", codeName = "한식", - address = "서울특별시 용산구 청파동 911", - phone = "02-230-0220", - rating = 4.3, - menu = "김치찌개: 8000, 된장찌개 9000", - review = mockReviews + address = "서울특별시 용산구 청파동 31", + phone = "02-223-0220", + favorite = true ), - BabsangDetailEntity( - id = 3, - name = "송이네 밥상3", + ProfileLikeListEntity( + id=4, + avatar = null, + name = "송이네 중식", codeName = "중식", - address = "서울특별시 용산구 청파동 321", - phone = "02-210-2097", - rating = 4.3, - menu = "김치찌개: 8000, 된장찌개 9000", - review = mockReviews + address = "서울특별시 용산구 청파동 31", + phone = "02-223-0220", + favorite = true ), - BabsangDetailEntity( - id = 4, - name = "송이네 밥상4", - codeName = "기타외식업", - address = "서울특별시 용산구 청파동 14", - phone = "02-210-0270", - rating = 4.3, - menu = "김치찌개: 8000, 된장찌개 9000", - review = mockReviews + ProfileLikeListEntity( + id=4, + avatar = "https://avatars.githubusercontent.com/u/166610834?s=400&u=568eacc2e4696d563a4fd732c148edba2196e4f6&v=4", + name = "송이네 밥상", + codeName = "중식", + address = "서울특별시 용산구 청파동 31", + phone = "02-223-0220", + favorite = true ) + ) } \ No newline at end of file diff --git a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/ProfileLikeListScreen.kt b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/ProfileLikeListScreen.kt index d6cf882..9c517b2 100644 --- a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/ProfileLikeListScreen.kt +++ b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/ProfileLikeListScreen.kt @@ -35,7 +35,7 @@ import com.hackathon.alddeul_babsang.core_ui.theme.Orange800 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 -import com.hackathon.alddeul_babsang.domain.entity.BabsangDetailEntity +import com.hackathon.alddeul_babsang.domain.entity.ProfileLikeListEntity import com.hackathon.alddeul_babsang.presentation.profile.navigation.ProfileNavigator @Composable @@ -44,15 +44,14 @@ fun ProfileLikeListRoute( ) { val LikeListViewModel: LikeListViewModel = hiltViewModel() ProfileLikeListScreen( - data = BabsangDetailEntity( - id = 1, + data = ProfileLikeListEntity( + id=1, + avatar = "", name = "송이네 밥상", codeName = "경양식/일식", address = "서울특별시 용산구 청파동 11", phone = "02-210-0220", - rating = 4.3, - menu = "김치찌개: 8000, 된장찌개 9000", - review = LikeListViewModel.mockReviews + favorite = true ), onBackClick = { navigator.navigateBack() }, LikeListViewModel = LikeListViewModel @@ -62,7 +61,7 @@ fun ProfileLikeListRoute( @OptIn(ExperimentalMaterial3Api::class) @Composable fun ProfileLikeListScreen( - data: BabsangDetailEntity, + data: ProfileLikeListEntity, onBackClick: () -> Unit = {}, LikeListViewModel: LikeListViewModel ) { @@ -144,16 +143,14 @@ fun ProfileLikeListScreenPreview() { val LikeListViewModel: LikeListViewModel = hiltViewModel() AlddeulBabsangTheme { ProfileLikeListScreen( - data = BabsangDetailEntity( - id = 1, + data = ProfileLikeListEntity( + id=1, avatar = "", name = "송이네 밥상", codeName = "경양식/일식", address = "서울특별시 용산구 청파동 11", phone = "02-210-0220", - rating = 4.3, - menu = "김치찌개: 8000, 된장찌개 9000", - review = LikeListViewModel.mockReviews + favorite = true ), onBackClick = { }, LikeListViewModel = LikeListViewModel diff --git a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/ProfileScreen.kt b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/ProfileScreen.kt index c183bb6..40665df 100644 --- a/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/ProfileScreen.kt +++ b/app/src/main/java/com/hackathon/alddeul_babsang/presentation/profile/screen/ProfileScreen.kt @@ -140,7 +140,7 @@ fun ProfileScreen( onClick = { navigateToWebsite( context = context, - "https://massive-maple-b53.notion.site/426578b24235447abccaae359549cdb7?pvs=4" + "https://flowery-alloy-47e.notion.site/1336b8d0ab7b8019a7a9da0d80ff285b" ) } ) @@ -151,7 +151,7 @@ fun ProfileScreen( onClick = { navigateToWebsite( context = context, - "https://massive-maple-b53.notion.site/430e2c92b8694ad6a8b4497f3a3b4452" + "https://flowery-alloy-47e.notion.site/1336b8d0ab7b80949a59fe847a7e94d8" ) } ) @@ -273,7 +273,6 @@ fun BottomSheetContent( ) { Text( text = tv1, - color = Gray500, style = head5Semi, modifier = Modifier.padding(bottom = 2.dp) ) @@ -281,7 +280,6 @@ fun BottomSheetContent( Text( text = tv2, - color = Gray500, style = body2Semi, modifier = Modifier.padding(bottom = 2.dp) )