detekt: cleanup code

This commit is contained in:
Cuong Tran 2024-03-10 16:41:29 +07:00
parent 58797677ae
commit 9e8b9f84fd
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
4 changed files with 28 additions and 19 deletions

View file

@ -211,10 +211,11 @@ fun FeedAddSearchDialog(
val savedSearchStrings = remember { val savedSearchStrings = remember {
savedSearches.map { savedSearches.map {
// KMK --> // KMK -->
it?.name ?: if (source.supportsLatest) it?.name ?: if (source.supportsLatest) {
context.stringResource(MR.strings.latest) context.stringResource(MR.strings.latest)
else } else {
context.stringResource(MR.strings.popular) context.stringResource(MR.strings.popular)
}
// KMK <-- // KMK <--
}.toImmutableList() }.toImmutableList()
} }
@ -228,7 +229,10 @@ fun FeedAddSearchDialog(
}, },
onDismissRequest = onDismiss, onDismissRequest = onDismiss,
confirmButton = { confirmButton = {
TextButton(onClick = { onClickAdd(source, selected?.let { savedSearches[it] }) }, /* KMK --> */ enabled = selected != null /* KMK <-- */) { TextButton(
onClick = { onClickAdd(source, selected?.let { savedSearches[it] }) },
enabled = selected != null,
) {
Text(text = stringResource(MR.strings.action_ok)) Text(text = stringResource(MR.strings.action_ok))
} }
}, },
@ -240,7 +244,7 @@ fun <T> RadioSelector(
options: ImmutableList<T>, options: ImmutableList<T>,
selected: Int?, selected: Int?,
optionStrings: ImmutableList<String> = remember { options.map { it.toString() }.toImmutableList() }, optionStrings: ImmutableList<String> = remember { options.map { it.toString() }.toImmutableList() },
onSelectOption: (Int) -> Unit /* KMK --> */ = {} /* KMK <-- */, onSelectOption: (Int) -> Unit = {},
) { ) {
Column(Modifier.verticalScroll(rememberScrollState())) { Column(Modifier.verticalScroll(rememberScrollState())) {
optionStrings.forEachIndexed { index, option -> optionStrings.forEachIndexed { index, option ->

View file

@ -21,8 +21,8 @@ import eu.kanade.tachiyomi.ui.browse.source.globalsearch.SourceFilter
import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.LocaleHelper
import kotlinx.collections.immutable.ImmutableMap import kotlinx.collections.immutable.ImmutableMap
import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.source.model.Source as DomainSource
import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.domain.source.model.Source as DomainSource
@Composable @Composable
fun GlobalSearchScreen( fun GlobalSearchScreen(
@ -109,20 +109,25 @@ internal fun GlobalSearchContent(
// KMK --> // KMK -->
val domainSource = DomainSource( val domainSource = DomainSource(
source.id, source.id,
"", "", "",
"",
supportsLatest = false, supportsLatest = false,
isStub = false isStub = false
) )
// KMK <-- // KMK <--
GlobalSearchResultItem( GlobalSearchResultItem(
title = (fromSourceId?.let { title = (
"${source.name}".takeIf { source.id == fromSourceId } fromSourceId?.let {
} ?: source.name) + "${source.name}".takeIf { source.id == fromSourceId }
} ?: source.name
) +
// KMK --> // KMK -->
(domainSource.installedExtension?.let { extension -> (
" (${extension.name})".takeIf { extension.name != source.name } domainSource.installedExtension?.let { extension ->
} ?: ""), " (${extension.name})".takeIf { extension.name != source.name }
} ?: ""
),
// KMK <-- // KMK <--
subtitle = LocaleHelper.getLocalizedDisplayName(source.lang), subtitle = LocaleHelper.getLocalizedDisplayName(source.lang),
onClick = { onClickSource(source) }, onClick = { onClickSource(source) },

View file

@ -17,14 +17,13 @@ import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.source.local.LocalSource import tachiyomi.source.local.LocalSource
// KMK -->
@Composable @Composable
fun SourceSettingsButton( fun SourceSettingsButton(
id: Long, id: Long,
@Suppress("UNUSED_PARAMETER") modifier: Modifier = Modifier @Suppress("UNUSED_PARAMETER") modifier: Modifier = Modifier
) { ) {
// Create a fake source // Create a fake source
val source = Source(id,"", "", supportsLatest = false, isStub = false) val source = Source(id, "", "", supportsLatest = false, isStub = false)
SourceSettingsButton(source = source) SourceSettingsButton(source = source)
} }
@ -38,8 +37,9 @@ fun SourceSettingsButton(
val navigator = LocalNavigator.currentOrThrow val navigator = LocalNavigator.currentOrThrow
IconButton(onClick = { IconButton(onClick = {
if (source.installedExtension !== null) if (source.installedExtension !== null) {
navigator.push(ExtensionDetailsScreen(source.installedExtension!!.pkgName)) navigator.push(ExtensionDetailsScreen(source.installedExtension!!.pkgName))
}
}) { }) {
Icon( Icon(
imageVector = Icons.Outlined.Settings, imageVector = Icons.Outlined.Settings,
@ -47,4 +47,3 @@ fun SourceSettingsButton(
) )
} }
} }
// KMK <--

View file

@ -110,10 +110,11 @@ fun Screen.feedTab(
BrowseSourceScreen( BrowseSourceScreen(
source.id, source.id,
// KMK --> // KMK -->
listingQuery = if (!source.supportsLatest) listingQuery = if (!source.supportsLatest) {
GetRemoteManga.QUERY_POPULAR GetRemoteManga.QUERY_POPULAR
else } else {
GetRemoteManga.QUERY_LATEST, GetRemoteManga.QUERY_LATEST
},
// KMK <-- // KMK <--
), ),
) )