|
|
|
@@ -18,6 +18,7 @@ import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
import androidx.tv.material3.Text
|
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
import kotlinx.coroutines.withContext
|
|
|
|
|
import org.json.JSONArray
|
|
|
|
|
import org.json.JSONObject
|
|
|
|
@@ -42,13 +43,16 @@ internal class DeskOption(val number: Int, val name: String, val reason: String)
|
|
|
|
|
|
|
|
|
|
/** A discovery: [options] are where it can go, its suggested channel first. [id], [type] and [year] are the library item's, for placing it. */
|
|
|
|
|
internal class DeskPick(val title: String, val channel: String, val tag: String, val line: String, val id: String = "", val type: String = "", val year: Int? = null,
|
|
|
|
|
val options: List<DeskOption> = emptyList())
|
|
|
|
|
val options: List<DeskOption> = emptyList(),
|
|
|
|
|
/** Its first-run event: Orbit Premiere, offered only for a film never booked on Orbit that suits an event debut. */
|
|
|
|
|
val firstRun: DeskOption? = null)
|
|
|
|
|
/** An either-or call: [options] are the two channels it's torn between. */
|
|
|
|
|
internal class DeskAsk(val title: String, val first: String, val second: String, val id: String = "", val type: String = "", val year: Int? = null,
|
|
|
|
|
val options: List<DeskOption> = emptyList(), val line: String = "")
|
|
|
|
|
val options: List<DeskOption> = emptyList(), val line: String = "", val firstRun: DeskOption? = null)
|
|
|
|
|
|
|
|
|
|
private fun JSONObject.item(id: String, type: String, year: Int?, options: List<DeskOption>) =
|
|
|
|
|
put("i", id).put("k", type).put("y", year ?: JSONObject.NULL).put("o", JSONArray(options.map { it.toJson() }))
|
|
|
|
|
private fun JSONObject.item(id: String, type: String, year: Int?, options: List<DeskOption>, firstRun: DeskOption?) =
|
|
|
|
|
put("i", id).put("k", type).put("y", year ?: JSONObject.NULL).put("o", JSONArray(options.map { it.toJson() })).put("f", firstRun?.toJson() ?: JSONObject.NULL)
|
|
|
|
|
private fun JSONObject.firstRun() = optJSONObject("f")?.let(DeskOption::of)
|
|
|
|
|
private fun JSONObject.options() = optJSONArray("o")?.let { a -> (0 until a.length()).map { DeskOption.of(a.getJSONObject(it)) } }.orEmpty()
|
|
|
|
|
private fun JSONObject.year() = if (isNull("y")) null else optInt("y").takeIf { it > 0 }
|
|
|
|
|
|
|
|
|
@@ -58,8 +62,8 @@ internal class DeskReport(val newlyReleased: Int, val newToLibrary: Int, val sca
|
|
|
|
|
val decided: Int = 0) {
|
|
|
|
|
fun toJson(): JSONObject = JSONObject().put("newlyReleased", newlyReleased).put("newToLibrary", newToLibrary).put("scanned", scanned).put("unread", unread)
|
|
|
|
|
.put("strong", strong).put("strongByChannel", JSONArray(strongByChannel.map { JSONObject().put("c", it.first).put("n", it.second) }))
|
|
|
|
|
.put("picks", JSONArray(picks.map { JSONObject().put("t", it.title).put("c", it.channel).put("g", it.tag).put("l", it.line).item(it.id, it.type, it.year, it.options) }))
|
|
|
|
|
.put("asks", JSONArray(asks.map { JSONObject().put("t", it.title).put("a", it.first).put("b", it.second).put("l", it.line).item(it.id, it.type, it.year, it.options) }))
|
|
|
|
|
.put("picks", JSONArray(picks.map { JSONObject().put("t", it.title).put("c", it.channel).put("g", it.tag).put("l", it.line).item(it.id, it.type, it.year, it.options, it.firstRun) }))
|
|
|
|
|
.put("asks", JSONArray(asks.map { JSONObject().put("t", it.title).put("a", it.first).put("b", it.second).put("l", it.line).item(it.id, it.type, it.year, it.options, it.firstRun) }))
|
|
|
|
|
.put("collections", collections).put("franchises", franchises).put("catalogueComplete", catalogueComplete).put("computedMs", computedMs).put("tookMs", tookMs)
|
|
|
|
|
.put("decided", decided)
|
|
|
|
|
companion object {
|
|
|
|
@@ -67,20 +71,22 @@ internal class DeskReport(val newlyReleased: Int, val newToLibrary: Int, val sca
|
|
|
|
|
fun list(key: String) = o.optJSONArray(key)?.let { a -> (0 until a.length()).map { a.getJSONObject(it) } }.orEmpty()
|
|
|
|
|
return DeskReport(o.optInt("newlyReleased"), o.optInt("newToLibrary"), o.optInt("scanned"), o.optInt("unread"),
|
|
|
|
|
list("strongByChannel").map { it.optString("c") to it.optInt("n") }, o.optInt("strong"),
|
|
|
|
|
list("picks").map { DeskPick(it.optString("t"), it.optString("c"), it.optString("g"), it.optString("l"), it.optString("i"), it.optString("k"), it.year(), it.options()) },
|
|
|
|
|
list("asks").map { DeskAsk(it.optString("t"), it.optString("a"), it.optString("b"), it.optString("i"), it.optString("k"), it.year(), it.options(), it.optString("l")) },
|
|
|
|
|
list("picks").map { DeskPick(it.optString("t"), it.optString("c"), it.optString("g"), it.optString("l"), it.optString("i"), it.optString("k"), it.year(), it.options(), it.firstRun()) },
|
|
|
|
|
list("asks").map { DeskAsk(it.optString("t"), it.optString("a"), it.optString("b"), it.optString("i"), it.optString("k"), it.year(), it.options(), it.optString("l"), it.firstRun()) },
|
|
|
|
|
o.optInt("collections"), o.optBoolean("catalogueComplete"), o.optInt("franchises"), o.optLong("computedMs"), o.optLong("tookMs"), o.optInt("decided"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** A decision you made on the Chair: placed on [channel], or dropped (channel null). Recorded for the Chair to learn from. */
|
|
|
|
|
internal class ChairDecision(val id: String, val title: String, val type: String, val placed: Boolean, val channel: Int?, val suggested: Int?, val atMs: Long) {
|
|
|
|
|
internal class ChairDecision(val id: String, val title: String, val type: String, val placed: Boolean, val channel: Int?, val suggested: Int?, val atMs: Long,
|
|
|
|
|
/** Placed with a premiere run first: [channel] is its home, after the run. */
|
|
|
|
|
val premiere: Boolean = false) {
|
|
|
|
|
fun toJson(): JSONObject = JSONObject().put("i", id).put("t", title).put("k", type).put("p", placed).put("c", channel ?: JSONObject.NULL)
|
|
|
|
|
.put("s", suggested ?: JSONObject.NULL).put("a", atMs)
|
|
|
|
|
.put("s", suggested ?: JSONObject.NULL).put("a", atMs).put("r", premiere)
|
|
|
|
|
companion object {
|
|
|
|
|
fun of(o: JSONObject) = ChairDecision(o.getString("i"), o.optString("t"), o.optString("k"), o.optBoolean("p"),
|
|
|
|
|
if (o.isNull("c")) null else o.optInt("c"), if (o.isNull("s")) null else o.optInt("s"), o.optLong("a"))
|
|
|
|
|
if (o.isNull("c")) null else o.optInt("c"), if (o.isNull("s")) null else o.optInt("s"), o.optLong("a"), o.optBoolean("r"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -98,6 +104,15 @@ private val DecisionLock = Any()
|
|
|
|
|
private fun reasonLine(why: List<String>): String =
|
|
|
|
|
why.filter { it.startsWith("themes:") || it.startsWith("genres ") || it.startsWith("British") || it.startsWith("in the ") }.take(2).joinToString("; ")
|
|
|
|
|
.ifEmpty { why.firstOrNull { it.startsWith("description like") } ?: "fits the channel's brief" }
|
|
|
|
|
/** Premiere is a broadcast stage, not a home (Paul, 5 November 2026): a title's homes are its other channels, best first. */
|
|
|
|
|
internal fun homeOf(p: Placement): Placement {
|
|
|
|
|
val homes = p.ranked.filter { it.first.number != PREMIERE_NUMBER }
|
|
|
|
|
if (homes.size == p.ranked.size && p.top.number != PREMIERE_NUMBER && p.second.number != PREMIERE_NUMBER) return p
|
|
|
|
|
val nowhere = Briefs.first { it.number != PREMIERE_NUMBER }
|
|
|
|
|
return Placement(p.evidence, homes.getOrNull(0)?.first ?: nowhere, homes.getOrNull(0)?.second ?: 0.0, homes.getOrNull(1)?.first ?: nowhere,
|
|
|
|
|
homes.getOrNull(1)?.second ?: 0.0, homes.getOrNull(0)?.third ?: listOf("no home channel"), homes)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Where a placed title can go: the scored channels, best first, three at most, never one the scoring ruled out. */
|
|
|
|
|
private fun optionsOf(p: Placement, max: Int = 3): List<DeskOption> = p.ranked.take(max).map { (b, _, why) -> DeskOption(b.number, b.name, reasonLine(why)) }
|
|
|
|
|
|
|
|
|
@@ -135,14 +150,16 @@ internal fun franchiseLinks(file: File, pools: Map<Int, List<String>>): Triple<F
|
|
|
|
|
*/
|
|
|
|
|
internal fun buildDeskReport(evidenceFile: File, collectionsFile: File, pools: Map<Int, List<String>>, released: List<Arrival>, carriedWorks: Set<String>,
|
|
|
|
|
originals: Map<String, String>, newToLibrary: Int, catalogueComplete: Boolean, mode: DirectorMode, nowMs: Long, zone: ZoneId = ZoneId.systemDefault(),
|
|
|
|
|
decided: Set<String> = emptySet()): DeskReport =
|
|
|
|
|
buildDeskReports(evidenceFile, collectionsFile, pools, released, carriedWorks, originals, newToLibrary, catalogueComplete, nowMs, zone, decided).getValue(mode)
|
|
|
|
|
decided: Set<String> = emptySet(), aired: Set<String> = emptySet()): DeskReport =
|
|
|
|
|
buildDeskReports(evidenceFile, collectionsFile, pools, released, carriedWorks, originals, newToLibrary, catalogueComplete, nowMs, zone, decided, aired).getValue(mode)
|
|
|
|
|
|
|
|
|
|
/** All three modes' reports from one scoring pass: the modes only differ in how many discoveries they show and how far they reach. */
|
|
|
|
|
internal fun buildDeskReports(evidenceFile: File, collectionsFile: File, pools: Map<Int, List<String>>, released: List<Arrival>, carriedWorks: Set<String>,
|
|
|
|
|
originals: Map<String, String>, newToLibrary: Int, catalogueComplete: Boolean, nowMs: Long, zone: ZoneId = ZoneId.systemDefault(),
|
|
|
|
|
/** Titles you've placed or dropped on the Chair: never shown again, so the next ones take their place. */
|
|
|
|
|
decided: Set<String> = emptySet()): Map<DirectorMode, DeskReport> {
|
|
|
|
|
decided: Set<String> = emptySet(),
|
|
|
|
|
/** Every library item and work ever booked on Orbit: a film among them has had its first airing, so it has no premiere. */
|
|
|
|
|
aired: Set<String> = emptySet()): Map<DirectorMode, DeskReport> {
|
|
|
|
|
val started = System.nanoTime()
|
|
|
|
|
val evidence = if (evidenceFile.exists()) evidenceFile.readLines().mapNotNull { runCatching { JSONObject(it) }.getOrNull() }
|
|
|
|
|
.associate { it.optString("id") to TitleEvidence.of(it, originals[it.optString("id")]) } else emptyMap()
|
|
|
|
@@ -151,7 +168,15 @@ internal fun buildDeskReports(evidenceFile: File, collectionsFile: File, pools:
|
|
|
|
|
val carriedIds = pools.values.flatten().toSet()
|
|
|
|
|
val candidates = released.filter { it.id !in carriedIds && it.work !in carriedWorks }.distinctBy { it.work }
|
|
|
|
|
val read = candidates.mapNotNull { evidence[it.id] }
|
|
|
|
|
val placed = read.map { placeTitle(it, text, links) }
|
|
|
|
|
val scored = read.map { placeTitle(it, text, links) }
|
|
|
|
|
val placed = scored.map(::homeOf)
|
|
|
|
|
val workOf = candidates.associate { it.id to it.work }
|
|
|
|
|
// Paul's policy: a premiere is a first airing on Orbit, never just a new film. Offered for a film that suits an event debut.
|
|
|
|
|
val firstRuns = scored.mapNotNull { p ->
|
|
|
|
|
val fit = p.ranked.firstOrNull { it.first.number == PREMIERE_NUMBER }?.takeIf { it.second >= .35 } ?: return@mapNotNull null
|
|
|
|
|
if (p.evidence.type != "Movie" || p.evidence.id in aired || workOf[p.evidence.id] in aired) return@mapNotNull null
|
|
|
|
|
p.evidence.id to DeskOption(PREMIERE_NUMBER, fit.first.name, "First run on Orbit: " + reasonLine(fit.third))
|
|
|
|
|
}.toMap()
|
|
|
|
|
val strong = placed.filter { it.tier == FitTier.Strong }
|
|
|
|
|
val byChannel = strong.groupingBy { it.top.name }.eachCount().entries.sortedByDescending { it.value }.map { it.key to it.value }
|
|
|
|
|
val today = Instant.ofEpochMilli(nowMs).atZone(zone).toLocalDate()
|
|
|
|
@@ -159,7 +184,8 @@ internal fun buildDeskReports(evidenceFile: File, collectionsFile: File, pools:
|
|
|
|
|
fun recent(id: String) = premiered[id]?.takeIf { it.length == 10 }?.let { runCatching { LocalDate.parse(it) }.getOrNull() }?.let { !it.isBefore(today.minusDays(14)) } == true
|
|
|
|
|
val undecided = placed.filter { it.evidence.id !in decided }
|
|
|
|
|
val asks = undecided.filter { it.tier == FitTier.NeedsEye }.sortedByDescending { it.s1 }.take(3).map {
|
|
|
|
|
DeskAsk(it.evidence.name, it.top.name, it.second.name, it.evidence.id, it.evidence.type, it.evidence.year, optionsOf(it, 2), it.evidence.overview?.let { o -> sentence(o) } ?: "No description in the library yet") }
|
|
|
|
|
DeskAsk(it.evidence.name, it.top.name, it.second.name, it.evidence.id, it.evidence.type, it.evidence.year, optionsOf(it, 2), it.evidence.overview?.let { o -> sentence(o) } ?: "No description in the library yet",
|
|
|
|
|
firstRuns[it.evidence.id]?.takeIf { _ -> it.ranked.isNotEmpty() }) }
|
|
|
|
|
val tookMs = (System.nanoTime() - started) / 1_000_000
|
|
|
|
|
return DirectorMode.values().associateWith { mode ->
|
|
|
|
|
// Discoveries: the strongest strong matches, one per channel; Surprise Me reaches into the possibles for channels the strong list missed.
|
|
|
|
@@ -167,7 +193,7 @@ internal fun buildDeskReports(evidenceFile: File, collectionsFile: File, pools:
|
|
|
|
|
if (mode == DirectorMode.Surprise) pool += undecided.filter { it.tier == FitTier.Possible && pool.none { p -> p.top.number == it.top.number } }.sortedByDescending { it.s1 }.take(2)
|
|
|
|
|
val picks = pool.take(mode.picks).map { p ->
|
|
|
|
|
DeskPick(p.evidence.name, p.top.name, when { p.tier == FitTier.Possible -> "SOMETHING DIFFERENT"; recent(p.evidence.id) -> "JUST RELEASED"; else -> "STRONG MATCH" },
|
|
|
|
|
p.evidence.overview?.let { sentence(it) } ?: "No description in the library yet", p.evidence.id, p.evidence.type, p.evidence.year, optionsOf(p))
|
|
|
|
|
p.evidence.overview?.let { sentence(it) } ?: "No description in the library yet", p.evidence.id, p.evidence.type, p.evidence.year, optionsOf(p), firstRuns[p.evidence.id])
|
|
|
|
|
}
|
|
|
|
|
DeskReport(candidates.size, newToLibrary, read.size, candidates.size - read.size, byChannel, strong.size, picks, asks, collections, catalogueComplete, franchises, nowMs, tookMs, placed.count { it.evidence.id in decided })
|
|
|
|
|
}
|
|
|
|
@@ -194,7 +220,7 @@ internal fun directorReports(store: ScheduleStore, catalogue: CatalogueStore, us
|
|
|
|
|
val (arrivals, _) = store.loadArrivals(userId)
|
|
|
|
|
val newToLibrary = arrivals.count { nowMs - it.firstSeenMs < NEW_TO_LIBRARY_DAYS * 24 * 60 * 60_000L }
|
|
|
|
|
val reports = buildDeskReports(evidence, collections, ids, released, carriedWorks, catalogue.originalTitles(released.map { it.id }), newToLibrary, catalogue.complete(), nowMs,
|
|
|
|
|
decided = loadDecisions(decisions).map { it.id }.toSet())
|
|
|
|
|
decided = loadDecisions(decisions).map { it.id }.toSet(), aired = store.loadBooked(userId).let { booked -> booked + catalogue.worksOf(booked).values })
|
|
|
|
|
runCatching { cache.writeText(JSONObject().put("key", key).put("savedMs", nowMs).put("reports", JSONObject().apply { reports.forEach { (m, r) -> put(m.name, r.toJson()) } }).toString()) }
|
|
|
|
|
val b = reports.getValue(DirectorMode.Balanced)
|
|
|
|
|
android.util.Log.i("OrbitSchedule", "director newlyReleased=${b.newlyReleased} read=${b.scanned} strong=${b.strong} asks=${b.asks.size} collections=${b.collections} tookMs=${b.tookMs}")
|
|
|
|
@@ -221,7 +247,8 @@ internal fun dropFromChair(store: ScheduleStore, id: String, title: String, type
|
|
|
|
|
saveDecision(store.decisionsFile(), ChairDecision(id, title.take(160), type, false, null, suggested, nowMs))
|
|
|
|
|
|
|
|
|
|
/** What the Chair's pop-up acts on: one pick or one ask. */
|
|
|
|
|
internal class ChairChoice(val title: String, val id: String, val type: String, val year: Int?, val tag: String?, val line: String, val options: List<DeskOption>, val ask: Boolean)
|
|
|
|
|
internal class ChairChoice(val title: String, val id: String, val type: String, val year: Int?, val tag: String?, val line: String, val options: List<DeskOption>, val ask: Boolean,
|
|
|
|
|
val firstRun: DeskOption? = null)
|
|
|
|
|
|
|
|
|
|
private val ChairNavy = Color(0xFF07163A)
|
|
|
|
|
private val ChairPanel = Color(0xFF10285A)
|
|
|
|
@@ -235,7 +262,9 @@ private val ChairSky = Color(0xFF78BEFF)
|
|
|
|
|
*/
|
|
|
|
|
@Composable
|
|
|
|
|
internal fun DirectorChair(load: (DirectorMode) -> DeskReport?, first: FocusRequester, modifier: Modifier,
|
|
|
|
|
place: (ChairChoice, DeskOption) -> Unit = { _, _ -> }, drop: (ChairChoice) -> Unit = {}) {
|
|
|
|
|
place: (ChairChoice, DeskOption) -> Unit = { _, _ -> }, drop: (ChairChoice) -> Unit = {},
|
|
|
|
|
/** Premiere first, then [DeskOption] as its home; returns what to tell you (the debut, or why there's none). */
|
|
|
|
|
premiere: suspend (ChairChoice, DeskOption) -> String = { _, _ -> "" }) {
|
|
|
|
|
var mode by remember { mutableStateOf(DirectorMode.Balanced) }
|
|
|
|
|
var version by remember { mutableIntStateOf(0) }
|
|
|
|
|
var report by remember { mutableStateOf<DeskReport?>(null) }
|
|
|
|
@@ -243,6 +272,7 @@ internal fun DirectorChair(load: (DirectorMode) -> DeskReport?, first: FocusRequ
|
|
|
|
|
var decided by remember { mutableStateOf(emptySet<String>()) }
|
|
|
|
|
var open by remember { mutableStateOf<ChairChoice?>(null) }
|
|
|
|
|
var said by remember { mutableStateOf<String?>(null) }
|
|
|
|
|
val scope = rememberCoroutineScope()
|
|
|
|
|
LaunchedEffect(mode, version) { withContext(Dispatchers.Default) { runCatching { load(mode) }.getOrNull() }?.let { report = it } }
|
|
|
|
|
Column(modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
|
|
|
|
Row(verticalAlignment = androidx.compose.ui.Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
|
|
|
@@ -280,15 +310,15 @@ internal fun DirectorChair(load: (DirectorMode) -> DeskReport?, first: FocusRequ
|
|
|
|
|
Text("WORTH A LOOK", color = Color.White, fontFamily = Anton, fontSize = 14.sp)
|
|
|
|
|
val picks = r.picks.filter { it.id !in decided }
|
|
|
|
|
if (picks.isEmpty()) Text("Nothing stands out this week.", color = Muted, fontSize = 12.sp)
|
|
|
|
|
picks.forEach { p -> ChairCard(p.tag, p.title, p.channel.uppercase(java.util.Locale.UK), p.line,
|
|
|
|
|
onClick = { open = ChairChoice(p.title, p.id, p.type, p.year, p.tag, p.line, p.options, false) }.takeIf { p.options.isNotEmpty() && p.id.isNotEmpty() }) }
|
|
|
|
|
picks.forEach { p -> ChairCard(p.tag, p.title, p.channel.uppercase(java.util.Locale.UK) + if (p.firstRun != null) " · PREMIERE FIRST" else "", p.line,
|
|
|
|
|
onClick = { open = ChairChoice(p.title, p.id, p.type, p.year, p.tag, p.line, p.options, false, p.firstRun) }.takeIf { p.options.isNotEmpty() && p.id.isNotEmpty() }) }
|
|
|
|
|
}
|
|
|
|
|
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(5.dp)) {
|
|
|
|
|
Text("NEEDS YOUR EYE", color = Color.White, fontFamily = Anton, fontSize = 14.sp)
|
|
|
|
|
val asks = r.asks.filter { it.id !in decided }
|
|
|
|
|
if (asks.isEmpty()) Text("No either-or calls this week.", color = Muted, fontSize = 12.sp)
|
|
|
|
|
asks.forEach { a -> ChairCard(null, a.title, null, "${a.first} or ${a.second}?",
|
|
|
|
|
onClick = { open = ChairChoice(a.title, a.id, a.type, a.year, null, a.line, a.options, true) }.takeIf { a.options.isNotEmpty() && a.id.isNotEmpty() }) }
|
|
|
|
|
onClick = { open = ChairChoice(a.title, a.id, a.type, a.year, null, a.line, a.options, true, a.firstRun) }.takeIf { a.options.isNotEmpty() && a.id.isNotEmpty() }) }
|
|
|
|
|
Spacer(Modifier.height(4.dp))
|
|
|
|
|
Text("RULES IN FORCE", color = Color.White, fontFamily = Anton, fontSize = 13.sp)
|
|
|
|
|
DirectorRules.forEach { Text("· $it", color = Muted, fontSize = 10.sp, maxLines = 1, overflow = TextOverflow.Ellipsis) }
|
|
|
|
@@ -304,13 +334,16 @@ internal fun DirectorChair(load: (DirectorMode) -> DeskReport?, first: FocusRequ
|
|
|
|
|
}, onDrop = {
|
|
|
|
|
open = null; decided = decided + choice.id; drop(choice)
|
|
|
|
|
said = "${choice.title} dropped. The Chair won't offer it again."; version++
|
|
|
|
|
}, onPremiere = { home ->
|
|
|
|
|
open = null; decided = decided + choice.id
|
|
|
|
|
scope.launch { said = premiere(choice, home); version++ }
|
|
|
|
|
}, onClose = { open = null })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** The pop-up for one title: its suggested channel (or, for an ask, the two it's torn between), any other fits, and Drop. */
|
|
|
|
|
@Composable
|
|
|
|
|
private fun ChairPopup(choice: ChairChoice, onPlace: (DeskOption) -> Unit, onDrop: () -> Unit, onClose: () -> Unit) {
|
|
|
|
|
private fun ChairPopup(choice: ChairChoice, onPlace: (DeskOption) -> Unit, onDrop: () -> Unit, onPremiere: (DeskOption) -> Unit, onClose: () -> Unit) {
|
|
|
|
|
var others by remember { mutableStateOf(false) }
|
|
|
|
|
androidx.compose.ui.window.Dialog(onDismissRequest = onClose, properties = androidx.compose.ui.window.DialogProperties(usePlatformDefaultWidth = false)) {
|
|
|
|
|
val firstButton = remember { FocusRequester() }
|
|
|
|
@@ -321,6 +354,16 @@ private fun ChairPopup(choice: ChairChoice, onPlace: (DeskOption) -> Unit, onDro
|
|
|
|
|
Text(choice.title.uppercase(java.util.Locale.UK), color = Color.White, fontFamily = Anton, fontSize = 28.sp, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
|
|
|
|
Text(listOfNotNull(choice.year?.toString(), if (choice.type == "Series") "Series" else "Film").joinToString(" · "), color = ChairSky, fontSize = 12.sp)
|
|
|
|
|
Text(choice.line, color = Color.White, fontSize = 13.sp, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
|
|
|
|
// Two recommendations, not one: the first-run event on Premiere, then the film's genre home.
|
|
|
|
|
val home = choice.options.firstOrNull()
|
|
|
|
|
if (choice.firstRun != null && home != null) Row(Modifier.fillMaxWidth().background(ChairPanel, RoundedCornerShape(6.dp)).border(1.dp, ChairGold, RoundedCornerShape(6.dp)).padding(10.dp),
|
|
|
|
|
verticalAlignment = androidx.compose.ui.Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
|
|
|
|
Column(Modifier.weight(1f)) {
|
|
|
|
|
Text("FIRST-RUN EVENT: ${choice.firstRun.name.uppercase(java.util.Locale.UK)} · THEN HOME: ${home.name.uppercase(java.util.Locale.UK)}", color = ChairGold, fontSize = 12.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
Text("A debut night on Premiere, its window of ${PREMIERE_WINDOW_MS / (24 * 60 * 60_000L) / 7} weeks, then ${home.name}'s regular rotation.", color = Muted, fontSize = 11.sp, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
|
|
|
|
}
|
|
|
|
|
OrbitButton("Premiere, then ${home.name.removePrefix("Orbit ")}", Modifier.focusRequester(firstButton), onClick = { onPremiere(home) })
|
|
|
|
|
}
|
|
|
|
|
// Asks show both channels from the start; a pick shows its suggestion, and the other fits on Change channel.
|
|
|
|
|
val shown = when { choice.ask || others -> choice.options; else -> choice.options.take(1) }
|
|
|
|
|
shown.forEachIndexed { i, option ->
|
|
|
|
@@ -330,7 +373,7 @@ private fun ChairPopup(choice: ChairChoice, onPlace: (DeskOption) -> Unit, onDro
|
|
|
|
|
Text(option.name.uppercase(java.util.Locale.UK) + if (i == 0 && !choice.ask) " · SUGGESTED" else "", color = ChairSky, fontSize = 12.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
Text(option.reason, color = Muted, fontSize = 11.sp, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
|
|
|
|
}
|
|
|
|
|
OrbitButton("Place on ${option.name}", if (i == 0) Modifier.focusRequester(firstButton) else Modifier, onClick = { onPlace(option) })
|
|
|
|
|
OrbitButton("Place on ${option.name}", if (i == 0 && choice.firstRun == null) Modifier.focusRequester(firstButton) else Modifier, onClick = { onPlace(option) })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
|
|
|
|