Updates to chapter card UI (#1729)
## Description Changes the chapter cards to use the chapter's image's aspect ratio instead of forcing the video's aspect ratio. These ratios can be different sometimes often for "dummy" chapters. Also, the font size for the chapter name & position is reduced a bit. ### Related issues N/A ### Testing Emulator ## Screenshots <img width="873" height="193" alt="image" src="https://github.com/user-attachments/assets/e1c0e8a8-2e37-4644-bc99-899e20c4af09" /> ## AI or LLM usage None
This commit is contained in:
parent
0a4ab7a547
commit
48005ce67a
8 changed files with 57 additions and 47 deletions
|
|
@ -1,38 +1,30 @@
|
|||
package com.github.damontecres.wholphin.data.model
|
||||
|
||||
import org.jellyfin.sdk.api.client.ApiClient
|
||||
import org.jellyfin.sdk.api.client.extensions.imageApi
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||
import org.jellyfin.sdk.model.api.ImageType
|
||||
import org.jellyfin.sdk.model.extensions.ticks
|
||||
import java.util.UUID
|
||||
import kotlin.time.Duration
|
||||
|
||||
/**
|
||||
* Represents a chapter within a video
|
||||
*/
|
||||
data class Chapter(
|
||||
val itemId: UUID,
|
||||
val name: String?,
|
||||
val position: Duration,
|
||||
val imageUrl: String?,
|
||||
val tag: String?,
|
||||
val index: Int,
|
||||
) {
|
||||
companion object {
|
||||
fun fromDto(
|
||||
dto: BaseItemDto,
|
||||
api: ApiClient,
|
||||
): List<Chapter> =
|
||||
fun fromDto(dto: BaseItemDto): List<Chapter> =
|
||||
dto.chapters
|
||||
?.mapIndexed { index, chapter ->
|
||||
Chapter(
|
||||
chapter.name,
|
||||
chapter.startPositionTicks.ticks,
|
||||
chapter.imageTag?.let {
|
||||
api.imageApi.getItemImageUrl(
|
||||
itemId = dto.id,
|
||||
imageType = ImageType.CHAPTER,
|
||||
tag = it,
|
||||
imageIndex = index,
|
||||
)
|
||||
},
|
||||
itemId = dto.id,
|
||||
name = chapter.name,
|
||||
position = chapter.startPositionTicks.ticks,
|
||||
tag = chapter.imageTag,
|
||||
index = index,
|
||||
)
|
||||
}?.sortedBy { it.position }
|
||||
.orEmpty()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue