mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-23 19:26:50 +00:00
feat(series): add confirmation dialog before marking series as watched
This commit is contained in:
@@ -3,9 +3,11 @@ package hu.bbara.purefin.ui.screen.series
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.Download
|
import androidx.compose.material.icons.outlined.Download
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@@ -144,6 +146,7 @@ private fun SeriesScreenInternal(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val navigationManager = LocalNavigationManager.current
|
val navigationManager = LocalNavigationManager.current
|
||||||
var showDownloadDialog by remember { mutableStateOf(false) }
|
var showDownloadDialog by remember { mutableStateOf(false) }
|
||||||
|
var showMarkAsWatchedDialog by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
fun getDefaultSeason(): Season? {
|
fun getDefaultSeason(): Season? {
|
||||||
return series.seasons.firstOrNull { it.unwatchedEpisodeCount > 0 } ?: series.seasons.firstOrNull()
|
return series.seasons.firstOrNull { it.unwatchedEpisodeCount > 0 } ?: series.seasons.firstOrNull()
|
||||||
@@ -188,7 +191,13 @@ private fun SeriesScreenInternal(
|
|||||||
nextUpEpisode = nextUpEpisode,
|
nextUpEpisode = nextUpEpisode,
|
||||||
onPlayClick = playAction ?: {},
|
onPlayClick = playAction ?: {},
|
||||||
onDownloadClick = { showDownloadDialog = true },
|
onDownloadClick = { showDownloadDialog = true },
|
||||||
onMarkAsWatched = onMarkAsWatched,
|
onMarkAsWatched = { watched ->
|
||||||
|
if (watched) {
|
||||||
|
showMarkAsWatchedDialog = true
|
||||||
|
} else {
|
||||||
|
onMarkAsWatched(false)
|
||||||
|
}
|
||||||
|
},
|
||||||
bodyColor = scheme.onSurface
|
bodyColor = scheme.onSurface
|
||||||
),
|
),
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
@@ -233,6 +242,16 @@ private fun SeriesScreenInternal(
|
|||||||
onDismiss = { showDownloadDialog = false }
|
onDismiss = { showDownloadDialog = false }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showMarkAsWatchedDialog) {
|
||||||
|
MarkSeriesAsWatchedConfirmationDialog(
|
||||||
|
onConfirm = {
|
||||||
|
showMarkAsWatchedDialog = false
|
||||||
|
onMarkAsWatched(true)
|
||||||
|
},
|
||||||
|
onDismiss = { showMarkAsWatchedDialog = false }
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Series.toMediaDetailScaffoldUiModel(
|
private fun Series.toMediaDetailScaffoldUiModel(
|
||||||
@@ -312,3 +331,25 @@ private fun SeriesDownloadOption.requiresNotificationPermission(): Boolean = whe
|
|||||||
SeriesDownloadOption.SMART -> true
|
SeriesDownloadOption.SMART -> true
|
||||||
SeriesDownloadOption.DELETE_SMART -> false
|
SeriesDownloadOption.DELETE_SMART -> false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun MarkSeriesAsWatchedConfirmationDialog(
|
||||||
|
onConfirm: () -> Unit,
|
||||||
|
onDismiss: () -> Unit
|
||||||
|
) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = onDismiss,
|
||||||
|
title = { Text("Mark series as watched?") },
|
||||||
|
text = { Text("This will mark every episode of this series as watched.") },
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(onClick = onConfirm) {
|
||||||
|
Text("Mark as watched")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = onDismiss) {
|
||||||
|
Text("Cancel")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user