Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT/#99] 장소 상세 페이지 더미 데이터 구현 #100

Merged
merged 11 commits into from
Jan 21, 2025
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.spoony.spoony.data.di

import com.spoony.spoony.data.repositoryimpl.DummyRepositoryImpl
import com.spoony.spoony.data.repositoryimpl.PostRepositoryImpl
import com.spoony.spoony.domain.repository.DummyRepository
import com.spoony.spoony.domain.repository.PostRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -14,4 +16,8 @@ abstract class RepositoryModule {
@Binds
@Singleton
abstract fun bindDummyRepository(dummyRepositoryImpl: DummyRepositoryImpl): DummyRepository

@Binds
@Singleton
abstract fun bindPostRepository(postRepositoryImpl: PostRepositoryImpl): PostRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.spoony.spoony.data.repositoryimpl

import com.spoony.spoony.domain.entity.CategoryEntity
import com.spoony.spoony.domain.entity.PostEntity
import com.spoony.spoony.domain.repository.PostRepository
import javax.inject.Inject
import kotlinx.collections.immutable.persistentListOf

class PostRepositoryImpl @Inject constructor() : PostRepository {
override suspend fun getPost(postId: Int): Result<PostEntity> =
Result.success(
PostEntity(
postId = postId,
userId = 1,
photoUrlList = persistentListOf(
"https://spoony-storage.s3.ap-northeast-2.amazonaws.com/post/%2Fc4c71962-10df-4b79-999d-f17737bfa5a6starbucks_1.jpg",
"https://spoony-storage.s3.ap-northeast-2.amazonaws.com/post/%2Fe14dc4d1-f11c-4187-a120-54ab0c2493b2starbucks_2.jpg",
"https://spoony-storage.s3.ap-northeast-2.amazonaws.com/post/%2Fd25a3ca9-f107-47e2-8ca7-b00ed9a1704cstarbucks_3.jpg"
),
title = "스타벅스 강남R점 후기",
date = "2025년 1월",
menuList = persistentListOf(
"아메리카노",
"카페라떼"
),
description = "강남R점에서 커피를 마셨습니다. 분위기가 좋았어요!",
placeName = "스타벅스 강남R점",
placeAddress = "서울특별시 강남구 역삼동 825",
latitude = 37.497711,
longitude = 127.028439,
addMapCount = 1,
isAddMap = false,
isScooped = false,
category = CategoryEntity(
categoryId = 1,
categoryName = "카페",
iconUrl = "https://spoony-storage.s3.ap-northeast-2.amazonaws.com/category/icons/cafe_color.png",
unSelectedIconUrl = "unSelectedIconUrl",
textColor = "FF7E84",
backgroundColor = "FFE4E5"
)
)
)

override suspend fun postScoopPost(postId: Int, userId: Int): Result<Boolean> =
Result.success(
true
)

override suspend fun postAddMap(postId: Int, userId: Int): Result<Boolean> =
Result.success(
true
)

override suspend fun deletePinMap(postId: Int, userId: Int): Result<Boolean> =
Result.success(
true
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.spoony.spoony.domain.entity

data class UserEntity(
val userProfileUrl: String,
val userId: Int,
val userEmail: String,
val userName: String,
val userProfileUrl: String,
val userRegion: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.spoony.spoony.domain.repository

import com.spoony.spoony.domain.entity.PostEntity

interface PostRepository {
suspend fun getPost(postId: Int): Result<PostEntity>

suspend fun postScoopPost(postId: Int, userId: Int): Result<Boolean>

suspend fun postAddMap(postId: Int, userId: Int): Result<Boolean>

suspend fun deletePinMap(postId: Int, userId: Int): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import androidx.compose.runtime.remember
import androidx.navigation.NavDestination
import androidx.navigation.NavDestination.Companion.hasRoute
import androidx.navigation.NavHostController
import androidx.navigation.NavOptions
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navOptions
import com.spoony.spoony.presentation.explore.navigation.navigateToExplore
import com.spoony.spoony.presentation.map.navigaion.Map
import com.spoony.spoony.presentation.map.navigaion.navigateToMap
import com.spoony.spoony.presentation.register.navigation.navigateToRegister
import com.spoony.spoony.presentation.report.navigation.navigateToReport

class MainNavigator(
val navController: NavHostController
Expand Down Expand Up @@ -51,6 +53,14 @@ class MainNavigator(
currentDestination?.hasRoute(it::class) == true
}

fun navigateToReport(navOptions: NavOptions? = null) {
navController.navigateToReport(navOptions)
}

fun navigateUp() {
navController.navigateUp()
}

inline fun isCurrentDestination(destination: NavDestination): Boolean {
return navController.currentDestination == destination
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ fun MainScreen(
)

placeDetailNavGraph(
paddingValues = innerPadding
paddingValues = innerPadding,
navigateUp = navigator::navigateUp,
navigateToReport = navigator::navigateToReport
)

reportNavGraph()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import android.os.Build
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
Expand Down Expand Up @@ -56,11 +58,14 @@ import com.spoony.spoony.presentation.placeDetail.component.PlaceDetailImageLazy
import com.spoony.spoony.presentation.placeDetail.component.ScoopDialog
import com.spoony.spoony.presentation.placeDetail.component.StoreInfo
import com.spoony.spoony.presentation.placeDetail.component.UserProfileInfo
import com.spoony.spoony.presentation.placeDetail.type.DropdownOption
import kotlinx.collections.immutable.ImmutableList

@Composable
fun PlaceDetailRoute(
paddingValues: PaddingValues,
navigateToReport: () -> Unit,
navigateUp: () -> Unit,
viewModel: PlaceDetailViewModel = hiltViewModel()
) {
val lifecycleOwner = LocalLifecycleOwner.current
Expand All @@ -69,24 +74,27 @@ fun PlaceDetailRoute(

val spoonAmount = when (state.spoonAmountEntity) {
is UiState.Success -> (state.spoonAmountEntity as UiState.Success<Int>).data
else -> 0
else -> 99
}

val userProfile = when (state.userEntity) {
is UiState.Success -> (state.userEntity as UiState.Success<UserEntity>).data
else -> UserEntity(
userProfileUrl = "",
userName = "",
userRegion = ""
userId = -1,
userEmail = "[email protected]",
userProfileUrl = "https://avatars.githubusercontent.com/u/93641814?v=4",
userName = "안세홍",
userRegion = "성북구"
)
}

when (state.postEntity) {
is UiState.Empty -> {}
is UiState.Loading -> {}
is UiState.Failure -> {}
is UiState.Success -> {
with(state.postEntity as UiState.Success<PostEntity>) {
val postId = (state.postId as? UiState.Success)?.data ?: return
val userId = (state.userId as? UiState.Success)?.data ?: return
PlaceDetailScreen(
paddingValues = paddingValues,
menuList = data.menuList,
Expand All @@ -106,11 +114,12 @@ fun PlaceDetailRoute(
isAddMap = data.isAddMap,
latitude = data.latitude,
longitude = data.longitude,
onScoopButtonClick = viewModel::useSpoon,
onAddMapButtonClick = viewModel::updateAddMap,
onScoopButtonClick = { viewModel.useSpoon(postId, userId) },
onAddMapButtonClick = { viewModel.addMyMap(postId, userId) },
onDeletePinMapButtonClick = { viewModel.deletePinMap(postId, userId) },
dropdownMenuList = state.dropDownMenuList,
onBackButtonClick = {},
onReportButtonClick = {}
onBackButtonClick = navigateUp,
onReportButtonClick = navigateToReport
)
}
}
Expand Down Expand Up @@ -138,10 +147,11 @@ private fun PlaceDetailScreen(
latitude: Double,
longitude: Double,
onScoopButtonClick: () -> Unit,
onAddMapButtonClick: (Boolean) -> Unit,
onAddMapButtonClick: () -> Unit,
onDeletePinMapButtonClick: () -> Unit,
onBackButtonClick: () -> Unit,
dropdownMenuList: ImmutableList<String>,
onReportButtonClick: (String) -> Unit
onReportButtonClick: () -> Unit
) {
val scrollState = rememberScrollState()
val context = LocalContext.current
Expand All @@ -163,7 +173,7 @@ private fun PlaceDetailScreen(
Column(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
.padding(bottom = paddingValues.calculateBottomPadding())
) {
TagTopAppBar(
count = spoonAmount,
Expand Down Expand Up @@ -193,7 +203,13 @@ private fun PlaceDetailScreen(

IconDropdownMenu(
menuItems = dropdownMenuList,
onMenuItemClick = onReportButtonClick
onMenuItemClick = { menu ->
when (menu) {
DropdownOption.REPORT.string -> {
onReportButtonClick()
}
}
}
)
}

Expand Down Expand Up @@ -264,7 +280,8 @@ private fun PlaceDetailScreen(
context = context
)
},
onAddMapButtonClick = onAddMapButtonClick
onAddMapButtonClick = onAddMapButtonClick,
onDeletePinMapButtonClick = onDeletePinMapButtonClick
)
}
}
Expand Down Expand Up @@ -306,7 +323,8 @@ private fun PlaceDetailBottomBar(
addMapCount: Int,
onScoopButtonClick: () -> Unit,
onSearchMapClick: () -> Unit,
onAddMapButtonClick: (Boolean) -> Unit,
onAddMapButtonClick: () -> Unit,
onDeletePinMapButtonClick: () -> Unit,
modifier: Modifier = Modifier,
isScooped: Boolean = false,
isAddMap: Boolean = false
Expand All @@ -318,7 +336,8 @@ private fun PlaceDetailBottomBar(
.padding(
horizontal = 20.dp,
vertical = 10.dp
),
)
.height(IntrinsicSize.Max),
verticalAlignment = Alignment.CenterVertically
) {
if (isScooped) {
Expand All @@ -334,8 +353,15 @@ private fun PlaceDetailBottomBar(

Column(
modifier = Modifier
.sizeIn(minWidth = 56.dp, minHeight = 56.dp)
.noRippleClickable { onAddMapButtonClick(isAddMap) },
.fillMaxHeight()
.sizeIn(minWidth = 56.dp)
.noRippleClickable(
if (isAddMap) {
onDeletePinMapButtonClick
} else {
onAddMapButtonClick
}
),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf

data class PlaceDetailState(
val postId: UiState<Int> = UiState.Loading,
val userId: UiState<Int> = UiState.Loading,
val postEntity: UiState<PostEntity> = UiState.Loading,
val userEntity: UiState<UserEntity> = UiState.Loading,
val spoonAmountEntity: UiState<Int> = UiState.Loading,
Expand Down
Loading
Loading