Show tag icons on tag settings screen
This commit is contained in:
parent
eeaa8fa8dd
commit
b2a39e2350
@ -19,8 +19,10 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.component.ShapedLauncherIcon
|
||||
import de.mm20.launcher2.ui.component.preferences.Preference
|
||||
import de.mm20.launcher2.ui.component.preferences.PreferenceCategory
|
||||
import de.mm20.launcher2.ui.component.preferences.PreferenceScreen
|
||||
@ -46,19 +48,16 @@ fun TagsSettingsScreen() {
|
||||
for (tag in tags) {
|
||||
var showMenu by remember { mutableStateOf(false) }
|
||||
|
||||
val (emoji, tagName) = remember(tag) {
|
||||
tag.splitLeadingEmoji()
|
||||
}
|
||||
val icon by remember(tag) { viewModel.getIcon(tag) }.collectAsState(null)
|
||||
|
||||
Preference(
|
||||
icon = {
|
||||
if (emoji != null) {
|
||||
Text(emoji)
|
||||
} else {
|
||||
Icon(Icons.Rounded.Tag, null)
|
||||
}
|
||||
ShapedLauncherIcon(
|
||||
size = 36.dp,
|
||||
icon = { icon },
|
||||
)
|
||||
},
|
||||
title = { Text(tagName ?: "") },
|
||||
title = { Text(tag) },
|
||||
onClick = {
|
||||
viewModel.editTag.value = tag
|
||||
},
|
||||
|
||||
@ -4,7 +4,11 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import de.mm20.launcher2.data.customattrs.CustomAttributesRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.search.Tag
|
||||
import de.mm20.launcher2.services.tags.TagsService
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.core.component.KoinComponent
|
||||
@ -12,6 +16,7 @@ import org.koin.core.component.inject
|
||||
|
||||
class TagsSettingsScreenVM: ViewModel(), KoinComponent {
|
||||
private val tagsService: TagsService by inject()
|
||||
private val iconService: IconService by inject()
|
||||
|
||||
val tags = tagsService.getAllTags()
|
||||
|
||||
@ -35,4 +40,8 @@ class TagsSettingsScreenVM: ViewModel(), KoinComponent {
|
||||
tagsService.deleteTag(tag)
|
||||
}
|
||||
|
||||
fun getIcon(tag: String): Flow<LauncherIcon?> {
|
||||
return iconService.getIcon(Tag(tag), 1)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user