Skip to content

Commit

Permalink
[fix] #76 지도에서 기프티콘 상세 네비게이션 등록 및 변경 시 자동 갱신되도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ows3090 committed May 19, 2024
1 parent 7a79e66 commit 9a89c59
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.yapp.buddycon.designsystem.component.modal

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -65,7 +66,8 @@ fun GifticonInfoListModalSheet(
countOfUsableGifticon: Int,
countOfImminetGifticon: Int,
gifticonInfos: LazyPagingItems<AvailableGifticon.AvailableGifticonInfo>,
gifticonStore: GifticonStore
gifticonStore: GifticonStore,
onClick: (Int) -> Unit = {}
) {
Column(
modifier = modifier
Expand Down Expand Up @@ -123,7 +125,11 @@ fun GifticonInfoListModalSheet(
) {
items(gifticonInfos.itemCount) { index ->
gifticonInfos[index]?.let { gifticonInfo ->
Column {
Column(
modifier = Modifier.clickable {
onClick(gifticonInfo.gifticonId)
}
) {
Box(
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.yapp.buddycon.map.MapScreen
import com.yapp.buddycon.navigation.gifticon.GifticonDestination

private const val MAP_GRAPH = "map_graph"

Expand All @@ -16,7 +17,10 @@ internal fun NavGraphBuilder.mapGraph(
route = MAP_GRAPH
) {
composable(MapDestination.Map.route) {
MapScreen()
MapScreen { id ->
val fromRegister = false
navHostController.navigate("${GifticonDestination.Detail.route}/$id/$fromRegister")
}
}
}
}
16 changes: 12 additions & 4 deletions feature/map/src/main/java/com/yapp/buddycon/map/MapScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ private const val MapBarSize = 184f
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MapScreen(
mapViewModel: MapViewModel = hiltViewModel()
mapViewModel: MapViewModel = hiltViewModel(),
onNavigateToGifticonDetail: (Int) -> Unit = {}
) {
val context = LocalContext.current
val coroutineScope = rememberCoroutineScope()
Expand Down Expand Up @@ -139,6 +140,10 @@ fun MapScreen(
}
}
}

LaunchedEffect(Unit) {
mapViewModel.fetchAvailableGifticon()
}

// 최초 시스템 위치 권한 요청
RequestLocationPermission(
Expand All @@ -158,7 +163,8 @@ fun MapScreen(
BottomSheetScaffold(
sheetContent = {
MapBottomSheet(
mapHeightDp = mapHeightDp
mapHeightDp = mapHeightDp,
onNavigateToGifticonDetail = onNavigateToGifticonDetail
)
},
sheetPeekHeight = mapUiState.heightDp.dp,
Expand Down Expand Up @@ -196,7 +202,8 @@ fun MapScreen(
private fun MapBottomSheet(
modifier: Modifier = Modifier,
mapViewModel: MapViewModel = hiltViewModel(),
mapHeightDp: Float
mapHeightDp: Float,
onNavigateToGifticonDetail: (Int) -> Unit = {}
) {
val context = LocalContext.current
val density = context.resources.displayMetrics.density
Expand Down Expand Up @@ -248,7 +255,8 @@ private fun MapBottomSheet(
countOfUsableGifticon = mapUiState.totalCount,
countOfImminetGifticon = mapUiState.deadLineCount,
gifticonInfos = gifticonInfos,
gifticonStore = mapUiState.store
gifticonStore = mapUiState.store,
onClick = onNavigateToGifticonDetail
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ class MapViewModel @Inject constructor(
val placeLabels = _placeLabels.asStateFlow()

init {
fetchAvailableGifticon()
getGifticonCount()
}

private fun fetchAvailableGifticon() {
fun fetchAvailableGifticon() {
gifticonRepository.fetchAvailableGifticon(
gifticonStore = mapUiState.value.store,
gifticonSortType = SortType.EXPIRATION_DATE
Expand Down

0 comments on commit 9a89c59

Please sign in to comment.