Fixed tabs being partially dragged accidentally (instead of clicked)
This commit is contained in:
parent
59a9b270a7
commit
81253c0f06
@ -97,19 +97,23 @@ fun RepositoriesTabPanel(
|
||||
modifier = Modifier
|
||||
.height(tabsHeight)
|
||||
.weight(1f, false)
|
||||
.horizontalDragContainer(dragDropState),
|
||||
.horizontalDragContainer(
|
||||
dragDropState = dragDropState,
|
||||
onDraggedTab = {
|
||||
val tab = tabs.getOrNull(it)
|
||||
|
||||
if (tab != null) {
|
||||
onTabSelected(tab)
|
||||
}
|
||||
},
|
||||
),
|
||||
state = stateHorizontal,
|
||||
) {
|
||||
itemsIndexed(
|
||||
items = tabs,
|
||||
key = { _, tab -> tab.tabViewModel }
|
||||
) { index, tab ->
|
||||
HorizontalDraggableItem(dragDropState, index) { isDragged ->
|
||||
LaunchedEffect(isDragged) {
|
||||
if (isDragged) {
|
||||
onTabSelected(tab)
|
||||
}
|
||||
}
|
||||
HorizontalDraggableItem(dragDropState, index) { _ ->
|
||||
Tooltip(tab.path) {
|
||||
Tab(
|
||||
modifier = Modifier,
|
||||
|
@ -290,7 +290,7 @@ class VerticalDragDropState internal constructor(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Modifier.horizontalDragContainer(dragDropState: HorizontalDragDropState): Modifier {
|
||||
fun Modifier.horizontalDragContainer(dragDropState: HorizontalDragDropState, onDraggedTab: (Int) -> Unit): Modifier {
|
||||
val state = rememberDraggableState {
|
||||
println("Dragging horizontally $it")
|
||||
dragDropState.onDrag(Offset(it, 0f))
|
||||
@ -302,6 +302,11 @@ fun Modifier.horizontalDragContainer(dragDropState: HorizontalDragDropState): Mo
|
||||
startDragImmediately = false,
|
||||
onDragStarted = {
|
||||
dragDropState.onDragStart(it)
|
||||
val index = dragDropState.draggingItemIndex
|
||||
|
||||
if (index != null) {
|
||||
onDraggedTab(index)
|
||||
}
|
||||
},
|
||||
onDragStopped = {
|
||||
println("On drag stopped")
|
||||
|
Loading…
Reference in New Issue
Block a user