Show tags in item detail views
This commit is contained in:
parent
21bdbb2f0a
commit
2c307693f2
@ -4,7 +4,6 @@ import androidx.compose.animation.*
|
|||||||
import androidx.compose.animation.core.snap
|
import androidx.compose.animation.core.snap
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.ExperimentalMaterialApi
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.rounded.*
|
import androidx.compose.material.icons.rounded.*
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
@ -35,7 +34,6 @@ import de.mm20.launcher2.ui.locals.LocalGridIconSize
|
|||||||
import de.mm20.launcher2.ui.locals.LocalSnackbarHostState
|
import de.mm20.launcher2.ui.locals.LocalSnackbarHostState
|
||||||
import de.mm20.launcher2.ui.modifier.scale
|
import de.mm20.launcher2.ui.modifier.scale
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.min
|
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@ -62,7 +60,22 @@ fun AppItem(
|
|||||||
.weight(1f)
|
.weight(1f)
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
) {
|
) {
|
||||||
Text(text = app.labelOverride ?: app.label, style = MaterialTheme.typography.titleMedium)
|
Text(
|
||||||
|
text = app.labelOverride ?: app.label,
|
||||||
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
)
|
||||||
|
|
||||||
|
val tags by remember(viewModel) { viewModel.getTags() }.collectAsState(emptyList())
|
||||||
|
if (tags.isNotEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(top = 1.dp, bottom = 4.dp),
|
||||||
|
text = tags.joinToString(separator = " #", prefix = "#"),
|
||||||
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
|
style = MaterialTheme.typography.labelSmall
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
app.version?.let {
|
app.version?.let {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.app_info_version, it),
|
text = stringResource(R.string.app_info_version, it),
|
||||||
@ -75,16 +88,16 @@ fun AppItem(
|
|||||||
Text(
|
Text(
|
||||||
text = app.`package`,
|
text = app.`package`,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
modifier = Modifier.padding(top = 4.dp),
|
modifier = Modifier.padding(top = 1.dp),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis,
|
||||||
)
|
)
|
||||||
|
|
||||||
FlowRow(
|
FlowRow(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(top = 16.dp)
|
.padding(top = 12.dp)
|
||||||
.animateContentSize(),
|
.animateContentSize(),
|
||||||
mainAxisSpacing = 16.dp,
|
mainAxisSpacing = 12.dp,
|
||||||
crossAxisSpacing = 0.dp
|
crossAxisSpacing = 0.dp
|
||||||
) {
|
) {
|
||||||
val notifications by viewModel.notifications.collectAsState(initial = emptyList())
|
val notifications by viewModel.notifications.collectAsState(initial = emptyList())
|
||||||
|
|||||||
@ -88,6 +88,17 @@ fun CalendarItem(
|
|||||||
style = MaterialTheme.typography.bodySmall
|
style = MaterialTheme.typography.bodySmall
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
AnimatedVisibility(showDetails) {
|
||||||
|
val tags by remember(viewModel) { viewModel.getTags() }.collectAsState(emptyList())
|
||||||
|
if (tags.isNotEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(top = 1.dp, bottom = 4.dp),
|
||||||
|
text = tags.joinToString(separator = " #", prefix = "#"),
|
||||||
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
|
style = MaterialTheme.typography.labelSmall
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AnimatedVisibility(showDetails) {
|
AnimatedVisibility(showDetails) {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.compose.ui.geometry.Rect
|
import androidx.compose.ui.geometry.Rect
|
||||||
import androidx.core.app.ActivityOptionsCompat
|
import androidx.core.app.ActivityOptionsCompat
|
||||||
import de.mm20.launcher2.badges.BadgeRepository
|
import de.mm20.launcher2.badges.BadgeRepository
|
||||||
|
import de.mm20.launcher2.customattrs.CustomAttributesRepository
|
||||||
import de.mm20.launcher2.favorites.FavoritesRepository
|
import de.mm20.launcher2.favorites.FavoritesRepository
|
||||||
import de.mm20.launcher2.icons.IconRepository
|
import de.mm20.launcher2.icons.IconRepository
|
||||||
import de.mm20.launcher2.icons.LauncherIcon
|
import de.mm20.launcher2.icons.LauncherIcon
|
||||||
@ -22,6 +23,7 @@ abstract class SearchableItemVM(
|
|||||||
protected val favoritesRepository: FavoritesRepository by inject()
|
protected val favoritesRepository: FavoritesRepository by inject()
|
||||||
protected val badgeRepository: BadgeRepository by inject()
|
protected val badgeRepository: BadgeRepository by inject()
|
||||||
protected val iconRepository: IconRepository by inject()
|
protected val iconRepository: IconRepository by inject()
|
||||||
|
protected val customAttributesRepository: CustomAttributesRepository by inject()
|
||||||
|
|
||||||
val isPinned = favoritesRepository.isPinned(searchable)
|
val isPinned = favoritesRepository.isPinned(searchable)
|
||||||
fun pin() {
|
fun pin() {
|
||||||
@ -47,6 +49,10 @@ abstract class SearchableItemVM(
|
|||||||
return iconRepository.getIcon(searchable, size)
|
return iconRepository.getIcon(searchable, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getTags(): Flow<List<String>> {
|
||||||
|
return customAttributesRepository.getTags(searchable)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
open fun launch(context: Context, bounds: Rect? = null): Boolean {
|
open fun launch(context: Context, bounds: Rect? = null): Boolean {
|
||||||
val view = (context as? AppCompatActivity)?.window?.decorView
|
val view = (context as? AppCompatActivity)?.window?.decorView
|
||||||
|
|||||||
@ -94,6 +94,17 @@ fun ContactItem(
|
|||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
AnimatedVisibility(showDetails) {
|
||||||
|
val tags by remember(viewModel) { viewModel.getTags() }.collectAsState(emptyList())
|
||||||
|
if (tags.isNotEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(top = 1.dp),
|
||||||
|
text = tags.joinToString(separator = " #", prefix = "#"),
|
||||||
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
|
style = MaterialTheme.typography.labelSmall
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -88,6 +88,15 @@ fun FileItem(
|
|||||||
}
|
}
|
||||||
AnimatedVisibility(showDetails) {
|
AnimatedVisibility(showDetails) {
|
||||||
Column {
|
Column {
|
||||||
|
val tags by remember(viewModel) { viewModel.getTags() }.collectAsState(emptyList())
|
||||||
|
if (tags.isNotEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(top = 1.dp, bottom = 4.dp),
|
||||||
|
text = tags.joinToString(separator = " #", prefix = "#"),
|
||||||
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
|
style = MaterialTheme.typography.labelSmall
|
||||||
|
)
|
||||||
|
}
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(
|
text = stringResource(
|
||||||
R.string.file_meta_type,
|
R.string.file_meta_type,
|
||||||
|
|||||||
@ -69,6 +69,18 @@ fun AppShortcutItem(
|
|||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AnimatedVisibility(showDetails) {
|
||||||
|
val tags by remember(viewModel) { viewModel.getTags() }.collectAsState(emptyList())
|
||||||
|
if (tags.isNotEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(top = 1.dp, bottom = 2.dp),
|
||||||
|
text = tags.joinToString(separator = " #", prefix = "#"),
|
||||||
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
|
style = MaterialTheme.typography.labelSmall
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
val textSpace by transition.animateDp(label = "textSpace") {
|
val textSpace by transition.animateDp(label = "textSpace") {
|
||||||
if (it) 4.dp else 2.dp
|
if (it) 4.dp else 2.dp
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,6 +60,15 @@ fun WebsiteItem(
|
|||||||
text = website.label,
|
text = website.label,
|
||||||
style = MaterialTheme.typography.titleLarge
|
style = MaterialTheme.typography.titleLarge
|
||||||
)
|
)
|
||||||
|
val tags by remember(viewModel) { viewModel.getTags() }.collectAsState(emptyList())
|
||||||
|
if (tags.isNotEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(top = 2.dp, bottom = 2.dp),
|
||||||
|
text = tags.joinToString(separator = " #", prefix = "#"),
|
||||||
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
|
style = MaterialTheme.typography.labelSmall
|
||||||
|
)
|
||||||
|
}
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.padding(vertical = 8.dp),
|
modifier = Modifier.padding(vertical = 8.dp),
|
||||||
text = website.description,
|
text = website.description,
|
||||||
|
|||||||
@ -61,6 +61,15 @@ fun WikipediaItem(
|
|||||||
text = wikipedia.label,
|
text = wikipedia.label,
|
||||||
style = MaterialTheme.typography.titleLarge
|
style = MaterialTheme.typography.titleLarge
|
||||||
)
|
)
|
||||||
|
val tags by remember(viewModel) { viewModel.getTags() }.collectAsState(emptyList())
|
||||||
|
if (tags.isNotEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(top = 1.dp, bottom = 4.dp),
|
||||||
|
text = tags.joinToString(separator = " #", prefix = "#"),
|
||||||
|
color = MaterialTheme.colorScheme.secondary,
|
||||||
|
style = MaterialTheme.typography.labelSmall
|
||||||
|
)
|
||||||
|
}
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.padding(top = 4.dp),
|
modifier = Modifier.padding(top = 4.dp),
|
||||||
text = stringResource(id = R.string.wikipedia_source),
|
text = stringResource(id = R.string.wikipedia_source),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user