Skip to content

Commit

Permalink
Merge pull request #50 from halilozercan/kmp
Browse files Browse the repository at this point in the history
Kotlin Multiplatform Compose support for RichText
  • Loading branch information
halilozercan authored Sep 8, 2021
2 parents 15ed66f + 3fb779d commit af48714
Show file tree
Hide file tree
Showing 117 changed files with 1,761 additions and 1,390 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
[![Maven Central](https://img.shields.io/maven-central/v/com.halilibo.compose-richtext/richtext-ui.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.halilibo.compose-richtext%22)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)

A collection of Compose libraries for working with rich text formatting and documents. This repo
is currently very experimental and really just proofs-of-concept: there are no tests and some things
A collection of Compose libraries for working with rich text formatting and documents.

`richtext-ui`, `richtext-commonmark`, and `richtext-material-ui` are Kotlin Multiplatform Compose Libraries.

This repo is currently very experimental and really just proofs-of-concept: there are no tests and some things
might be broken or very non-performant.

----
Expand Down
49 changes: 49 additions & 0 deletions android-sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
id("com.android.application")
kotlin("android")
}

android {
compileSdk = AndroidConfiguration.compileSdk

defaultConfig {
minSdk = 21
targetSdk = AndroidConfiguration.targetSdk
}

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = Compose.version
}

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

configurations.all {
resolutionStrategy.eachDependency {
if (requested.group.contains("org.jetbrains.compose")) {
val groupName = requested.group.replace("org.jetbrains.compose", "androidx.compose")
useTarget(
mapOf("group" to groupName, "name" to requested.name, "version" to Compose.version)
)
}
}
}

dependencies {
implementation(project(":printing"))
implementation(project(":richtext-commonmark"))
implementation(project(":richtext-ui-material"))
implementation(project(":slideshow"))
implementation(AndroidX.appcompat)
implementation(Compose.activity)
implementation(Compose.foundation)
implementation(Compose.icons)
implementation(Compose.material)
implementation(Compose.tooling)
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.zachklipp.richtext.ui.BlockQuote
import com.zachklipp.richtext.ui.CodeBlock
import com.zachklipp.richtext.ui.FormattedList
import com.zachklipp.richtext.ui.Heading
import com.zachklipp.richtext.ui.HorizontalRule
import com.zachklipp.richtext.ui.ListType
import com.zachklipp.richtext.ui.ListType.Ordered
import com.zachklipp.richtext.ui.ListType.Unordered
import com.zachklipp.richtext.ui.RichTextScope
import com.zachklipp.richtext.ui.RichTextStyle
import com.zachklipp.richtext.ui.Table
import com.zachklipp.richtext.ui.material.MaterialRichText
import com.halilibo.richtext.ui.BlockQuote
import com.halilibo.richtext.ui.CodeBlock
import com.halilibo.richtext.ui.FormattedList
import com.halilibo.richtext.ui.Heading
import com.halilibo.richtext.ui.HorizontalRule
import com.halilibo.richtext.ui.ListType
import com.halilibo.richtext.ui.ListType.Ordered
import com.halilibo.richtext.ui.ListType.Unordered
import com.halilibo.richtext.ui.RichTextScope
import com.halilibo.richtext.ui.RichTextStyle
import com.halilibo.richtext.ui.Table
import com.halilibo.richtext.ui.material.MaterialRichText

@Preview(widthDp = 300, heightDp = 1000)
@Composable fun RichTextDemoOnWhite() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ import androidx.compose.ui.unit.constrainWidth
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.offset
import androidx.compose.ui.unit.sp
import com.zachklipp.richtext.ui.FormattedList
import com.zachklipp.richtext.ui.ListType.Unordered
import com.zachklipp.richtext.ui.material.MaterialRichText
import com.halilibo.richtext.ui.FormattedList
import com.halilibo.richtext.ui.ListType.Unordered
import com.halilibo.richtext.ui.material.MaterialRichText
import com.zachklipp.richtext.ui.printing.Printable
import com.zachklipp.richtext.ui.printing.PrintableController
import com.zachklipp.richtext.ui.printing.hideWhenPrinting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.zachklipp.richtext.markdown.Markdown
import com.zachklipp.richtext.ui.RichTextStyle
import com.zachklipp.richtext.ui.material.MaterialRichText
import com.zachklipp.richtext.ui.resolveDefaults
import com.halilibo.richtext.markdown.Markdown
import com.halilibo.richtext.ui.RichTextStyle
import com.halilibo.richtext.ui.material.MaterialRichText
import com.halilibo.richtext.ui.resolveDefaults

@Preview
@Composable private fun MarkdownSamplePreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.zachklipp.richtext.ui.RichTextStyle
import com.zachklipp.richtext.ui.resolveDefaults
import com.halilibo.richtext.ui.RichTextStyle
import com.halilibo.richtext.ui.resolveDefaults

@Preview
@Composable private fun RichTextSamplePreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ private val Samples = listOf<Pair<String, @Composable () -> Unit>>(
var currentSampleIndex: Int? by remember { mutableStateOf(null) }

Crossfade(currentSampleIndex) { index ->
index?.let {
if (index != null) {
BackHandler(onBack = { currentSampleIndex = null })
Samples[it].second()
Samples[index].second()
} else {
SamplesListScreen(onSampleClicked = { currentSampleIndex = it })
}
?: SamplesListScreen(onSampleClicked = { currentSampleIndex = it })
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import com.zachklipp.richtext.ui.FormattedList
import com.zachklipp.richtext.ui.ListType.Ordered
import com.zachklipp.richtext.ui.material.MaterialRichText
import com.halilibo.richtext.ui.FormattedList
import com.halilibo.richtext.ui.ListType.Ordered
import com.halilibo.richtext.ui.material.MaterialRichText
import com.zachklipp.richtext.ui.slideshow.BodySlide
import com.zachklipp.richtext.ui.slideshow.NavigableContentContainer
import com.zachklipp.richtext.ui.slideshow.SlideDivider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import com.zachklipp.richtext.ui.material.MaterialRichText
import com.zachklipp.richtext.ui.string.InlineContent
import com.zachklipp.richtext.ui.string.RichTextString.Builder
import com.zachklipp.richtext.ui.string.RichTextString.Format
import com.zachklipp.richtext.ui.string.RichTextString.Format.Bold
import com.zachklipp.richtext.ui.string.RichTextString.Format.Code
import com.zachklipp.richtext.ui.string.RichTextString.Format.Italic
import com.zachklipp.richtext.ui.string.RichTextString.Format.Link
import com.zachklipp.richtext.ui.string.RichTextString.Format.Strikethrough
import com.zachklipp.richtext.ui.string.RichTextString.Format.Subscript
import com.zachklipp.richtext.ui.string.RichTextString.Format.Superscript
import com.zachklipp.richtext.ui.string.RichTextString.Format.Underline
import com.zachklipp.richtext.ui.string.Text
import com.zachklipp.richtext.ui.string.richTextString
import com.zachklipp.richtext.ui.string.withFormat
import com.halilibo.richtext.ui.material.MaterialRichText
import com.halilibo.richtext.ui.string.InlineContent
import com.halilibo.richtext.ui.string.RichTextString.Builder
import com.halilibo.richtext.ui.string.RichTextString.Format
import com.halilibo.richtext.ui.string.RichTextString.Format.Bold
import com.halilibo.richtext.ui.string.RichTextString.Format.Code
import com.halilibo.richtext.ui.string.RichTextString.Format.Italic
import com.halilibo.richtext.ui.string.RichTextString.Format.Link
import com.halilibo.richtext.ui.string.RichTextString.Format.Strikethrough
import com.halilibo.richtext.ui.string.RichTextString.Format.Subscript
import com.halilibo.richtext.ui.string.RichTextString.Format.Superscript
import com.halilibo.richtext.ui.string.RichTextString.Format.Underline
import com.halilibo.richtext.ui.string.Text
import com.halilibo.richtext.ui.string.richTextString
import com.halilibo.richtext.ui.string.withFormat
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
196 changes: 0 additions & 196 deletions build.gradle

This file was deleted.

Loading

0 comments on commit af48714

Please sign in to comment.