Small adjustment on the previous feature.

This commit is contained in:
Thomas Andres Gomez 2025-03-29 15:39:36 +01:00
parent 3bb25f4e63
commit 81c6450dbe
3 changed files with 13 additions and 31 deletions

View file

@ -5,10 +5,7 @@ import com.pixelized.desktop.lwa.ui.screen.gamemaster.common.tag.GMTagUio
import com.pixelized.desktop.lwa.utils.extention.unAccent
import com.pixelized.shared.lwa.model.campaign.Campaign
import com.pixelized.shared.lwa.model.characterSheet.CharacterSheetPreview
import lwacharactersheet.composeapp.generated.resources.Res
import lwacharactersheet.composeapp.generated.resources.game_master__character_tag__character
import lwacharactersheet.composeapp.generated.resources.game_master__character_tag__npc
import org.jetbrains.compose.resources.getString
import java.text.Collator
class GMCharacterFactory {
@ -49,7 +46,7 @@ class GMCharacterFactory {
character = it,
tagIdMap = tagIdMap,
)
}
}.sortedWith(compareBy(Collator.getInstance()) { it.name })
}
private suspend fun convertToGMCharacterPreviewUio(
@ -90,25 +87,4 @@ class GMCharacterFactory {
actions = actions,
)
}
suspend fun convertToGMTagItemUio(
id: String?,
highlight: Boolean,
): GMTagUio? {
return when (id) {
PLAYER_ID -> GMTagUio(
id = id,
label = getString(Res.string.game_master__character_tag__character),
highlight = highlight,
)
NPC_ID -> GMTagUio(
id = id,
label = getString(Res.string.game_master__character_tag__npc),
highlight = highlight,
)
else -> null
}
}
}

View file

@ -21,6 +21,7 @@ import kotlinx.coroutines.runBlocking
import lwacharactersheet.composeapp.generated.resources.Res
import lwacharactersheet.composeapp.generated.resources.game_master__character__filter
import org.jetbrains.compose.resources.getString
import java.text.Collator
class GMCharacterViewModel(
private val networkRepository: NetworkRepository,

View file

@ -1,6 +1,7 @@
package com.pixelized.desktop.lwa.ui.screen.gamemaster.common.tag
import com.pixelized.shared.lwa.model.tag.Tag
import java.text.Collator
class GMTagFactory {
@ -8,12 +9,16 @@ class GMTagFactory {
tags: Collection<Tag>,
selectedTagId: String?,
): List<GMTagUio> {
return tags.map { tag ->
convertToGMTagItemUio(
tag = tag,
selectedTagId = selectedTagId,
return tags
.map { tag ->
convertToGMTagItemUio(
tag = tag,
selectedTagId = selectedTagId,
)
}
.sortedWith(
comparator = compareBy(Collator.getInstance()) { it.label }
)
}
}
fun convertToGMTagItemUio(