From 2092b65a9486c7044d23105fc75150c737194d31 Mon Sep 17 00:00:00 2001 From: imashnake0 Date: Mon, 19 Feb 2024 03:12:27 -0500 Subject: [PATCH] Added `animiteBlockQuoteStyle` --- .../core/markdown/MarkdownDocument.kt | 3 +- core/build.gradle.kts | 2 + .../animite/core/extensions/Material3Ext.kt | 38 +++++++++++++++++++ .../animite/profile/ProfileScreen.kt | 3 +- 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 core/src/main/kotlin/com/imashnake/animite/core/extensions/Material3Ext.kt diff --git a/compose-markdown/src/main/kotlin/com/nasdroid/core/markdown/MarkdownDocument.kt b/compose-markdown/src/main/kotlin/com/nasdroid/core/markdown/MarkdownDocument.kt index d039c4c5..44ef319f 100644 --- a/compose-markdown/src/main/kotlin/com/nasdroid/core/markdown/MarkdownDocument.kt +++ b/compose-markdown/src/main/kotlin/com/nasdroid/core/markdown/MarkdownDocument.kt @@ -193,7 +193,8 @@ fun MarkdownTextPreview() { > block quote - >> nested block quote + > nested + >> block quote table | with | content --- | --- | --- diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 9902ea76..1490f92d 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -28,6 +28,8 @@ kotlin { } dependencies { + implementation(projects.composeMarkdown) + // AndroidX implementation(libs.androidx.activityCompose) implementation(libs.androidx.coreKtx) diff --git a/core/src/main/kotlin/com/imashnake/animite/core/extensions/Material3Ext.kt b/core/src/main/kotlin/com/imashnake/animite/core/extensions/Material3Ext.kt new file mode 100644 index 00000000..e0dc3ca5 --- /dev/null +++ b/core/src/main/kotlin/com/imashnake/animite/core/extensions/Material3Ext.kt @@ -0,0 +1,38 @@ +package com.imashnake.animite.core.extensions + +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import com.nasdroid.core.markdown.style.BlockQuoteStyle + +/** + * Constructs a better [BlockQuoteStyle]. + */ +@Composable +fun animiteBlockQuoteStyle( + background: Color = MaterialTheme.colorScheme.surfaceVariant, + barWidth: Dp = 2.5f.dp, + barColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, + barShape: Shape = CircleShape, + paddingAfterBar: Dp = 5f.dp, + innerPadding: PaddingValues = PaddingValues(8.dp) +) = BlockQuoteStyle( + background = background, + shape = RoundedCornerShape( + topStart = barWidth/2 + innerPadding.calculateTopPadding(), + topEnd = barWidth/2 + innerPadding.calculateTopPadding(), + bottomStart = barWidth/2 + innerPadding.calculateBottomPadding(), + bottomEnd = barWidth/2 + innerPadding.calculateBottomPadding() + ), + barShape = barShape, + barWidth = barWidth, + barColor = barColor, + paddingAfterBar = paddingAfterBar, + innerPadding = innerPadding +) diff --git a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt index 94f0cc74..dd4b7d4f 100644 --- a/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt +++ b/profile/src/main/kotlin/com/imashnake/animite/profile/ProfileScreen.kt @@ -20,6 +20,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import coil.compose.AsyncImage +import com.imashnake.animite.core.extensions.animiteBlockQuoteStyle import com.imashnake.animite.core.ui.LocalPaddings import com.imashnake.animite.core.ui.NestedScrollableContent import com.imashnake.animite.core.ui.layouts.BannerLayout @@ -99,7 +100,7 @@ fun ProfileScreen( textStyle = m3TextStyles().textStyle.copy(color = textColor) ), textStyleModifiers = m3TextStyleModifiers(), - blockQuoteStyle = m3BlockQuoteStyle(), + blockQuoteStyle = animiteBlockQuoteStyle(), codeBlockStyle = m3CodeBlockStyle(), modifier = contentModifier.clickable { } )