Display feed description in FeedBottomSheet instead of folder name

This commit is contained in:
Shinokuni 2024-04-15 16:34:39 +02:00
parent 99ff159434
commit ea51df49bc
5 changed files with 27 additions and 22 deletions

View File

@ -92,22 +92,16 @@ object FeedTab : Tab {
is DialogState.FeedSheet -> {
FeedModalBottomSheet(
feed = dialog.feed,
folder = dialog.folder,
onDismissRequest = { viewModel.closeDialog() },
onOpen = {
uriHandler.openUri(dialog.feed.siteUrl!!)
viewModel.closeDialog()
},
onUpdate = {
viewModel.openDialog(
DialogState.UpdateFeed(
dialog.feed,
dialog.folder
)
)
viewModel.openDialog(DialogState.UpdateFeed(dialog.feed, dialog.folder))
},
onUpdateColor = {},
onDelete = { viewModel.openDialog(DialogState.DeleteFeed(dialog.feed)) },
onDelete = { viewModel.openDialog(DialogState.DeleteFeed(dialog.feed)) }
)
}
@ -170,10 +164,12 @@ object FeedTab : Tab {
onClick = { viewModel.setFolderExpandState(state.areFoldersExpanded.not()) }
) {
Icon(
painter = painterResource(id = if (state.areFoldersExpanded)
R.drawable.ic_unfold_less
else
R.drawable.ic_unfold_more),
painter = painterResource(
id = if (state.areFoldersExpanded)
R.drawable.ic_unfold_less
else
R.drawable.ic_unfold_more
),
contentDescription = null
)
}
@ -282,7 +278,8 @@ object FeedTab : Tab {
}
is FolderAndFeedsState.ErrorState -> {
val exception = (state.foldersAndFeeds as FolderAndFeedsState.ErrorState).exception
val exception =
(state.foldersAndFeeds as FolderAndFeedsState.ErrorState).exception
ErrorMessage(exception = exception)
}
}

View File

@ -21,6 +21,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextOverflow
@ -31,13 +32,11 @@ import com.readrops.app.compose.util.theme.MediumSpacer
import com.readrops.app.compose.util.theme.VeryShortSpacer
import com.readrops.app.compose.util.theme.spacing
import com.readrops.db.entities.Feed
import com.readrops.db.entities.Folder
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FeedModalBottomSheet(
feed: Feed,
folder: Folder?,
onDismissRequest: () -> Unit,
onOpen: () -> Unit,
onUpdate: () -> Unit,
@ -58,6 +57,8 @@ fun FeedModalBottomSheet(
AsyncImage(
model = feed.iconUrl,
contentDescription = feed.name!!,
placeholder = painterResource(id = R.drawable.ic_rss_feed_grey),
error = painterResource(id = R.drawable.ic_rss_feed_grey),
modifier = Modifier.size(MaterialTheme.spacing.veryLargeSpacing)
)
@ -71,12 +72,15 @@ fun FeedModalBottomSheet(
overflow = TextOverflow.Ellipsis
)
if (folder != null) {
if (feed.description != null) {
VeryShortSpacer()
Text(
text = folder.name!!,
style = MaterialTheme.typography.labelLarge
text = feed.description!!,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.85f),
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
}
}

View File

@ -39,6 +39,7 @@ class GetFoldersWithFeeds(
iconUrl = it.feedIcon,
url = it.feedUrl,
siteUrl = it.feedSiteUrl,
description = it.feedDescription,
unreadCount = it.unreadCount
)
}
@ -61,6 +62,7 @@ class GetFoldersWithFeeds(
iconUrl = feedWithoutFolder.feedIcon,
url = feedWithoutFolder.feedUrl,
siteUrl = feedWithoutFolder.feedSiteUrl,
description = feedWithoutFolder.feedDescription,
unreadCount = feedWithoutFolder.unreadCount
)
})

View File

@ -19,6 +19,7 @@ data class FolderWithFeed(
val feedName: String? = null,
val feedIcon: String? = null,
val feedUrl: String? = null,
val feedDescription: String? = null,
val feedSiteUrl: String? = null,
val unreadCount: Int = 0,
val accountId: Int = 0
@ -30,6 +31,7 @@ data class FeedWithCount(
val feedIcon: String? = null,
val feedUrl: String? = null,
val feedSiteUrl: String? = null,
val feedDescription: String? = null,
val unreadCount: Int = 0,
val accountId: Int = 0
)

View File

@ -17,11 +17,11 @@ object FoldersAndFeedsQueriesBuilder {
@Language("SQL")
val query = SimpleSQLiteQuery("""
With main As (Select Folder.id As folderId, Folder.name As folderName, Feed.id As feedId,
Feed.name As feedName, Feed.icon_url As feedIcon, Feed.url As feedUrl, Feed.siteUrl As feedSiteUrl,
Feed.name As feedName, Feed.icon_url As feedIcon, Feed.url As feedUrl, Feed.siteUrl As feedSiteUrl, Feed.description as feedDescription,
Folder.account_id As accountId, Item.read as itemRead
From Folder Left Join Feed On Folder.id = Feed.folder_id Left Join Item On Item.feed_id = Feed.id
Where Feed.folder_id is NULL OR Feed.folder_id is NOT NULL And Feed.account_id = $accountId $filter)
Select folderId, folderName, feedId, feedName, feedIcon, feedUrl, feedSiteUrl, accountId,
Select folderId, folderName, feedId, feedName, feedIcon, feedUrl, feedSiteUrl, accountId, feedDescription,
(Select count(*) From main Where (itemRead = 0)) as unreadCount
From main Group by feedId, folderId Order By folderName, feedName
""".trimIndent())
@ -38,10 +38,10 @@ object FoldersAndFeedsQueriesBuilder {
@Language("SQL")
val query = SimpleSQLiteQuery("""
With main As (Select Feed.id As feedId, Feed.name As feedName, Feed.icon_url As feedIcon,
With main As (Select Feed.id As feedId, Feed.name As feedName, Feed.icon_url As feedIcon, feed.description as feedDescription,
Feed.url As feedUrl, Feed.siteUrl As feedSiteUrl, Feed.account_id As accountId, Item.read As itemRead
From Feed Left Join Item On Feed.id = Item.feed_id Where Feed.folder_id is Null And Feed.account_id = $accountId $filter)
Select feedId, feedName, feedIcon, feedUrl, feedSiteUrl, accountId,
Select feedId, feedName, feedIcon, feedUrl, feedSiteUrl, accountId, feedDescription,
(Select count(*) From main Where (itemRead = 0)) as unreadCount From main Group by feedId Order By feedName
""".trimIndent())