Skip to content

Commit

Permalink
map icons by media type/format
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 10, 2024
1 parent 070e271 commit dd8a366
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package dev.datlag.aniflow.common

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.MenuBook
import androidx.compose.material.icons.rounded.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.graphics.vector.ImageVector
import dev.datlag.aniflow.LocalDI
import dev.datlag.aniflow.SharedRes
import dev.datlag.aniflow.anilist.model.Character
Expand Down Expand Up @@ -62,6 +64,12 @@ fun Medium.Title.notPreferred(setting: SettingsTitle?): String? {
}
}

fun MediaFormat.icon(): ImageVector = when (this) {
MediaFormat.MANGA, MediaFormat.NOVEL, MediaFormat.ONE_SHOT -> Icons.AutoMirrored.Rounded.MenuBook
MediaFormat.MUSIC -> Icons.Rounded.MusicNote
else -> Icons.Rounded.OndemandVideo
}

fun MediaFormat.text(): StringResource {
return when (this) {
MediaFormat.TV -> SharedRes.strings.media_format_tv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package dev.datlag.aniflow.ui.navigation.screen.medium.component
import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.List
import androidx.compose.material.icons.automirrored.rounded.List
import androidx.compose.material.icons.filled.NoAdultContent
import androidx.compose.material.icons.filled.OndemandVideo
import androidx.compose.material.icons.filled.RssFeed
import androidx.compose.material.icons.filled.Timelapse
import androidx.compose.material.icons.rounded.NoAdultContent
import androidx.compose.material.icons.rounded.RssFeed
import androidx.compose.material.icons.rounded.Timelapse
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -22,6 +26,7 @@ import dev.datlag.aniflow.SharedRes
import dev.datlag.aniflow.anilist.model.Medium
import dev.datlag.aniflow.anilist.type.MediaFormat
import dev.datlag.aniflow.anilist.type.MediaStatus
import dev.datlag.aniflow.common.icon
import dev.datlag.aniflow.common.text
import dev.datlag.tooling.compose.ifTrue
import dev.datlag.tooling.decompose.lifecycle.collectAsStateWithLifecycle
Expand Down Expand Up @@ -95,7 +100,7 @@ fun CoverSection(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(
imageVector = Icons.Default.OndemandVideo,
imageVector = format.icon(),
contentDescription = null
)
Text(text = stringResource(format.text()))
Expand All @@ -107,7 +112,7 @@ fun CoverSection(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(
imageVector = Icons.Default.NoAdultContent,
imageVector = Icons.Rounded.NoAdultContent,
contentDescription = null
)
Text(text = stringResource(SharedRes.strings.explicit))
Expand All @@ -120,7 +125,7 @@ fun CoverSection(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(
imageVector = Icons.AutoMirrored.Filled.List,
imageVector = Icons.AutoMirrored.Rounded.List,
contentDescription = null
)
Text(text = "$episodes Episodes")
Expand All @@ -133,7 +138,7 @@ fun CoverSection(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(
imageVector = Icons.Default.Timelapse,
imageVector = Icons.Rounded.Timelapse,
contentDescription = null
)
Text(text = "${duration}min / Episode")
Expand All @@ -145,7 +150,7 @@ fun CoverSection(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(
imageVector = Icons.Default.RssFeed,
imageVector = Icons.Rounded.RssFeed,
contentDescription = null
)
Text(text = stringResource(status.text()))
Expand Down

0 comments on commit dd8a366

Please sign in to comment.