mirror of
https://github.com/pawelorzech/Swoosh.git
synced 2026-03-31 11:55:47 +00:00
feat: show blog name and site icon in Feed top bar
Replace account name with blog title from SiteMetadataCache in the Feed TopAppBar. Show site icon (24dp, circular) before the title. Truncate blog name to 20 characters with ellipsis. Falls back to account name or "Swoosh" if no cached site data exists.
This commit is contained in:
parent
471fea6183
commit
0679b18b8e
1 changed files with 23 additions and 3 deletions
|
|
@ -81,6 +81,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
|||
import coil.compose.AsyncImage
|
||||
import com.swoosh.microblog.data.CredentialsManager
|
||||
import com.swoosh.microblog.data.ShareUtils
|
||||
import com.swoosh.microblog.data.SiteMetadataCache
|
||||
import com.swoosh.microblog.data.model.FeedPost
|
||||
import com.swoosh.microblog.data.model.GhostAccount
|
||||
import com.swoosh.microblog.data.model.PostFilter
|
||||
|
|
@ -113,6 +114,10 @@ fun FeedScreen(
|
|||
val context = LocalContext.current
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val baseUrl = remember { CredentialsManager(context).ghostUrl }
|
||||
val siteMetadataCache = remember { SiteMetadataCache(context) }
|
||||
val siteData = remember(activeAccount?.id) {
|
||||
activeAccount?.let { siteMetadataCache.get(it.id) }
|
||||
}
|
||||
|
||||
// Track which post is pending delete confirmation
|
||||
var postPendingDelete by remember { mutableStateOf<FeedPost?>(null) }
|
||||
|
|
@ -201,8 +206,19 @@ fun FeedScreen(
|
|||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.clickable { showAccountSwitcher = true }
|
||||
) {
|
||||
// Account color indicator
|
||||
if (activeAccount != null) {
|
||||
// Site icon or account avatar
|
||||
val siteIconUrl = siteData?.icon ?: siteData?.logo
|
||||
if (siteIconUrl != null) {
|
||||
AsyncImage(
|
||||
model = siteIconUrl,
|
||||
contentDescription = "Site icon",
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.clip(CircleShape),
|
||||
contentScale = ContentScale.Crop
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
} else if (activeAccount != null) {
|
||||
AccountAvatar(
|
||||
account = activeAccount!!,
|
||||
size = 28
|
||||
|
|
@ -211,8 +227,12 @@ fun FeedScreen(
|
|||
}
|
||||
|
||||
Column {
|
||||
// Use blog name from site metadata, truncate to ~20 chars
|
||||
val displayName = siteData?.title?.let {
|
||||
if (it.length > 20) it.take(20) + "\u2026" else it
|
||||
} ?: activeAccount?.name ?: "Swoosh"
|
||||
Text(
|
||||
text = activeAccount?.name ?: "Swoosh",
|
||||
text = displayName,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
|
|
|
|||
Loading…
Reference in a new issue