feat(YouTube - Settings): Sort preference screens below other types of preference

This commit is contained in:
oSumAtrIX 2023-11-18 04:55:19 +01:00
parent 14ea9674c4
commit 9561db50a8
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4

View file

@ -32,17 +32,25 @@ abstract class AbstractPreferenceScreen(
preferences: MutableList<BasePreference> = mutableListOf(),
val categories: MutableList<Category> = mutableListOf()
) : BasePreferenceCollection(key, title, preferences) {
override fun transform(): PreferenceScreen {
return PreferenceScreen(
override fun transform() = PreferenceScreen(
key,
StringResource("${key}_title", title),
preferences.sortedBy { it.title.value.removePunctuation().lowercase() } +
categories.sortedBy { it.title.removePunctuation().lowercase() }.map { it.transform() },
StringResource(
"${key}_title", title
),
preferences.sortedWith(
compareBy(
{ it is PreferenceScreen },
{ it.title.value.removePunctuation().lowercase() }
)
) + categories.sortedBy {
it.title.removePunctuation().lowercase()
}.map {
it.transform()
},
summary?.let { summary ->
StringResource("${key}_summary", summary)
}
)
}
private fun ensureScreenInserted() {
// Add to screens if not yet done