Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
activityCompose = "1.13.0"
agp = "9.2.1"
agp = "9.3.0"
androidJunit5 = "2.0.1"
annotation = "1.10.0"
assertjCore = "3.27.7"
Expand All @@ -14,10 +14,10 @@ handoff = "0.30.3"
jodaTime = "2.14.2"
jsoup = "1.22.2"
junit = "4.13.2"
junitJupiterApi = "6.1.0"
junitJupiterApi = "6.1.2"
junitKtx = "1.3.0"
kotlinxCoroutinesRx3 = "1.11.0"
kotlin = "2.4.0"
kotlin = "2.4.10"
ktorVersion = "3.5.1"
lazyJ = "0.11.0"
lifecycle = "2.11.0"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material.ripple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -43,9 +41,9 @@ import com.lasthopesoftware.bluewater.shared.android.UndoStack
import com.lasthopesoftware.bluewater.shared.android.messages.ViewModelMessageBus
import com.lasthopesoftware.bluewater.shared.android.viewmodels.PooledCloseablesViewModel
import com.lasthopesoftware.bluewater.shared.messages.registerReceiver
import com.lasthopesoftware.observables.mapNotNull
import com.lasthopesoftware.observables.subscribeAsState
import com.lasthopesoftware.promises.extensions.toPromise
import kotlinx.coroutines.launch

@Composable
fun DragDropItemScope.NowPlayingFileView(
Expand Down Expand Up @@ -305,41 +303,31 @@ fun NowPlayingPlaylist(
val nowPlayingFiles by playlistViewModel.nowPlayingList.subscribeAsState()
val activeLibraryId by nowPlayingFilePropertiesViewModel.activeLibraryId.subscribeAsState()

val dragDropListState = rememberDragDropListState(
lazyListState = lazyListState,
onMove = { from, to ->
playlistViewModel.swapFiles(from, to)
},
onDragEnd = { from, to ->
activeLibraryId?.also {
playbackServiceController.moveFile(it, from, to)
}
}
)

val playingFile by nowPlayingFilePropertiesViewModel.nowPlayingFile.subscribeAsState()

val isAutoScrollEnabled by playlistViewModel.isAutoScrolling.subscribeAsState()
if (isAutoScrollEnabled) {
var lastScrolledToItem by rememberSaveable { mutableStateOf<PositionedFile?>(null) }
LaunchedEffect(key1 = playingFile) {
playingFile?.also {
if (it != lastScrolledToItem) {
dragDropListState.lazyListState.scrollToFileIfNotScrolling(it)
lastScrolledToItem = it
DisposableEffect(key1 = nowPlayingFilePropertiesViewModel, key2 = lazyListState) {
val sub = nowPlayingFilePropertiesViewModel
.nowPlayingFile
.mapNotNull()
.forEach {
if (it != lastScrolledToItem) {
lazyListState.requestScrollToFileIfNotScrolling(it)
lastScrolledToItem = it
}
}

onDispose {
sub.dispose()
}
}
}

val scope = rememberCoroutineScope()
DisposableEffect(key1 = Unit) {
DisposableEffect(key1 = viewModelMessageBus, key2 = lazyListState, key3 = nowPlayingFilePropertiesViewModel) {
val registration =
viewModelMessageBus.registerReceiver { _: NowPlayingMessage.ScrollToNowPlaying ->
scope.launch {
playingFile?.apply {
dragDropListState.lazyListState.scrollToItem(playlistPosition)
}
nowPlayingFilePropertiesViewModel.nowPlayingFile.value?.also {
lazyListState.requestScrollToFileIfNotScrolling(it)
}
}

Expand All @@ -348,8 +336,21 @@ fun NowPlayingPlaylist(
}
}

val playingFile by nowPlayingFilePropertiesViewModel.nowPlayingFile.subscribeAsState()
val inputMode = LocalInputModeManager.current
if (inputMode.inputMode == InputMode.Touch) {
val dragDropListState = rememberDragDropListState(
lazyListState = lazyListState,
onMove = { from, to ->
playlistViewModel.swapFiles(from, to)
},
onDragEnd = { from, to ->
activeLibraryId?.also {
playbackServiceController.moveFile(it, from, to)
}
}
)

DragDropLazyColumn(
dragDropListState = dragDropListState,
modifier = modifier,
Expand All @@ -369,7 +370,7 @@ fun NowPlayingPlaylist(
}
}
} else {
LazyColumn(modifier = modifier) {
LazyColumn(modifier = modifier, state = lazyListState) {
items(items = nowPlayingFiles, key = { it }) { f ->
NowPlayingFileView(
activeLibraryId = activeLibraryId,
Expand Down

This file was deleted.

Loading
Loading