mirror of
https://github.com/wismna/DoNext.git
synced 2025-12-06 00:02:40 -05:00
Prevent navigation to current destination
This commit is contained in:
@@ -57,7 +57,7 @@ fun MenuScreen(
|
|||||||
},
|
},
|
||||||
icon = { Icon(Icons.Default.Today, contentDescription = "Due Today") },
|
icon = { Icon(Icons.Default.Today, contentDescription = "Due Today") },
|
||||||
selected = currentDestination is AppDestination.DueTodayList,
|
selected = currentDestination is AppDestination.DueTodayList,
|
||||||
onClick = { viewModel.navigateTo(AppDestination.DueTodayList.route) },
|
onClick = { viewModel.navigateTo(AppDestination.DueTodayList.route, currentDestination.route) },
|
||||||
modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding)
|
modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding)
|
||||||
)
|
)
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
@@ -73,7 +73,7 @@ fun MenuScreen(
|
|||||||
icon = { Icon(Icons.Default.LineWeight, contentDescription = list.name) },
|
icon = { Icon(Icons.Default.LineWeight, contentDescription = list.name) },
|
||||||
selected = currentDestination is AppDestination.TaskList &&
|
selected = currentDestination is AppDestination.TaskList &&
|
||||||
currentDestination.taskListId == list.id,
|
currentDestination.taskListId == list.id,
|
||||||
onClick = { viewModel.navigateTo("taskList/${list.id}") },
|
onClick = { viewModel.navigateTo("taskList/${list.id}", currentDestination.route) },
|
||||||
badge = {
|
badge = {
|
||||||
if (list.overdueCount > 0) {
|
if (list.overdueCount > 0) {
|
||||||
Badge { Text(list.overdueCount.toString()) }
|
Badge { Text(list.overdueCount.toString()) }
|
||||||
@@ -90,14 +90,14 @@ fun MenuScreen(
|
|||||||
label = { Text("Recycle Bin") },
|
label = { Text("Recycle Bin") },
|
||||||
icon = { Icon(Icons.Default.Delete, contentDescription = "Recycle Bin") },
|
icon = { Icon(Icons.Default.Delete, contentDescription = "Recycle Bin") },
|
||||||
selected = currentDestination is AppDestination.RecycleBin,
|
selected = currentDestination is AppDestination.RecycleBin,
|
||||||
onClick = { viewModel.navigateTo(AppDestination.RecycleBin.route) },
|
onClick = { viewModel.navigateTo(AppDestination.RecycleBin.route, currentDestination.route) },
|
||||||
modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding)
|
modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding)
|
||||||
)
|
)
|
||||||
NavigationDrawerItem(
|
NavigationDrawerItem(
|
||||||
label = { Text("Edit Lists") },
|
label = { Text("Edit Lists") },
|
||||||
icon = { Icon(Icons.Default.EditNote, contentDescription = "Edit Lists") },
|
icon = { Icon(Icons.Default.EditNote, contentDescription = "Edit Lists") },
|
||||||
selected = currentDestination is AppDestination.ManageLists,
|
selected = currentDestination is AppDestination.ManageLists,
|
||||||
onClick = { viewModel.navigateTo(AppDestination.ManageLists.route) },
|
onClick = { viewModel.navigateTo(AppDestination.ManageLists.route, currentDestination.route) },
|
||||||
modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding)
|
modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.wismna.geoffroy.donext.domain.model.AppDestination
|
||||||
import com.wismna.geoffroy.donext.domain.model.TaskListWithOverdue
|
import com.wismna.geoffroy.donext.domain.model.TaskListWithOverdue
|
||||||
import com.wismna.geoffroy.donext.domain.usecase.GetDueTodayTasksUseCase
|
import com.wismna.geoffroy.donext.domain.usecase.GetDueTodayTasksUseCase
|
||||||
import com.wismna.geoffroy.donext.domain.usecase.GetTaskListsWithOverdueUseCase
|
import com.wismna.geoffroy.donext.domain.usecase.GetTaskListsWithOverdueUseCase
|
||||||
@@ -42,9 +43,11 @@ class MenuViewModel @Inject constructor(
|
|||||||
.launchIn(viewModelScope)
|
.launchIn(viewModelScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun navigateTo(route: String) {
|
fun navigateTo(route: String, currentRoute: String) {
|
||||||
viewModelScope.launch {
|
if (route != currentRoute) {
|
||||||
uiEventBus.send(UiEvent.Navigate(route))
|
viewModelScope.launch {
|
||||||
|
uiEventBus.send(UiEvent.Navigate(route))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user