wip: better ploogin cards
This commit is contained in:
parent
0c653f4be3
commit
a1b6097f11
2 changed files with 38 additions and 9 deletions
|
|
@ -37,9 +37,10 @@ fun PluginsList() = Column(
|
|||
|
||||
if (plugins.isNotEmpty()) {
|
||||
OutlinedTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
maxLines = 1,
|
||||
value = search,
|
||||
onValueChange = { search = it },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
label = { Text(stringResource(R.string.search)) },
|
||||
trailingIcon = { Icon(Icons.Default.Search, stringResource(R.string.search_plugins)) },
|
||||
keyboardOptions = KeyboardOptions(autoCorrect = false, imeAction = ImeAction.Search),
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ package com.aliucord.manager.ui.components.plugins
|
|||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.selection.toggleable
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
|
|
@ -35,6 +37,7 @@ fun PluginCard(
|
|||
modifier = Modifier.padding(12.dp)
|
||||
) {
|
||||
var isEnabled by remember { mutableStateOf(true) }
|
||||
val uriHandler = LocalUriHandler.current
|
||||
|
||||
// Header
|
||||
Row(
|
||||
|
|
@ -54,10 +57,33 @@ fun PluginCard(
|
|||
}
|
||||
)
|
||||
|
||||
// Author(s)
|
||||
Text(
|
||||
"By ${plugin.manifest.authors.joinToString { it.name }}",
|
||||
style = MaterialTheme.typography.labelMedium
|
||||
// Authors
|
||||
val authors = buildAnnotatedString {
|
||||
pushStyle(SpanStyle(color = MaterialTheme.colorScheme.secondary))
|
||||
append("By ")
|
||||
|
||||
val authors = plugin.manifest.authors
|
||||
authors.forEachIndexed { i, author ->
|
||||
withStyle(SpanStyle(color = MaterialTheme.colorScheme.primary)) {
|
||||
val start = this@buildAnnotatedString.length
|
||||
append(author.name)
|
||||
addStringAnnotation("authorId", author.id.toString(), start, start + author.name.length)
|
||||
}
|
||||
if (authors.size < i)
|
||||
append(',')
|
||||
}
|
||||
}
|
||||
ClickableText(
|
||||
text = authors,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
onClick = {
|
||||
authors.getStringAnnotations("authorId", it, it)
|
||||
.firstOrNull()
|
||||
?.let { (id) ->
|
||||
val url = "https://discord.com/users/$id"
|
||||
uriHandler.openUri(url)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -70,17 +96,19 @@ fun PluginCard(
|
|||
)
|
||||
}
|
||||
|
||||
Divider(modifier = Modifier.alpha(0.1f))
|
||||
|
||||
// Description
|
||||
Text(
|
||||
text = plugin.manifest.description,
|
||||
modifier = Modifier.heightIn(min = 50.dp),
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier
|
||||
.heightIn(max = 60.dp, min = 20.dp)
|
||||
.padding(top = 10.dp),
|
||||
)
|
||||
|
||||
// Buttons
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
val uriHandler = LocalUriHandler.current
|
||||
|
||||
IconButton(
|
||||
onClick = {
|
||||
uriHandler.openUri(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue