Skip to content

Commit

Permalink
[FIX/#47] 짧은 시간 다중 사진 클릭시 여러 개의 GalleryDetail 화면이 나오는 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
yihwanggeun committed Nov 28, 2024
1 parent 12305cb commit 374cec3
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import androidx.navigation.navOptions
import androidx.navigation.toRoute
import com.sopt.shinmungo.presentation.gallery.GalleryDetailScreen
import com.sopt.shinmungo.presentation.gallery.GalleryScreen
Expand All @@ -17,7 +18,12 @@ fun NavHostController.navigateToGallery(navOptions: NavOptions? = null) =
navigate(route = Gallery, navOptions = navOptions)

fun NavHostController.navigateToGalleryDetail(photoId: Int, navOptions: NavOptions? = null) =
navigate(route = GalleryDetail(photoId), navOptions = navOptions)
navigate(
route = GalleryDetail(photoId),
navOptions = navOptions ?: navOptions {
launchSingleTop = true
}
)

fun NavGraphBuilder.galleryScreen(
navController: NavHostController,
Expand All @@ -28,7 +34,7 @@ fun NavGraphBuilder.galleryScreen(
modifier = modifier,
onBackClick = { navController.popBackStack() },
onPhotoClick = { photoId ->
navController.navigate(GalleryDetail(photoId))
navController.navigateToGalleryDetail(photoId)
},
onConfirmClick = { selectedPhotos ->
navController.previousBackStackEntry?.savedStateHandle?.set(
Expand Down

0 comments on commit 374cec3

Please sign in to comment.