mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-03 14:07:45 +01:00
feat(posts): add host to community view in card
This commit is contained in:
parent
4b80c78e30
commit
74cda9afcd
@ -3,6 +3,6 @@ package com.github.diegoberaldin.raccoonforlemmy.data
|
||||
data class CommunityModel(
|
||||
val id: Int = 0,
|
||||
val name: String = "",
|
||||
val instance: String = "",
|
||||
val host: String = "",
|
||||
val icon: String? = null,
|
||||
)
|
||||
|
@ -8,4 +8,5 @@ data class PostModel(
|
||||
val comments: Int = 0,
|
||||
val thumbnailUrl: String? = null,
|
||||
val community: CommunityModel? = null,
|
||||
val author: UserModel? = null,
|
||||
)
|
@ -2,4 +2,5 @@ package com.github.diegoberaldin.raccoonforlemmy.data
|
||||
|
||||
data class UserModel(
|
||||
val name: String = "",
|
||||
val instance: String = "",
|
||||
)
|
@ -17,4 +17,5 @@ class CommunityRepository(
|
||||
private fun CommunityView.toModel() = CommunityModel(
|
||||
name = community.name,
|
||||
icon = community.icon,
|
||||
)
|
||||
host = extractHost(community.actorId),
|
||||
)
|
||||
|
@ -0,0 +1,6 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.domain_post.repository
|
||||
|
||||
internal fun extractHost(value: String) = value.replace("https://", "").let {
|
||||
val i = it.indexOf("/")
|
||||
it.substring(0, i)
|
||||
}
|
@ -66,6 +66,7 @@ class HomeScreenModel(
|
||||
community = it.community?.copy(
|
||||
name = remoteCommunity?.name.orEmpty(),
|
||||
icon = remoteCommunity?.icon,
|
||||
host = remoteCommunity?.host.orEmpty(),
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
@ -55,7 +55,8 @@ fun PostCard(
|
||||
|
||||
val communityName = post.community?.name.orEmpty()
|
||||
val communityIcon = post.community?.icon.orEmpty()
|
||||
val iconSize = 21.dp
|
||||
val communityHost = post.community?.host.orEmpty()
|
||||
val iconSize = 20.dp
|
||||
if (communityName.isNotEmpty()) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@ -68,11 +69,16 @@ fun PostCard(
|
||||
.clip(RoundedCornerShape(iconSize / 2)),
|
||||
painter = painter,
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.FillWidth,
|
||||
contentScale = ContentScale.FillBounds,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = communityName,
|
||||
text = buildString {
|
||||
append(communityName)
|
||||
if (communityHost.isNotEmpty()) {
|
||||
append("@$communityHost")
|
||||
}
|
||||
},
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
)
|
||||
}
|
||||
@ -120,6 +126,7 @@ fun PostCard(
|
||||
colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onSurface)
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier.padding(end = Spacing.s),
|
||||
text = "${post.comments}"
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user