Prevent multiple clicks of navigation icon on contacts screen
This commit is contained in:
@ -38,8 +38,11 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
@ -77,6 +80,7 @@ fun NavGraphBuilder.contactsScreenRoute(
|
||||
private fun ContactsScreen(navController: NavController, viewModel: ViewModel) {
|
||||
|
||||
val ctx = LocalContext.current
|
||||
var navigationClicks by remember { mutableIntStateOf(0) }
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize().imePadding(),
|
||||
@ -103,7 +107,13 @@ private fun ContactsScreen(navController: NavController, viewModel: ViewModel) {
|
||||
titleContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
),
|
||||
navigationIcon = {
|
||||
IconButton(onClick = { navController.popBackStack() }) {
|
||||
IconButton(
|
||||
onClick = {
|
||||
navigationClicks++
|
||||
if (navigationClicks == 1)
|
||||
navController.popBackStack()
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = "Back",
|
||||
|
||||
Reference in New Issue
Block a user