Further tweak migration config screen sheet

This commit is contained in:
AntsyLich
2025-06-13 15:19:57 +06:00
parent 288f577a45
commit 019fc08da2
2 changed files with 46 additions and 44 deletions

View File

@ -29,6 +29,8 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.util.fastForEach
import eu.kanade.core.util.fastFilterNot
import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.source.service.SourcePreferences
import eu.kanade.presentation.components.AdaptiveSheet import eu.kanade.presentation.components.AdaptiveSheet
import mihon.domain.migration.models.MigrationFlag import mihon.domain.migration.models.MigrationFlag
@ -77,31 +79,32 @@ fun MigrationConfigScreenSheet(
.padding(bottom = MaterialTheme.padding.extraSmall), .padding(bottom = MaterialTheme.padding.extraSmall),
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small), horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
) { ) {
MigrationFlag.entries.forEach { flag -> MigrationFlag.entries
if (flag == MigrationFlag.REMOVE_DOWNLOAD) return@forEach .fastFilterNot { it == MigrationFlag.REMOVE_DOWNLOAD }
val selected = flag in migrationFlags .fastForEach { flag ->
FilterChip( val selected = flag in migrationFlags
selected = selected, FilterChip(
onClick = { selected = selected,
preferences.migrationFlags().getAndSet { onClick = {
if (selected) { preferences.migrationFlags().getAndSet { currentFlags ->
it - flag if (flag in currentFlags) {
} else { currentFlags - flag
it + flag } else {
currentFlags + flag
}
} }
} },
}, label = { Text(stringResource(flag.getLabel())) },
label = { Text(stringResource(flag.getLabel())) }, leadingIcon = {
leadingIcon = { if (selected) {
if (selected) { Icon(
Icon( imageVector = Icons.Outlined.Check,
imageVector = Icons.Outlined.Check, contentDescription = null,
contentDescription = null, )
) }
} },
}, )
) }
}
} }
val removeDownloads = MigrationFlag.REMOVE_DOWNLOAD in migrationFlags val removeDownloads = MigrationFlag.REMOVE_DOWNLOAD in migrationFlags
MigrationSheetSwitchItem( MigrationSheetSwitchItem(
@ -123,9 +126,6 @@ fun MigrationConfigScreenSheet(
value = extraSearchQuery, value = extraSearchQuery,
onValueChange = { extraSearchQuery = it }, onValueChange = { extraSearchQuery = it },
label = { Text(stringResource(MR.strings.migrationConfigScreen_additionalSearchQueryLabel)) }, label = { Text(stringResource(MR.strings.migrationConfigScreen_additionalSearchQueryLabel)) },
placeholder = {
Text(stringResource(MR.strings.migrationConfigScreen_additionalSearchQueryPlaceholder))
},
supportingText = { supportingText = {
Text(stringResource(MR.strings.migrationConfigScreen_additionalSearchQuerySupportingText)) Text(stringResource(MR.strings.migrationConfigScreen_additionalSearchQuerySupportingText))
}, },
@ -142,13 +142,13 @@ fun MigrationConfigScreenSheet(
subtitle = null, subtitle = null,
preference = preferences.migrationHideUnmatched(), preference = preferences.migrationHideUnmatched(),
) )
MigrationSheetDividerItem()
MigrationSheetWarningItem(stringResource(MR.strings.migrationConfigScreen_enhancedOptionsWarning))
MigrationSheetSwitchItem( MigrationSheetSwitchItem(
title = stringResource(MR.strings.migrationConfigScreen_hideWithoutUpdatesTitle), title = stringResource(MR.strings.migrationConfigScreen_hideWithoutUpdatesTitle),
subtitle = stringResource(MR.strings.migrationConfigScreen_hideWithoutUpdatesSubtitle), subtitle = stringResource(MR.strings.migrationConfigScreen_hideWithoutUpdatesSubtitle),
preference = preferences.migrationHideWithoutUpdates(), preference = preferences.migrationHideWithoutUpdates(),
) )
MigrationSheetDividerItem()
MigrationSheetWarningItem(stringResource(MR.strings.migrationConfigScreen_enhancedOptionsWarning))
MigrationSheetSwitchItem( MigrationSheetSwitchItem(
title = stringResource(MR.strings.migrationConfigScreen_deepSearchModeTitle), title = stringResource(MR.strings.migrationConfigScreen_deepSearchModeTitle),
subtitle = stringResource(MR.strings.migrationConfigScreen_deepSearchModeSubtitle), subtitle = stringResource(MR.strings.migrationConfigScreen_deepSearchModeSubtitle),
@ -156,13 +156,16 @@ fun MigrationConfigScreenSheet(
) )
MigrationSheetSwitchItem( MigrationSheetSwitchItem(
title = stringResource(MR.strings.migrationConfigScreen_prioritizeByChaptersTitle), title = stringResource(MR.strings.migrationConfigScreen_prioritizeByChaptersTitle),
subtitle = null, subtitle = stringResource(MR.strings.migrationConfigScreen_prioritizeByChaptersSubtitle),
preference = preferences.migrationPrioritizeByChapters(), preference = preferences.migrationPrioritizeByChapters(),
) )
} }
HorizontalDivider() HorizontalDivider()
Button( Button(
onClick = { onStartMigration(extraSearchQuery) }, onClick = {
val cleanedExtraSearchQuery = extraSearchQuery.trim().ifBlank { null }
onStartMigration(cleanedExtraSearchQuery)
},
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding( .padding(
@ -182,11 +185,10 @@ private fun MigrationSheetSwitchItem(
subtitle: String?, subtitle: String?,
preference: Preference<Boolean>, preference: Preference<Boolean>,
) { ) {
val checked by preference.collectAsState()
MigrationSheetSwitchItem( MigrationSheetSwitchItem(
title = title, title = title,
subtitle = subtitle, subtitle = subtitle,
checked = checked, checked = preference.collectAsState().value,
onClick = { preference.toggle() }, onClick = { preference.toggle() },
) )
} }

View File

@ -1005,15 +1005,15 @@
<string name="migrationConfigScreen.selectPinnedLabel">Select pinned sources</string> <string name="migrationConfigScreen.selectPinnedLabel">Select pinned sources</string>
<string name="migrationConfigScreen.continueButtonText">Continue</string> <string name="migrationConfigScreen.continueButtonText">Continue</string>
<string name="migrationConfigScreen.dataToMigrateHeader">Data to migrate</string> <string name="migrationConfigScreen.dataToMigrateHeader">Data to migrate</string>
<string name="migrationConfigScreen.removeDownloadsTitle">Delete downloads after migration</string> <string name="migrationConfigScreen.removeDownloadsTitle">Delete downloads of current entry after migration</string>
<string name="migrationConfigScreen.additionalSearchQueryLabel">Additional search keywords</string> <string name="migrationConfigScreen.additionalSearchQueryLabel">Additional keywords (optional)</string>
<string name="migrationConfigScreen.additionalSearchQueryPlaceholder">e.g. language:english</string> <string name="migrationConfigScreen.additionalSearchQuerySupportingText">Helps narrow down search results by adding additional keywords</string>
<string name="migrationConfigScreen.additionalSearchQuerySupportingText">Appends keywords to the search query</string> <string name="migrationConfigScreen.hideUnmatchedTitle">Hide entries without a match</string>
<string name="migrationConfigScreen.hideUnmatchedTitle">Hide unmatched manga</string> <string name="migrationConfigScreen.hideWithoutUpdatesTitle">Hide entries without newer chapters</string>
<string name="migrationConfigScreen.enhancedOptionsWarning">Settings below can be slower and may lead to temporary source restrictions</string> <string name="migrationConfigScreen.hideWithoutUpdatesSubtitle">Only show entry if the match has additional chapters</string>
<string name="migrationConfigScreen.hideWithoutUpdatesTitle">Hide if no new chapters</string> <string name="migrationConfigScreen.enhancedOptionsWarning">These options are slow and dangerous and may lead to restrictions from sources</string>
<string name="migrationConfigScreen.hideWithoutUpdatesSubtitle">Show only if the match offers newer chapters</string> <string name="migrationConfigScreen.deepSearchModeTitle">Advanced search mode</string>
<string name="migrationConfigScreen.deepSearchModeTitle">Deep search mode</string> <string name="migrationConfigScreen.deepSearchModeSubtitle">Breaks down the title into keywords for a wider search</string>
<string name="migrationConfigScreen.deepSearchModeSubtitle">More detailed keyword search</string> <string name="migrationConfigScreen.prioritizeByChaptersTitle">Match based on chapter number</string>
<string name="migrationConfigScreen.prioritizeByChaptersTitle">Prioritize by newer chapters</string> <string name="migrationConfigScreen.prioritizeByChaptersSubtitle">If enabled, chooses the match furthest ahead. Otherwise, picks the first match by source priority.</string>
</resources> </resources>