|
|
|
@@ -46,6 +46,12 @@ internal fun guideCells(channel: SampleChannel, windowStart: Long, windowEnd: Lo
|
|
|
|
|
|
|
|
|
|
internal fun guideWindowStart(nowMs: Long, slotsAhead: Int) = Math.floorDiv(nowMs, GUIDE_SLOT_MS) * GUIDE_SLOT_MS + slotsAhead * GUIDE_SLOT_MS
|
|
|
|
|
|
|
|
|
|
/** Episodes arrive as "Series / S1 E4 / Name". The grid shows the series and the number; the panel above has the rest. */
|
|
|
|
|
internal fun guideTitleParts(title: String): Pair<String, String?> {
|
|
|
|
|
val parts = title.split(" / ")
|
|
|
|
|
return parts[0] to parts.getOrNull(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Cursor time after moving one programme along a channel, never earlier than now. */
|
|
|
|
|
internal fun guideStep(channel: SampleChannel, cursorMs: Long, nowMs: Long, forward: Boolean): Long {
|
|
|
|
|
val show = channel.at(maxOf(cursorMs, nowMs))
|
|
|
|
@@ -77,17 +83,17 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
|
|
|
|
slotsAhead = ahead
|
|
|
|
|
}
|
|
|
|
|
Column(modifier.fillMaxWidth().background(Navy).padding(horizontal = 14.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(5.dp)) {
|
|
|
|
|
Row(Modifier.fillMaxWidth().height(126.dp), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
|
|
|
|
Row(Modifier.fillMaxWidth().height(96.dp), horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
|
|
|
|
val branding = ChannelBrands.forNumber(channel.number)
|
|
|
|
|
Box(Modifier.width(224.dp).fillMaxHeight().background(Panel)) {
|
|
|
|
|
Box(Modifier.width(170.dp).fillMaxHeight().background(Panel)) {
|
|
|
|
|
if (branding != null) Image(painterResource(branding.background), null, Modifier.matchParentSize(), contentScale = ContentScale.Crop)
|
|
|
|
|
}
|
|
|
|
|
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(3.dp)) {
|
|
|
|
|
if (branding != null) Image(painterResource(branding.logo), branding.displayName, Modifier.width(112.dp).height(35.dp))
|
|
|
|
|
if (branding != null) Image(painterResource(branding.logo), branding.displayName, Modifier.width(90.dp).height(28.dp))
|
|
|
|
|
else Text(ChannelBrands.displayName(channel), color = Color.White, fontSize = 16.sp)
|
|
|
|
|
Text(focused.media.item.title, color = Color.White, fontSize = 21.sp, fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
|
|
|
|
Text("${clock(focused.startMs)} to ${clock(focused.endMs)} • ${channel.number} ${ChannelBrands.displayName(channel)}", color = Muted, fontSize = 13.sp, maxLines = 1)
|
|
|
|
|
Text(if (focused.startMs <= now) "OK Watch" else "On later", color = Muted, fontSize = 12.sp)
|
|
|
|
|
Text(focused.media.item.title, color = Color.White, fontSize = 17.sp, fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
|
|
|
|
Text("${clock(focused.startMs)} to ${clock(focused.endMs)} • ${channel.number} ${ChannelBrands.displayName(channel)}", color = Muted, fontSize = 12.sp, maxLines = 1)
|
|
|
|
|
Text(if (focused.startMs <= now) "OK Watch" else "On later", color = Muted, fontSize = 11.sp)
|
|
|
|
|
}
|
|
|
|
|
Column(verticalArrangement = Arrangement.Top) {
|
|
|
|
|
OrbitButton("Test transition", Modifier.focusRequester(toolsFocus).onPreviewKeyEvent { event ->
|
|
|
|
@@ -95,13 +101,13 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
|
|
|
|
}, onClick = { onWatch(channel.number, channel.transitionCheckOffset(System.currentTimeMillis())) })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Row(Modifier.fillMaxWidth().height(24.dp).background(Panel), verticalAlignment = Alignment.CenterVertically) {
|
|
|
|
|
Text("All Channels", Modifier.width(150.dp).padding(start = 8.dp), color = Color.White, fontSize = 13.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
Row(Modifier.fillMaxWidth().height(20.dp).background(Panel), verticalAlignment = Alignment.CenterVertically) {
|
|
|
|
|
Text("All Channels", Modifier.width(130.dp).padding(start = 8.dp), color = Color.White, fontSize = 12.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
Row(Modifier.weight(1f)) {
|
|
|
|
|
repeat(GUIDE_SLOTS) { Text(clock(windowStart + it * GUIDE_SLOT_MS), Modifier.weight(1f).padding(start = 4.dp), color = Color.White, fontSize = 13.sp, fontWeight = FontWeight.SemiBold) }
|
|
|
|
|
repeat(GUIDE_SLOTS) { Text(clock(windowStart + it * GUIDE_SLOT_MS), Modifier.weight(1f).padding(start = 4.dp), color = Color.White, fontSize = 12.sp, fontWeight = FontWeight.SemiBold) }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Column(Modifier.fillMaxWidth().weight(1f).focusRequester(gridFocus).onFocusChanged { gridFocused = it.isFocused }.focusable().onPreviewKeyEvent { event ->
|
|
|
|
|
Column(Modifier.fillMaxWidth().focusRequester(gridFocus).onFocusChanged { gridFocused = it.isFocused }.focusable().onPreviewKeyEvent { event ->
|
|
|
|
|
val native = event.nativeKeyEvent
|
|
|
|
|
if (native.action != KeyEvent.ACTION_DOWN) return@onPreviewKeyEvent false
|
|
|
|
|
when (native.keyCode) {
|
|
|
|
@@ -116,13 +122,13 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
|
|
|
|
}
|
|
|
|
|
else -> false
|
|
|
|
|
}
|
|
|
|
|
}, verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
|
|
|
|
}, verticalArrangement = Arrangement.spacedBy(3.dp)) {
|
|
|
|
|
channels.forEachIndexed { index, line ->
|
|
|
|
|
Row(Modifier.fillMaxWidth().weight(1f).widthIn(max = 2000.dp), horizontalArrangement = Arrangement.spacedBy(0.dp)) {
|
|
|
|
|
Row(Modifier.fillMaxWidth().height(40.dp), horizontalArrangement = Arrangement.spacedBy(0.dp)) {
|
|
|
|
|
val mark = ChannelBrands.forNumber(line.number)
|
|
|
|
|
Row(Modifier.width(150.dp).fillMaxHeight().background(Panel).padding(start = 6.dp), verticalAlignment = Alignment.CenterVertically) {
|
|
|
|
|
Text(line.number.toString(), Modifier.width(34.dp), color = Muted, fontSize = 13.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
if (mark != null) Image(painterResource(mark.logo), mark.displayName, Modifier.width(104.dp).height(32.dp))
|
|
|
|
|
Row(Modifier.width(130.dp).fillMaxHeight().background(Panel).padding(start = 6.dp), verticalAlignment = Alignment.CenterVertically) {
|
|
|
|
|
Text(line.number.toString(), Modifier.width(30.dp), color = Muted, fontSize = 12.sp, fontWeight = FontWeight.SemiBold)
|
|
|
|
|
if (mark != null) Image(painterResource(mark.logo), mark.displayName, Modifier.width(88.dp).height(28.dp))
|
|
|
|
|
else Text(ChannelBrands.displayName(line), color = Color.White, fontSize = 13.sp, maxLines = 1)
|
|
|
|
|
}
|
|
|
|
|
BoxWithConstraints(Modifier.weight(1f).fillMaxHeight()) {
|
|
|
|
@@ -131,7 +137,15 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
|
|
|
|
val onNow = cell.show.startMs <= now
|
|
|
|
|
Box(Modifier.offset(x = maxWidth * cell.startFraction).width((maxWidth * cell.widthFraction - 2.dp).coerceAtLeast(1.dp)).fillMaxHeight()
|
|
|
|
|
.background(if (isFocus) Yellow else if (onNow) Blue else Panel).padding(horizontal = 6.dp), contentAlignment = Alignment.CenterStart) {
|
|
|
|
|
Text(cell.show.media.item.title, color = if (isFocus) Navy else Color.White, fontSize = 14.sp, fontWeight = if (isFocus) FontWeight.SemiBold else FontWeight.Normal, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
|
|
|
|
// Too narrow for a readable word, so the panel above carries the name.
|
|
|
|
|
if (cell.widthFraction >= .09f) {
|
|
|
|
|
val (name, detail) = guideTitleParts(cell.show.media.item.title)
|
|
|
|
|
val ink = if (isFocus) Navy else Color.White
|
|
|
|
|
Column {
|
|
|
|
|
Text(name, color = ink, fontSize = 13.sp, fontWeight = if (isFocus) FontWeight.SemiBold else FontWeight.Normal, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
|
|
|
|
if (detail != null) Text(detail, color = if (isFocus) Navy else Muted, fontSize = 11.sp, maxLines = 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (now in windowStart until windowEnd)
|
|
|
|
@@ -140,6 +154,6 @@ internal fun GuideGrid(channels: List<SampleChannel>, selectedNumber: Int, modif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Text("▲▼ Channel ◄► Time OK Watch Back Menu", color = Muted, fontSize = 12.sp)
|
|
|
|
|
Text("▲▼ Channel ◄► Time OK Watch Back Menu", color = Muted, fontSize = 11.sp)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|