mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 03:07:25 +01:00
Make stub source icon part of SourceIcon
(#7337)
* Make stub source icon part of `SourceIcon` * Review Changes
This commit is contained in:
parent
9f66c85281
commit
82879a129e
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.presentation.browse
|
package eu.kanade.presentation.browse
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@ -16,10 +15,8 @@ import androidx.compose.runtime.collectAsState
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.ColorFilter
|
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.res.painterResource
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -117,17 +114,7 @@ fun MigrateSourceItem(
|
|||||||
showLanguageInContent = source.lang != "",
|
showLanguageInContent = source.lang != "",
|
||||||
onClickItem = onClickItem,
|
onClickItem = onClickItem,
|
||||||
onLongClickItem = onLongClickItem,
|
onLongClickItem = onLongClickItem,
|
||||||
icon = {
|
icon = { SourceIcon(source = source) },
|
||||||
if (source.isStub) {
|
|
||||||
Image(
|
|
||||||
painter = painterResource(R.drawable.ic_warning_white_24dp),
|
|
||||||
contentDescription = "",
|
|
||||||
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.error),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
SourceIcon(source = source)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
action = { ItemBadges(primaryText = "$count") },
|
action = { ItemBadges(primaryText = "$count") },
|
||||||
content = { source, showLanguageInContent ->
|
content = { source, showLanguageInContent ->
|
||||||
Column(
|
Column(
|
||||||
|
@ -7,6 +7,9 @@ import androidx.compose.foundation.layout.Box
|
|||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Warning
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@ -14,6 +17,7 @@ import androidx.compose.runtime.produceState
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
import androidx.compose.ui.graphics.ImageBitmap
|
import androidx.compose.ui.graphics.ImageBitmap
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.graphics.painter.ColorPainter
|
import androidx.compose.ui.graphics.painter.ColorPainter
|
||||||
@ -40,18 +44,29 @@ fun SourceIcon(
|
|||||||
) {
|
) {
|
||||||
val icon = source.icon
|
val icon = source.icon
|
||||||
|
|
||||||
if (icon != null) {
|
when {
|
||||||
Image(
|
source.isStub && icon == null -> {
|
||||||
bitmap = icon,
|
Image(
|
||||||
contentDescription = "",
|
imageVector = Icons.Default.Warning,
|
||||||
modifier = modifier.then(defaultModifier),
|
contentDescription = "",
|
||||||
)
|
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.error),
|
||||||
} else {
|
modifier = modifier.then(defaultModifier),
|
||||||
Image(
|
)
|
||||||
painter = painterResource(id = R.mipmap.ic_local_source),
|
}
|
||||||
contentDescription = "",
|
icon != null -> {
|
||||||
modifier = modifier.then(defaultModifier),
|
Image(
|
||||||
)
|
bitmap = icon,
|
||||||
|
contentDescription = "",
|
||||||
|
modifier = modifier.then(defaultModifier),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
Image(
|
||||||
|
painter = painterResource(id = R.mipmap.ic_local_source),
|
||||||
|
contentDescription = "",
|
||||||
|
modifier = modifier.then(defaultModifier),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user