From 872fa85a10ac07a9ae783fa8d8870b39ce3a193f Mon Sep 17 00:00:00 2001 From: halilozercan Date: Fri, 10 Sep 2021 00:20:42 +0300 Subject: [PATCH 1/4] Revert back to fully composable gutter instead of Modifier based one --- android-sample/build.gradle.kts | 4 ---- .../main/kotlin/richtext-android-library.gradle.kts | 4 ---- .../kotlin/com/halilibo/richtext/ui/BlockQuote.kt | 12 ++++++++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/android-sample/build.gradle.kts b/android-sample/build.gradle.kts index f80c2f92..90973229 100644 --- a/android-sample/build.gradle.kts +++ b/android-sample/build.gradle.kts @@ -18,10 +18,6 @@ android { composeOptions { kotlinCompilerExtensionVersion = Compose.version } - - lint { - disable("ComposableModifierFactory", "ModifierFactoryExtensionFunction", "ModifierFactoryReturnType", "ModifierFactoryUnreferencedReceiver") - } } configurations.all { diff --git a/buildSrc/src/main/kotlin/richtext-android-library.gradle.kts b/buildSrc/src/main/kotlin/richtext-android-library.gradle.kts index 919c16c9..9bf54dc1 100644 --- a/buildSrc/src/main/kotlin/richtext-android-library.gradle.kts +++ b/buildSrc/src/main/kotlin/richtext-android-library.gradle.kts @@ -24,8 +24,4 @@ android { composeOptions { kotlinCompilerExtensionVersion = Compose.version } - - lint { - disable("ComposableModifierFactory", "ModifierFactoryExtensionFunction", "ModifierFactoryReturnType", "ModifierFactoryUnreferencedReceiver") - } } diff --git a/richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/BlockQuote.kt b/richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/BlockQuote.kt index 8cf6a26e..9a40604f 100644 --- a/richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/BlockQuote.kt +++ b/richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/BlockQuote.kt @@ -28,7 +28,7 @@ internal val DefaultBlockQuoteGutter = BarGutter() * [BarGutter] is provided as the reasonable default of a simple vertical line. */ public interface BlockQuoteGutter { - @Composable public fun RichTextScope.gutterModifier(): Modifier + @Composable public fun RichTextScope.drawGutter() @Immutable public data class BarGutter( @@ -37,11 +37,13 @@ public interface BlockQuoteGutter { val endMargin: TextUnit = 6.sp, val color: (contentColor: Color) -> Color = { it.copy(alpha = .25f) } ) : BlockQuoteGutter { - @Composable override fun RichTextScope.gutterModifier(): Modifier { + + @Composable + override fun RichTextScope.drawGutter() { with(LocalDensity.current) { val color = color(currentContentColor) - return remember(startMargin, endMargin, barWidth, color) { + val modifier = remember(startMargin, endMargin, barWidth, color) { // Padding must come before width. Modifier .padding( @@ -51,6 +53,8 @@ public interface BlockQuoteGutter { .width(barWidth.toDp()) .background(color, RoundedCornerShape(50)) } + + Box(modifier) } } } @@ -66,7 +70,7 @@ public interface BlockQuoteGutter { } Layout(content = { - Box(modifier = with(gutter) { gutterModifier() }) + with(gutter) { drawGutter() } RichText( modifier = Modifier.padding(top = spacing, bottom = spacing), children = children From 4b70c99a3271d9ffd6166f165796be5c32f55200 Mon Sep 17 00:00:00 2001 From: halilozercan Date: Fri, 10 Sep 2021 00:27:45 +0300 Subject: [PATCH 2/4] Use proper padding modifier in CodeBlock --- .../com/halilibo/richtext/ui/CodeBlock.kt | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/CodeBlock.kt b/richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/CodeBlock.kt index c2fef401..2ee83be1 100644 --- a/richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/CodeBlock.kt +++ b/richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/CodeBlock.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Immutable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -12,7 +11,6 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.TextUnit -import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp /** @@ -61,19 +59,19 @@ internal fun CodeBlockStyle.resolveDefaults() = CodeBlockStyle( * background. */ @Composable public fun RichTextScope.CodeBlock(children: @Composable RichTextScope.() -> Unit) { - val richTextStyle = currentRichTextStyle.resolveDefaults().codeBlockStyle!! - val textStyle = currentTextStyle.merge(richTextStyle.textStyle) - val background = Modifier.background(color = richTextStyle.background!!) + val codeBlockStyle = currentRichTextStyle.resolveDefaults().codeBlockStyle!! + val textStyle = currentTextStyle.merge(codeBlockStyle.textStyle) val blockPadding = with(LocalDensity.current) { - richTextStyle.padding!!.toDp() + codeBlockStyle.padding!!.toDp() } - Box(modifier = background) { - // Can't use Box(padding=) because that property doesn't seem affect the intrinsic size. - Box(Modifier.padding(blockPadding)) { - ProvideTextStyle(textStyle) { - children() - } + Box( + modifier = Modifier + .background(color = codeBlockStyle.background!!) + .padding(blockPadding) + ) { + ProvideTextStyle(textStyle) { + children() } } } From c13969790a6ef2b8a4f8382c8b9cb62b6807972b Mon Sep 17 00:00:00 2001 From: halilozercan Date: Sat, 11 Sep 2021 18:22:56 +0300 Subject: [PATCH 3/4] Remove POM_ARTIFACT_ID from gradle.properties files and MavenPublication configuration Make desktop-sample a JVM app instead of multiplatform --- build.gradle.kts | 1 - desktop-sample/build.gradle.kts | 20 ++++++------------- .../com/halilibo/richtext/desktop/Main.kt | 0 printing/gradle.properties | 4 +--- richtext-commonmark/gradle.properties | 4 +--- richtext-ui-material/gradle.properties | 4 +--- richtext-ui/gradle.properties | 4 +--- slideshow/gradle.properties | 2 -- 8 files changed, 10 insertions(+), 29 deletions(-) rename desktop-sample/src/{jvmMain => main}/kotlin/com/halilibo/richtext/desktop/Main.kt (100%) diff --git a/build.gradle.kts b/build.gradle.kts index 080213f9..6deeac46 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -100,7 +100,6 @@ subprojects { artifact(tasks.named("javadocJar").get()) groupId = property("GROUP").toString() - artifactId = property("POM_ARTIFACT_ID").toString() version = property("VERSION_NAME").toString() pom { diff --git a/desktop-sample/build.gradle.kts b/desktop-sample/build.gradle.kts index 0ba39d99..e5ca69d4 100644 --- a/desktop-sample/build.gradle.kts +++ b/desktop-sample/build.gradle.kts @@ -2,27 +2,19 @@ import org.jetbrains.compose.compose import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { - kotlin("multiplatform") + kotlin("jvm") id("org.jetbrains.compose") version "1.0.0-alpha3" } -kotlin { - jvm() - sourceSets { - val jvmMain by getting { - dependencies { - implementation(project(":richtext-commonmark")) - implementation(project(":richtext-ui-material")) - implementation(compose.desktop.currentOs) - } - } - val jvmTest by getting - } +dependencies { + implementation(project(":richtext-commonmark")) + implementation(project(":richtext-ui-material")) + implementation(compose.desktop.currentOs) } compose.desktop { application { - mainClass = "MainKt" + mainClass = "com.halilibo.richtext.desktop.MainKt" nativeDistributions { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) packageName = "jvm" diff --git a/desktop-sample/src/jvmMain/kotlin/com/halilibo/richtext/desktop/Main.kt b/desktop-sample/src/main/kotlin/com/halilibo/richtext/desktop/Main.kt similarity index 100% rename from desktop-sample/src/jvmMain/kotlin/com/halilibo/richtext/desktop/Main.kt rename to desktop-sample/src/main/kotlin/com/halilibo/richtext/desktop/Main.kt diff --git a/printing/gradle.properties b/printing/gradle.properties index c843541f..0eb02902 100644 --- a/printing/gradle.properties +++ b/printing/gradle.properties @@ -1,4 +1,2 @@ -POM_ARTIFACT_ID=printing POM_NAME=Compose Printing -POM_DESCRIPTION=A library for rendering Composables to Android printers. -POM_PACKAGING=aar +POM_DESCRIPTION=A library for rendering Composables to Android printers. \ No newline at end of file diff --git a/richtext-commonmark/gradle.properties b/richtext-commonmark/gradle.properties index 8336656c..572446d8 100644 --- a/richtext-commonmark/gradle.properties +++ b/richtext-commonmark/gradle.properties @@ -1,4 +1,2 @@ -POM_ARTIFACT_ID=richtext-commonmark POM_NAME=Compose Richtext Commonmark -POM_DESCRIPTION=A library for rendering markdown in Compose using the Commonmark library. -POM_PACKAGING=aar \ No newline at end of file +POM_DESCRIPTION=A library for rendering markdown in Compose using the Commonmark library. \ No newline at end of file diff --git a/richtext-ui-material/gradle.properties b/richtext-ui-material/gradle.properties index 28a01fa9..bfcdc7b1 100644 --- a/richtext-ui-material/gradle.properties +++ b/richtext-ui-material/gradle.properties @@ -1,4 +1,2 @@ -POM_ARTIFACT_ID=richtext-ui-material POM_NAME=Compose Richtext UI Material -POM_DESCRIPTION=An extension library for RichText UI to easily bind with Material apps. -POM_PACKAGING=aar \ No newline at end of file +POM_DESCRIPTION=An extension library for RichText UI to easily bind with Material apps. \ No newline at end of file diff --git a/richtext-ui/gradle.properties b/richtext-ui/gradle.properties index 38a0614a..51352e71 100644 --- a/richtext-ui/gradle.properties +++ b/richtext-ui/gradle.properties @@ -1,4 +1,2 @@ -POM_ARTIFACT_ID=richtext-ui POM_NAME=Compose Richtext UI -POM_DESCRIPTION=A library for rendering high-level text formatting in Compose. -POM_PACKAGING=aar \ No newline at end of file +POM_DESCRIPTION=A library for rendering high-level text formatting in Compose. \ No newline at end of file diff --git a/slideshow/gradle.properties b/slideshow/gradle.properties index 79c8f58a..d87d087c 100644 --- a/slideshow/gradle.properties +++ b/slideshow/gradle.properties @@ -1,4 +1,2 @@ -POM_ARTIFACT_ID=slideshow POM_NAME=Compose Slideshow POM_DESCRIPTION=A library for creating slideshows using Compose. -POM_PACKAGING=aar From ac3fc9851213d779fba8cd6882245ba5dfeb0e0a Mon Sep 17 00:00:00 2001 From: halilozercan Date: Sat, 11 Sep 2021 18:23:49 +0300 Subject: [PATCH 4/4] Prepare a new release 0.8.1 Fix docs links for sample projects --- docs/index.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index d6c3c3cd..92b86b6f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -72,5 +72,5 @@ The `LIBRARY_ARTIFACT`s for each individual library can be found on their respec ## Samples -Please check out ![Android](https://github.com/halilozercan/compose-richtext/tree/main/sample) and ![Desktop](https://github.com/halilozercan/compose-richtext/tree/main/desktop) +Please check out ![Android](https://github.com/halilozercan/compose-richtext/tree/main/android-sample) and ![Desktop](https://github.com/halilozercan/compose-richtext/tree/main/desktop-sample) projects to see various use cases of RichText in both platforms. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 623091ac..0f58278b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,7 +22,7 @@ kotlin.code.style=official systemProp.org.gradle.internal.publish.checksums.insecure=true GROUP=com.halilibo.compose-richtext -VERSION_NAME=0.8.0-SNAPSHOT +VERSION_NAME=0.8.1 POM_DESCRIPTION=A collection of Compose libraries for advanced text formatting and alternative display types.