mirror of https://github.com/readrops/Readrops.git
Implement FeedIcon once
This commit is contained in:
parent
4d8de57ade
commit
c932022fe6
|
@ -7,18 +7,15 @@ import androidx.compose.foundation.layout.Row
|
|||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.VerticalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
import com.readrops.app.R
|
||||
import com.readrops.app.util.components.FeedIcon
|
||||
import com.readrops.app.util.theme.MediumSpacer
|
||||
import com.readrops.app.util.theme.ShortSpacer
|
||||
import com.readrops.app.util.theme.spacing
|
||||
|
@ -65,12 +62,10 @@ fun FeedItem(
|
|||
) {
|
||||
MediumSpacer()
|
||||
|
||||
AsyncImage(
|
||||
model = feed.iconUrl,
|
||||
placeholder = painterResource(id = R.drawable.ic_rss_feed_grey),
|
||||
error = painterResource(id = R.drawable.ic_rss_feed_grey),
|
||||
contentDescription = feed.name!!,
|
||||
modifier = Modifier.size(16.dp)
|
||||
FeedIcon(
|
||||
iconUrl = feed.iconUrl,
|
||||
name = feed.name!!,
|
||||
size = 16.dp
|
||||
)
|
||||
|
||||
ShortSpacer()
|
||||
|
|
|
@ -7,18 +7,14 @@ import androidx.compose.foundation.layout.Column
|
|||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
import com.readrops.app.R
|
||||
import com.readrops.app.util.components.FeedIcon
|
||||
import com.readrops.app.util.theme.MediumSpacer
|
||||
import com.readrops.app.util.theme.spacing
|
||||
|
||||
|
@ -43,12 +39,9 @@ fun NotificationItem(
|
|||
vertical = MaterialTheme.spacing.shortSpacing
|
||||
)
|
||||
) {
|
||||
AsyncImage(
|
||||
model = iconUrl,
|
||||
contentDescription = feedName,
|
||||
placeholder = painterResource(id = R.drawable.ic_rss_feed_grey),
|
||||
error = painterResource(id = R.drawable.ic_rss_feed_grey),
|
||||
modifier = Modifier.size(24.dp)
|
||||
FeedIcon(
|
||||
iconUrl = iconUrl,
|
||||
name = feedName
|
||||
)
|
||||
|
||||
MediumSpacer()
|
||||
|
|
|
@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.Row
|
|||
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.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
|
@ -29,7 +28,6 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
|
@ -38,6 +36,7 @@ import coil.compose.AsyncImage
|
|||
import coil.request.ImageRequest
|
||||
import com.readrops.api.utils.DateUtils
|
||||
import com.readrops.app.R
|
||||
import com.readrops.app.util.components.FeedIcon
|
||||
import com.readrops.app.util.theme.ShortSpacer
|
||||
import com.readrops.app.util.theme.spacing
|
||||
import com.readrops.db.pojo.ItemWithFeed
|
||||
|
@ -258,12 +257,9 @@ fun TimelineItemHeader(
|
|||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.weight(1f)
|
||||
) {
|
||||
AsyncImage(
|
||||
model = feedIconUrl,
|
||||
error = painterResource(id = R.drawable.ic_rss_feed_grey),
|
||||
placeholder = painterResource(R.drawable.ic_rss_feed_grey),
|
||||
contentDescription = feedName,
|
||||
modifier = Modifier.size(24.dp)
|
||||
FeedIcon(
|
||||
iconUrl = feedIconUrl,
|
||||
name = feedName
|
||||
)
|
||||
|
||||
ShortSpacer()
|
||||
|
|
|
@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.Row
|
|||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowDropDown
|
||||
|
@ -29,11 +28,9 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
import com.readrops.app.R
|
||||
import com.readrops.app.util.components.FeedIcon
|
||||
import com.readrops.app.util.theme.DrawerSpacing
|
||||
import com.readrops.db.entities.Feed
|
||||
|
||||
|
@ -122,12 +119,9 @@ fun DrawerFolderItem(
|
|||
)
|
||||
},
|
||||
icon = {
|
||||
AsyncImage(
|
||||
model = feed.iconUrl,
|
||||
contentDescription = feed.name,
|
||||
error = painterResource(id = R.drawable.ic_rss_feed_grey),
|
||||
placeholder = painterResource(id = R.drawable.ic_folder_grey),
|
||||
modifier = Modifier.size(24.dp)
|
||||
FeedIcon(
|
||||
iconUrl = feed.iconUrl,
|
||||
name = feed.name!!
|
||||
)
|
||||
},
|
||||
badge = { Text(feed.unreadCount.toString()) },
|
||||
|
|
|
@ -22,9 +22,9 @@ import androidx.compose.ui.res.painterResource
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
import com.readrops.app.R
|
||||
import com.readrops.app.timelime.TimelineState
|
||||
import com.readrops.app.util.components.FeedIcon
|
||||
import com.readrops.app.util.theme.spacing
|
||||
import com.readrops.db.entities.Feed
|
||||
import com.readrops.db.entities.Folder
|
||||
|
@ -96,12 +96,9 @@ fun TimelineDrawer(
|
|||
)
|
||||
},
|
||||
icon = {
|
||||
AsyncImage(
|
||||
model = feed.iconUrl,
|
||||
contentDescription = feed.name,
|
||||
error = painterResource(id = R.drawable.ic_rss_feed_grey),
|
||||
placeholder = painterResource(id = R.drawable.ic_folder_grey),
|
||||
modifier = Modifier.size(24.dp)
|
||||
FeedIcon(
|
||||
iconUrl = feed.iconUrl,
|
||||
name = feed.name!!
|
||||
)
|
||||
},
|
||||
badge = { Text(feed.unreadCount.toString()) },
|
||||
|
@ -136,7 +133,16 @@ fun DrawerDefaultItems(
|
|||
)
|
||||
|
||||
NavigationDrawerItem(
|
||||
label = { Text("${stringResource(id = R.string.new_articles)} (${stringResource(id = R.string.unread, unreadNewItemsCount)})") },
|
||||
label = {
|
||||
Text(
|
||||
"${stringResource(id = R.string.new_articles)} (${
|
||||
stringResource(
|
||||
id = R.string.unread,
|
||||
unreadNewItemsCount
|
||||
)
|
||||
})"
|
||||
)
|
||||
},
|
||||
icon = {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_new),
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.readrops.app.util.components
|
||||
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
import com.readrops.app.R
|
||||
|
||||
@Composable
|
||||
fun FeedIcon(
|
||||
iconUrl: String?,
|
||||
name: String,
|
||||
size: Dp = 24.dp
|
||||
) {
|
||||
AsyncImage(
|
||||
model = iconUrl,
|
||||
error = painterResource(id = R.drawable.ic_rss_feed_grey),
|
||||
placeholder = painterResource(R.drawable.ic_rss_feed_grey),
|
||||
fallback = painterResource(id = R.drawable.ic_rss_feed_grey),
|
||||
contentDescription = name,
|
||||
modifier = Modifier.size(size)
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue