@@ -149,6 +149,7 @@ fun LongPressMenuEditorPage(onBackClick: () -> Unit) {
149149 ItemInListUi (
150150 item = item,
151151 focused = state.currentlyFocusedItem == i,
152+ beingDragged = false ,
152153 // We only want placement animations: fade in/out animations interfere with
153154 // items being replaced by a drag marker while being dragged around, and a
154155 // fade in/out animation there does not make sense as the item was just
@@ -167,7 +168,8 @@ fun LongPressMenuEditorPage(onBackClick: () -> Unit) {
167168 }
168169 ItemInListUi (
169170 item = activeDragItem,
170- focused = true ,
171+ focused = false ,
172+ beingDragged = true ,
171173 modifier = Modifier
172174 .size(size)
173175 .offset { state.activeDragPosition }
@@ -287,12 +289,15 @@ private fun ActionOrHeaderBox(
287289 * different parameters
288290 * @param focused if `true`, a box will be drawn around the item to indicate that it is focused
289291 * (this will only ever be `true` when the user is navigating with DPAD, e.g. on Android TVs)
292+ * @param beingDragged if `true`, draw a semi-transparent background to show that the item is being
293+ * dragged
290294 */
291295@Composable
292296private fun ItemInListUi (
293297 item : ItemInList ,
294298 focused : Boolean ,
295- modifier : Modifier = Modifier
299+ beingDragged : Boolean ,
300+ modifier : Modifier
296301) {
297302 when (item) {
298303 ItemInList .EnabledCaption -> {
@@ -319,7 +324,9 @@ private fun ItemInListUi(
319324 focused = focused,
320325 icon = item.type.icon,
321326 text = item.type.label,
322- contentColor = MaterialTheme .colorScheme.onSurface
327+ contentColor = MaterialTheme .colorScheme.onSurface,
328+ backgroundColor = MaterialTheme .colorScheme.surface
329+ .letIf(beingDragged) { copy(alpha = 0.7f ) }
323330 )
324331 }
325332
@@ -330,7 +337,8 @@ private fun ItemInListUi(
330337 icon = Icons .Default .ArtTrack ,
331338 text = R .string.long_press_menu_header,
332339 contentColor = MaterialTheme .colorScheme.onSurfaceVariant,
333- backgroundColor = MaterialTheme .colorScheme.surfaceContainer,
340+ backgroundColor = MaterialTheme .colorScheme.surfaceContainer
341+ .letIf(beingDragged) { copy(alpha = 0.85f ) },
334342 horizontalPadding = 12 .dp
335343 )
336344 }
@@ -384,6 +392,7 @@ private fun QuickActionButtonPreview(
384392 ItemInListUi (
385393 item = itemInList,
386394 focused = itemInList.stableUniqueKey() % 2 == 0 ,
395+ beingDragged = false ,
387396 modifier = Modifier .width(MinButtonWidth * (itemInList.columnSpan ? : 4 ))
388397 )
389398 }
0 commit comments