Use feed icon and feed color in TimelineItem

This commit is contained in:
Shinokuni 2023-08-15 21:48:56 +02:00
parent d97da320b4
commit f67c3f8892
2 changed files with 30 additions and 8 deletions

View File

@ -3,6 +3,8 @@ package com.readrops.app.compose.repositories
import com.readrops.api.localfeed.LocalRSSDataSource
import com.readrops.api.services.SyncResult
import com.readrops.api.utils.ApiUtils
import com.readrops.api.utils.HtmlParser
import com.readrops.app.compose.utils.FeedColors
import com.readrops.db.Database
import com.readrops.db.entities.Feed
import com.readrops.db.entities.Item
@ -11,12 +13,14 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.Headers
import org.jsoup.Jsoup
import org.koin.core.component.KoinComponent
import org.koin.core.component.get
class LocalRSSRepository(
private val dataSource: LocalRSSDataSource,
database: Database,
account: Account
) : BaseRepository(database, account) {
) : BaseRepository(database, account), KoinComponent {
override suspend fun login() { /* useless here */
}
@ -108,6 +112,10 @@ class LocalRSSRepository(
etag = null
lastModified = null
iconUrl = HtmlParser.getFaviconLink(siteUrl!!, get()).also { feedUrl ->
feedUrl?.let { backgroundColor = FeedColors.getFeedColor(it) }
}
id = database.newFeedDao().insert(this).toInt()
}
}

View File

@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Add
import androidx.compose.material.icons.outlined.FavoriteBorder
@ -16,10 +17,12 @@ import androidx.compose.material.icons.outlined.Share
import androidx.compose.material3.Card
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
@ -67,9 +70,10 @@ fun TimelineItem(
Row(
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painter = painterResource(id = R.drawable.ic_rss_feed_grey),
AsyncImage(
model = itemWithFeed.feedIconUrl,
contentDescription = null,
placeholder = painterResource(R.drawable.ic_rss_feed_grey),
modifier = Modifier.size(MaterialTheme.typography.labelLarge.fontSize.value.dp)
)
@ -94,10 +98,20 @@ fun TimelineItem(
}
}
Text(
text = DateUtils.formattedDateByLocal(itemWithFeed.item.pubDate!!),
style = MaterialTheme.typography.labelMedium,
)
Surface(
color = if (itemWithFeed.bgColor != 0) Color(itemWithFeed.bgColor) else MaterialTheme.colorScheme.primary,
shape = RoundedCornerShape(48.dp)
) {
Text(
text = DateUtils.formattedDateByLocal(itemWithFeed.item.pubDate!!),
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.padding(
horizontal = MaterialTheme.spacing.shortSpacing,
vertical = MaterialTheme.spacing.veryShortSpacing
)
)
}
}
ShortSpacer()
@ -140,7 +154,7 @@ fun TimelineItem(
contentDescription = null,
modifier = Modifier.clickable { onReadLater() }
)
Icon(
imageVector = Icons.Outlined.Share,
contentDescription = null,