Skip to content

Commit

Permalink
Merge pull request #58 from halilozercan/halilozercan/0.8.1
Browse files Browse the repository at this point in the history
0.8.1 Release
  • Loading branch information
halilozercan authored Sep 11, 2021
2 parents af48714 + ac3fc98 commit e840b52
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 55 deletions.
4 changes: 0 additions & 4 deletions android-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = Compose.version
}

lint {
disable("ComposableModifierFactory", "ModifierFactoryExtensionFunction", "ModifierFactoryReturnType", "ModifierFactoryUnreferencedReceiver")
}
}

configurations.all {
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions buildSrc/src/main/kotlin/richtext-android-library.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,4 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = Compose.version
}

lint {
disable("ComposableModifierFactory", "ModifierFactoryExtensionFunction", "ModifierFactoryReturnType", "ModifierFactoryUnreferencedReceiver")
}
}
20 changes: 6 additions & 14 deletions desktop-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 1 addition & 3 deletions printing/gradle.properties
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 1 addition & 3 deletions richtext-commonmark/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
POM_DESCRIPTION=A library for rendering markdown in Compose using the Commonmark library.
4 changes: 1 addition & 3 deletions richtext-ui-material/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
POM_DESCRIPTION=An extension library for RichText UI to easily bind with Material apps.
4 changes: 1 addition & 3 deletions richtext-ui/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
POM_DESCRIPTION=A library for rendering high-level text formatting in Compose.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -51,6 +53,8 @@ public interface BlockQuoteGutter {
.width(barWidth.toDp())
.background(color, RoundedCornerShape(50))
}

Box(modifier)
}
}
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ 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
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

/**
Expand Down Expand Up @@ -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()
}
}
}
2 changes: 0 additions & 2 deletions slideshow/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
POM_ARTIFACT_ID=slideshow
POM_NAME=Compose Slideshow
POM_DESCRIPTION=A library for creating slideshows using Compose.
POM_PACKAGING=aar

0 comments on commit e840b52

Please sign in to comment.