UI: polish Hugging Face download dialog UI
This commit is contained in:
parent
58adb6c6a5
commit
1c73f6215f
|
|
@ -48,6 +48,7 @@ import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontStyle
|
import androidx.compose.ui.text.font.FontStyle
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
|
@ -519,7 +520,7 @@ fun HuggingFaceModelListItem(
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.fillMaxWidth().padding(8.dp)) {
|
Column(modifier = Modifier.fillMaxWidth().padding(8.dp)) {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.basicMarquee(),
|
modifier = Modifier.fillMaxWidth().basicMarquee(),
|
||||||
text = model.modelId.substringAfterLast("/"),
|
text = model.modelId.substringAfterLast("/"),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium,
|
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium,
|
||||||
|
|
@ -527,9 +528,15 @@ fun HuggingFaceModelListItem(
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(8.dp))
|
Spacer(modifier = Modifier.size(8.dp))
|
||||||
|
|
||||||
Row(verticalAlignment = Alignment.Bottom) {
|
Row(
|
||||||
Column {
|
modifier = Modifier.fillMaxWidth(),
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Column(modifier = Modifier.weight(0.9f)) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.padding(bottom = 8.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Attribution,
|
imageVector = Icons.Default.Attribution,
|
||||||
contentDescription = "Author",
|
contentDescription = "Author",
|
||||||
|
|
@ -537,18 +544,19 @@ fun HuggingFaceModelListItem(
|
||||||
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(4.dp))
|
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
text = model.author,
|
text = model.author,
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(8.dp))
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Row(modifier = Modifier.weight(5f).padding(end = 8.dp)) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Today,
|
imageVector = Icons.Default.Today,
|
||||||
contentDescription = "Author",
|
contentDescription = "Author",
|
||||||
|
|
@ -556,16 +564,15 @@ fun HuggingFaceModelListItem(
|
||||||
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(4.dp))
|
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
text = dateFormatter.format(model.lastModified),
|
text = dateFormatter.format(model.lastModified),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(8.dp))
|
Row(modifier = Modifier.weight(3f).padding(end = 8.dp)) {
|
||||||
|
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Favorite,
|
imageVector = Icons.Default.Favorite,
|
||||||
contentDescription = "Favorite count",
|
contentDescription = "Favorite count",
|
||||||
|
|
@ -573,16 +580,15 @@ fun HuggingFaceModelListItem(
|
||||||
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(4.dp))
|
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
text = formatContextLength(model.likes),
|
text = formatContextLength(model.likes),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(8.dp))
|
Row(modifier = Modifier.weight(4f).padding(end = 4.dp)) {
|
||||||
|
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Download,
|
imageVector = Icons.Default.Download,
|
||||||
contentDescription = "Download count",
|
contentDescription = "Download count",
|
||||||
|
|
@ -590,27 +596,24 @@ fun HuggingFaceModelListItem(
|
||||||
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.size(4.dp))
|
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
text = formatContextLength(model.downloads),
|
text = formatContextLength(model.downloads),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(Modifier.weight(1f))
|
|
||||||
|
|
||||||
if (isSelected) {
|
|
||||||
Checkbox(
|
Checkbox(
|
||||||
|
modifier = Modifier.size(32.dp).alpha(if (isSelected) 1f else 0f),
|
||||||
checked = isSelected,
|
checked = isSelected,
|
||||||
onCheckedChange = null, // handled by parent selectable
|
onCheckedChange = null, // handled by parent selectable
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue