Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display show genres in a small chip on show details #1524

Merged
merged 1 commit into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface CommonTiviTextCreator {
watchedEpisodeCount < episodeCount -> {
strings.followedWatchStatsToWatch(episodeCount - watchedEpisodeCount)
}

watchedEpisodeCount > 0 -> strings.followedWatchStatsComplete
else -> ""
}
Expand All @@ -58,6 +59,7 @@ interface CommonTiviTextCreator {
season != null && episode != null -> {
strings.seasonEpisodeNumber(season.number!!, episode.number!!)
}

else -> ""
}

Expand Down Expand Up @@ -109,19 +111,10 @@ interface CommonTiviTextCreator {
return text
}

fun genreString(genres: List<Genre>?): CharSequence? {
if (!genres.isNullOrEmpty()) {
return buildString {
for (i in genres.indices) {
val genre = genres[i]
append(strings.getGenreLabel(genre))
append("\u00A0") // nbsp
append(GenreStringer.getEmoji(genre))
if (i < genres.size - 1) append(" \u2022 ")
}
}
}
return null
fun genreLabel(genre: Genre): String = buildString {
append(strings.getGenreLabel(genre))
append("\u00A0") // nbsp
append(GenreStringer.getEmoji(genre))
}

fun genreContentDescription(genres: List<Genre>?): CharSequence? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import androidx.compose.material.icons.filled.FavoriteBorder
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.Star
import androidx.compose.material.rememberDismissState
import androidx.compose.material3.Card
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -602,6 +603,7 @@ private fun Header(title: String) {
}
}

@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun Genres(genres: List<Genre>) {
val textCreator = LocalTiviTextCreator.current
Expand All @@ -616,10 +618,20 @@ private fun Genres(genres: List<Genre>) {
.toString()
},
) {
Text(
text = textCreator.genreString(genres).toString(),
style = MaterialTheme.typography.bodyMedium,
)
FlowRow(
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
genres.forEach { genre ->
Card {
Text(
text = textCreator.genreLabel(genre),
style = MaterialTheme.typography.labelLarge,
modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp),
)
}
}
}
}
}

Expand Down
Loading