mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
WIP Playlist updates
This commit is contained in:
parent
dc58b31e2b
commit
0bb91f2438
2 changed files with 29 additions and 18 deletions
|
|
@ -8,6 +8,7 @@ import androidx.compose.ui.text.buildAnnotatedString
|
||||||
import com.github.damontecres.wholphin.ui.DateFormatter
|
import com.github.damontecres.wholphin.ui.DateFormatter
|
||||||
import com.github.damontecres.wholphin.ui.abbreviateNumber
|
import com.github.damontecres.wholphin.ui.abbreviateNumber
|
||||||
import com.github.damontecres.wholphin.ui.detail.CardGridItem
|
import com.github.damontecres.wholphin.ui.detail.CardGridItem
|
||||||
|
import com.github.damontecres.wholphin.ui.detail.music.artistsString
|
||||||
import com.github.damontecres.wholphin.ui.detail.series.SeasonEpisodeIds
|
import com.github.damontecres.wholphin.ui.detail.series.SeasonEpisodeIds
|
||||||
import com.github.damontecres.wholphin.ui.dot
|
import com.github.damontecres.wholphin.ui.dot
|
||||||
import com.github.damontecres.wholphin.ui.formatDateTime
|
import com.github.damontecres.wholphin.ui.formatDateTime
|
||||||
|
|
@ -57,6 +58,7 @@ data class BaseItem(
|
||||||
when (type) {
|
when (type) {
|
||||||
BaseItemKind.EPISODE -> data.seasonEpisode + " - " + name
|
BaseItemKind.EPISODE -> data.seasonEpisode + " - " + name
|
||||||
BaseItemKind.SERIES -> data.seriesProductionYears
|
BaseItemKind.SERIES -> data.seriesProductionYears
|
||||||
|
BaseItemKind.AUDIO -> listOfNotNull(data.album, artistsString).joinToString(" - ")
|
||||||
else -> data.productionYear?.toString()
|
else -> data.productionYear?.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ import com.github.damontecres.wholphin.data.model.BaseItem
|
||||||
import com.github.damontecres.wholphin.data.model.GetItemsFilter
|
import com.github.damontecres.wholphin.data.model.GetItemsFilter
|
||||||
import com.github.damontecres.wholphin.data.model.LibraryDisplayInfo
|
import com.github.damontecres.wholphin.data.model.LibraryDisplayInfo
|
||||||
import com.github.damontecres.wholphin.services.BackdropService
|
import com.github.damontecres.wholphin.services.BackdropService
|
||||||
|
import com.github.damontecres.wholphin.services.MusicService
|
||||||
|
import com.github.damontecres.wholphin.services.MusicServiceState
|
||||||
import com.github.damontecres.wholphin.services.NavigationManager
|
import com.github.damontecres.wholphin.services.NavigationManager
|
||||||
import com.github.damontecres.wholphin.ui.DefaultItemFields
|
import com.github.damontecres.wholphin.ui.DefaultItemFields
|
||||||
import com.github.damontecres.wholphin.ui.TimeFormatter
|
import com.github.damontecres.wholphin.ui.TimeFormatter
|
||||||
|
|
@ -117,6 +119,7 @@ class PlaylistViewModel
|
||||||
private val backdropService: BackdropService,
|
private val backdropService: BackdropService,
|
||||||
private val serverRepository: ServerRepository,
|
private val serverRepository: ServerRepository,
|
||||||
private val libraryDisplayInfoDao: LibraryDisplayInfoDao,
|
private val libraryDisplayInfoDao: LibraryDisplayInfoDao,
|
||||||
|
private val musicService: MusicService,
|
||||||
) : ItemViewModel(api) {
|
) : ItemViewModel(api) {
|
||||||
val loading = MutableLiveData<LoadingState>(LoadingState.Pending)
|
val loading = MutableLiveData<LoadingState>(LoadingState.Pending)
|
||||||
val items = MutableLiveData<List<BaseItem?>>(listOf())
|
val items = MutableLiveData<List<BaseItem?>>(listOf())
|
||||||
|
|
@ -131,6 +134,7 @@ class PlaylistViewModel
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
val musicState = musicService.state
|
||||||
|
|
||||||
fun init(playlistId: UUID) {
|
fun init(playlistId: UUID) {
|
||||||
loading.value = LoadingState.Loading
|
loading.value = LoadingState.Loading
|
||||||
|
|
@ -253,6 +257,7 @@ fun PlaylistDetails(
|
||||||
val playlist by viewModel.item.observeAsState(null)
|
val playlist by viewModel.item.observeAsState(null)
|
||||||
val items by viewModel.items.observeAsState(listOf())
|
val items by viewModel.items.observeAsState(listOf())
|
||||||
val filterAndSort by viewModel.filterAndSort.collectAsState()
|
val filterAndSort by viewModel.filterAndSort.collectAsState()
|
||||||
|
val musicState by viewModel.musicState.collectAsState()
|
||||||
|
|
||||||
var longClickDialog by remember { mutableStateOf<DialogParams?>(null) }
|
var longClickDialog by remember { mutableStateOf<DialogParams?>(null) }
|
||||||
|
|
||||||
|
|
@ -263,6 +268,7 @@ fun PlaylistDetails(
|
||||||
loadingState = loading,
|
loadingState = loading,
|
||||||
playlist = playlist,
|
playlist = playlist,
|
||||||
items = items,
|
items = items,
|
||||||
|
musicState = musicState,
|
||||||
onChangeBackdrop = viewModel::updateBackdrop,
|
onChangeBackdrop = viewModel::updateBackdrop,
|
||||||
onClickIndex = { index, _ ->
|
onClickIndex = { index, _ ->
|
||||||
viewModel.navigationManager.navigateTo(
|
viewModel.navigationManager.navigateTo(
|
||||||
|
|
@ -333,6 +339,7 @@ fun PlaylistDetails(
|
||||||
fun PlaylistDetailsContent(
|
fun PlaylistDetailsContent(
|
||||||
playlist: BaseItem?,
|
playlist: BaseItem?,
|
||||||
items: List<BaseItem?>,
|
items: List<BaseItem?>,
|
||||||
|
musicState: MusicServiceState,
|
||||||
onClickIndex: (Int, BaseItem) -> Unit,
|
onClickIndex: (Int, BaseItem) -> Unit,
|
||||||
onLongClickIndex: (Int, BaseItem) -> Unit,
|
onLongClickIndex: (Int, BaseItem) -> Unit,
|
||||||
onClickPlay: (shuffle: Boolean) -> Unit,
|
onClickPlay: (shuffle: Boolean) -> Unit,
|
||||||
|
|
@ -592,14 +599,12 @@ fun PlaylistItem(
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(
|
||||||
text = item?.title ?: "",
|
text = item?.title ?: "",
|
||||||
style = MaterialTheme.typography.titleLarge,
|
|
||||||
modifier = Modifier.enableMarquee(focused),
|
modifier = Modifier.enableMarquee(focused),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
Text(
|
Text(
|
||||||
text = item?.subtitle ?: "",
|
text = item?.subtitle ?: "",
|
||||||
style = MaterialTheme.typography.titleSmall,
|
|
||||||
modifier = Modifier.enableMarquee(focused),
|
modifier = Modifier.enableMarquee(focused),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -615,10 +620,12 @@ fun PlaylistItem(
|
||||||
Text(
|
Text(
|
||||||
text = duration.toString(),
|
text = duration.toString(),
|
||||||
)
|
)
|
||||||
Text(
|
if (item.type != BaseItemKind.AUDIO) {
|
||||||
text = stringResource(R.string.ends_at, endTimeStr),
|
Text(
|
||||||
style = MaterialTheme.typography.bodySmall,
|
text = stringResource(R.string.ends_at, endTimeStr),
|
||||||
)
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -631,18 +638,20 @@ fun PlaylistItem(
|
||||||
text = "${index + 1}.",
|
text = "${index + 1}.",
|
||||||
style = MaterialTheme.typography.labelLarge,
|
style = MaterialTheme.typography.labelLarge,
|
||||||
)
|
)
|
||||||
ItemCardImage(
|
if (item?.type != BaseItemKind.AUDIO) {
|
||||||
item = item,
|
ItemCardImage(
|
||||||
name = item?.name,
|
item = item,
|
||||||
showOverlay = true,
|
name = item?.name,
|
||||||
favorite = item?.data?.userData?.isFavorite ?: false,
|
showOverlay = true,
|
||||||
watched = item?.data?.userData?.played ?: false,
|
favorite = item?.data?.userData?.isFavorite ?: false,
|
||||||
unwatchedCount = item?.data?.userData?.unplayedItemCount ?: -1,
|
watched = item?.data?.userData?.played ?: false,
|
||||||
watchedPercent = 0.0,
|
unwatchedCount = item?.data?.userData?.unplayedItemCount ?: -1,
|
||||||
numberOfVersions = item?.data?.mediaSourceCount ?: 0,
|
watchedPercent = 0.0,
|
||||||
modifier = Modifier.width(160.dp),
|
numberOfVersions = item?.data?.mediaSourceCount ?: 0,
|
||||||
useFallbackText = false,
|
modifier = Modifier.width(160.dp),
|
||||||
)
|
useFallbackText = false,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue