mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 21:07:04 +05:30
fix(android): add visual indication when there are no saved posts
This commit is contained in:
parent
13b1c699f6
commit
8de49d670b
1 changed files with 34 additions and 16 deletions
|
@ -9,13 +9,22 @@ package dev.msfjarvis.claw.android.ui.lists
|
||||||
import androidx.activity.compose.ReportDrawn
|
import androidx.activity.compose.ReportDrawn
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.LazyListState
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.Inbox
|
||||||
import androidx.compose.material3.Divider
|
import androidx.compose.material3.Divider
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import dev.msfjarvis.claw.common.posts.PostActions
|
import dev.msfjarvis.claw.common.posts.PostActions
|
||||||
import dev.msfjarvis.claw.common.ui.decorations.MonthHeader
|
import dev.msfjarvis.claw.common.ui.decorations.MonthHeader
|
||||||
import dev.msfjarvis.claw.database.local.SavedPost
|
import dev.msfjarvis.claw.database.local.SavedPost
|
||||||
|
@ -32,22 +41,31 @@ fun DatabasePosts(
|
||||||
) {
|
) {
|
||||||
ReportDrawn()
|
ReportDrawn()
|
||||||
Box(modifier = modifier.fillMaxSize()) {
|
Box(modifier = modifier.fillMaxSize()) {
|
||||||
LazyColumn(
|
if (items.isEmpty()) {
|
||||||
state = listState,
|
Column(modifier = Modifier.align(Alignment.Center)) {
|
||||||
) {
|
Icon(
|
||||||
items.forEach { (month, posts) ->
|
imageVector = Icons.Outlined.Inbox,
|
||||||
stickyHeader(contentType = "month-header") { MonthHeader(month = month) }
|
contentDescription = "Empty inbox icon",
|
||||||
items(
|
modifier = Modifier.align(Alignment.CenterHorizontally).size(36.dp),
|
||||||
items = posts,
|
)
|
||||||
key = { it.shortId },
|
Text(text = "No saved posts", style = MaterialTheme.typography.headlineSmall)
|
||||||
contentType = { "LobstersItem" },
|
}
|
||||||
) { item ->
|
} else {
|
||||||
ListItem(
|
LazyColumn(state = listState) {
|
||||||
item = item,
|
items.forEach { (month, posts) ->
|
||||||
isSaved = { true },
|
stickyHeader(contentType = "month-header") { MonthHeader(month = month) }
|
||||||
postActions = postActions,
|
items(
|
||||||
)
|
items = posts,
|
||||||
Divider()
|
key = { it.shortId },
|
||||||
|
contentType = { "LobstersItem" },
|
||||||
|
) { item ->
|
||||||
|
ListItem(
|
||||||
|
item = item,
|
||||||
|
isSaved = { true },
|
||||||
|
postActions = postActions,
|
||||||
|
)
|
||||||
|
Divider()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue