make background visiable when dragging playlist item
This commit is contained in:
parent
9a71e8f0b5
commit
9c9d628f0c
|
@ -145,15 +145,16 @@ fun ReorderableStreamItemsList(
|
||||||
key = playlistItem.uniqueId
|
key = playlistItem.uniqueId
|
||||||
) { isDragging ->
|
) { isDragging ->
|
||||||
StreamItem(
|
StreamItem(
|
||||||
id = index,
|
uniqueId = playlistItem.uniqueId,
|
||||||
title = playlistItem.title,
|
title = playlistItem.title,
|
||||||
creator = playlistItem.creator,
|
creator = playlistItem.creator,
|
||||||
thumbnail = playlistItem.thumbnail,
|
thumbnail = playlistItem.thumbnail,
|
||||||
lengthInMs = playlistItem.lengthInS.toLong() * 1000,
|
lengthInMs = playlistItem.lengthInS.toLong() * 1000,
|
||||||
onClicked = { viewModel.streamSelected(it) },
|
onClicked = { viewModel.streamSelected(0) },
|
||||||
reorderableScope = this@ReorderableItem,
|
reorderableScope = this@ReorderableItem,
|
||||||
haptic = haptic,
|
haptic = haptic,
|
||||||
onDragFinished = viewModel::onStreamItemDragFinished
|
onDragFinished = viewModel::onStreamItemDragFinished,
|
||||||
|
isDragging = isDragging
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,13 @@
|
||||||
|
|
||||||
package net.newpipe.newplayer.ui.videoplayer.streamselect
|
package net.newpipe.newplayer.ui.videoplayer.streamselect
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.core.tween
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
@ -37,6 +42,7 @@ import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.DragHandle
|
import androidx.compose.material.icons.filled.DragHandle
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -55,6 +61,8 @@ import coil.compose.AsyncImage
|
||||||
import net.newpipe.newplayer.R
|
import net.newpipe.newplayer.R
|
||||||
import net.newpipe.newplayer.ui.CONTROLLER_UI_BACKGROUND_COLOR
|
import net.newpipe.newplayer.ui.CONTROLLER_UI_BACKGROUND_COLOR
|
||||||
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
import net.newpipe.newplayer.ui.theme.VideoPlayerTheme
|
||||||
|
import net.newpipe.newplayer.ui.videoplayer.gesture_ui.SEEK_ANIMATION_FADE_IN
|
||||||
|
import net.newpipe.newplayer.ui.videoplayer.gesture_ui.SEEK_ANIMATION_FADE_OUT
|
||||||
import net.newpipe.newplayer.utils.BitmapThumbnail
|
import net.newpipe.newplayer.utils.BitmapThumbnail
|
||||||
import net.newpipe.newplayer.utils.OnlineThumbnail
|
import net.newpipe.newplayer.utils.OnlineThumbnail
|
||||||
import net.newpipe.newplayer.utils.ReorderHapticFeedback
|
import net.newpipe.newplayer.utils.ReorderHapticFeedback
|
||||||
|
@ -98,24 +106,39 @@ private fun Thumbnail(thumbnail: Thumbnail?, contentDescription: String) {
|
||||||
@Composable
|
@Composable
|
||||||
fun StreamItem(
|
fun StreamItem(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
id: Int,
|
uniqueId: Long,
|
||||||
title: String,
|
title: String,
|
||||||
creator: String?,
|
creator: String?,
|
||||||
thumbnail: Thumbnail?,
|
thumbnail: Thumbnail?,
|
||||||
lengthInMs: Long,
|
lengthInMs: Long,
|
||||||
onClicked: (Int) -> Unit,
|
onClicked: (Long) -> Unit,
|
||||||
onDragFinished: () -> Unit,
|
onDragFinished: () -> Unit,
|
||||||
reorderableScope: ReorderableCollectionItemScope?,
|
reorderableScope: ReorderableCollectionItemScope?,
|
||||||
haptic: ReorderHapticFeedback?
|
haptic: ReorderHapticFeedback?,
|
||||||
|
isDragging: Boolean
|
||||||
) {
|
) {
|
||||||
val locale = getLocale()!!
|
val locale = getLocale()!!
|
||||||
|
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
|
Box(modifier = modifier.height(60.dp).clickable {
|
||||||
|
onClicked(uniqueId)
|
||||||
|
}) {
|
||||||
|
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = isDragging,
|
||||||
|
enter = fadeIn(animationSpec = tween(200)),
|
||||||
|
exit = fadeOut(animationSpec = tween(400))
|
||||||
|
) {
|
||||||
|
Surface(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
color = MaterialTheme.colorScheme.background,
|
||||||
|
shadowElevation = 8.dp
|
||||||
|
) {}
|
||||||
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.padding(5.dp)
|
.padding(5.dp)
|
||||||
.height(60.dp)
|
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
@ -138,7 +161,11 @@ fun StreamItem(
|
||||||
top = 0.5.dp,
|
top = 0.5.dp,
|
||||||
bottom = 0.5.dp
|
bottom = 0.5.dp
|
||||||
),
|
),
|
||||||
text = getTimeStringFromMs(lengthInMs, locale, leadingZerosForMinutes = false),
|
text = getTimeStringFromMs(
|
||||||
|
lengthInMs,
|
||||||
|
locale,
|
||||||
|
leadingZerosForMinutes = false
|
||||||
|
),
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -157,7 +184,10 @@ fun StreamItem(
|
||||||
)
|
)
|
||||||
if (creator != null) {
|
if (creator != null) {
|
||||||
Text(
|
Text(
|
||||||
text = creator, fontSize = 13.sp, fontWeight = FontWeight.Light, maxLines = 1,
|
text = creator,
|
||||||
|
fontSize = 13.sp,
|
||||||
|
fontWeight = FontWeight.Light,
|
||||||
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -193,6 +223,7 @@ fun StreamItem(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Preview(device = "spec:width=1080px,height=400px,dpi=440,orientation=landscape")
|
@Preview(device = "spec:width=1080px,height=400px,dpi=440,orientation=landscape")
|
||||||
|
@ -202,7 +233,7 @@ fun StreamItemPreview() {
|
||||||
Surface(modifier = Modifier.fillMaxSize(), color = Color.DarkGray) {
|
Surface(modifier = Modifier.fillMaxSize(), color = Color.DarkGray) {
|
||||||
Box(modifier = Modifier.fillMaxSize()) {
|
Box(modifier = Modifier.fillMaxSize()) {
|
||||||
StreamItem(
|
StreamItem(
|
||||||
id = 0,
|
uniqueId = 0,
|
||||||
title = "Video Title",
|
title = "Video Title",
|
||||||
creator = "Video Creator",
|
creator = "Video Creator",
|
||||||
thumbnail = null,
|
thumbnail = null,
|
||||||
|
@ -210,7 +241,8 @@ fun StreamItemPreview() {
|
||||||
onClicked = {},
|
onClicked = {},
|
||||||
reorderableScope = null,
|
reorderableScope = null,
|
||||||
haptic = null,
|
haptic = null,
|
||||||
onDragFinished = {}
|
onDragFinished = {},
|
||||||
|
isDragging = false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue