diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/character/list/GMCharacterFactory.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/character/list/GMCharacterFactory.kt index 8b8863d..0d4696a 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/character/list/GMCharacterFactory.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/character/list/GMCharacterFactory.kt @@ -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 - } - } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/character/list/GMCharacterViewModel.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/character/list/GMCharacterViewModel.kt index 7e913d2..212848f 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/character/list/GMCharacterViewModel.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/character/list/GMCharacterViewModel.kt @@ -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, diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/common/tag/GMTagFactory.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/common/tag/GMTagFactory.kt index 55167f9..10f59cd 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/common/tag/GMTagFactory.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/gamemaster/common/tag/GMTagFactory.kt @@ -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, selectedTagId: String?, ): List { - 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(