Inverted filter presets
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.koitharu.kotatsu.history.domain
|
||||
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.os.NetworkState
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.history.data.HistoryRepository
|
||||
@@ -25,14 +24,7 @@ class HistoryListQuickFilter @Inject constructor(
|
||||
}
|
||||
add(ListFilterOption.Macro.COMPLETED)
|
||||
add(ListFilterOption.Macro.FAVORITE)
|
||||
add(
|
||||
ListFilterOption.Inverted(
|
||||
option = ListFilterOption.Macro.FAVORITE,
|
||||
iconResId = R.drawable.ic_heart_off,
|
||||
titleResId = R.string.not_in_favorites,
|
||||
titleText = null,
|
||||
),
|
||||
)
|
||||
add(ListFilterOption.NOT_FAVORITE)
|
||||
if (!settings.isNsfwContentDisabled && !settings.isHistoryExcludeNsfw) {
|
||||
add(ListFilterOption.Macro.NSFW)
|
||||
}
|
||||
|
||||
@@ -98,4 +98,23 @@ sealed interface ListFilterOption {
|
||||
override val groupKey: String
|
||||
get() = "_inv" + option.groupKey
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
val SFW
|
||||
get() = Inverted(
|
||||
option = Macro.NSFW,
|
||||
iconResId = R.drawable.ic_sfw,
|
||||
titleResId = R.string.sfw,
|
||||
titleText = null,
|
||||
)
|
||||
|
||||
val NOT_FAVORITE
|
||||
get() = Inverted(
|
||||
option = Macro.FAVORITE,
|
||||
iconResId = R.drawable.ic_heart_off,
|
||||
titleResId = R.string.not_in_favorites,
|
||||
titleText = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.plus
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.core.prefs.ListMode
|
||||
import org.koitharu.kotatsu.core.prefs.observeAsFlow
|
||||
@@ -67,7 +66,7 @@ abstract class MangaListViewModel(
|
||||
settings.observeAsFlow(AppSettings.KEY_DISABLE_NSFW) { isNsfwContentDisabled },
|
||||
) { filters, skipNsfw ->
|
||||
if (skipNsfw) {
|
||||
filters + ListFilterOption.Inverted(ListFilterOption.Macro.NSFW, R.drawable.ic_sfw, R.string.sfw, null)
|
||||
filters + ListFilterOption.SFW
|
||||
} else {
|
||||
filters
|
||||
}
|
||||
|
||||
@@ -17,14 +17,7 @@ class SuggestionsListQuickFilter @Inject constructor(
|
||||
}
|
||||
if (!settings.isNsfwContentDisabled && !settings.isSuggestionsExcludeNsfw) {
|
||||
add(ListFilterOption.Macro.NSFW)
|
||||
add(
|
||||
ListFilterOption.Inverted(
|
||||
option = ListFilterOption.Macro.NSFW,
|
||||
iconResId = R.drawable.ic_sfw,
|
||||
titleResId = R.string.sfw,
|
||||
titleText = null,
|
||||
),
|
||||
)
|
||||
add(ListFilterOption.SFW)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ class FeedViewModel @Inject constructor(
|
||||
settings.observeAsFlow(AppSettings.KEY_DISABLE_NSFW) { isNsfwContentDisabled },
|
||||
) { filters, skipNsfw ->
|
||||
if (skipNsfw) {
|
||||
filters + ListFilterOption.Inverted(ListFilterOption.Macro.NSFW, R.drawable.ic_sfw, R.string.sfw, null)
|
||||
filters + ListFilterOption.SFW
|
||||
} else {
|
||||
filters
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user