diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt index a3d991fa9..0887341b2 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt @@ -65,7 +65,7 @@ fun PostCard( ) { PostCardTitle( modifier = Modifier.padding(top = Spacing.s), - post = post + text = post.title ) PostCardSubtitle( community = post.community, diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardBody.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardBody.kt index 299d53da0..88f7ab915 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardBody.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardBody.kt @@ -5,6 +5,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.github.diegoberaldin.raccoonforlemmy.core.markdown.compose.Markdown import com.github.diegoberaldin.raccoonforlemmy.core.markdown.model.markdownColor +import com.github.diegoberaldin.raccoonforlemmy.core.markdown.model.markdownTypography @Composable fun PostCardBody( @@ -15,10 +16,20 @@ fun PostCardBody( Markdown( modifier = modifier, content = text, + typography = markdownTypography( + h1 = MaterialTheme.typography.displayLarge, + h2 = MaterialTheme.typography.displayMedium, + h3 = MaterialTheme.typography.displaySmall, + h4 = MaterialTheme.typography.headlineMedium, + h5 = MaterialTheme.typography.headlineSmall, + h6 = MaterialTheme.typography.titleLarge, + text = MaterialTheme.typography.bodyMedium, + paragraph = MaterialTheme.typography.bodyMedium, + ), colors = markdownColor( text = MaterialTheme.colorScheme.onSurfaceVariant, backgroundCode = MaterialTheme.colorScheme.surfaceVariant, - ) + ), ) } } diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardTitle.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardTitle.kt index 812e154a7..3b9a36e33 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardTitle.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCardTitle.kt @@ -4,17 +4,25 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import com.github.diegoberaldin.raccoonforlemmy.core.markdown.compose.Markdown +import com.github.diegoberaldin.raccoonforlemmy.core.markdown.model.markdownColor +import com.github.diegoberaldin.raccoonforlemmy.core.markdown.model.markdownTypography import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.PostModel @Composable fun PostCardTitle( - post: PostModel, + text: String, modifier: Modifier = Modifier, ) { - Text( + Markdown( modifier = modifier, - text = post.title, - style = MaterialTheme.typography.titleLarge, - color = MaterialTheme.colorScheme.onSurfaceVariant, + content = text, + typography = markdownTypography( + text = MaterialTheme.typography.displaySmall, + ), + colors = markdownColor( + text = MaterialTheme.colorScheme.onSurfaceVariant, + backgroundCode = MaterialTheme.colorScheme.surfaceVariant, + ), ) } diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt index 9b6df0dff..740499afb 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt @@ -232,7 +232,9 @@ class PostDetailScreen( horizontal = Spacing.s, ), ) { - PostCardTitle(post) + PostCardTitle( + text = post.title + ) PostCardSubtitle( community = post.community, creator = post.creator?.copy(avatar = null), diff --git a/domain-lemmy/data/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/domain/lemmy/data/PostModel.kt b/domain-lemmy/data/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/domain/lemmy/data/PostModel.kt index eb4e64851..ece485c78 100644 --- a/domain-lemmy/data/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/domain/lemmy/data/PostModel.kt +++ b/domain-lemmy/data/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/domain/lemmy/data/PostModel.kt @@ -7,6 +7,8 @@ data class PostModel( val score: Int = 0, val comments: Int = 0, val thumbnailUrl: String? = null, + val url: String? = null, + val embedVideoUrl: String? = null, val community: CommunityModel? = null, val creator: UserModel? = null, val saved: Boolean = false, diff --git a/domain-lemmy/repository/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/domain/lemmy/repository/utils/Mappings.kt b/domain-lemmy/repository/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/domain/lemmy/repository/utils/Mappings.kt index 7306de991..8b080043f 100644 --- a/domain-lemmy/repository/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/domain/lemmy/repository/utils/Mappings.kt +++ b/domain-lemmy/repository/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/domain/lemmy/repository/utils/Mappings.kt @@ -85,12 +85,14 @@ internal fun PostView.toModel() = PostModel( score = counts.score, comments = counts.comments, thumbnailUrl = post.thumbnailUrl.orEmpty(), + url = post.url, community = community.toModel(), creator = creator.toModel(), saved = saved, myVote = myVote ?: 0, publishDate = post.published, nsfw = post.nsfw, + embedVideoUrl = post.embedVideoUrl ) internal fun CommentView.toModel() = CommentModel( @@ -125,7 +127,16 @@ internal fun PersonMentionView.toModel() = PersonMentionModel( id = post.id, title = post.name, text = post.body.orEmpty(), + score = counts.score, + thumbnailUrl = post.thumbnailUrl.orEmpty(), + url = post.url, + community = community.toModel(), + creator = creator.toModel(), + saved = saved, + myVote = myVote ?: 0, + publishDate = post.published, nsfw = post.nsfw, + embedVideoUrl = post.embedVideoUrl ), comment = CommentModel( id = comment.id, @@ -147,9 +158,16 @@ internal fun CommentReplyView.toModel() = PersonMentionModel( id = post.id, title = post.name, text = post.body.orEmpty(), - creator = UserModel(id = post.creatorId), + score = counts.score, + thumbnailUrl = post.thumbnailUrl.orEmpty(), + url = post.url, + community = community.toModel(), + creator = creator.toModel(), + saved = saved, + myVote = myVote ?: 0, publishDate = post.published, nsfw = post.nsfw, + embedVideoUrl = post.embedVideoUrl ), comment = CommentModel( id = comment.id,