mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 08:01:20 +02:00
Long click seasons & show season overlay
This commit is contained in:
parent
4113f990b2
commit
61a69f206b
3 changed files with 69 additions and 4 deletions
|
|
@ -41,6 +41,7 @@ fun SeasonCard(
|
||||||
imageHeight: Dp = Dp.Unspecified,
|
imageHeight: Dp = Dp.Unspecified,
|
||||||
imageWidth: Dp = Dp.Unspecified,
|
imageWidth: Dp = Dp.Unspecified,
|
||||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||||
|
showImageOverlay: Boolean = false,
|
||||||
) {
|
) {
|
||||||
val dto = item?.data
|
val dto = item?.data
|
||||||
val focused by interactionSource.collectIsFocusedAsState()
|
val focused by interactionSource.collectIsFocusedAsState()
|
||||||
|
|
@ -89,7 +90,7 @@ fun SeasonCard(
|
||||||
ItemCardImage(
|
ItemCardImage(
|
||||||
imageUrl = item?.imageUrl,
|
imageUrl = item?.imageUrl,
|
||||||
name = item?.name,
|
name = item?.name,
|
||||||
showOverlay = false,
|
showOverlay = showImageOverlay,
|
||||||
favorite = dto?.userData?.isFavorite ?: false,
|
favorite = dto?.userData?.isFavorite ?: false,
|
||||||
watched = dto?.userData?.played ?: false,
|
watched = dto?.userData?.played ?: false,
|
||||||
unwatchedCount = dto?.userData?.unplayedItemCount ?: -1,
|
unwatchedCount = dto?.userData?.unplayedItemCount ?: -1,
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,9 @@ import com.github.damontecres.dolphin.ui.cards.ItemRow
|
||||||
import com.github.damontecres.dolphin.ui.cards.PersonRow
|
import com.github.damontecres.dolphin.ui.cards.PersonRow
|
||||||
import com.github.damontecres.dolphin.ui.cards.SeasonCard
|
import com.github.damontecres.dolphin.ui.cards.SeasonCard
|
||||||
import com.github.damontecres.dolphin.ui.components.ConfirmDialog
|
import com.github.damontecres.dolphin.ui.components.ConfirmDialog
|
||||||
|
import com.github.damontecres.dolphin.ui.components.DialogItem
|
||||||
|
import com.github.damontecres.dolphin.ui.components.DialogParams
|
||||||
|
import com.github.damontecres.dolphin.ui.components.DialogPopup
|
||||||
import com.github.damontecres.dolphin.ui.components.DotSeparatedRow
|
import com.github.damontecres.dolphin.ui.components.DotSeparatedRow
|
||||||
import com.github.damontecres.dolphin.ui.components.ErrorMessage
|
import com.github.damontecres.dolphin.ui.components.ErrorMessage
|
||||||
import com.github.damontecres.dolphin.ui.components.ExpandableFaButton
|
import com.github.damontecres.dolphin.ui.components.ExpandableFaButton
|
||||||
|
|
@ -95,6 +98,7 @@ fun SeriesDetails(
|
||||||
|
|
||||||
var overviewDialog by remember { mutableStateOf<ItemDetailsDialogInfo?>(null) }
|
var overviewDialog by remember { mutableStateOf<ItemDetailsDialogInfo?>(null) }
|
||||||
var showWatchConfirmation by remember { mutableStateOf(false) }
|
var showWatchConfirmation by remember { mutableStateOf(false) }
|
||||||
|
var seasonDialog by remember { mutableStateOf<DialogParams?>(null) }
|
||||||
|
|
||||||
when (val state = loading) {
|
when (val state = loading) {
|
||||||
is LoadingState.Error -> ErrorMessage(state)
|
is LoadingState.Error -> ErrorMessage(state)
|
||||||
|
|
@ -112,6 +116,20 @@ fun SeriesDetails(
|
||||||
played = played,
|
played = played,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
onClickItem = { viewModel.navigateTo(it.destination()) },
|
onClickItem = { viewModel.navigateTo(it.destination()) },
|
||||||
|
onLongClickItem = { season ->
|
||||||
|
seasonDialog =
|
||||||
|
buildDialogForSeason(
|
||||||
|
season,
|
||||||
|
onClickItem = { viewModel.navigateTo(it.destination()) },
|
||||||
|
markPlayed = { played ->
|
||||||
|
viewModel.setWatched(
|
||||||
|
season.id,
|
||||||
|
played,
|
||||||
|
null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
overviewOnClick = {
|
overviewOnClick = {
|
||||||
overviewDialog =
|
overviewDialog =
|
||||||
ItemDetailsDialogInfo(
|
ItemDetailsDialogInfo(
|
||||||
|
|
@ -145,6 +163,15 @@ fun SeriesDetails(
|
||||||
onDismissRequest = { overviewDialog = null },
|
onDismissRequest = { overviewDialog = null },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
seasonDialog?.let { params ->
|
||||||
|
DialogPopup(
|
||||||
|
showDialog = true,
|
||||||
|
title = params.title,
|
||||||
|
dialogItems = params.items,
|
||||||
|
waitToLoad = params.fromLongClick,
|
||||||
|
onDismissRequest = { seasonDialog = null },
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -155,6 +182,7 @@ fun SeriesDetailsContent(
|
||||||
people: List<Person>,
|
people: List<Person>,
|
||||||
played: Boolean,
|
played: Boolean,
|
||||||
onClickItem: (BaseItem) -> Unit,
|
onClickItem: (BaseItem) -> Unit,
|
||||||
|
onLongClickItem: (BaseItem) -> Unit,
|
||||||
overviewOnClick: () -> Unit,
|
overviewOnClick: () -> Unit,
|
||||||
playOnClick: () -> Unit,
|
playOnClick: () -> Unit,
|
||||||
watchOnClick: () -> Unit,
|
watchOnClick: () -> Unit,
|
||||||
|
|
@ -230,7 +258,7 @@ fun SeriesDetailsContent(
|
||||||
title = "Seasons",
|
title = "Seasons",
|
||||||
items = seasons.items,
|
items = seasons.items,
|
||||||
onClickItem = onClickItem,
|
onClickItem = onClickItem,
|
||||||
onLongClickItem = { },
|
onLongClickItem = onLongClickItem,
|
||||||
cardOnFocus = { isFocused, index ->
|
cardOnFocus = { isFocused, index ->
|
||||||
// if (isFocused) {
|
// if (isFocused) {
|
||||||
// scope.launch(ExceptionHandler()) {
|
// scope.launch(ExceptionHandler()) {
|
||||||
|
|
@ -251,6 +279,7 @@ fun SeriesDetailsContent(
|
||||||
onLongClick = onLongClick,
|
onLongClick = onLongClick,
|
||||||
imageHeight = Cards.height2x3,
|
imageHeight = Cards.height2x3,
|
||||||
imageWidth = Dp.Unspecified,
|
imageWidth = Dp.Unspecified,
|
||||||
|
showImageOverlay = true,
|
||||||
modifier =
|
modifier =
|
||||||
mod
|
mod
|
||||||
.ifElse(
|
.ifElse(
|
||||||
|
|
@ -388,3 +417,36 @@ fun SeriesDetailsHeader(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun buildDialogForSeason(
|
||||||
|
s: BaseItem,
|
||||||
|
onClickItem: (BaseItem) -> Unit,
|
||||||
|
markPlayed: (Boolean) -> Unit,
|
||||||
|
): DialogParams {
|
||||||
|
val items =
|
||||||
|
buildList {
|
||||||
|
add(
|
||||||
|
DialogItem("Go to", Icons.Default.PlayArrow) {
|
||||||
|
onClickItem.invoke(s)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if (s.data.userData?.played == true) {
|
||||||
|
add(
|
||||||
|
DialogItem("Mark as unplayed", R.string.fa_eye) {
|
||||||
|
markPlayed.invoke(false)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
add(
|
||||||
|
DialogItem("Mark as played", R.string.fa_eye_slash) {
|
||||||
|
markPlayed.invoke(true)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DialogParams(
|
||||||
|
title = s.name ?: "Season",
|
||||||
|
fromLongClick = true,
|
||||||
|
items = items,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -244,14 +244,16 @@ class SeriesViewModel
|
||||||
fun setWatched(
|
fun setWatched(
|
||||||
itemId: UUID,
|
itemId: UUID,
|
||||||
played: Boolean,
|
played: Boolean,
|
||||||
listIndex: Int,
|
listIndex: Int?,
|
||||||
) = viewModelScope.launch(ExceptionHandler()) {
|
) = viewModelScope.launch(ExceptionHandler()) {
|
||||||
if (played) {
|
if (played) {
|
||||||
api.playStateApi.markPlayedItem(itemId)
|
api.playStateApi.markPlayedItem(itemId)
|
||||||
} else {
|
} else {
|
||||||
api.playStateApi.markUnplayedItem(itemId)
|
api.playStateApi.markUnplayedItem(itemId)
|
||||||
}
|
}
|
||||||
refreshEpisode(itemId, listIndex)
|
listIndex?.let {
|
||||||
|
refreshEpisode(itemId, listIndex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setWatchedSeries(played: Boolean) =
|
fun setWatchedSeries(played: Boolean) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue