Skip to content

Commit 83bbf7d

Browse files
authored
Merge pull request #64 from MohamedRejeb/0.5.x
0.5.x
2 parents fb6a663 + d199975 commit 83bbf7d

10 files changed

Lines changed: 44 additions & 53 deletions

File tree

compose-dnd/src/commonMain/kotlin/com/mohamedrejeb/compose/dnd/drop/DropTargetState.kt

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,58 +51,68 @@ class DropTargetState<T> internal constructor(
5151

5252
internal fun getDropTopLeft(droppedItemSize: Size): Offset =
5353
topLeft + dropOffset + when (dropAlignment) {
54-
Alignment.TopStart ->
54+
Alignment.TopStart -> {
5555
Offset.Zero
56+
}
5657

57-
Alignment.TopCenter ->
58+
Alignment.TopCenter -> {
5859
Offset(
5960
x = size.width / 2f - droppedItemSize.width / 2f,
6061
y = 0f,
6162
)
63+
}
6264

63-
Alignment.TopEnd ->
65+
Alignment.TopEnd -> {
6466
Offset(
6567
x = size.width - droppedItemSize.width,
6668
y = 0f,
6769
)
70+
}
6871

69-
Alignment.CenterStart ->
72+
Alignment.CenterStart -> {
7073
Offset(
7174
x = 0f,
7275
y = size.height / 2f - droppedItemSize.height / 2f,
7376
)
77+
}
7478

75-
Alignment.Center ->
79+
Alignment.Center -> {
7680
Offset(
7781
x = size.width / 2f - droppedItemSize.width / 2f,
7882
y = size.height / 2f - droppedItemSize.height / 2f,
7983
)
84+
}
8085

81-
Alignment.CenterEnd ->
86+
Alignment.CenterEnd -> {
8287
Offset(
8388
x = size.width - droppedItemSize.width,
8489
y = size.height / 2f - droppedItemSize.height / 2f,
8590
)
91+
}
8692

87-
Alignment.BottomStart ->
93+
Alignment.BottomStart -> {
8894
Offset(
8995
x = 0f,
9096
y = size.height - droppedItemSize.height,
9197
)
98+
}
9299

93-
Alignment.BottomCenter ->
100+
Alignment.BottomCenter -> {
94101
Offset(
95102
x = size.width / 2f - droppedItemSize.width / 2f,
96103
y = size.height - droppedItemSize.height,
97104
)
105+
}
98106

99-
Alignment.BottomEnd ->
107+
Alignment.BottomEnd -> {
100108
Offset(
101109
x = size.width - droppedItemSize.width,
102110
y = size.height - droppedItemSize.height,
103111
)
112+
}
104113

105-
else ->
114+
else -> {
106115
Offset.Zero
116+
}
107117
}
108118
}

compose-dnd/src/commonMain/kotlin/com/mohamedrejeb/compose/dnd/scroll/DragAutoScroll.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,15 @@ internal fun computeScrollSpeed(
453453
val ratio = (startOverlap / startThresholdPx).coerceIn(0f, 1f)
454454
-maxScrollSpeed * ratio * ratio
455455
}
456+
456457
// Item's end edge is within the end threshold → scroll toward end
457458
endOverlap > 0f -> {
458459
val ratio = (endOverlap / endThresholdPx).coerceIn(0f, 1f)
459460
maxScrollSpeed * ratio * ratio
460461
}
461462

462-
else -> 0f
463+
else -> {
464+
0f
465+
}
463466
}
464467
}

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ android-minSdk = "23"
66
android-compileSdk = "36"
77
android-targetSdk = "36"
88
androidx-activityCompose = "1.13.0"
9-
androidx-core-ktx = "1.16.0"
9+
androidx-core-ktx = "1.18.0"
1010
jetbrains-navigation-compose = "2.9.2"
11-
spotless = "7.2.1"
11+
spotless = "8.4.0"
1212
vanniktech-maven-publish = "0.36.0"
1313

1414
[libraries]

renovate.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

sample/common/src/commonMain/kotlin/ui/AutoScrollDemoScreen.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ fun AutoScrollDemoScreen(
9898
.fillMaxSize()
9999
.padding(16.dp),
100100
)
101+
101102
1 -> LazyGridReorderContent(
102103
modifier = Modifier
103104
.fillMaxSize()
104105
.padding(16.dp),
105106
)
107+
106108
2 -> ScrollStateReorderContent(
107109
modifier = Modifier
108110
.fillMaxSize()
@@ -164,7 +166,7 @@ private fun LazyRowReorderContent(modifier: Modifier = Modifier) {
164166
.fillMaxHeight(),
165167
)
166168
},
167-
modifier = Modifier,
169+
modifier = Modifier.animateItem(),
168170
) {
169171
AutoScrollItem(
170172
number = number,
@@ -232,7 +234,7 @@ private fun LazyGridReorderContent(modifier: Modifier = Modifier) {
232234
.height(80.dp),
233235
)
234236
},
235-
modifier = Modifier,
237+
modifier = Modifier.animateItem(),
236238
) {
237239
AutoScrollItem(
238240
number = number,

sample/common/src/commonMain/kotlin/ui/AxisLockedDragScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ private fun FreeMovementDemo() {
320320
)
321321
}
322322
}
323+
323324
hasItemB -> {
324325
DraggableItem(
325326
state = state,

sample/common/src/commonMain/kotlin/ui/DragHandleReorderScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private fun DragHandleReorderContent(
123123
isDragShadow = true,
124124
)
125125
},
126-
modifier = Modifier,
126+
modifier = Modifier.animateItem(),
127127
) {
128128
DragHandleListItem(
129129
text = item,

sample/common/src/commonMain/kotlin/ui/DropStrategiesPlaygroundScreen.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,16 +437,21 @@ private fun StrategySelector(
437437
@Composable
438438
private fun StrategyDescription(strategy: DropStrategy) {
439439
val description = when (strategy) {
440-
DropStrategy.Surface ->
440+
DropStrategy.Surface -> {
441441
"Picks the target with the most overlap area (pixels). Favors larger targets."
442+
}
442443

443-
DropStrategy.SurfacePercentage ->
444+
DropStrategy.SurfacePercentage -> {
444445
"Picks the target with the highest overlap relative to its own size. Favors smaller targets."
446+
}
445447

446-
DropStrategy.CenterDistance ->
448+
DropStrategy.CenterDistance -> {
447449
"Picks the target whose center is closest to the dragged item. Size doesn't matter."
450+
}
448451

449-
else -> ""
452+
else -> {
453+
""
454+
}
450455
}
451456

452457
Text(

sample/common/src/commonMain/kotlin/ui/ListToListWithReorderScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private fun ListToListWithReorderContent(
145145
.height(60.dp),
146146
)
147147
},
148-
modifier = Modifier,
148+
modifier = Modifier.animateItem(),
149149
) {
150150
DndItemCard(
151151
label = item,
@@ -214,7 +214,7 @@ private fun ListToListWithReorderContent(
214214
.height(60.dp),
215215
)
216216
},
217-
modifier = Modifier,
217+
modifier = Modifier.animateItem(),
218218
) {
219219
DndItemCard(
220220
label = item,

sample/common/src/commonMain/kotlin/ui/ReorderListScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ private fun ReorderScreenContent(
9292
DndItemCard(
9393
label = "#$number",
9494
modifier = Modifier
95+
.animateItem()
9596
.graphicsLayer { alpha = if (isDragging) 0f else 1f }
9697
.reorderableItem(
9798
key = item,

0 commit comments

Comments
 (0)