Skip to content

Commit

Permalink
Merge pull request #154 from SOPT-all/feat/#152-place-detail-mine-post
Browse files Browse the repository at this point in the history
[FEAT/#152] GetPostResponseDto isMine 추가 및 해당 게시글이 나의 글일 경우 분기 처리
  • Loading branch information
Roel4990 authored Jan 23, 2025
2 parents ec65331 + c1a79b2 commit 9828dc8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ data class GetPostResponseDto(
val longitude: Double,
@SerialName("zzimCount")
val zzimCount: Int,
@SerialName("isMine")
val isMine: Boolean,
@SerialName("isZzim")
val isZzim: Boolean,
@SerialName("isScoop")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fun GetPostResponseDto.toDomain() =
latitude = this.latitude,
longitude = this.longitude,
addMapCount = this.zzimCount,
isMine = this.isMine,
isAddMap = this.isZzim,
isScooped = this.isScoop,
category = this.categoryColorResponse.toDomain()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class PostEntity(
val latitude: Double,
val longitude: Double,
val addMapCount: Int,
val isMine: Boolean,
val isAddMap: Boolean,
val isScooped: Boolean,
val category: CategoryEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import com.spoony.spoony.presentation.placeDetail.component.UserProfileInfo
import com.spoony.spoony.presentation.placeDetail.model.PostModel
import com.spoony.spoony.presentation.placeDetail.type.DropdownOption
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -135,6 +136,10 @@ fun PlaceDetailRoute(
is UiState.Failure -> {}
is UiState.Success -> {
with(state.postModel as UiState.Success<PostModel>) {
val dropDownMenuList = when (data.isMine) {
true -> persistentListOf()
false -> persistentListOf(DropdownOption.REPORT)
}
Scaffold(
snackbarHost = {
SnackbarHost(hostState = snackBarHostState) { snackbarData ->
Expand Down Expand Up @@ -185,7 +190,7 @@ fun PlaceDetailRoute(
placeAddress = data.placeAddress,
placeName = data.placeName,
isScooped = state.isScooped,
dropdownMenuList = state.dropDownMenuList,
dropdownMenuList = dropDownMenuList,
onReportButtonClick = { navigateToReport(postId, userId) }
)
}
Expand All @@ -210,7 +215,7 @@ private fun PlaceDetailScreen(
placeAddress: String,
placeName: String,
isScooped: Boolean,
dropdownMenuList: ImmutableList<String>,
dropdownMenuList: ImmutableList<DropdownOption>,
onReportButtonClick: () -> Unit
) {
val scrollState = rememberScrollState()
Expand Down Expand Up @@ -240,7 +245,7 @@ private fun PlaceDetailScreen(
menuItems = dropdownMenuList,
onMenuItemClick = { menu ->
when (menu) {
DropdownOption.REPORT.string -> {
DropdownOption.REPORT.name -> {
onReportButtonClick()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ data class PlaceDetailState(
val postModel: UiState<PostModel> = UiState.Loading,
val userEntity: UiState<UserEntity> = UiState.Loading,
val spoonCount: UiState<Int> = UiState.Loading,
val dropDownMenuList: ImmutableList<String> = persistentListOf("신고하기")
val dropDownMenuList: ImmutableList<String> = persistentListOf()
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,27 @@ import androidx.compose.ui.unit.dp
import com.spoony.spoony.R
import com.spoony.spoony.core.designsystem.theme.SpoonyAndroidTheme
import com.spoony.spoony.core.util.extension.noRippleClickable
import com.spoony.spoony.presentation.placeDetail.type.DropdownOption
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.immutableListOf
import kotlinx.collections.immutable.persistentListOf

@Composable
fun IconDropdownMenu(
menuItems: ImmutableList<String>,
menuItems: ImmutableList<DropdownOption>,
onMenuItemClick: (String) -> Unit,
modifier: Modifier = Modifier
) {
var expanded by remember { mutableStateOf(false) }

Column(modifier = modifier.wrapContentSize(Alignment.TopEnd)) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.ic_menu_24),
contentDescription = null,
tint = SpoonyAndroidTheme.colors.gray500,
modifier = Modifier
.noRippleClickable {
expanded = !expanded
if (menuItems.isNotEmpty()) {
expanded = !expanded
}
}
)
Spacer(modifier = Modifier.height(4.dp))
Expand All @@ -74,14 +76,14 @@ fun IconDropdownMenu(
modifier = Modifier
.widthIn(min = 91.dp)
.noRippleClickable {
onMenuItemClick(menuItem)
onMenuItemClick(menuItem.name)
expanded = false
}
.padding(6.dp),
contentAlignment = Alignment.CenterStart
) {
Text(
text = menuItem,
text = menuItem.string,
style = SpoonyAndroidTheme.typography.caption1b,
color = SpoonyAndroidTheme.colors.gray900
)
Expand All @@ -97,21 +99,7 @@ fun IconDropdownMenu(
@Preview
@Composable
private fun IconDropdownMenuOnePreview() {
val menuItems = immutableListOf("신고하기")
SpoonyAndroidTheme {
IconDropdownMenu(
menuItems = menuItems,
onMenuItemClick = { selectedItem ->
// selectedItem
}
)
}
}

@Preview
@Composable
private fun IconDropdownMenuTwoPreview() {
val menuItems = immutableListOf("신고하기", "수정하기")
val menuItems = persistentListOf(DropdownOption.REPORT)
SpoonyAndroidTheme {
IconDropdownMenu(
menuItems = menuItems,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ data class PostModel(
val placeAddress: String,
val latitude: Double,
val longitude: Double,
val isMine: Boolean,
val category: CategoryEntity
)

Expand All @@ -28,5 +29,6 @@ fun PostEntity.toModel(): PostModel = PostModel(
placeAddress = this.placeAddress,
latitude = this.latitude,
longitude = this.longitude,
isMine = this.isMine,
category = this.category
)

0 comments on commit 9828dc8

Please sign in to comment.