Skip to content

Commit

Permalink
Merge pull request #243 from kisa002/fix/prevent-multiple-click
Browse files Browse the repository at this point in the history
[Bug] 버튼 연타 시 중복 호출 이슈 수정
  • Loading branch information
laco-dev authored Sep 4, 2023
2 parents e37a531 + 7d98e2b commit 7ad3e27
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -55,6 +56,7 @@ fun KnightsTopAppBar(
modifier = Modifier
.fillMaxWidth()
.background(containerColor)
.pointerInput(Unit) { /* no-op */ }
.then(modifier)
) {
if (navigationType == TopAppBarNavigationType.Back) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.navigation.compose.rememberNavController
import androidx.navigation.navOptions
import com.droidknights.app2023.feature.bookmark.navigation.navigateBookmark
import com.droidknights.app2023.feature.contributor.navigation.navigateContributor
import com.droidknights.app2023.feature.home.navigation.HomeRoute
import com.droidknights.app2023.feature.home.navigation.navigateHome
import com.droidknights.app2023.feature.session.navigation.navigateSession
import com.droidknights.app2023.feature.session.navigation.navigateSessionDetail
Expand Down Expand Up @@ -61,6 +62,15 @@ internal class MainNavigator(
navController.popBackStack()
}

fun popBackStackIfNotHome() {
if (!isSameCurrentDestination(HomeRoute.route)) {
popBackStack()
}
}

private fun isSameCurrentDestination(route: String) =
navController.currentDestination?.route == route

@Composable
fun shouldShowBottomBar(): Boolean {
val currentRoute = currentDestination?.route ?: return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ internal fun MainScreen(
)

contributorNavGraph(
onBackClick = { navigator.popBackStack() },
onBackClick = navigator::popBackStackIfNotHome,
onShowErrorSnackBar = onShowErrorSnackBar
)

sessionNavGraph(
onBackClick = { navigator.popBackStack() },
onBackClick = navigator::popBackStackIfNotHome,
onSessionClick = { navigator.navigateSessionDetail(it.id) },
onShowErrorSnackBar = onShowErrorSnackBar
)
Expand Down

0 comments on commit 7ad3e27

Please sign in to comment.