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
|
modifier = Modifier
|
||||||
.height(tabsHeight)
|
.height(tabsHeight)
|
||||||
.weight(1f, false)
|
.weight(1f, false)
|
||||||
.horizontalDragContainer(dragDropState),
|
.horizontalDragContainer(
|
||||||
|
dragDropState = dragDropState,
|
||||||
|
onDraggedTab = {
|
||||||
|
val tab = tabs.getOrNull(it)
|
||||||
|
|
||||||
|
if (tab != null) {
|
||||||
|
onTabSelected(tab)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
state = stateHorizontal,
|
state = stateHorizontal,
|
||||||
) {
|
) {
|
||||||
itemsIndexed(
|
itemsIndexed(
|
||||||
items = tabs,
|
items = tabs,
|
||||||
key = { _, tab -> tab.tabViewModel }
|
key = { _, tab -> tab.tabViewModel }
|
||||||
) { index, tab ->
|
) { index, tab ->
|
||||||
HorizontalDraggableItem(dragDropState, index) { isDragged ->
|
HorizontalDraggableItem(dragDropState, index) { _ ->
|
||||||
LaunchedEffect(isDragged) {
|
|
||||||
if (isDragged) {
|
|
||||||
onTabSelected(tab)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Tooltip(tab.path) {
|
Tooltip(tab.path) {
|
||||||
Tab(
|
Tab(
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
|
@ -290,7 +290,7 @@ class VerticalDragDropState internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Modifier.horizontalDragContainer(dragDropState: HorizontalDragDropState): Modifier {
|
fun Modifier.horizontalDragContainer(dragDropState: HorizontalDragDropState, onDraggedTab: (Int) -> Unit): Modifier {
|
||||||
val state = rememberDraggableState {
|
val state = rememberDraggableState {
|
||||||
println("Dragging horizontally $it")
|
println("Dragging horizontally $it")
|
||||||
dragDropState.onDrag(Offset(it, 0f))
|
dragDropState.onDrag(Offset(it, 0f))
|
||||||
@ -302,6 +302,11 @@ fun Modifier.horizontalDragContainer(dragDropState: HorizontalDragDropState): Mo
|
|||||||
startDragImmediately = false,
|
startDragImmediately = false,
|
||||||
onDragStarted = {
|
onDragStarted = {
|
||||||
dragDropState.onDragStart(it)
|
dragDropState.onDragStart(it)
|
||||||
|
val index = dragDropState.draggingItemIndex
|
||||||
|
|
||||||
|
if (index != null) {
|
||||||
|
onDraggedTab(index)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onDragStopped = {
|
onDragStopped = {
|
||||||
println("On drag stopped")
|
println("On drag stopped")
|
||||||
|
Loading…
Reference in New Issue
Block a user