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

View File

@ -21,6 +21,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextOverflow 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.VeryShortSpacer
import com.readrops.app.compose.util.theme.spacing import com.readrops.app.compose.util.theme.spacing
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import com.readrops.db.entities.Folder
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun FeedModalBottomSheet( fun FeedModalBottomSheet(
feed: Feed, feed: Feed,
folder: Folder?,
onDismissRequest: () -> Unit, onDismissRequest: () -> Unit,
onOpen: () -> Unit, onOpen: () -> Unit,
onUpdate: () -> Unit, onUpdate: () -> Unit,
@ -58,6 +57,8 @@ fun FeedModalBottomSheet(
AsyncImage( AsyncImage(
model = feed.iconUrl, model = feed.iconUrl,
contentDescription = feed.name!!, 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) modifier = Modifier.size(MaterialTheme.spacing.veryLargeSpacing)
) )
@ -71,12 +72,15 @@ fun FeedModalBottomSheet(
overflow = TextOverflow.Ellipsis overflow = TextOverflow.Ellipsis
) )
if (folder != null) { if (feed.description != null) {
VeryShortSpacer() VeryShortSpacer()
Text( Text(
text = folder.name!!, text = feed.description!!,
style = MaterialTheme.typography.labelLarge 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, iconUrl = it.feedIcon,
url = it.feedUrl, url = it.feedUrl,
siteUrl = it.feedSiteUrl, siteUrl = it.feedSiteUrl,
description = it.feedDescription,
unreadCount = it.unreadCount unreadCount = it.unreadCount
) )
} }
@ -61,6 +62,7 @@ class GetFoldersWithFeeds(
iconUrl = feedWithoutFolder.feedIcon, iconUrl = feedWithoutFolder.feedIcon,
url = feedWithoutFolder.feedUrl, url = feedWithoutFolder.feedUrl,
siteUrl = feedWithoutFolder.feedSiteUrl, siteUrl = feedWithoutFolder.feedSiteUrl,
description = feedWithoutFolder.feedDescription,
unreadCount = feedWithoutFolder.unreadCount unreadCount = feedWithoutFolder.unreadCount
) )
}) })

View File

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

View File

@ -17,11 +17,11 @@ object FoldersAndFeedsQueriesBuilder {
@Language("SQL") @Language("SQL")
val query = SimpleSQLiteQuery(""" val query = SimpleSQLiteQuery("""
With main As (Select Folder.id As folderId, Folder.name As folderName, Feed.id As feedId, 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 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 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) 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 (Select count(*) From main Where (itemRead = 0)) as unreadCount
From main Group by feedId, folderId Order By folderName, feedName From main Group by feedId, folderId Order By folderName, feedName
""".trimIndent()) """.trimIndent())
@ -38,10 +38,10 @@ object FoldersAndFeedsQueriesBuilder {
@Language("SQL") @Language("SQL")
val query = SimpleSQLiteQuery(""" 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 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) 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 (Select count(*) From main Where (itemRead = 0)) as unreadCount From main Group by feedId Order By feedName
""".trimIndent()) """.trimIndent())